Unity 3D double sided shader with alpha and depth masking

匆匆过客 提交于 2019-12-07 19:23:41

问题


I want to create a shader in Unity 3D that you can add a material to that has both depth and transparency. I have so far created a shader that appears in 'scene' mode with transparency, but when I try to preview this in my VR setup, I cannot see the backface of the image. This is a set up for Google Cardboard, so I need to have the camera inside the mesh.

This is my code so far:

Shader "Custom/transparentDepth" {
    Properties {
        _Color ("Main Color", Color) = (1,1,1,1)
            _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
    }
    SubShader {
        Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
        LOD 200

        // extra pass that renders to depth buffer only
        Pass {
            ZWrite On
            ColorMask 0
        }

        // paste in forward rendering passes from Transparent/Diffuse
        UsePass "Transparent/Diffuse/FORWARD"
    }

    Fallback "Transparent/VertexLit"
}

...and I can only assume the transparency is working as this is my 'scene' output:

来源:https://stackoverflow.com/questions/35429034/unity-3d-double-sided-shader-with-alpha-and-depth-masking

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