[Bf-committers] Shadow buf question

Jonathan Merritt j.merritt at pgrad.unimelb.edu.au
Sun Nov 11 04:35:04 CET 2007


Hi Joe,

I may be wrong, but I think this is because the coordinates used in  
the rendering pipeline have already been multiplied by re->viewmat for  
the camera.

Some abbreviations:
     C = re->viewmat for render camera (not the light source)
     O = ob->obmat for the object being rendered (object->world)
     L = ob->obmat for the light (light->world)
     x_w = world coordinates of object
     x_c = coordinates of object during rendering (in render camera  
coordinates)
     x_l = coordinates of object in shadow buffer render
     x_o = original object coordinates

Now, initially, when objects are prepared for rendering, their  
coordinates are transformed as follows:
     x_c = x_o * O * C
     (see, for example, line 1883 of convertblender.c where mesh  
vertices are transformed)
Since x_w = x_o * O, this is equivalent to:
     x_c = x_w * C

When the shadow buffer is set up, its matrix is:
     C^{-1} * L^{-1}
Hence, shadow buffer coordinates of the object are given by:
     x_l = x_c * C^{-1} * L^{-1}
         = (x_o * O * C) * C^{-1} * L^{-1}
         = x_o * O * L^{-1}
But, x_o * O are just the world coordinates of the object:
     x_l = x_w * L{-1}
This last line is what you expect.

Uh-oh spaghetti-code... :-/

Jonathan Merritt.

On 11/11/2007, at 1:02 PM, Joe Eagar wrote:

> Hi.  The shadow buffer view matrix is initialized in
> source/blender/render/intern/source/convertblender.c in initshadowbuf.
> This matrix is used by all the shadow buffer code, including DSM.
>
> The matrix is initilized by multiplying the inverted camera matrix  
> with
> the inverted lamp orientation matrix.  Anyone know
> why this is? I think if I knew the answer to this question, I might be
> able to track down why I keep getting crazy zbuffer
> behaviour among other things.
>
> Joe
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers



More information about the Bf-committers mailing list