// Made with Amplify Shader Editor // Available at the Unity Asset Store - http://u3d.as/y3X Shader "SyntyStudios/TriplanarGrime" { Properties { _Overlay("Overlay", 2D) = "white" {} _FallOff("FallOff", Float) = 0 _Tiling("Tiling", Float) = 0 _Emission("Emission", 2D) = "white" {} _Texture("Texture", 2D) = "white" {} _EmissionColor("EmissionColor", Color) = (0,0,0,0) _DirtAmount("DirtAmount", Range( 0.5 , 1.2)) = 1 _SmoothnessSpec("Smoothness(Spec)", Range( 0 , 1)) = 0.2 _Metallic("Metallic", Range( 0 , 1)) = 0 _NormalMap("NormalMap", 2D) = "bump" {} [HideInInspector] _texcoord( "", 2D ) = "white" {} [HideInInspector] __dirty( "", Int ) = 1 } SubShader { Tags{ "RenderType" = "Opaque" "Queue" = "Geometry+0" "IsEmissive" = "true" } Cull Back CGINCLUDE #include "UnityPBSLighting.cginc" #include "Lighting.cginc" #pragma target 3.0 #ifdef UNITY_PASS_SHADOWCASTER #undef INTERNAL_DATA #undef WorldReflectionVector #undef WorldNormalVector #define INTERNAL_DATA half3 internalSurfaceTtoW0; half3 internalSurfaceTtoW1; half3 internalSurfaceTtoW2; #define WorldReflectionVector(data,normal) reflect (data.worldRefl, half3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal))) #define WorldNormalVector(data,normal) half3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal)) #endif struct Input { float2 uv_texcoord; float3 worldPos; float3 worldNormal; INTERNAL_DATA }; uniform sampler2D _NormalMap; uniform float4 _NormalMap_ST; uniform sampler2D _Texture; uniform float4 _Texture_ST; uniform sampler2D _Overlay; uniform float _Tiling; uniform float _FallOff; uniform float _DirtAmount; uniform sampler2D _Emission; uniform float4 _Emission_ST; uniform float4 _EmissionColor; uniform float _Metallic; uniform float _SmoothnessSpec; inline float4 TriplanarSampling1( sampler2D topTexMap, sampler2D midTexMap, sampler2D botTexMap, float3 worldPos, float3 worldNormal, float falloff, float2 tiling, float3 normalScale, float3 index ) { float3 projNormal = ( pow( abs( worldNormal ), falloff ) ); projNormal /= ( projNormal.x + projNormal.y + projNormal.z ) + 0.00001; float3 nsign = sign( worldNormal ); float negProjNormalY = max( 0, projNormal.y * -nsign.y ); projNormal.y = max( 0, projNormal.y * nsign.y ); half4 xNorm; half4 yNorm; half4 yNormN; half4 zNorm; xNorm = tex2D( midTexMap, tiling * worldPos.zy * float2( nsign.x, 1.0 ) ); yNorm = tex2D( topTexMap, tiling * worldPos.xz * float2( nsign.y, 1.0 ) ); yNormN = tex2D( botTexMap, tiling * worldPos.xz * float2( nsign.y, 1.0 ) ); zNorm = tex2D( midTexMap, tiling * worldPos.xy * float2( -nsign.z, 1.0 ) ); return xNorm * projNormal.x + yNorm * projNormal.y + yNormN * negProjNormalY + zNorm * projNormal.z; } void surf( Input i , inout SurfaceOutputStandard o ) { float2 uv_NormalMap = i.uv_texcoord * _NormalMap_ST.xy + _NormalMap_ST.zw; o.Normal = UnpackNormal( tex2D( _NormalMap, uv_NormalMap ) ); float2 uv_Texture = i.uv_texcoord * _Texture_ST.xy + _Texture_ST.zw; float3 ase_worldPos = i.worldPos; float3 ase_worldNormal = WorldNormalVector( i, float3( 0, 0, 1 ) ); float4 triplanar1 = TriplanarSampling1( _Overlay, _Overlay, _Overlay, ase_worldPos, ase_worldNormal, _FallOff, _Tiling, float3( 1,1,1 ), float3(0,0,0) ); float4 temp_cast_0 = (_DirtAmount).xxxx; float4 clampResult17 = clamp( triplanar1 , temp_cast_0 , float4( 1,1,1,0 ) ); o.Albedo = ( tex2D( _Texture, uv_Texture ) * clampResult17 ).rgb; float2 uv_Emission = i.uv_texcoord * _Emission_ST.xy + _Emission_ST.zw; o.Emission = ( tex2D( _Emission, uv_Emission ) * _EmissionColor ).rgb; o.Metallic = _Metallic; o.Smoothness = _SmoothnessSpec; o.Alpha = 1; } ENDCG CGPROGRAM #pragma surface surf Standard keepalpha fullforwardshadows ENDCG Pass { Name "ShadowCaster" Tags{ "LightMode" = "ShadowCaster" } ZWrite On CGPROGRAM #pragma vertex vert #pragma fragment frag #pragma target 3.0 #pragma multi_compile_shadowcaster #pragma multi_compile UNITY_PASS_SHADOWCASTER #pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2 #include "HLSLSupport.cginc" #if ( SHADER_API_D3D11 || SHADER_API_GLCORE || SHADER_API_GLES3 || SHADER_API_METAL || SHADER_API_VULKAN ) #define CAN_SKIP_VPOS #endif #include "UnityCG.cginc" #include "Lighting.cginc" #include "UnityPBSLighting.cginc" struct v2f { V2F_SHADOW_CASTER; float2 customPack1 : TEXCOORD1; float4 tSpace0 : TEXCOORD2; float4 tSpace1 : TEXCOORD3; float4 tSpace2 : TEXCOORD4; UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_OUTPUT_STEREO }; v2f vert( appdata_full v ) { v2f o; UNITY_SETUP_INSTANCE_ID( v ); UNITY_INITIALIZE_OUTPUT( v2f, o ); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o ); UNITY_TRANSFER_INSTANCE_ID( v, o ); Input customInputData; float3 worldPos = mul( unity_ObjectToWorld, v.vertex ).xyz; half3 worldNormal = UnityObjectToWorldNormal( v.normal ); half3 worldTangent = UnityObjectToWorldDir( v.tangent.xyz ); half tangentSign = v.tangent.w * unity_WorldTransformParams.w; half3 worldBinormal = cross( worldNormal, worldTangent ) * tangentSign; o.tSpace0 = float4( worldTangent.x, worldBinormal.x, worldNormal.x, worldPos.x ); o.tSpace1 = float4( worldTangent.y, worldBinormal.y, worldNormal.y, worldPos.y ); o.tSpace2 = float4( worldTangent.z, worldBinormal.z, worldNormal.z, worldPos.z ); o.customPack1.xy = customInputData.uv_texcoord; o.customPack1.xy = v.texcoord; TRANSFER_SHADOW_CASTER_NORMALOFFSET( o ) return o; } half4 frag( v2f IN #if !defined( CAN_SKIP_VPOS ) , UNITY_VPOS_TYPE vpos : VPOS #endif ) : SV_Target { UNITY_SETUP_INSTANCE_ID( IN ); Input surfIN; UNITY_INITIALIZE_OUTPUT( Input, surfIN ); surfIN.uv_texcoord = IN.customPack1.xy; float3 worldPos = float3( IN.tSpace0.w, IN.tSpace1.w, IN.tSpace2.w ); half3 worldViewDir = normalize( UnityWorldSpaceViewDir( worldPos ) ); surfIN.worldPos = worldPos; surfIN.worldNormal = float3( IN.tSpace0.z, IN.tSpace1.z, IN.tSpace2.z ); surfIN.internalSurfaceTtoW0 = IN.tSpace0.xyz; surfIN.internalSurfaceTtoW1 = IN.tSpace1.xyz; surfIN.internalSurfaceTtoW2 = IN.tSpace2.xyz; SurfaceOutputStandard o; UNITY_INITIALIZE_OUTPUT( SurfaceOutputStandard, o ) surf( surfIN, o ); #if defined( CAN_SKIP_VPOS ) float2 vpos = IN.pos; #endif SHADOW_CASTER_FRAGMENT( IN ) } ENDCG } } Fallback "Diffuse" CustomEditor "ASEMaterialInspector" } /*ASEBEGIN Version=18909 342;146;2255;1274;1351.673;603.8397;1.37;True;True Node;AmplifyShaderEditor.TexturePropertyNode;2;-726.93,-421.19;Float;True;Property;_Overlay;Overlay;0;0;Create;True;0;0;0;False;0;False;None;9e88b336bd16b1e4b99de75f486126c1;False;white;Auto;Texture2D;-1;0;2;SAMPLER2D;0;SAMPLERSTATE;1 Node;AmplifyShaderEditor.RangedFloatNode;4;-697.93,-62.18997;Float;False;Property;_FallOff;FallOff;1;0;Create;True;0;0;0;False;0;False;0;5.01;0;0;0;1;FLOAT;0 Node;AmplifyShaderEditor.RangedFloatNode;3;-702.14,-185.7001;Float;False;Property;_Tiling;Tiling;2;0;Create;True;0;0;0;False;0;False;0;6.24;0;0;0;1;FLOAT;0 Node;AmplifyShaderEditor.RangedFloatNode;15;-221.5038,-199.16;Float;False;Property;_DirtAmount;DirtAmount;6;0;Create;True;0;0;0;False;0;False;1;0;0.5;1.2;0;1;FLOAT;0 Node;AmplifyShaderEditor.TriplanarNode;1;-376.0699,-425.0102;Inherit;True;Cylindrical;World;False;Top Texture 0;_TopTexture0;white;1;None;Mid Texture 0;_MidTexture0;white;-1;None;Bot Texture 0;_BotTexture0;white;0;None;Triplanar Sampler;Tangent;10;0;SAMPLER2D;;False;5;FLOAT;1;False;1;SAMPLER2D;;False;6;FLOAT;0;False;2;SAMPLER2D;;False;7;FLOAT;0;False;9;FLOAT3;0,0,0;False;8;FLOAT3;1,1,1;False;3;FLOAT;1;False;4;FLOAT;1;False;5;FLOAT4;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.ColorNode;11;68.00011,303;Float;False;Property;_EmissionColor;EmissionColor;5;0;Create;True;0;0;0;False;0;False;0,0,0,0;0.1878804,0.6724138,0.6296608,1;False;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.ClampOpNode;17;70.60491,-389.6209;Inherit;False;3;0;FLOAT4;0,0,0,0;False;1;FLOAT4;0,0,0,0;False;2;FLOAT4;1,1,1,0;False;1;FLOAT4;0 Node;AmplifyShaderEditor.SamplerNode;7;-722.7402,-705.2298;Inherit;True;Property;_Texture;Texture;4;0;Create;True;0;0;0;False;0;False;-1;None;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;1;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.SamplerNode;9;-282.9999,207;Inherit;True;Property;_Emission;Emission;3;0;Create;True;0;0;0;False;0;False;-1;None;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;1;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.RangedFloatNode;22;380.6927,259.9445;Inherit;False;Property;_Metallic;Metallic;8;0;Create;True;0;0;0;False;0;False;0;0;0;1;0;1;FLOAT;0 Node;AmplifyShaderEditor.SimpleMultiplyOpNode;10;60.45004,-6.910056;Inherit;False;2;2;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;1;COLOR;0 Node;AmplifyShaderEditor.RangedFloatNode;21;395.7621,128.4246;Inherit;False;Property;_SmoothnessSpec;Smoothness(Spec);7;0;Create;True;0;0;0;False;0;False;0.2;0.2;0;1;0;1;FLOAT;0 Node;AmplifyShaderEditor.SimpleMultiplyOpNode;8;636.5526,-465.2808;Inherit;False;2;2;0;COLOR;0,0,0,0;False;1;FLOAT4;0,0,0,0;False;1;COLOR;0 Node;AmplifyShaderEditor.SamplerNode;23;394.3923,798.3549;Inherit;True;Property;_NormalMap;NormalMap;9;0;Create;True;0;0;0;False;0;False;-1;63d3b2d11a818734eb3a55461e2c2f61;63d3b2d11a818734eb3a55461e2c2f61;True;0;True;bump;Auto;True;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;854.3712,-51.2295;Float;False;True;-1;2;ASEMaterialInspector;0;0;Standard;SyntyStudios/TriplanarGrime;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;Back;0;False;-1;0;False;-1;False;0;False;-1;0;False;-1;False;0;Opaque;0.5;True;True;0;False;Opaque;;Geometry;All;14;all;True;True;True;True;0;False;-1;False;0;False;-1;255;False;-1;255;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;False;2;15;10;25;False;0.5;True;0;0;False;-1;0;False;-1;0;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;0;0,0,0,0;VertexOffset;True;False;Cylindrical;False;Relative;0;;-1;-1;-1;-1;0;False;0;0;False;-1;-1;0;False;-1;0;0;0;False;0.1;False;-1;0;False;-1;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;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 WireConnection;1;0;2;0 WireConnection;1;1;2;0 WireConnection;1;2;2;0 WireConnection;1;3;3;0 WireConnection;1;4;4;0 WireConnection;17;0;1;0 WireConnection;17;1;15;0 WireConnection;10;0;9;0 WireConnection;10;1;11;0 WireConnection;8;0;7;0 WireConnection;8;1;17;0 WireConnection;0;0;8;0 WireConnection;0;1;23;0 WireConnection;0;2;10;0 WireConnection;0;3;22;0 WireConnection;0;4;21;0 ASEEND*/ //CHKSM=D3DDAF905C9ACF8F2FF2F95D6EDB36AB727E06D7