I have a simple GLSL shader that I want to use on a SpriteRenderer. However, Unity tells me that “Material uses fixed function shader. It is not compatible with SpriteRenderer.”
Indeed, when I click on the shader, the Inspector says:
Vertex Shader SM2.0
Fragment Shader Fixed Function
I don’t get why my shader is considered fixed function though. It defines a custom vertex and fragment shader, so there’s nothing FF about it afaict. What am I missing?
Thanks!
Here’s the shader code for reference:
Shader "Custom/CircleShader" {
Properties {
_Radius ("Radius",Float) = 1
_Center ("Center",Vector) = (0.0,0.0,0.0,1.0)
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
//Tags { "Queue" = "Transparent+1" }
Pass {
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
GLSLPROGRAM
#include "UnityCG.glslinc"
uniform float _Radius;
uniform vec4 _Center;
varying vec4 world_pos;
#ifdef VERTEX
void main()
{
world_pos = _Object2World * gl_Vertex;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
#endif
#ifdef FRAGMENT
void main()
{
vec2 p = vec2( world_pos.x, world_pos.y );
vec2 c = vec2( _Center.x, _Center.y );
if( distance(p,c) <= _Radius )
gl_FragColor = vec4(1.0,0.0,0.0,1.0);
else
gl_FragColor = vec4(0.0,1.0,0.0,0.0);
}
#endif
ENDGLSL
}
}
FallBack "Diffuse"
}