Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "443eb9/Ground"
- {
- Properties
- {
- _BaseColor ("BaseColor", Color) = (1, 1, 1, 1)
- _Smoothness ("Smoothness", Range(0, 1)) = 0.5
- _RippleTexture ("RippleTexture", 2D) = "bump" {}
- _RippleStrength ("RippleStrength", Float) = 1
- _RippleAnimSpeed ("RippleAnimSpeed", Float) = 1
- }
- SubShader
- {
- Tags
- {
- "Pipeline"="UniversalPipeline"
- "RenderType"="Opaque"
- "RenderType"="Opaque"
- }
- LOD 100
- Pass
- {
- HLSLPROGRAM
- #pragma vertex vert;
- #pragma fragment frag;
- #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
- #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
- #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
- #pragma multi_compile_instancing
- #pragma instancing_options renderinglayer
- CBUFFER_START(UnityPerMaterial)
- float4 _BaseColor;
- float _Smoothness;
- float4 _RippleTexture_ST;
- float _RippleStrength;
- float _RippleAnimSpeed;
- CBUFFER_END
- #if defined(UNITY_DOTS_INSTANCING_ENABLED)
- UNITY_DOTS_INSTANCING_START(MaterialPropertyMetadata)
- UNITY_DOTS_INSTANCED_PROP(float4, _BaseColor)
- UNITY_DOTS_INSTANCED_PROP(float, _Smoothness)
- UNITY_DOTS_INSTANCED_PROP(float4, _RippleTexture_ST)
- UNITY_DOTS_INSTANCED_PROP(float, _RippleStrength)
- UNITY_DOTS_INSTANCED_PROP(float, _RippleAnimSpeed)
- UNITY_DOTS_INSTANCING_END(MaterialPropertyMetadata)
- #define _BaseColor UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4, _BaseColor)
- #define _Smoothness UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float, _Smoothness)
- #define _RippleTexture_ST UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4, _RippleTexture_ST)
- #define _RippleStrength UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float, _RippleStrength)
- #define _RippleStrength UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float, _RippleAnimSpeed)
- #endif
- TEXTURE2D(_RippleTexture);
- SAMPLER(sampler_RippleTexture);
- struct Attributes
- {
- float3 positionOS : POSITION;
- float3 normalOS : NORMAL;
- UNITY_VERTEX_INPUT_INSTANCE_ID
- };
- struct Varyings
- {
- float4 positionHCS : SV_POSITION;
- float3 positionWS : TEXCOORD0;
- float3x3 ttw : TEXCOORD1;
- UNITY_VERTEX_INPUT_INSTANCE_ID
- };
- static const float totalFrames = 16.0;
- Varyings vert(Attributes IN)
- {
- Varyings OUT;
- VertexPositionInputs vpi = GetVertexPositionInputs(IN.positionOS);
- OUT.positionHCS = vpi.positionCS;
- OUT.positionWS = vpi.positionWS;
- VertexNormalInputs vni = GetVertexNormalInputs(IN.normalOS);
- OUT.ttw = float3x3(vni.tangentWS, vni.bitangentWS, vni.normalWS);
- UNITY_TRANSFER_INSTANCE_ID(IN, OUT);
- return OUT;
- }
- float3 frag(Varyings IN) : SV_Target
- {
- UNITY_SETUP_INSTANCE_ID(IN);
- float2 uv = float2
- (
- IN.positionWS.x / _RippleTexture_ST.x,
- frac(IN.positionWS.z / _RippleTexture_ST.y) / totalFrames + floor(_Time.w * _RippleAnimSpeed) / totalFrames
- );
- float3 normalTS = UnpackNormal(SAMPLE_TEXTURE2D(_RippleTexture, sampler_RippleTexture, uv));
- float3 normalWS = mul(normalTS, IN.ttw);
- normalWS.xz *= _RippleStrength;
- Light mainLight = GetMainLight();
- float3 viewWS = GetWorldSpaceNormalizeViewDir(IN.positionWS);
- BRDFData data;
- InitializeBRDFData(_BaseColor.rgb, 0, 1, _Smoothness, _BaseColor.a, data);
- float3 color = LightingPhysicallyBased(data, mainLight, normalWS, viewWS);
- return color;
- }
- ENDHLSL
- }
- UsePass "Universal Render Pipeline/Lit/DEPTHNORMALS"
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement