So I am using CSG to create a custom mesh with slight ‘cuts’ in them, but then it appears there is a problem with the lights not updating.
In the playground attached, if you look at line 69-70, one has wall has the CSG cut mesh, the other one not, but you will notice that when the camera rotates, the wall with the CSG cuts does NOT update the lighting effect.
Switch second wall with commented one, and rotate it to side. you will see dark wall
Can you repro without SPS? Just to make sure we can isolate the issue
Here is a old one that doesnt use SPS, just plain boxes.
I re-applied the same lightening conditions, and the wall seems fine here.
https://playground.babylonjs.com/#V9FSLG#2
Yeah so this is related to SPS I guess then
@jerome
I notice that if I don’t do the rotation in the CSG function, the light works per expected, but obviously the cube faces the wrong way…
Quite difficult to get the reason here with this long code. Could you please isolate the problem ?
I think the only relevant lines is the function at line 199 (ApplyEdgeCutsNewer), and line 69-70.
if you comment out line 203 rotation, the light appears fine, but if you apply that rotation, the lighting doesnt update anymore.
https://playground.babylonjs.com/#7B5AN8#2
Ok it definitely something with the rotation.
In my original function , I made a cube, and placed 4x 45Degree angled cubes on the edges and then cut it.
For other faces, I just rotated the primary cube, and re-applied those cuts. In the end, I just removed all rotation. This approached caused the bug.
Now I keep my primary cube stationary, and then move the 4 ‘cutting cubes’ around. Doing this way, the lightening works as expected.
https://playground.babylonjs.com/#TCUS8V#4