Forum begins after the advertisement:
-
::I’m getting an error that says “undeclared identifier ‘ambient'” This is my code.
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.screenPos);
if (i.screenPos.y > _WaterLevel.x * i.screenPos.x + _WaterLevel.y - _WaterLevel.x * 0.5) return col;
float depth = LinearEyeDepth(tex2D(_DepthMap, i.screenPos.xy));
depth = saturate((depth - _DepthStart) / _DepthEnd);
return lerp(col, (0.5 * ambient + _DepthColor * 0.5) * ambient.w, depth);
::Can you try adding this to your code?
fixed4 frag(v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.screenPos);
if (i.screenPos.y > _WaterLevel.x * i.screenPos.x + _WaterLevel.y - _WaterLevel.x * 0.5) return col;
float depth = LinearEyeDepth(tex2D(_DepthMap, i.screenPos.xy));
depth = saturate((depth - _DepthStart) / _DepthEnd);
// Use Unity's ambient light
fixed4 ambient = UNITY_LIGHTMODEL_AMBIENT;
return lerp(col, (0.5 * ambient + _DepthColor * 0.5) * ambient.w, depth);
}
Advertisement below: