PssmShadowRenderer change shadow angle

hello guys, i’m kinda trying some cool terrain effects, and i’m having issues with the Pssm shadow filter, is it possible to use a vertex shader on it so I can set it on the floor?
because I am using a vertex shader to make a cylindrical world, everything works great except for the shadows who are rendered on the y = 0 plane…

Is it possible to bend the shadows?

here is an example :

If you have a vertex shader that moves the points around then that material will also need a vertex shader that moves them for the shadow passes also. A j3md file has several techniques in it and yours is probably still using the standard shadow passes, I guess. I think it’s the preshadow you’d need to change but I’m not sure.

1 Like

yeap, I extended the pssm there was a post shadow material protected constructor :confused:

but its weird, the ground shadow works well, but the shadow on the character now moves to the ground

const mat4 biasMat = mat4(0.5, 0.0, 0.0, 0.0,
0.0, 0.5, 0.0, 0.0,
0.0, 0.0, 0.5, 0.0,
0.5, 0.5, 0.5, 1.0);

i think it has something to do with the biasMat for calculating the projCoord

// populate the light view matrices array and convert vertex to light viewProj space
projCoord0 = biasMat * m_LightViewProjectionMatrix0 * gl_Position;
projCoord1 = biasMat * m_LightViewProjectionMatrix1 * gl_Position;
projCoord2 = biasMat * m_LightViewProjectionMatrix2 * gl_Position;
projCoord3 = biasMat * m_LightViewProjectionMatrix3 * gl_Position;

You also need to move the vertex in the pre shadow pass

1 Like

The problem was that I moved around my players in the update method, and only the terrain had a deformation shader.
Now I have applied the shader to all my models, and everything is fixed, because when I moved them in the update method, their shadow moved along, and when I applied the pssm, it just started from the already translated position, and deformed the shadow, so the effect was kind of applied twice.

So I jujst figured i’d keep the character where he is, NO translation, and use a shader to move its vertexes arouns, so when I would apply the pssm, it would just move to shadows to the model position.

:slight_smile:
thanks alot guys for your help!

mhh you may have bad side effects doing this.
For example if you want to use picking at some point it won’t work.

oh my god ui didn’t think about that :confused:

the problem is that the postshadow vertew shader affects both the shadow on the ground and the shadow on the character :confused: and the shadow on the character,
another dolution, would be to check if the vertex modified is on the ground or not, if it is I apply the transformation.

I didnt want to implement it because I thought I would be able to fix it the way I did.

but now the only solution that remains, ius to check on the vertex shader if the vertex has for y = 0 or normal pointing up or something.

Or modify the meshes in CPU instead of GPU?

what do you mean zarch by CPU instead of GPu, r u implying to not use the shaders? I reverted back to Update methods to move the objects in the correct position, now i still have the problem with the shadows :confused:

Rather than using shaders use the information from the custom meshes (as per https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:custom_meshes) to modify the actual vertices on the objects. Keep the originals as a template and then each frame update the active model with the data from the template modified by your algorithm.

Each frame modify the vertices and then update the bounds.

It will be significantly less efficient but it does mean picking etc will work correctly…so there are trade offs. I’m not saying it is definitely the way to go but it’s worth a try.

…and if it’s a straight forward formula, Lemur’s DMesh might be able to help. It wraps a regular mesh and applies a deformation function of your choosing.

In Mythruna, I use it to bend the pages of books and animate them.