Adding UV Coords to Terrain Textures.
by Andrew "Blorf" Hume · in Torque Game Engine · 02/01/2005 (9:09 pm) · 2 replies
I have been trying to figure out how to get more detail out of the texture my player is standing on. We have all seen it, the big black and green smudge right below and nearby the player. Looks great from far away but up close it is a big smear.
Terrain Textures seem to have to be 256 X 256 i tried other sizes with ugly results.
I also want to leave the square size at 8 because I need a 2km square area to run around in.
Then it occured to me that the waterblocks do not have this problem. You can set a tessShore and tessSurface value and lo and behold the texture shrinks way down. Sure you get tiling at a distance, but up close it looks awesome. So I spent the last five hours trying to jam some of that code into TerrainRender::renderBlock with not dazzling results. The ground ended up looking like a shimmering mass of moving lines.
I am not a rendering programmer at all, but I know some of you guys live and breathe this stuff so I am asking for a little help here that would also im sure be one of the biggest improvments to the TGE in a long while. I really dont know why it has been overlooked for so long.
What we need to be able to do is set the tiling value per square. The current value would be 1 (aka the big smear up close) I think something around 4 (meaning 4 tiles side to side and 4 tile up and down totalling 16 tiles) would look awesome. I would also like to help with a solution. Here are the few little things I have gathered while looking at this.
1. The place the terrain block is rendered: TerrainRender::renderBlock
Look at: glBindTexture(GL_TEXTURE_2D, walk->handle.getGLName());
I threw other textures in here and they tiled all over the terrain so this is the spot.
2. What I think is responsible for tiling but not sure how: glTexCoordPointer. This seems to be used everywhere in the engine UV coords are used.
3 I also noticed that the detail texture tiles quite a bit smaller than the ground texture. This may be another avenue of attack. Unfortunatly I cant see any tiling options in that area so how the number of tiles per square is set is a mystery to me.
I will keep working on the problem. I am hoping to get discussion going on this. If anyone has any ideas, post em. This could really be a great advancment for the engine.
Terrain Textures seem to have to be 256 X 256 i tried other sizes with ugly results.
I also want to leave the square size at 8 because I need a 2km square area to run around in.
Then it occured to me that the waterblocks do not have this problem. You can set a tessShore and tessSurface value and lo and behold the texture shrinks way down. Sure you get tiling at a distance, but up close it looks awesome. So I spent the last five hours trying to jam some of that code into TerrainRender::renderBlock with not dazzling results. The ground ended up looking like a shimmering mass of moving lines.
I am not a rendering programmer at all, but I know some of you guys live and breathe this stuff so I am asking for a little help here that would also im sure be one of the biggest improvments to the TGE in a long while. I really dont know why it has been overlooked for so long.
What we need to be able to do is set the tiling value per square. The current value would be 1 (aka the big smear up close) I think something around 4 (meaning 4 tiles side to side and 4 tile up and down totalling 16 tiles) would look awesome. I would also like to help with a solution. Here are the few little things I have gathered while looking at this.
1. The place the terrain block is rendered: TerrainRender::renderBlock
Look at: glBindTexture(GL_TEXTURE_2D, walk->handle.getGLName());
I threw other textures in here and they tiled all over the terrain so this is the spot.
2. What I think is responsible for tiling but not sure how: glTexCoordPointer. This seems to be used everywhere in the engine UV coords are used.
3 I also noticed that the detail texture tiles quite a bit smaller than the ground texture. This may be another avenue of attack. Unfortunatly I cant see any tiling options in that area so how the number of tiles per square is set is a mystery to me.
I will keep working on the problem. I am hoping to get discussion going on this. If anyone has any ideas, post em. This could really be a great advancment for the engine.
#2
The blended terrain textures are 128x128 as I recall. Might be 256x256. Been a bit since I looked at that code. The biggest problem is just that terrain is INCREDIBLY texture intensive. Consider how many texels you'd need to cover a 1 kilometer by 1 kilometer area to the level of 32 texels/meter!
The biggest advantage of the blender approach is that you can make it blend far away areas into one texture, stretching your very limited texels over a wider area.
Nevermind that whenever you change textures, the hardware has to flush everything, meaning that even the most optimal geometry gets the snot fragmented out of it.
Lots of very tough problems in this space. :)
02/02/2005 (9:50 pm)
Actually, most GPU implementations handle FEWER layers than Torque's software blender. Sort of like most GPU skinning implementations handle only a few bones at a time...The blended terrain textures are 128x128 as I recall. Might be 256x256. Been a bit since I looked at that code. The biggest problem is just that terrain is INCREDIBLY texture intensive. Consider how many texels you'd need to cover a 1 kilometer by 1 kilometer area to the level of 32 texels/meter!
The biggest advantage of the blender approach is that you can make it blend far away areas into one texture, stretching your very limited texels over a wider area.
Nevermind that whenever you change textures, the hardware has to flush everything, meaning that even the most optimal geometry gets the snot fragmented out of it.
Lots of very tough problems in this space. :)
Associate Manoel Neto
Default Studio Name
Just kidding.
There is a major reason the terrain textures are they way they are, and it's called "the blender". The water block can tile ad nauseum because it deals pratically with only one tiling texture, and renders the shore geometry on top of those.
The terrain has texture layers, and it needs to blend those. Nowadays people do that using the GPU's increased texture units size, allowing them to render more textures layers at once than in the past days. But Torque uses an ingenuous system to allow multiple texture layers without requiring a video card with multiple texture units.
Each terrain tile gets it's texture built in real time, by blending all terrain layers that affect it and the lightmap. The result (it's a small part of the 256x256 texture, 32x32, I think) is then sent to the videocard and that terrain tile is rendered.
The blender code is highly optimized and hasn't been touched for a while. Attempts to make it blend higher resolution textures have resulted in major performance hits so far, so all bets are on TSE's new terrain system.