in threejs i was able to change the depthmaterial on each mesh to discard the same way the dissolve runs and i would get the shadow to reflect what was going on the mesh.
I have simply copied the standard shadow map vertex and fragment shaders used by the shadow generator and added the check to discard the fragment based on the noise value.
It’s a bit complicated, maybe we should think of a better way to handle this…
Note that I have disabled back face culling on the sphere, as it’s probably what you want for the shadow to be correct.
yes thats what i am going for.
but it looks like its doing it on the entire scene instead of each observable.
i added a box https://www.babylonjs-playground.com/#I669IL#4
i updated the effect values per object and now its doing what i expect. it was holding onto the effect values per observable. https://www.babylonjs-playground.com/#I669IL#5
and yeah, id agree this is a very weird way of doing it.
@Evgeni_Popov now the problem i see is if i want different shader effects for different shadows.
would i just have this giant shadow shader that i need to reset values on every observable. it doesnt look like i can quite make this dynamic per shadow very easily, i tried updating the shadowGenerator.customShaderOptions after each observable but it didnt do anything.
As an aside, how would you have used the depth material in threejs to achieve this effect? I looked at the doc of this class and could not see how it could make it worked.
[…] Ok, it is not through the MeshDepthMaterial class (what I was looking at) but by setting the customDepthMaterial / customDistanceMaterial properties it seems.
Sorry for the late response! We are about ready to deploy our project so i was finally able to test this out.
I love the new implementation, its so much easier!
But…
I am seeing significantly slower speeds when initializing objects using it compared to the work around.
I am also seeing the shadow generated flicker when resizing the screen and running engine.resize()
I will see if i can get tests in a playground to validate these issues when i get a chance…