Sign in to follow this  

Strange terrain texture mapping problem

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

This topic is 3588 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this