Sunday, November 7, 2010

G-Buffer and Light Buffer

Yay! I'm almost done with my Light Pre-pass system. I need to implement light-hulls, right now I'm just doing CW culling and rendering every pixel greater than the light's bounding sphere. I have a few issues with my Light Buffer, though...

I'm storing the normal's X and Y in the R and G channels, and I'm packing the surface's depth in viewspace across Z and W. However, when I go to reconstruct Z from the normal, something doesn't seem quite right.

Am I wrong in assuming that, given a left-handed coordinate system, Normal.z = abs(Normal.x) + abs(Normal.y) - 1? I'm sure I can safely assume that all stored normals are pointed at me, so that guarantees a negative z-value for my normal.

The results are that at certain view-dependent angles, my model appears a uniform gray. Fortunately everything seems good for the most part.

Here's what the image looks like when Tad is washed out.

Oh well, off to bed for now. I'll see what comes tomorrow.

<3 Lighting

2 comments:

  1. If the normal you're retrieving is normalized and z is negative, solving for z gives:
    z = -sqrt(x^2 + y^2 - 1).

    By your equation,
    z^2 = (abs(x) + abs(y) - 1)^2 = x^2 + y^2 + abs(2xy) - abs(2x) - abs(2y) + 1
    which is not equivalent to z^2 = x^2 + y^2 - 1.

    ReplyDelete
  2. Yeah, I cover that in a later post. Also, I found out this is also wrong. You can have negative z-values due to FOV.

    Slide 12:
    http://www.insomniacgames.com/tech/articles/0409/files/GDC09_Lee_Prelighting.pdf

    ReplyDelete