# Pixel shader and UV problems

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

## 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. (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. (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 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 on other sites
Quote:
 Original post by sirob2) 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.

(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 on other sites
resolved

[Edited by - Valor Knight on January 29, 2006 4:07:17 PM]

1. 1
2. 2
3. 3
4. 4
Rutin
18
5. 5

• 11
• 21
• 12
• 11
• 11
• ### Forum Statistics

• Total Topics
631405
• Total Posts
2999886
×