11/20/2023 0 Comments Grass texture seamless 256x256Vec3 tx = mix(texWater, texRock, mixmap.a) TexWater = mix(texGrass, texWater, mixmap.b) TexGrass = mix(texSand, texGrass, mixmap.g) Vec3 texRock = texture2D( rock, gl_TexCoord.st * texscale ).rgb Vec3 texWater = texture2D( water, gl_TexCoord.st * texscale ).rgb Vec3 texGrass = texture2D( grass, gl_TexCoord.st * texscale ).rgb Vec3 texSand = texture2D( sand, gl_TexCoord.st * texscale ).rgb Vec3 alpha = texture2D( alpha, gl_TexCoord.st ).rgb Here is the GLSL code I am using for the fragment shader: uniform sampler2D alpha This mixmap is then put to use in the fragment shader, where I take these color channels of the mixmap and use them to combine the detail textures. As I get higher into the mountains, I set the alpha color channel to a high value since I want a lot of rock texture, but I set all of the other color channels to lower values. For instance, close to the sea level, I mostly want water, so I set a high value in the blue channel and low values in the other channels. This mixmap is calculated based off of the heightmap at initialization and I use altitudes to determine these values. I am using the red color channel to determine how opaque the sand is, green is for grass, blue is for water, and alpha is for rock. This mixmap uses all 4 color channels (r,g,b,a) to describe how much of a detail texture to display at that specific location. The mixmap is a giant texture that covers the entire terrain, in my case is 4096x4096. These textures are smallish, 512x512 textures, and they are tiled across the terrain. Four of these textures are detail textures: grass, rock, water, and sand. The technique I use is best described as texture splatting. I have recently written a small terrain rendering engine in OpenGL that does something similar to what you are talking about. Here's an example image, notice how the cobblestone blends into the grass, unrealistically but smoothly: Īlso I think I read about this in one of the Game Programming Gems books, but I didn't pay much attention to it at the time, and now that it's summer I don't have access to my university's library to check! I'm looking for tables of contents right now and will edit if I find it, but I will still not be able to read it until mid August.ĮDIT: Ah man, Game Programming Gems 7 has a chapter 5.8 titled "Mapping Large Textures for Outdoor Terrain Rendering", that sounds like exactly what I need, but my U's library doesn't even have that book! I couldn't find anything exactly like this in the other Game Programming Gems books, though a couple had some terrain geometry articles. I don't know how the ground's geometry is (heightmap, static 3D models, etc) but their terrain has different ground types and smooth transitions between them, like I'm talking about. Just for clarification, Oblivion is a good reference as to what I'm looking for. I'm using OpenGL so if you can provide tips as far as OpenGL's way of doing things, and functions that I may never have heard of, that would be great. I'm mostly just looking for theory and options here. Of course that would be the easy way but it's too much of a sacrifice in graphics quality and 'realism'. space (0,0) is grass, space (0,2) is dirt, space (0,1) is grass-dirt transition) I'd rather be able to arbitrarily paint so that it looks more convincing. I'd rather not have to 'snap' the texture to the grid (i.e. So then do I use a huge alpha map for each existing texture? In theory it sounds okay to me but how do I actually go about doing that and what are the consequences? I really don't know where to start, and my Google searches aren't proving very effective. How do computer games render their ground? I will be using a heightmap for geometry (though I will later optimize it) but I am wondering what the best technique is, for example, to 'paint' my ground grass most everywhere, dirt paths here and there, gravel inside towns, and smooth transitions between each type of material.ĭo I just use a huge pre-baked texture? That seems very inefficient, when I could tile existing textures.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |