Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

lesni_bleble

terrain texturing

This topic is 5181 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!