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.

166 lines
7.7 KiB

  1. // Made with Amplify Shader Editor
  2. // Available at the Unity Asset Store - http://u3d.as/y3X
  3. Shader "ASESampleShaders/CubemapReflections"
  4. {
  5. Properties
  6. {
  7. _Albedo("Albedo", 2D) = "white" {}
  8. _Normals("Normals", 2D) = "bump" {}
  9. _Cubemap("Cubemap", CUBE) = "white" {}
  10. _Metallic("Metallic", 2D) = "white" {}
  11. [HideInInspector] _texcoord( "", 2D ) = "white" {}
  12. [HideInInspector] __dirty( "", Int ) = 1
  13. }
  14. SubShader
  15. {
  16. Tags{ "RenderType" = "Opaque" "Queue" = "Geometry+0" "IsEmissive" = "true" }
  17. Cull Back
  18. ZTest LEqual
  19. CGINCLUDE
  20. #include "UnityPBSLighting.cginc"
  21. #include "Lighting.cginc"
  22. #pragma target 3.0
  23. #ifdef UNITY_PASS_SHADOWCASTER
  24. #undef INTERNAL_DATA
  25. #undef WorldReflectionVector
  26. #undef WorldNormalVector
  27. #define INTERNAL_DATA half3 internalSurfaceTtoW0; half3 internalSurfaceTtoW1; half3 internalSurfaceTtoW2;
  28. #define WorldReflectionVector(data,normal) reflect (data.worldRefl, half3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal)))
  29. #define WorldNormalVector(data,normal) fixed3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal))
  30. #endif
  31. struct Input
  32. {
  33. float2 uv_texcoord;
  34. float3 worldRefl;
  35. INTERNAL_DATA
  36. };
  37. uniform sampler2D _Normals;
  38. uniform float4 _Normals_ST;
  39. uniform sampler2D _Albedo;
  40. uniform float4 _Albedo_ST;
  41. uniform samplerCUBE _Cubemap;
  42. uniform sampler2D _Metallic;
  43. uniform float4 _Metallic_ST;
  44. void surf( Input i , inout SurfaceOutputStandard o )
  45. {
  46. float2 uv_Normals = i.uv_texcoord * _Normals_ST.xy + _Normals_ST.zw;
  47. float3 tex2DNode10 = UnpackNormal( tex2D( _Normals, uv_Normals ) );
  48. o.Normal = tex2DNode10;
  49. float2 uv_Albedo = i.uv_texcoord * _Albedo_ST.xy + _Albedo_ST.zw;
  50. o.Albedo = ( tex2D( _Albedo, uv_Albedo ) * 0.5 ).rgb;
  51. o.Emission = ( ( 1.0 - 0.5 ) * texCUBE( _Cubemap, WorldReflectionVector( i , tex2DNode10 ) ) ).rgb;
  52. float2 uv_Metallic = i.uv_texcoord * _Metallic_ST.xy + _Metallic_ST.zw;
  53. o.Metallic = tex2D( _Metallic, uv_Metallic ).r;
  54. o.Alpha = 1;
  55. }
  56. ENDCG
  57. CGPROGRAM
  58. #pragma surface surf Standard keepalpha fullforwardshadows
  59. ENDCG
  60. Pass
  61. {
  62. Name "ShadowCaster"
  63. Tags{ "LightMode" = "ShadowCaster" }
  64. ZWrite On
  65. CGPROGRAM
  66. #pragma vertex vert
  67. #pragma fragment frag
  68. #pragma target 3.0
  69. #pragma multi_compile_shadowcaster
  70. #pragma multi_compile UNITY_PASS_SHADOWCASTER
  71. #pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
  72. #include "HLSLSupport.cginc"
  73. #if ( SHADER_API_D3D11 || SHADER_API_GLCORE || SHADER_API_GLES3 || SHADER_API_METAL || SHADER_API_VULKAN )
  74. #define CAN_SKIP_VPOS
  75. #endif
  76. #include "UnityCG.cginc"
  77. #include "Lighting.cginc"
  78. #include "UnityPBSLighting.cginc"
  79. struct v2f
  80. {
  81. V2F_SHADOW_CASTER;
  82. float4 tSpace0 : TEXCOORD1;
  83. float4 tSpace1 : TEXCOORD2;
  84. float4 tSpace2 : TEXCOORD3;
  85. float4 texcoords01 : TEXCOORD4;
  86. UNITY_VERTEX_INPUT_INSTANCE_ID
  87. };
  88. v2f vert( appdata_full v )
  89. {
  90. v2f o;
  91. UNITY_SETUP_INSTANCE_ID( v );
  92. UNITY_INITIALIZE_OUTPUT( v2f, o );
  93. UNITY_TRANSFER_INSTANCE_ID( v, o );
  94. float3 worldPos = mul( unity_ObjectToWorld, v.vertex ).xyz;
  95. fixed3 worldNormal = UnityObjectToWorldNormal( v.normal );
  96. fixed3 worldTangent = UnityObjectToWorldDir( v.tangent.xyz );
  97. fixed tangentSign = v.tangent.w * unity_WorldTransformParams.w;
  98. fixed3 worldBinormal = cross( worldNormal, worldTangent ) * tangentSign;
  99. o.tSpace0 = float4( worldTangent.x, worldBinormal.x, worldNormal.x, worldPos.x );
  100. o.tSpace1 = float4( worldTangent.y, worldBinormal.y, worldNormal.y, worldPos.y );
  101. o.tSpace2 = float4( worldTangent.z, worldBinormal.z, worldNormal.z, worldPos.z );
  102. o.texcoords01 = float4( v.texcoord.xy, v.texcoord1.xy );
  103. TRANSFER_SHADOW_CASTER_NORMALOFFSET( o )
  104. return o;
  105. }
  106. fixed4 frag( v2f IN
  107. #if !defined( CAN_SKIP_VPOS )
  108. , UNITY_VPOS_TYPE vpos : VPOS
  109. #endif
  110. ) : SV_Target
  111. {
  112. UNITY_SETUP_INSTANCE_ID( IN );
  113. Input surfIN;
  114. UNITY_INITIALIZE_OUTPUT( Input, surfIN );
  115. surfIN.uv_texcoord.xy = IN.texcoords01.xy;
  116. float3 worldPos = float3( IN.tSpace0.w, IN.tSpace1.w, IN.tSpace2.w );
  117. fixed3 worldViewDir = normalize( UnityWorldSpaceViewDir( worldPos ) );
  118. surfIN.worldRefl = -worldViewDir;
  119. surfIN.internalSurfaceTtoW0 = IN.tSpace0.xyz;
  120. surfIN.internalSurfaceTtoW1 = IN.tSpace1.xyz;
  121. surfIN.internalSurfaceTtoW2 = IN.tSpace2.xyz;
  122. SurfaceOutputStandard o;
  123. UNITY_INITIALIZE_OUTPUT( SurfaceOutputStandard, o )
  124. surf( surfIN, o );
  125. #if defined( CAN_SKIP_VPOS )
  126. float2 vpos = IN.pos;
  127. #endif
  128. SHADOW_CASTER_FRAGMENT( IN )
  129. }
  130. ENDCG
  131. }
  132. }
  133. Fallback "Diffuse"
  134. CustomEditor "ASEMaterialInspector"
  135. }
  136. /*ASEBEGIN
  137. Version=13803
  138. 566;511;900;507;1894.669;558.1631;2.459016;True;False
  139. Node;AmplifyShaderEditor.SamplerNode;10;-1232,16;Float;True;Property;_Normals;Normals;1;0;None;True;0;True;bump;Auto;True;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;0,0;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;FLOAT3;FLOAT;FLOAT;FLOAT;FLOAT
  140. Node;AmplifyShaderEditor.RangedFloatNode;4;-640,-32;Float;False;Constant;_Float0;Float 0;-1;0;0.5;0;0;0;1;FLOAT
  141. Node;AmplifyShaderEditor.WorldReflectionVector;9;-896,256;Float;False;1;0;FLOAT3;0,0,0;False;4;FLOAT3;FLOAT;FLOAT;FLOAT
  142. Node;AmplifyShaderEditor.OneMinusNode;6;-432,144;Float;False;1;0;FLOAT;0.0;False;1;FLOAT
  143. Node;AmplifyShaderEditor.SamplerNode;2;-640,-256;Float;True;Property;_Albedo;Albedo;0;0;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;0,0;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
  144. Node;AmplifyShaderEditor.SamplerNode;1;-640,256;Float;True;Property;_Cubemap;Cubemap;2;0;None;True;0;False;white;Auto;False;Object;-1;Auto;Cube;6;0;SAMPLER2D;0,0;False;1;FLOAT3;0,0;False;2;FLOAT;1.0;False;3;FLOAT3;0,0,0;False;4;FLOAT3;0,0,0;False;5;FLOAT;1.0;False;5;COLOR;FLOAT;FLOAT;FLOAT;FLOAT
  145. Node;AmplifyShaderEditor.SamplerNode;13;-304,304;Float;True;Property;_Metallic;Metallic;3;0;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;0,0;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
  146. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;7;-240,144;Float;False;2;2;0;FLOAT;0.0;False;1;COLOR;0;False;1;COLOR
  147. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;3;-256,-48;Float;False;2;2;0;COLOR;0.0,0,0,0;False;1;FLOAT;0.0,0,0,0;False;1;COLOR
  148. Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;64,0;Float;False;True;2;Float;ASEMaterialInspector;0;0;Standard;ASESampleShaders/CubemapReflections;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;Back;0;3;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;False;0;4;10;25;False;0.5;True;0;Zero;Zero;0;Zero;Zero;OFF;OFF;0;False;0;0,0,0,0;VertexOffset;False;Cylindrical;False;Relative;0;;-1;-1;-1;-1;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;False;13;FLOAT3;0,0,0;False;11;FLOAT3;0,0,0;False;12;FLOAT3;0.0,0,0;False;14;FLOAT4;0,0,0,0;False;15;FLOAT3;0,0,0;False;0
  149. WireConnection;9;0;10;0
  150. WireConnection;6;0;4;0
  151. WireConnection;1;1;9;0
  152. WireConnection;7;0;6;0
  153. WireConnection;7;1;1;0
  154. WireConnection;3;0;2;0
  155. WireConnection;3;1;4;0
  156. WireConnection;0;0;3;0
  157. WireConnection;0;1;10;0
  158. WireConnection;0;2;7;0
  159. WireConnection;0;3;13;0
  160. ASEEND*/
  161. //CHKSM=FC88F8FF86234414514219923686C8BBBB380421