How to add transparency with a shader in SceneKit?

后端 未结 3 1328
不思量自难忘°
不思量自难忘° 2021-01-13 16:31

I would like to have a transparency effect from an image, for now I just test with a torus, but the shader does not seem to work with alpha. From what I understood from this

3条回答
  •  余生分开走
    2021-01-13 17:12

    Adding transparency can be quite easily done in the SCNShadable Surface or Fragment entry point

    The SCNShaderModifierEntryPointSurface entry point version

    #pragma transparent
    #pragma body
    
    _surface.diffuse.a = 0.5;
    

    The SCNShaderModifierEntryPointFragment entry point version

    #pragma transparent
    #pragma body
    
    _output.color.a = 0.5;
    

提交回复
热议问题