Shader Support VR Single Pass Instanced

在 VR 中,有时只有一只眼睛可以看见,另一只眼睛没有渲染
是因为 Shader 没有支持 Single Pass Instanced Render Mode
不用怕性能损失的话,可以 直接使用 Multi-pass Mode 解决

否则需要以下操作让 Shader 在 Single Pass Instanced 模式下让渲染 compatible

1. #include "UnityCG.cginc" - near the top of the CGPROGRAM block

2. UNITY_INSTANCE_ID - should be in the the vert input data struct (ex: appdata)

3. UNITY_SETUP_INSTANCE_ID(v); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); - should be in the vert function

4. UNITY_VERTEX_OUTPUT_STEREO - should be in the frag input data struct (ex: v2f)

–EOF–

王小兵 /
Published under (CC) BY-NC-SA in categories Unity  tagged with Unity