Search Unity

Single Pass Stereo Rendering for Standard Shader with Tesselation

Discussion in 'VR' started by zulaman, Jun 3, 2020.

  1. zulaman

    zulaman

    Joined:
    May 12, 2017
    Posts:
    26
    Hi there,
    I'm trying to add Single Pass Stereo Rendering support to a standard Phong tessellation shader found here (Phone Tessellation at the end).
    The problem is that every example that I found for adding single pass stereo is for vertex/frag shaders, not Unity Standard Surface shaders.
    Does anyone have a working example of single pass rendering shader that uses tessellation or know how to fix this shader? I'm adding the starting point shader below .
    Thanks.

    Code (CSharp):
    1.  Shader "Phong Tessellation" {
    2.         Properties {
    3.             _EdgeLength ("Edge length", Range(2,50)) = 5
    4.             _Phong ("Phong Strengh", Range(0,1)) = 0.5
    5.             _MainTex ("Base (RGB)", 2D) = "white" {}
    6.             _Color ("Color", color) = (1,1,1,0)
    7.         }
    8.         SubShader {
    9.             Tags { "RenderType"="Opaque" }
    10.             LOD 300
    11.            
    12.             CGPROGRAM
    13.             #pragma surface surf Lambert vertex:dispNone tessellate:tessEdge tessphong:_Phong nolightmap
    14.             #include "Tessellation.cginc"
    15.  
    16.             struct appdata {
    17.                 float4 vertex : POSITION;
    18.                 float3 normal : NORMAL;
    19.                 float2 texcoord : TEXCOORD0;
    20.             };
    21.  
    22.             void dispNone (inout appdata v) { }
    23.  
    24.             float _Phong;
    25.             float _EdgeLength;
    26.  
    27.             float4 tessEdge (appdata v0, appdata v1, appdata v2)
    28.             {
    29.                 return UnityEdgeLengthBasedTess (v0.vertex, v1.vertex, v2.vertex, _EdgeLength);
    30.             }
    31.  
    32.             struct Input {
    33.                 float2 uv_MainTex;
    34.             };
    35.  
    36.             fixed4 _Color;
    37.             sampler2D _MainTex;
    38.  
    39.             void surf (Input IN, inout SurfaceOutput o) {
    40.                 half4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
    41.                 o.Albedo = c.rgb;
    42.                 o.Alpha = c.a;
    43.             }
    44.  
    45.             ENDCG
    46.         }
    47.         FallBack "Diffuse"
    48.     }