问题
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