Assignment for RMIT Mixed Reality in 2020
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.

181 lines
8.7 KiB

  1. // Made with Amplify Shader Editor
  2. // Available at the Unity Asset Store - http://u3d.as/y3X
  3. Shader "ASESampleShaders/RimLight"
  4. {
  5. Properties
  6. {
  7. _RimColor("RimColor", Color) = (0,0,0,0)
  8. _RimPower("RimPower", Range( 0 , 10)) = 0
  9. _Metallic("Metallic", 2D) = "white" {}
  10. _Occlusion("Occlusion", 2D) = "white" {}
  11. _Normals("Normals", 2D) = "bump" {}
  12. _Albedo("Albedo", 2D) = "white" {}
  13. [HideInInspector] _texcoord( "", 2D ) = "white" {}
  14. [HideInInspector] __dirty( "", Int ) = 1
  15. }
  16. SubShader
  17. {
  18. Tags{ "RenderType" = "Opaque" "Queue" = "Geometry+0" "IsEmissive" = "true" }
  19. Cull Back
  20. ZTest LEqual
  21. CGINCLUDE
  22. #include "UnityPBSLighting.cginc"
  23. #include "Lighting.cginc"
  24. #pragma target 3.0
  25. #ifdef UNITY_PASS_SHADOWCASTER
  26. #undef INTERNAL_DATA
  27. #undef WorldReflectionVector
  28. #undef WorldNormalVector
  29. #define INTERNAL_DATA half3 internalSurfaceTtoW0; half3 internalSurfaceTtoW1; half3 internalSurfaceTtoW2;
  30. #define WorldReflectionVector(data,normal) reflect (data.worldRefl, half3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal)))
  31. #define WorldNormalVector(data,normal) fixed3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal))
  32. #endif
  33. struct Input
  34. {
  35. fixed2 uv_texcoord;
  36. float3 viewDir;
  37. INTERNAL_DATA
  38. };
  39. uniform sampler2D _Normals;
  40. uniform float4 _Normals_ST;
  41. uniform sampler2D _Albedo;
  42. uniform float4 _Albedo_ST;
  43. uniform fixed _RimPower;
  44. uniform fixed4 _RimColor;
  45. uniform sampler2D _Metallic;
  46. uniform float4 _Metallic_ST;
  47. uniform sampler2D _Occlusion;
  48. uniform float4 _Occlusion_ST;
  49. void surf( Input i , inout SurfaceOutputStandard o )
  50. {
  51. float2 uv_Normals = i.uv_texcoord * _Normals_ST.xy + _Normals_ST.zw;
  52. fixed3 tex2DNode3 = UnpackNormal( tex2D( _Normals, uv_Normals ) );
  53. o.Normal = tex2DNode3;
  54. float2 uv_Albedo = i.uv_texcoord * _Albedo_ST.xy + _Albedo_ST.zw;
  55. o.Albedo = tex2D( _Albedo, uv_Albedo ).rgb;
  56. float3 normalizeResult23 = normalize( i.viewDir );
  57. float dotResult21 = dot( tex2DNode3 , normalizeResult23 );
  58. o.Emission = ( pow( ( 1.0 - saturate( dotResult21 ) ) , _RimPower ) * _RimColor ).rgb;
  59. float2 uv_Metallic = i.uv_texcoord * _Metallic_ST.xy + _Metallic_ST.zw;
  60. o.Metallic = tex2D( _Metallic, uv_Metallic ).r;
  61. float2 uv_Occlusion = i.uv_texcoord * _Occlusion_ST.xy + _Occlusion_ST.zw;
  62. o.Occlusion = tex2D( _Occlusion, uv_Occlusion ).r;
  63. o.Alpha = 1;
  64. }
  65. ENDCG
  66. CGPROGRAM
  67. #pragma surface surf Standard keepalpha fullforwardshadows
  68. ENDCG
  69. Pass
  70. {
  71. Name "ShadowCaster"
  72. Tags{ "LightMode" = "ShadowCaster" }
  73. ZWrite On
  74. CGPROGRAM
  75. #pragma vertex vert
  76. #pragma fragment frag
  77. #pragma target 3.0
  78. #pragma multi_compile_shadowcaster
  79. #pragma multi_compile UNITY_PASS_SHADOWCASTER
  80. #pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
  81. #include "HLSLSupport.cginc"
  82. #if ( SHADER_API_D3D11 || SHADER_API_GLCORE || SHADER_API_GLES3 || SHADER_API_METAL || SHADER_API_VULKAN )
  83. #define CAN_SKIP_VPOS
  84. #endif
  85. #include "UnityCG.cginc"
  86. #include "Lighting.cginc"
  87. #include "UnityPBSLighting.cginc"
  88. struct v2f
  89. {
  90. V2F_SHADOW_CASTER;
  91. float4 tSpace0 : TEXCOORD1;
  92. float4 tSpace1 : TEXCOORD2;
  93. float4 tSpace2 : TEXCOORD3;
  94. float4 texcoords01 : TEXCOORD4;
  95. UNITY_VERTEX_INPUT_INSTANCE_ID
  96. };
  97. v2f vert( appdata_full v )
  98. {
  99. v2f o;
  100. UNITY_SETUP_INSTANCE_ID( v );
  101. UNITY_INITIALIZE_OUTPUT( v2f, o );
  102. UNITY_TRANSFER_INSTANCE_ID( v, o );
  103. float3 worldPos = mul( unity_ObjectToWorld, v.vertex ).xyz;
  104. fixed3 worldNormal = UnityObjectToWorldNormal( v.normal );
  105. fixed3 worldTangent = UnityObjectToWorldDir( v.tangent.xyz );
  106. fixed tangentSign = v.tangent.w * unity_WorldTransformParams.w;
  107. fixed3 worldBinormal = cross( worldNormal, worldTangent ) * tangentSign;
  108. o.tSpace0 = float4( worldTangent.x, worldBinormal.x, worldNormal.x, worldPos.x );
  109. o.tSpace1 = float4( worldTangent.y, worldBinormal.y, worldNormal.y, worldPos.y );
  110. o.tSpace2 = float4( worldTangent.z, worldBinormal.z, worldNormal.z, worldPos.z );
  111. o.texcoords01 = float4( v.texcoord.xy, v.texcoord1.xy );
  112. TRANSFER_SHADOW_CASTER_NORMALOFFSET( o )
  113. return o;
  114. }
  115. fixed4 frag( v2f IN
  116. #if !defined( CAN_SKIP_VPOS )
  117. , UNITY_VPOS_TYPE vpos : VPOS
  118. #endif
  119. ) : SV_Target
  120. {
  121. UNITY_SETUP_INSTANCE_ID( IN );
  122. Input surfIN;
  123. UNITY_INITIALIZE_OUTPUT( Input, surfIN );
  124. surfIN.uv_texcoord.xy = IN.texcoords01.xy;
  125. float3 worldPos = float3( IN.tSpace0.w, IN.tSpace1.w, IN.tSpace2.w );
  126. fixed3 worldViewDir = normalize( UnityWorldSpaceViewDir( worldPos ) );
  127. surfIN.viewDir = IN.tSpace0.xyz * worldViewDir.x + IN.tSpace1.xyz * worldViewDir.y + IN.tSpace2.xyz * worldViewDir.z;
  128. surfIN.internalSurfaceTtoW0 = IN.tSpace0.xyz;
  129. surfIN.internalSurfaceTtoW1 = IN.tSpace1.xyz;
  130. surfIN.internalSurfaceTtoW2 = IN.tSpace2.xyz;
  131. SurfaceOutputStandard o;
  132. UNITY_INITIALIZE_OUTPUT( SurfaceOutputStandard, o )
  133. surf( surfIN, o );
  134. #if defined( CAN_SKIP_VPOS )
  135. float2 vpos = IN.pos;
  136. #endif
  137. SHADOW_CASTER_FRAGMENT( IN )
  138. }
  139. ENDCG
  140. }
  141. }
  142. Fallback "Diffuse"
  143. }
  144. /*ASEBEGIN
  145. Version=13803
  146. 566;511;900;507;1495.187;170.1838;2.333382;True;False
  147. Node;AmplifyShaderEditor.ViewDirInputsCoordNode;22;-1552,416;Float;False;Tangent;0;4;FLOAT3;FLOAT;FLOAT;FLOAT
  148. Node;AmplifyShaderEditor.NormalizeNode;23;-1329.303,412.9002;Float;False;1;0;FLOAT3;0,0,0;False;1;FLOAT3
  149. Node;AmplifyShaderEditor.SamplerNode;3;-1552,144;Float;True;Property;_Normals;Normals;4;0;None;True;0;True;bump;Auto;True;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;0,0;False;1;FLOAT2;1.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
  150. Node;AmplifyShaderEditor.DotProductOpNode;21;-1137.603,334.4997;Float;False;2;0;FLOAT3;0.0,0,0;False;1;FLOAT3;0.0,0,0;False;1;FLOAT
  151. Node;AmplifyShaderEditor.SaturateNode;20;-962.4039,309.9996;Float;False;1;0;FLOAT;1.23;False;1;FLOAT
  152. Node;AmplifyShaderEditor.OneMinusNode;5;-793.4009,352.2989;Float;False;1;0;FLOAT;0;False;1;FLOAT
  153. Node;AmplifyShaderEditor.RangedFloatNode;28;-890.0026,467.6995;Float;False;Property;_RimPower;RimPower;1;0;0;0;10;0;1;FLOAT
  154. Node;AmplifyShaderEditor.PowerNode;26;-600.6031,375.6995;Float;False;2;0;FLOAT;0.0;False;1;FLOAT;0.0;False;1;FLOAT
  155. Node;AmplifyShaderEditor.ColorNode;25;-606.8026,555.4988;Float;False;Property;_RimColor;RimColor;0;0;0,0,0,0;0;5;COLOR;FLOAT;FLOAT;FLOAT;FLOAT
  156. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;27;-358.2028,390.8992;Float;False;2;2;0;FLOAT;0;False;1;COLOR;0.0;False;1;COLOR
  157. Node;AmplifyShaderEditor.SamplerNode;2;-213.5002,481.3999;Float;True;Property;_Metallic;Metallic;2;0;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;0,0;False;1;FLOAT2;1,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
  158. Node;AmplifyShaderEditor.SamplerNode;1;-210.5004,83.20016;Float;True;Property;_Albedo;Albedo;5;0;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;0,0;False;1;FLOAT2;1,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
  159. Node;AmplifyShaderEditor.SamplerNode;4;-208.9012,673.0024;Float;True;Property;_Occlusion;Occlusion;3;0;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;0,0;False;1;FLOAT2;1,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
  160. Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;147.2,339.6;Fixed;False;True;2;Fixed;;0;0;Standard;ASESampleShaders/RimLight;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;False;4;FLOAT;0;False;5;FLOAT;0;False;6;FLOAT3;0,0,0;False;7;FLOAT3;0,0,0;False;8;FLOAT;0.0;False;9;FLOAT;0;False;10;FLOAT;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
  161. WireConnection;23;0;22;0
  162. WireConnection;21;0;3;0
  163. WireConnection;21;1;23;0
  164. WireConnection;20;0;21;0
  165. WireConnection;5;0;20;0
  166. WireConnection;26;0;5;0
  167. WireConnection;26;1;28;0
  168. WireConnection;27;0;26;0
  169. WireConnection;27;1;25;0
  170. WireConnection;0;0;1;0
  171. WireConnection;0;1;3;0
  172. WireConnection;0;2;27;0
  173. WireConnection;0;3;2;0
  174. WireConnection;0;5;4;0
  175. ASEEND*/
  176. //CHKSM=2A3B3D22176020238140A4ABA160CFED64996DF3