I have a SCNLight
with type SCNLightTypeDirectional
. When scene rendered, model casts shadows on itself and It wasn't I expectation. How to exclude model's shadows on itself?
Or how to smooth the shadows edge? It looks very unnatural now.
There is the scenario :
Well, I find a simple way to achieve this but loss some material details.
Change the light model of material to SCNLightingModelConstant
and exclude model from lighting calculation of your SCNLight
.
1. set light model
SCNLightingModelConstant
only consider ambient light to shading, so We need ambient lights to keep model visible.
model.geometry.materials.firstObject.lightingModelName = SCNLightingModelConstant;
2. set category bit mask of model and lights
model.categoryBitMask = 1;
directionalLight.categoryBitMask = ~1UL;
If results of bitwise AND of categoryBitMask
is zero, node will not take consideration into light illumination, so there no self-shadows anymore. Shadows model casted will still remain in scene.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With