加入很多新内容,这波一块交了
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
Shader "Hidden/Bansonic/GlobalDistortion"
|
||||
{
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderPipeline" = "UniversalPipeline" }
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
ZTest Always
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "GlobalDistortion"
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex Vert
|
||||
#pragma fragment Frag
|
||||
#pragma target 4.5
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"
|
||||
|
||||
float _DistortionIntensity;
|
||||
float _NoiseStrength;
|
||||
float _RadialStrength;
|
||||
float _NoiseScale;
|
||||
float2 _DistortionCenter;
|
||||
float _EdgeFade;
|
||||
|
||||
half4 Frag(Varyings input) : SV_Target
|
||||
{
|
||||
float2 uv = input.texcoord;
|
||||
float2 centered = uv - _DistortionCenter;
|
||||
float distanceFromCenter = length(centered);
|
||||
float2 direction = distanceFromCenter > 0.0001 ? centered / distanceFromCenter : float2(0.0, 0.0);
|
||||
float normalizedDistance = saturate(distanceFromCenter * 1.41421356);
|
||||
float edgeMask = saturate(1.0 - pow(normalizedDistance, _EdgeFade));
|
||||
|
||||
float t = _Time.y;
|
||||
float noiseA = sin((uv.x + t * 0.73) * _NoiseScale) * cos((uv.y - t * 1.13) * (_NoiseScale * 0.87));
|
||||
float noiseB = cos((uv.x * 1.31 - t * 0.41) * (_NoiseScale * 0.63)) * sin((uv.y * 1.11 + t * 0.52) * (_NoiseScale * 1.21));
|
||||
|
||||
float2 radialOffset = direction * edgeMask * (_RadialStrength * 0.03) * _DistortionIntensity;
|
||||
float2 noiseOffset = float2(noiseA, noiseB) * (_NoiseStrength * 0.015) * _DistortionIntensity;
|
||||
float2 sampleUv = uv + radialOffset + noiseOffset;
|
||||
sampleUv = clamp(sampleUv, 0.0, 1.0);
|
||||
|
||||
return SAMPLE_TEXTURE2D_X(_BlitTexture, sampler_LinearClamp, sampleUv);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user