Jump to content
  • Advertisement
Sign in to follow this  
riff

Strange terrain texture mapping problem

This topic is 3893 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've been having my first foray into graphics programming by attempting to create a simple terrain engine. It was all going fine until I started having a problem with the blended textures which I can't solve. Basically, for each division of the terrain, the associated texture apparently has it's edges swapped around for some reason: Example of a generated texture: bad texture The effect this has on the terrain: bad terrain I was hoping that someone with more experience might instinctively know what's going on. I've looked through my code for days and can't figure it out. Thanks for any help you can give. :)

Share this post


Link to post
Share on other sites
Advertisement
thats almost certainly problem with texture address mode. search directX SDK for AddressV and AddressU and you`ll see what i`m talking about. however it might not be so easy to fix, it depends on your algorithm.

Share this post


Link to post
Share on other sites
A rather quick and easy way to fix this is to make sure each texture has the exact same pixel values along its border as neighboring textures. This will get rid of the visible borders.

Share this post


Link to post
Share on other sites
Changing the texture address mode on the code that blends the textures doesn't seem to make any difference at all.

Share this post


Link to post
Share on other sites
Here's the shader code:


terrainblend.frag
----------------------

2D opacityMap;
uniform sampler2D source0;
uniform sampler2D source1;
uniform sampler2D source2;
uniform sampler2D source3;

void main()
{
vec4 opacity = texture2D(opacityMap, gl_TexCoord[0].st);
vec4 texel0 = texture2D(source0, gl_TexCoord[0].st);
vec4 texel1 = texture2D(source1, gl_TexCoord[0].st);
vec4 texel2 = texture2D(source2, gl_TexCoord[0].st);
vec4 texel3 = texture2D(source3, gl_TexCoord[0].st);

//Combine texel colours
gl_FragColor = vec4(opacity.r * texel0.rgba +
opacity.g * texel1.rgba +
opacity.b * texel2.rgba +
opacity.a * texel3.rgba);
}


terrainblend.vert
-------------------

void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = ftransform();
}



And here is my texture blending code:

http://www.pastebin.ca/907373

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!