Boggling pixel shader issue

Started by
2 comments, last by n0ob 16 years, 6 months ago
So, I'm rendering a 101x101 texture (for testing) to a 1x1 render target. The input is just position and a texture coord. The pixel shader returns the texel at the input texture coord of the test texture: return tex2D( Sampler, In.UV ); However, it's returning the upper left texel, instead of the middle like I want. If I put in some checks for the UV value, such as: if( In.UV.x == .5 || In.UV.y == .5 ) return tex2D( SceneSampler, In.UV ); return float4(0,0,1,1); With this code it returns the color at the upper left corner of the texture, still (and not the blue color) So, apparently the value is (.5, .5), but when it's used by the sampler it's (0, 0). If I do this before everything: In.TextureUV.xy = float2(.5, .5); Then it works as expected, and I get the middle texel, and not a blue color. I'm just wasting a ton of time on this, and I don't know of anything that might cause this behavior (besides a compile bug?) I've tried compiling PS2.0 and PS3.0, with the same result. Any input is appreciated!! Thanks!
Advertisement
Hmm, that is boggling. Have you used the most recent DirectX SDK or have you tried compiling these on another computer?
Whenever something like this happens, you should always use PIX to find out what's going on. Using PIX, you can examine the ASM code to make sure nothing funky is going on.
NextWar: The Quest for Earth available now for Windows Phone 7.
Turns out the texture had mip levels with point filtering.. So whatever my logic was doing must've been making it choose a different level. Anyway, I made sure it was one level and it worked. Thanks for the PIX suggestion! I hadn't really used it before this.

This topic is closed to new replies.

Advertisement