SceneKit: Is it possible to cast an shadow on an Transparent Object?

前端 未结 3 1473
梦如初夏
梦如初夏 2021-01-15 05:50

i am trying to cast an shadow on an totally transparent plane in SceneKit on OSX. I am struggling with this problem since several hours and do not come to any solution.

3条回答
  •  离开以前
    2021-01-15 06:14

    I do not have an answer to your question, however I have a workaround:

    1. Render your scene and keep the image in memory
    2. Change all the materials in your object for pure black, no specular
    3. Change the plane and the sky to a fully white material, lights to white
    4. Render the scene to another image
    5. On the second image, apply the CIColorInvertand CIMaskToAlpha Core Image filters
    6. Using Core Image apply the Alpha Mask to the first render.

    You'll get an image with a correct Alpha channel, and transparent shadows. You will need to tweak the materials and lights to get the results you want.

    The shadow may become lighter on the edges, and the only way around that is rendering it as yet another image, and filling it with black after the Mask to Alpha step.

提交回复
热议问题