ScrollingTextureShader.shader 1.8 KB

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