How to exclude model shadows on yourself?

I have SCNLight with type SCNLightTypeDirectional . When the scene is rendered, the model casts a shadow over itself, and that was not me expectation. How to exclude model shadows on yourself?

Or how to smooth the edge of the shadows? Now it looks unnatural.

There is a scenario: enter image description here

+5
source share
1 answer

Well, I find an easy way to achieve this, but lose some material details.

Change the light model of the material to SCNLightingModelConstant and exclude the model from the lighting calculation of your SCNLight .

1. set light model

SCNLightingModelConstant consider ambient light only for shading, so we need external lights to preserve the visible model.

 model.geometry.materials.firstObject.lightingModelName = SCNLightingModelConstant; 

2. preset bitmask categories and indicators

 model.categoryBitMask = 1; directionalLight.categoryBitMask = ~1UL; 

If the results of bitwise AND from categoryBitMask are zero, the node will not be taken into account when lighting, so there is no longer a shadow. The Shadows model will remain in the scene.

+2
source

Source: https://habr.com/ru/post/1271002/


All Articles