Tessellation with vertex output shader?

I’m currently working on a water shader that contains animated waves by manipulating the vertex output and uses tessellation to subdivide the mesh for better optimization. I’m currently attempting to add another aspect of the shader that changes the wave color based on height (using a gradient), but In order to do this, I need to uses #pragma frag, which doesn’t seem to want to work with tessellation. How could this be achieved?

Here is what I have so far:

Shader "Animated/Water" {
        Properties {
            _Tess ("Tessellation", Range(1,32)) = 4
            _MainTex ("Base (RGB)", 2D) = "white" {}
            _GradientTex("Gradient", 2D) = "white" {}
            _ColorTint("Tint", Color) = (1, 1, 1, 1)
            _Color ("Color", color) = (1,1,1,0)
            _WaveAmpX("Wave Amplitude X", float) = 0.2
            _WaveAmpY("Wave Amplitude Y", float) = 0.2
            _WaveSpeedX("Wave Speed X", float) = 1.0
            _WaveSpeedY("Wave Speed Y", float) = 1.0
            _WaveScale("Wave Scale", float) = 1.0
        }
        SubShader {
            Tags { "RenderType"="Opaque" }
            LOD 300
           
            CGPROGRAM
            #pragma surface surf BlinnPhong addshadow fullforwardshadows vertex:disp tessellate:tessFixed nolightmap
            #pragma target 4.6
            //#pragma fragment frag

            struct appdata
            {
                float4 vertex : POSITION;
                float4 tangent : TANGENT;
                float3 normal : NORMAL;
                float2 texcoord : TEXCOORD0;
            };

            float _Tess;
            float _WaveSpeedX;
             float _WaveSpeedY;
            float _WaveAmpX;
            float _WaveAmpY;
            float _WaveScale;
            float _TimeValue;

            sampler2D _GradientTex;
            float4 _ColorTint;

            float4 tessFixed()
            {
                return _Tess;
            }

            sampler2D _DispTex;
            float _Displacement;

            void disp (inout appdata v)
            {
                half offsetvert1 = v.vertex.x;
                half offsetvert2 = v.vertex.z;

               half value1 = _WaveScale * sin(_TimeValue * _WaveSpeedX + offsetvert1 * _WaveAmpX);
               half value2 = _WaveScale * sin(_TimeValue * _WaveSpeedY + offsetvert2 * _WaveAmpY);

                v.vertex.y += value1;
                v.vertex.y += value2/2;
            }

            struct Input {
                float2 uv_MainTex;
            };

            sampler2D _MainTex;
            fixed4 _Color;

            void surf (Input IN, inout SurfaceOutput o) {
                half4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
                o.Albedo = c.rgb;
            }


            ENDCG
        }
        FallBack "Diffuse"
    }

You can use it with a frag as it sits between the vert and frag shader in the pipeline.

Follow this tutorial from start to finish:

It will show you what you need :slight_smile:

EDIT:

you have made a surface shader. You cant use a surface shader with a fragment shader. That is the problem here.