Jump to content
  • Advertisement

Archived

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

MARS_999

Problem with terrain texturing

This topic is 5380 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

I have 4 terrain types, sand, grass, rock, snow. I am using multitexturing and VBO''s and trying to blend each type smoothly. My problem is when I render sand and grass and then move onto grass and rock my sand is replaced by grass? Is this is a Z buffer issue? Or do I need to somehow disable the depth test function? If so how do I do that? Thanks

Share this post


Link to post
Share on other sites
Advertisement
Can you explain more about the specifics of how you are blending all these together? Multiple passes? Single pass? Register combiners? I just need more information to diagnose your problem.

Share this post


Link to post
Share on other sites
I am doing a single pass. Here is the code.


glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[DIRT]);
glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE_EXT);
glTexEnvi(GL_TEXTURE_ENV,GL_COMBINE_RGB_EXT,GL_INTERPOLATE_EXT);
glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE0_RGB_EXT,GL_PREVIOUS_EXT);
glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND0_RGB_EXT,GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE1_RGB_EXT,GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND1_RGB_EXT,GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE2_RGB_EXT,GL_TEXTURE2_ARB);
glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND2_RGB_EXT,GL_SRC_ALPHA);


Thanks

Share this post


Link to post
Share on other sites
I had this same problem, trying to blend four weighted textures in one pass. I tried all kinds of glTexEnvi() set ups, and also register combiners. I was never able to solve the problem until I did this:

I stored the weight for each texture at each vertex in the vertex color. I then used Cg to set up a fragment shader that multiplied each of the four texture units by the appropriate weight from the vertex color and added the products together for the final color. I'll elaborate more on this if you wish.

I found doing this much easier and more intuitive, and it also gave me a good introduction into Cg.

[edited by - GreenToad on September 25, 2003 3:41:36 PM]

Share this post


Link to post
Share on other sites
Not sure on this, but I am using a Radeon 9700Pro card. I don''t know if Cg will work with ATI products? Right now I am not in a hurry to learn shader languages. I have used procedural texturing and didn''t like the look I got. Maybe I was doing it wrong but if someone has a screenshot of a procedural textured terrain, so I can compare mine to theirs I would appreciate it. I was getting colors like purple and other colors that have nothing to do with the textures I was using?

So would I be better off doing this in multiple passes using multitexturing to avoid using Cg or any shader language? Thanks

Share this post


Link to post
Share on other sites
Don't shy away from shader languages, they are very powerful and very easy to learn (took me about 1.5 hours to learn Cg and get it working). Cg does indeed work with ATI products. I don't have any procedural texturing screenshots, but here is one of the first test shots I took using Cg. Note there are only 3 textures in this shot, and all of them are low resolution (I added a 4th texture and used higher res textures later on).

[edited by - GreenToad on September 25, 2003 6:33:29 PM]

Share this post


Link to post
Share on other sites
Looks good GreenToad. You drawing many polygons for the water and tiling the water texture? Also are you just using the vertex pixel shaders for texturing or using it for other things also? Nice work.

Share this post


Link to post
Share on other sites
Heh, don''t mind the water in that shot, its awful (big huge quad with a transparent tiled texture). No vertex shaders are used, only fragment shaders, and only on the terrain are those being used. I''m in the process of revising the whole thing and will be adding in lighting and perhaps a vertex shader to do some fun things with the texture coordinates based on their distance from the camera (not sure how that will turn out though).

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!