I have a shader where I set something in a vertex. When I reach the surf part, that value is lost. In the example shown it should be white in IN.objPos but its red
Shader “Custom/HoleShader”
{
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
_HoleDistance (“Hole Distance”, float) = 0.7
}
SubShader
{
Tags {“Queue” = “Transparent” “RenderType”=“Transparent” “DisableBatching” = “true” }
LOD 200
CGPROGRAM
#pragma surface surf Standard fullforwardshadows alpha:fade
#pragma target 3.0
sampler2D _MainTex;
struct Input {
float2 uv_MainTex;
float3 worldPos;
float4 objPos;
};
half _Glossiness;
half _Metallic;
fixed4 _Color;
float _BulletHoleCount;
float4 _BulletHoles[20];
float _HoleDistance;
void vert (inout appdata_full v, out Input o)
{
UNITY_INITIALIZE_OUTPUT(Input,o);
o.objPos.r=1;
o.objPos.g=1;
o.objPos.b=1;
o.objPos.a=1;
}
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
IN.objPos.a = 1;
IN.objPos.r = 1;
c *= IN.objPos;
o.Albedo = c.rgb;
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = c.a;
}
ENDCG
}
FallBack “Standard”
}