Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude model's shadows on itself?

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 : enter image description here

like image 888
ooOlly Avatar asked Oct 17 '22 07:10

ooOlly


1 Answers

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.

like image 86
ooOlly Avatar answered Nov 01 '22 10:11

ooOlly