Hello. and happy new year.
So, I have a project that I need working on mobile and desktop.
You know what it means:
Mobile needs optimised content, and dektop has a big screen that will seem empty without lots of details.
So I’m tryint to use layers for that.
In 3DSmax I use the babylon.js to export gltf with some tags.
I parse them and depending on the tag I put them on different layers.
No tag, it should always render.
“low” tag, should render only in low details mode, “high” is for high details mode, bith respectively default mode for mobile and desktop.
It works fine, I am quite happy, but I have an issue with layers and shadows.
When it makes sense I want to use some of the low polygon models to cast shadows, even when in high detail mode.
I know how to do that when using writeColor to false on the material.
But 1/ There are some material I reuse on the scene, seems wastefull to have to clone them.
2/ That would require parsing every object everytime I change between high resolution mode.
Layers seem much more appropriate. But somehow it doesn’t work the way I tried:
A bit of code is beter to explain than a long post I guess, so here is a jsfiddle with comments on the code please have a look:
http://jsfiddle.net/3x0pn6wc/1/
Click on the preview to switch between lox details and high details mode.
And as you can see, although I set the directional light shadow camera layers to 1, where only the elements I want casting or receiving shadows are, the shadow map seems to be rendered depending on the layer set on the scene camera ( 2 or 3 ).
I tried to check the three.js code… but it’s a maze to me.
So can anybody please tell me if:
This is possible to do it this way?
What I am doing wrong?
Where to tweek the three.js code so that the shadow map is generated with the layers I actually ask it to use?
Thanks a bunch.