Combining GLSL and CG..

I have a shader that on first pass uses CG to curve the plane I am using. On the second pass, it uses GLSL for lighting…

Is it possible to combine CG and GLSL like that? It compiled 100%, and the GLSL lighting effect is working 100%… But for some reason whenever I compile the shader with both the GLSL lighting and the CG curve, the curvature effect stops working, but the GLSL lighting continues to work… In other words, I can have one at a time active, but not both…

Here is my code:

Shader "Custom/Curved" {
    Properties {
        _MainTex ("Base (RGB)", 2D) = "white" {}
        _QOffset ("Offset", Vector) = (0,0,0,0)
        _Dist ("Distance", Float) = 100.0
        _BumpMap ("Normalmap", 2D) = "bump" {}
        _Color ("Main Color", Color) = (1,1,1,0.5)
        _Specular ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
		_Shininess ("Shininess", Range (0.01, 1)) = 0.5

    }

 

    SubShader {
        Tags { "RenderType"="Opaque" "LightMode" = "ForwardBase" }
        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #include "UnityCG.cginc"
            
            sampler2D _MainTex;
            float4 _QOffset;
			float _Dist;
			
			struct v2f {
			float4 pos : SV_POSITION;
			float4 uv : TEXCOORD0;
			};

 
            v2f vert (appdata_base v)
            {
            v2f o;
            float4 vPos = mul (UNITY_MATRIX_MV, v.vertex);
            float zOff = vPos.z/_Dist;
            vPos += _QOffset*zOff*zOff;
            o.pos = mul (UNITY_MATRIX_P, vPos);
            // o.uv = v.texcoord;
            o.uv = mul( UNITY_MATRIX_TEXTURE0, v.texcoord );
            return o;
            }
            
            half4 frag (v2f i) : COLOR
            {
            half4 col = tex2D(_MainTex, i.uv.xy);
            return col;
            }
            ENDCG
            
            }
            Pass {    
         	Tags { "LightMode" = "ForwardBase" } 
            // make sure that all uniforms are correctly set
 
         GLSLPROGRAM
 
         uniform vec4 _Color; // shader property specified by users
 
          //The following built-in uniforms (except _LightColor0) 
          //are also defined in "UnityCG.glslinc", 
         // i.e. one could #include "UnityCG.glslinc" 
         uniform mat4 _Object2World; // model matrix
         uniform mat4 _World2Object; // inverse model matrix
         uniform vec4 _WorldSpaceLightPos0; 
            // direction to or position of light source
         uniform vec4 _LightColor0; 
            // color of light source (from "Lighting.cginc")
 
         varying vec4 color; 
            // the diffuse lighting computed in the vertex shader
 
         #ifdef VERTEX
 
         void main()
         {                              
            mat4 modelMatrix = _Object2World;
            mat4 modelMatrixInverse = _World2Object; // unity_Scale.w
               // is unnecessary because we normalize vectors
 
            vec3 normalDirection = normalize(
               vec3(vec4(gl_Normal, 0.0) * modelMatrixInverse));
            vec3 lightDirection = normalize(
               vec3(_WorldSpaceLightPos0));
 
            vec3 diffuseReflection = vec3(_LightColor0) * vec3(_Color)
               * max(0.0, dot(normalDirection, lightDirection));
 
            color = vec4(diffuseReflection, 1.0);
            gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
         }
 
         #endif
 
         #ifdef FRAGMENT
 
         void main()
         {
            gl_FragColor = color;
         }
 
         #endif
 
         ENDGLSL
      }
            
           }
           SubShader {
	Tags { "RenderType"="Opaque" }
	LOD 300

CGPROGRAM
#pragma surface surf Lambert

sampler2D _MainTex;
sampler2D _BumpMap;
fixed4 _Color;

struct Input {
	float2 uv_MainTex;
	float2 uv_BumpMap;
};

void surf (Input IN, inout SurfaceOutput o) {
	fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
	o.Albedo = c.rgb;
	o.Alpha = c.a;
	o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
}
ENDCG  
}   
           FallBack "Diffuse"
           
        }

Why would anyone care if it worked? It seems pointless to me. What am I missing? Do you just want this because you’re copypasting?

I AM copypasting! :slight_smile:

I am trying to make a curvature shader accept lighting. But it isn’t. And I don’t think it’s possible. I read through every shader tutorial on Unity and I still can’t wrap my head around assigning light to this shader.