Hi.
I am trying to implement the penumbra map algorithm, and I am getting some artifacts, which I think are caused by using different matrices in different passes.
See this
There are some lit spots in the shadow, which are what I am having problem understanding.
So here is what I do:
Pass 1:
Render to float texture, using Lights MVP matrix
Pass 2:
Generate penumbra buffer.
still using lights MVP matrix.
Texture lookup in texture from pass 1 is done as follows:
MUL d3coord.xy, fragment.position, pixelSize;
MOV d3coord.z, fragment.position;
MOV d3coord.w, 1;
TXP tx0, d3coord, texture[ 0 ], 2D; #sample linear depth texture
pixelSize is 1/(size of the texture)
Pass 3:
Now using the scene MVP.
The texture coordinates for the penumbra and shadow map is generated as follows
DP4 t.x, mv[ 0 ], vertex.position;
DP4 t.y, mv[ 1 ], vertex.position;
DP4 t.z, mv[ 2 ], vertex.position;
DP4 t.w, mv[ 3 ], vertex.position;
DP4 tex0.x, toLight[ 0 ], t;
DP4 tex0.y, toLight[ 1 ], t;
DP4 tex0.z, toLight[ 2 ], t;
DP4 tex0.w, toLight[ 3 ], t;
where the toLight matrix is composed like this:
toLight = scale * LightProjection * LightView * inverse( SceneView )
and scale is
[ 0.5 0 0 0.5
0 0.5 0 0.5
0 0 0.5 0.5
0 0 0 1 ]
and mv is state.matrix.modelview.
I cannot explain why the lit spots are there - I am thinking perhaps my generation of coordinates in pass 2 could be wrong, because textures are sampled in some way that I don’t understand?
Oh, and, I only use nearest filtering.
Any hints or ideas appreciated.
Jonas
[This message has been edited by jonasmr (edited 03-01-2004).]
[This message has been edited by jonasmr (edited 03-01-2004).]