Sign in to follow this  

Pixel shader and UV problems

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

Currently I am trying to pallettize my textures. I have a texture, which on it has 4 textures. So, in current project, I have the uv's going from 0-and arbitrary number. I need the texture to repeat over and over. Image hosting by Photobucket (There is no cracks in this texture, just it is low quailty so it looks like there is.) I have got this, now when trying to seperate the textures out (say I need to only use texture 1 from the large texture) I get cracks in the texture. These cracks are purple-ish and are seen whenever the uv is edited. The top/bottom is exaggerated because the purple leaked onto my green texture when I saved the texture in paint, however, there is still a crack in the middle of it which is not a texture issue. Image hosting by Photobucket (It is the purple cracks, I do have a wireframe overlay on top of it, but that is not attributing to the problem) Now, I assume it has to do with how I am changing the coordinates:
float2 test = uvTiled;

if ((test.x - floor(test.x)) > 0.5f)
    test.x += 0.5f;
    
if((test.y - floor(test.y)) > 0.5f)
    test.y += 0.5f;
    
float3 texture = tex2D(LayerMap2Sampler, test);




uvTiled is the input uvCoordinates which are 0-a large number (>1 so it repeats) My question: How do I fix the cracks issue? Thanks

Share this post


Link to post
Share on other sites
Well, since you're using more than one actual texture on the same surface, and simulating several textures in one, when DX uses linear blending, to make the textures smoother, it actually goes out of the imaginary "bounds" you set for each texture. The purple in the cracks in fact comes from the texture next to the one you're drawing.

You have two basic options:

1) Disable linear blending. Set the MAG, MIN, and MIP filters to POINT, essentially disabling any blending. This would cause quite a loss in visual appearance, but is a quick fix. I'd suggest you try it, and if you're not satisfied, try the other option.

2) Only use the center of each texture. This might sound intimidating, but you really only need to avoid the very edge of each, so you don't sample from the next texture by accident. I'd start with adding 0.005f to the lower u and v and subtracting the same from the high u and v. If that's not enough, increase it until you find the correct values. If it's too much, decrease to find the best value for you.

Hope this helps.

Share this post


Link to post
Share on other sites
Quote:
Original post by sirob
2) Only use the center of each texture. This might sound intimidating, but you really only need to avoid the very edge of each, so you don't sample from the next texture by accident. I'd start with adding 0.005f to the lower u and v and subtracting the same from the high u and v. If that's not enough, increase it until you find the correct values. If it's too much, decrease to find the best value for you.

That is what I thought, until I noticed that it was the same color, no matter what was next to it, and I tried out doing only the centers of the images, I have the same problem.
Image hosting by Photobucket
(again the yellow lines are wireframe, not the problem, the blue one is the problem)

I also tried changing min/mag filter to point, and has the same problem.

Is this possible in the Pixel Shader? When I try it in the Vertex shader, there is no cracks, but the uv's come out all funky. Perhaps Im trying to do something I cannot.

[Edited by - Valor Knight on January 27, 2006 12:54:25 AM]

Share this post


Link to post
Share on other sites

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