Shadow receiver VP.

Crashy

13-03-2006 11:14:22

Hello, I'm trying to get the stexture hadows working on the terrain, but terrain is simply vanishing with shadows enabled.
I use vertex compression, and here is the shadow receiver VP I use.

void main_vp(
float4 pos : POSITION,
float2 iTexcoord : TEXCOORD0,

float2 iLodpos : BLENDWEIGHT,
uniform float4 compressionSettings,
uniform float4x4 worldViewProjMatrix,
uniform float4x4 texViewProjMatrix,
uniform float4x4 worldMatrix,

out float4 oPos : POSITION,
out float2 Coord1 : TEXCOORD0,
out float2 Coord2 : TEXCOORD1


)
{


float height = ((pos.x + 32768) + (iLodpos.x - pos.x) * compressionSettings[3]) * compressionSettings[1];
oPos = float4(iTexcoord.x*compressionSettings[0], height, iTexcoord.y*compressionSettings[2], 1.0);



float4 newpos = mul(worldMatrix, oPos); //at this time, oPos is the uncompressed input position

oPos = mul(worldViewProjMatrix, oPos); //we compute the output position
Coord1 = mul(texViewProjMatrix, newpos);
Coord2 = Coord1 ;

}



Any advice? :?

tuan kuranes

13-03-2006 12:44:13

All shadows type doesn't work ?
At least stencil shadow needs normals enabled on terrain mesh, maybe it comes from here ?

Crashy

13-03-2006 13:13:08

Didn't try with other techniques than Texture Shadow. I'll test .

Crashy

13-03-2006 19:13:24

With Stencil modulative it works but some parts of the terrain are not loaded, and there are artifacts(green bar on the top of the pic)

Falagard

14-03-2006 18:41:30

I'm very interested in shadows as well.

Is there any info on how to get them to work with the PLM2 (wiki, etc?) Crashy has been the main guy to get shadows working in the past, and tuan, I believe you said that shadows were working. Crashy, are you saying they're not working now, or are you doing something special such as using your own vertex program for the terrain? Do I have to set the shadow receiver VP, etc.?

Clay

Crashy

14-03-2006 19:01:39

Crashy has been the main guy to get shadows working in the past, I'm really flattered to read that, but I'm not as skilled as needed to do anything here, I think.


If you use a vertex program on your terrain, for real time splatting or things like that, you need to use a shadow receiver vertex program(cf the manual).

I just don't know where to begin my search for a solution in the code.

I'll start to test shadows without any shader on the terrain, to see if shadows are working.

Falagard

14-03-2006 21:56:01

What's your near clip distance? I noticed in my code I set my near clip distance to 0.1 and texture shadows weren't showing up but I'm not yet using PLM2 just the OctreeSceneManager.

Crashy

14-03-2006 22:10:34

I use 5 for near clip.
I'll test with a non "vertex&pixel shaded" terrain tomorrow, I'm deep in the university's project right now :lol:

Crashy

15-03-2006 12:37:23

It doesn't work too with texture shadows and simple terrain, without any shader. Terrain is just transparent, as before.

tuan kuranes

15-03-2006 13:48:12

Ok, i'm looking at it.

Why do you use 2 viewprojmatrix ?

When using decompressvertex, you need to modify plsm2 to update "compressionsettings" vertex shader arguments too, perhaps...

Crashy

15-03-2006 17:46:42

Why do you use 2 viewprojmatrix ?
on of the two is a texture_viewproj_matrix, to compute the shadow texture coordinates.
Manual:
Only applicable to vertex programs which have been specified as the 'shadow receiver' vertex program alternative; this provides details of the view/projection matrix for the current shadow projector.
This program worked some time ago(without compression, of course).


When using decompressvertex, you need to modify plsm2 to update "compressionsettings" vertex shader arguments too, perhaps...

You mean that the parameters of the shadow receiver VP are not updated because plsm2 only update the parameters of the first VP, and not the shadow receiver VP ?


BTw: for the test with no shaders, I used no vertex compression. So that's really the activation of texture shadows that makes the terrain invisible.

tuan kuranes

15-03-2006 18:07:03

one of the two is a texture_viewproj_matrix, to compute the shadow texture coordinates.
Was speaking of the two other worldMatrix and worldViewProjMatrix.
Why 2 of them... terrain is projected ?

You mean that the parameters of the shadow receiver VP are not updated because plsm2 only update the parameters of the first VP, and not the shadow receiver VP ?

yep. Just fixed that in CVS. now both are updated.

texture shadows that makes the terrain invisible
All texture shadows method ? (dagon added a new one.)
And with no shaders does other stencil based works ?

Crashy

15-03-2006 18:33:48

worldMatrix is just a world_matrix and worldViewProjMatrix is a worldviewproj_matrix .

worldViewProjMatrix is to compute the output position, and the other for the texture coordinates.
Here is the working program with no compression :


void main_vp(
float4 pos : POSITION,

out float4 oPos : POSITION,
out float2 Coord1 : TEXCOORD0,
out float2 Coord2 : TEXCOORD1,
out float4 color: COLOR,
uniform float4x4 worldViewProjMatrix,
uniform float4x4 texViewProjMatrix,
uniform float4x4 worldMatrix

)
{
oPos = mul(worldViewProjMatrix, pos);
float4 newpos = mul(worldMatrix, pos);
Coord1 = mul(texViewProjMatrix, newpos);
Coord2 = Coord1 ;
}



About others shadow techniques:
with texture additive: simply a crash!
with stencil additive: no shadows on terrain and artifacts:
http://crashy.cartman.free.fr/wip/shadowScreen_21.jpg
with stencil modulative: shadows on terrain but artifacts:
http://crashy.cartman.free.fr/wip/shadowScreen_1.jpg