no idea why it doesn’t work, all seems fine to me… but if i change tilling or _CleanTexture value on one instance the other one also applies it.
Shader "Custom/WaterDirt"
{
Properties
{
[Toggle(DEBUG_NOISE)]_debug("Noise map debug", int) = 0
[NoScaleOffset]_MainTex("Albedo (RGB)", 2D) = "white" {}
_TillingOffsetA ("Tilling & Offset", Vector) = (1,1,0,0)
[NoScaleOffset]_BumpMap("Bumpmap", 2D) = "bump" {}
[NoScaleOffset]_NoiseTex ("NoiseMask (RGB)", 2D) = "white" {}
_TillingOffsetN("Tilling & Offset", Vector) = (1,1,0,0)
_Cutoff("Alpha cutoff", Range(0,1)) = 0.5
_CleanTexture("Clean Texture", Range(0,1)) = 0.0
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
}
SubShader
{
Tags {"Queue" = "AlphaTest" "IgnoreProjector" = "True" "RenderType" = "TransparentCutout"}
LOD 300
CGPROGRAM
#pragma surface surf Standard fullforwardshadows alphatest:_Cutoff
#pragma shader_feature DEBUG_NOISE
#pragma multi_compile_instancing
#pragma target 3.0
sampler2D _MainTex;
sampler2D _BumpMap;
sampler2D _NoiseTex;
struct Input
{
float2 uv_MainTex;
};
half _Glossiness;
half _Metallic;
// #pragma instancing_options assumeuniformscaling
UNITY_INSTANCING_BUFFER_START(Props)
UNITY_DEFINE_INSTANCED_PROP(fixed4, _TillingOffsetA)
UNITY_DEFINE_INSTANCED_PROP(fixed4, _TillingOffsetN)
UNITY_DEFINE_INSTANCED_PROP(half, _CleanTexture)
UNITY_INSTANCING_BUFFER_END(Props)
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 toA = UNITY_ACCESS_INSTANCED_PROP(Props, _TillingOffsetA);
fixed4 a = tex2D(_MainTex, toA.zw + IN.uv_MainTex * toA.xy);
fixed3 b = UnpackNormal(tex2D(_MainTex, toA.zw + IN.uv_MainTex * toA.xy));
fixed4 toN = UNITY_ACCESS_INSTANCED_PROP(Props, _TillingOffsetN);
fixed3 n = tex2D (_NoiseTex, toN.zw + IN.uv_MainTex * toN.xy);
o.Albedo = a.rgb;
#ifdef DEBUG_NOISE
o.Albedo = n.rgb;
#endif
o.Alpha = a.a * n.r * UNITY_ACCESS_INSTANCED_PROP(Props, _CleanTexture);
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
}
ENDCG
}
FallBack "Diffuse"
}