   frustrum culling in pixel shader (hlsl)
  Hi,I have to perform frustrum culling in a shader that renders objects in texture space.I use this simple formula and it  does the job quite well:VS_output vs_pre(VS_input input){   VS_output output;   // This is passed as TexCoord0 to the pixel shader    output.wPos=mul(float4(input.pos.xyz, 1.0f), MatWVP);// This is the position used for transforming the vertex into uv space    input.UV-=0.5f + halfTexel; // i have to offset it by 0.5 / target size to map the pixels correctly.    input.UV.y=-input.UV.y;    output.Position=float4(input.UV * 2.0f, 0.0f, 1.0f);   return output;    }PS_output ps_pre(in VS_output input){PS_output output = (PS_output)0;    input.wPos.xyz /= input.wPos.w;clip(1.0f - abs(input.UV.xyz));// process pixelreturn output;}However, it seems that a pixel is already clipped when it's center is outside the view frustrum. I'm using 2x MSAA and point filtering on the render target for conservative rasterization. I've tried a lot but i can't find the right solution to fix this. Does anyone have an idea? :-)   
  Sounds like you'll want to use centroid sampling.   ;  Hey MJP, thanks, centroid sampling indeed caused a change. I also enabled 4x MSAA. But now the pixel seems to be clipped at the center of the left side. It may have to do with the dx9 half texel offset thing, but im not sure. i've tried almost everything that came to my mind. Maybe it's not even possible at all.I've put together this little rendermonkey space in case anyone would like to take a look at the situation: frustrumCulling.zip (you have to enable MSAA in the preferences). Just move the camera to the sides.I would be very thankful for any help   ;  *cough push*i still can't figure it out. maybe i'm trying something that isn't possible. can any pro let me know if this is even possible with shaders? i'm losing so much time over this.   ;  one thing i've noticed is that the viewport size seems so play a significant role. when i double the window width, the clipping area stays the same as in the 1:1 window. i don't know how this fits into the puzzle though.   ;  this seems to be an important step:   float3 wPos = Input.wPos.xyz /= Input.wPos.w; wPos.x *= fViewportHeight / fViewportWidth;   clip(1.0f - abs(wPos));in fact, it works almost correctly this way, still pixels are clipped to early   ;  ok this actually seems to work perfectly:   float3 wPos = Input.wPos.xyz /= Input.wPos.w; wPos.x *= fViewportHeight / fViewportWidth; wPos = abs(wPos.xyz); wPos.x -= targetSize / fViewportWidth;   wPos.y -= targetSize / fViewportHeight; wPos.x -= 0.5f / targetSize;   wPos.y -= 0.5f / targetSize;   clip(1.0f - wPos);it's a lot of trial and error but it gives me good results. nothing is clipped to early.if you see some obvious nonsense, please let me know :-)   