Recommended Posts

I've just got my deferred shader pipeline to a point where I start getting some images out, but I got a problem I can't figure out: When I light my scene with a spotlight I get a pixel-thin outline around objects.
Here is a slightly more complex scene with the same problem:
All the geometry get a thin edge of lighter pixels.
Here is the pixel shader I use in the lighting pass of the deferred shader:

Share this post

Link to post

Share on other sites

When you're calculating texture coordinates from normalized device coordinates (like you're doing), you need to offset your texture coordinate by half a pixel to account for the fact that pixels and texels don't have the same alignment in D3D9.

Also FYI, you can save a little bit of calculation by calculating passing the projected position you get in your vertex shader on to your pixel shader, rather than re-calculating it.

0

Share this post

Link to post

Share on other sites

Original post by MJPWhen you're calculating texture coordinates from normalized device coordinates (like you're doing), you need to offset your texture coordinate by half a pixel to account for the fact that pixels and texels don't have the same alignment in D3D9.

Yeah, good point. However, changing my spotlight lookup to

tex2D( texture_spot_sampler, float2( u, 1 - v ) + 0.5f / 512.0f )

(The spotlight texture is 512x512) didn't have much effect. Should it be the width/height of the G buffers? Or should the half-pixel be added somewhere else?

Quote:

Original post by MJPAlso FYI, you can save a little bit of calculation by calculating passing the projected position you get in your vertex shader on to your pixel shader, rather than re-calculating it.

I don't understand this one: I don't calculate any projected position in the vertex shader, since I'm just rendering a fullscreen quad.

Share this post

Link to post

Share on other sites

Original post by Matias GoldbergIf you don't like the loss of matching them (most likely in terms of performance vs quality gain) you can also try blurring them.(1st, bilinear filtering for the RTTs if you haven't already)

This got me thinking, and you got it, only in reverse. [smile] The problem was that I was using a bilinear filter when sampling the position and normal buffers. This caused the border between different normals to blur, creating false normals. Disabling filtering removed the artifacts (well, almost, still a bit left).