InstancedSurfaceShader.shader 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Upgrade NOTE: upgraded instancing buffer 'Props' to new syntax.
  2. Shader "Custom/InstancedSurfaceShader" {
  3. Properties {
  4. _Color ("Color", Color) = (1,1,1,1)
  5. _MainTex ("Albedo (RGB)", 2D) = "white" {}
  6. _Glossiness ("Smoothness", Range(0,1)) = 0.5
  7. _Metallic ("Metallic", Range(0,1)) = 0.0
  8. }
  9. SubShader {
  10. Tags { "RenderType"="Opaque" }
  11. LOD 200
  12. CGPROGRAM
  13. // Physically based Standard lighting model, and enable shadows on all light types
  14. #pragma surface surf Standard fullforwardshadows
  15. // Use shader model 3.0 target, to get nicer looking lighting
  16. #pragma target 3.0
  17. sampler2D _MainTex;
  18. struct Input {
  19. float2 uv_MainTex;
  20. };
  21. half _Glossiness;
  22. half _Metallic;
  23. fixed4 _Color;
  24. // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
  25. // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
  26. // #pragma instancing_options assumeuniformscaling
  27. UNITY_INSTANCING_BUFFER_START(Props)
  28. // put more per-instance properties here
  29. UNITY_DEFINE_INSTANCED_PROP (fixed4, _InstanceColor)
  30. #define _InstanceColor_arr Props
  31. UNITY_INSTANCING_BUFFER_END(Props)
  32. void surf (Input IN, inout SurfaceOutputStandard o) {
  33. // Albedo comes from a texture tinted by color
  34. fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * UNITY_ACCESS_INSTANCED_PROP (_InstanceColor_arr, _InstanceColor);
  35. o.Albedo = c.rgb;
  36. // Metallic and smoothness come from slider variables
  37. o.Metallic = _Metallic;
  38. o.Smoothness = _Glossiness;
  39. o.Alpha = c.a;
  40. }
  41. ENDCG
  42. }
  43. FallBack "Diffuse"
  44. }