terrain texturing

Started by
11 comments, last by lesni_bleble 19 years, 10 months ago
hello. i''m trying to draw large terrain (1024x1024), i''ve implemented ROAM and it works fine. but results with big texture are very bad, so i have to use texture tiling. can you show me some ways how can i realize that? (i''m looking for pretty fast solution. speed is going down when i bind texture per triangle) thanks a for your time eL
Advertisement
You are asking how to tile a texture? This is very simple.
If you are using shaders it''s as simply as multiplying the texture coordinates by the number of times you want it to tile.
If you aren''t using shaders, you can use the texture matrix. Just select the matrix with glMatrixMode(GL_TEXTURE) and do your normal glScaling.

(I think that''s the right call to select the matrix, might be a wrong keyword though)
no.

each triangle has index for texture. when i draw whole terrain i have to bind intensively too many textures. i need avoid that, coz it''s slow.
The only way to get around that is batching. You shouldn''t have very many textures, and if you want to reduce the number of switches, switch to a texture, draw every patch that has that texture, switch to another texture, draw every path that has that, etc.
hm. this is not good method in combination with ROAM algorithm.
Hi,

if you have multitexturing available, you can create an alpha-map for each tiling-texture that streches across the entire terrain.
Then you simply modulate the texture with the alpha. This way you render your terrain several times but you can also use linear filtering on the alpha map and get nice looking transitions between different textures.
This would even work without using multitexturing if you have destination-alpha available by using additive blending but it''s probably slow as hell because of the read-modify-write for the blending.

Regards,

Jan
jeickmann> sounds like a solution. but i''m not sure if i completely understand. each triangle has two uv - one to tile-texture and second to alpha-map, right? how it''s realized transition triangle then? (has been drawned twice?)
Yes, each triangle has two u/v''s (usually you can use texgen for it, which, on modern cards, is probably faster than sending 4 floats per vertex).
For the transition-triangles, you use additive blending:
glBlendFunc(GL_ONE, GL_ONE);

if you want to speed up rendering, you should also add an alpha-test that only allows fragments with alpha>0.0f to pass on to the blending stage. This prevents the black fragments from taking up memory bandwith for the blending.
glAlphaFunc(GL_GREATER, 0.0f);
glEnable(GL_ALPHA_TEST);

Jan
i see.
but roam algorithm split far triangles, which uv and texture i have to use then?
or should i look for another terrain visualisation algorithm, which will be better suitable with texturing?

eL
quote:Original post by jeickmann
Yes, each triangle has two u/v''s (usually you can use texgen for it, which, on modern cards, is probably faster than sending 4 floats per vertex).
For the transition-triangles, you use additive blending:
glBlendFunc(GL_ONE, GL_ONE);

if you want to speed up rendering, you should also add an alpha-test that only allows fragments with alpha>0.0f to pass on to the blending stage. This prevents the black fragments from taking up memory bandwith for the blending.
glAlphaFunc(GL_GREATER, 0.0f);
glEnable(GL_ALPHA_TEST);

Jan



Actually, the memory bandwidth stays the same I think no matter how many pixels are blocked by the alpha test. The alpha test isn''t performed until halfway into the pipeline, so its already been passed through memory into the GPU''s processor.
Author Freeworld3Dhttp://www.freeworld3d.org

This topic is closed to new replies.

Advertisement