{ "title": "Custom/RippleEffect", "Properties": { "_MainTex": { "name": "Base", "type": "2D", "default": "white" }, "_GradTex": { "name": "Gradient", "type": "2D", "default": "white" }, "_Reflection": { "name": "Reflection Color", "type": "Color", "default": "(0, 0, 0, 0)" }, "_Params1": { "name": "Parameters 1", "type": "Vector", "default": "(1, 1, 0.8, 0)" }, "_Params2": { "name": "Parameters 2", "type": "Vector", "default": "(1, 1, 1, 0)" }, "_Drop1": { "name": "Drop 1", "type": "Vector", "default": "(0.49, 0.5, 0, 0)" }, "_Drop2": { "name": "Drop 2", "type": "Vector", "default": "(0.50, 0.5, 0, 0)" }, "_Drop3": { "name": "Drop 3", "type": "Vector", "default": "(0.51, 0.5, 0, 0)" }, "_SeaLevel": { "name": "SeaLevel", "type": "Range", "default": "-1.0", "range": "(-1.0, 1.0)" } }, "SubShader": { "Tags": { "RenderType": "Transparent", "Queue": "Transparent" }, "Blend": "SrcAlpha OneMinusSrcAlpha", "Cull": "Off", "Pass": { "HLSLPROGRAM": { "#pragma vertex vert", "#pragma fragment frag", "#pragma target 3.0", "#pragma multi_compile_instancing", "#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"", "#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl"", "#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"", "#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/UnityInstancing.hlsl"", "#define PI 3.141592653589793", "Texture2D _MainTex;", "sampler2D _MainTexSampler;", "Texture2D _GradTex;", "sampler2D _GradTexSampler;", "float4 _Params1;", "float4 _Params2;", "float3 _Drop1;", "float3 _Drop2;", "float3 _Drop3;", "float _SeaLevel;", "struct VertexInput { float4 vertex : POSITION; float2 uv : TEXCOORD0; };", "struct VertexOutput { float4 vertex : SV_POSITION; float2 uv : TEXCOORD0; };", "float wave(float2 position, float2 origin, float time) { float d = length(position - origin); float t = time - d * _Params1.z; if (_SeaLevel > 0 && position.y > _SeaLevel) { return 0; } return (tex2D(_GradTexSampler, float2(t, 0)).a - 0.5f) * 2; }", "float allwave(float2 position) { return wave(position, _Drop1.xy, _Drop1.z) + wave(position, _Drop2.xy, _Drop2.z) + wave(position, _Drop3.xy, _Drop3.z); }", "VertexOutput vert(VertexInput input) { VertexOutput output; output.vertex = UnityObjectToClipPos(input.vertex); output.uv = input.uv * _Params1.xy; return output; }", "float4 frag(VertexOutput input) : SV_Target { const float2 dx = float2(0.01f, 0); const float2 dy = float2(0, 0.01f); float2 p = input.uv; float w = allwave(p); float2 dw = float2(allwave(p + dx) - w, allwave(p + dy) - w); float2 duv = dw * _Params2.xy * 0.2f * _Params2.z; float4 c = tex2D(_MainTexSampler, input.uv + duv); float fr = pow(length(dw) * 3 * _Params2.w, 3); return lerp(c, _Reflection, fr); }", "ENDHLSL" } }

URP 水波纹渲染 Shader: 自定义涟漪效果

原文地址: https://www.cveoy.top/t/topic/ouO9 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录