Can I convert the observation vector to the light source space

Hello,I want to draw the moon on the sky box,so I need the correct UV to map the moon texture to the sky box.
I found a solution on unity shader:
///////
float3 posInLight = mul((float3x3)_LightMatrix, normalize(OUT.viewDirWS));
OUT.sunAndMoonUV.xy = (posInLight * _SunSize).xy;
float2 sunUV = IN.sunAndMoonUV.xy + 0.5;
//////
This method requires a _LightMatrix to transform the observation vector into the light source space,Unfortunately, I don’t know how to do this on babylon.
Now I’m trying to convert viewDir with lightSpaceMatrix, but it doesn’t work at all.
This is what I do in PG:https://playground.babylonjs.com/#59EJPT#51
Looking forward to your reply very much.

You must pass to your shader the light view matrix like this:

1 Like

Thank you very much for your help!