Can we render shadow on a transparent Plane in SceneKit

最后都变了- 提交于 2019-11-28 01:38:42

问题


I have used shader modifiers for Plane but its not working. Can anyone suggest me how to solve it?

let myShaderfragment = "#pragma transparent;\n" + "_output.color.a = 0.0;"
let myShaderSurface = "#pragma transparent;\n" + "_surface.diffuse.a = 0.0;"
 material.shaderModifiers = [SCNShaderModifierEntryPoint.fragment : myShaderfragment, SCNShaderModifierEntryPoint.surface : myShaderSurface]

回答1:


The SceneKit: What's New session from WWDC 2017 explains how to do that.

  1. For the plane, use a material with constant as its lightingModel. It's the cheapest one.
  2. This material will have writesToDepthBuffer set to true and colorBufferWriteMask set to [] (empty option set). That way the plane will write in the depth buffer, but won't draw anything on screen.
  3. Set the light's shadowMode to deferred so that shadows are not applied when rendering the objects themselves, but as a final post-process.



回答2:


There's a dedicated lighting model now (SCNLightingModelShadowOnly) to only render shadows



来源:https://stackoverflow.com/questions/45505471/can-we-render-shadow-on-a-transparent-plane-in-scenekit

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!