You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
4.5 KiB

  1. // Made with Amplify Shader Editor
  2. // Available at the Unity Asset Store - http://u3d.as/y3X
  3. Shader "ASESampleShaders/Tessellation"
  4. {
  5. Properties
  6. {
  7. _TessValue( "Max Tessellation", Range( 1, 32 ) ) = 10
  8. _TessMin( "Tess Min Distance", Float ) = 1
  9. _TessMax( "Tess Max Distance", Float ) = 2
  10. _DisplacementTex("DisplacementTex", 2D) = "white" {}
  11. _Albedo("Albedo", 2D) = "white" {}
  12. _Displacement("Displacement", Range( 0 , 1)) = 0
  13. [HideInInspector] _texcoord( "", 2D ) = "white" {}
  14. [HideInInspector] __dirty( "", Int ) = 1
  15. }
  16. SubShader
  17. {
  18. Tags{ "RenderType" = "Opaque" "Queue" = "Geometry+0" }
  19. Cull Back
  20. CGPROGRAM
  21. #include "Tessellation.cginc"
  22. #pragma target 4.6
  23. #pragma surface surf Standard keepalpha addshadow fullforwardshadows vertex:vertexDataFunc tessellate:tessFunction
  24. struct Input
  25. {
  26. float2 uv_texcoord;
  27. };
  28. struct appdata
  29. {
  30. float4 vertex : POSITION;
  31. float4 tangent : TANGENT;
  32. float3 normal : NORMAL;
  33. float4 texcoord : TEXCOORD0;
  34. float4 texcoord1 : TEXCOORD1;
  35. float4 texcoord2 : TEXCOORD2;
  36. float4 texcoord3 : TEXCOORD3;
  37. fixed4 color : COLOR;
  38. UNITY_VERTEX_INPUT_INSTANCE_ID
  39. };
  40. uniform sampler2D _Albedo;
  41. uniform float4 _Albedo_ST;
  42. uniform sampler2D _DisplacementTex;
  43. uniform float4 _DisplacementTex_ST;
  44. uniform float _Displacement;
  45. uniform float _TessValue;
  46. uniform float _TessMin;
  47. uniform float _TessMax;
  48. float4 tessFunction( appdata v0, appdata v1, appdata v2 )
  49. {
  50. return UnityDistanceBasedTess( v0.vertex, v1.vertex, v2.vertex, _TessMin, _TessMax, _TessValue );
  51. }
  52. void vertexDataFunc( inout appdata v )
  53. {
  54. float2 uv_DisplacementTex = v.texcoord * _DisplacementTex_ST.xy + _DisplacementTex_ST.zw;
  55. float3 ase_vertexNormal = v.normal.xyz;
  56. v.vertex.xyz += ( ( tex2Dlod( _DisplacementTex, float4( uv_DisplacementTex, 0, 1.0) ) * float4( ase_vertexNormal , 0.0 ) ) * _Displacement ).rgb;
  57. }
  58. void surf( Input i , inout SurfaceOutputStandard o )
  59. {
  60. float2 uv_Albedo = i.uv_texcoord * _Albedo_ST.xy + _Albedo_ST.zw;
  61. o.Albedo = tex2D( _Albedo, uv_Albedo ).rgb;
  62. o.Alpha = 1;
  63. }
  64. ENDCG
  65. }
  66. Fallback "Diffuse"
  67. CustomEditor "ASEMaterialInspector"
  68. }
  69. /*ASEBEGIN
  70. Version=13803
  71. 566;511;900;507;1502.945;339.5894;2.004493;True;False
  72. Node;AmplifyShaderEditor.NormalVertexDataNode;3;-755,403.5;Float;False;0;5;FLOAT3;FLOAT;FLOAT;FLOAT;FLOAT
  73. Node;AmplifyShaderEditor.SamplerNode;1;-772,172.5;Float;True;Property;_DisplacementTex;DisplacementTex;5;0;Assets/AmplifyShaderEditor/Examples/Assets/Textures/Sand/Sand_height.tga;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;1.0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1.0;False;5;COLOR;FLOAT;FLOAT;FLOAT;FLOAT
  74. Node;AmplifyShaderEditor.RangedFloatNode;4;-522,483.5;Float;False;Property;_Displacement;Displacement;7;0;0;0;1;0;1;FLOAT
  75. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;5;-426,290.5;Float;False;2;2;0;COLOR;0.0,0,0,0;False;1;FLOAT3;0.0,0,0,0;False;1;COLOR
  76. Node;AmplifyShaderEditor.SamplerNode;2;-476,-29.5;Float;True;Property;_Albedo;Albedo;6;0;Assets/AmplifyShaderEditor/Examples/Assets/Textures/Sand/Sand_basecolor.tga;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;1.0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1.0;False;5;COLOR;FLOAT;FLOAT;FLOAT;FLOAT
  77. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;6;-221,310.5;Float;False;2;2;0;COLOR;0.0,0,0,0;False;1;FLOAT;0.0,0,0,0;False;1;COLOR
  78. Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;0,0;Float;False;True;6;Float;ASEMaterialInspector;0;0;Standard;ASESampleShaders/Tessellation;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;Back;0;0;False;0;0;Opaque;0.5;True;True;0;False;Opaque;Geometry;All;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;False;0;255;255;0;0;0;0;0;0;0;0;True;0;10;1;2;False;0.5;True;0;Zero;Zero;0;Zero;Zero;Add;Add;0;False;0;0,0,0,0;VertexOffset;False;Cylindrical;False;Relative;0;;-1;-1;-1;0;0;0;0;False;16;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT;0.0;False;4;FLOAT;0.0;False;5;FLOAT;0.0;False;6;FLOAT3;0,0,0;False;7;FLOAT3;0,0,0;False;8;FLOAT;0.0;False;9;FLOAT;0.0;False;10;FLOAT;0.0;False;13;FLOAT3;0,0,0;False;11;FLOAT3;0,0,0;False;12;FLOAT3;0,0,0;False;14;FLOAT4;0,0,0,0;False;15;FLOAT3;0,0,0;False;0
  79. WireConnection;5;0;1;0
  80. WireConnection;5;1;3;0
  81. WireConnection;6;0;5;0
  82. WireConnection;6;1;4;0
  83. WireConnection;0;0;2;0
  84. WireConnection;0;11;6;0
  85. ASEEND*/
  86. //CHKSM=24AD83E3CEA78FA9B65BE1EABDFA84BEBAC6877D