- Home /
Standard surface shader is pink
I am currently trying to learn more about surface shaders in Unity. Therefor I am using this guide to make waves( https://catlikecoding.com/unity/tutorials/flow/waves/ ). The only problem is that if I create a new "standard surface shader" and I apply this to a material on a plane. It is already pink from the start. The unlit shader doesnt have this problem. As shown below this is just the default code when I create the shader. Am I doing something wrong?
Thanks in advance.
Shader "Custom/Waves"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard fullforwardshadows
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _MainTex;
struct Input
{
float2 uv_MainTex;
};
half _Glossiness;
half _Metallic;
fixed4 _Color;
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
// #pragma instancing_options assumeuniformscaling
UNITY_INSTANCING_BUFFER_START(Props)
// put more per-instance properties here
UNITY_INSTANCING_BUFFER_END(Props)
void surf (Input IN, inout SurfaceOutputStandard o)
{
// Albedo comes from a texture tinted by color
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
// Metallic and smoothness come from slider variables
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
Are you using a custom render pipeline (URP, HDRP, etc)? Because surface shaders are only compatible with the builtin pipeline.
Yes I am using URP. So it seems like I cant use surface shaders with URP. But can I still use unlit shaders without any problems? Because these arent that different from each other right?
Surface shaders and unlit shaders are completely different. The point of surface shaders is to abstract away low level lighting control so that you can have a unified interface with the lighting system without needing to worry about all the specifics. However, these were written for the builtin pipeline, and the new SRPs use completely different lighting architectures and thus don't compile. Technically you could force the shader to compile, but you wouldn't get much out of doing so (chances are it would just render black). Unlit shaders are very basic and fairly platform agnostic, and as such should work with any of the new pipelines (although you would probably still want to write them in the style of the new pipelines rather than using older ones as a few things have changed).