PDA

View Full Version : Wierd artifacts with penumbra maps



jonasmr
03-01-2004, 08:04 AM
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 (http://www.jonas.dk/artifact3.png)

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).]

ml
03-01-2004, 09:55 AM
Try adding:
OPTION ARB_position_invariant;
to your vertex-programs.

jonasmr
03-01-2004, 10:08 AM
Hi - All mu programs are already using OPTION ARB_position_invariant.

JustHanging
03-02-2004, 11:11 PM
Hi,

It looks like some of the texels on the border of the object and it's extruded silhouette aren't shadowed neither by the shadow map nor the penumbra map. Like you'd have cracks between the object and it's silhouettes. Is there something that could be causing this?

It can also be some kind of sampling issue. I think it would be best to disable AA when rendering the shadow and penumbra maps. Or could the pixel shader somehow misfunction in border cases?

-Ilkka

jonasmr
03-04-2004, 11:23 AM
Problem solved.

I was using way too high polygon offset. Combining this with the fact that the faces around the are close to having a normal perpendicular to the direction of projection, I got a z value offset way too much.

It works now, though it seems even more unstable that shadowmapping alone.

Thanks, Jonas