ZXK_Sample/Assets/Art/URP/Reflection/Scripts/ReflectionBur.shader
2025-12-02 16:04:23 +08:00

66 lines
2.1 KiB
Plaintext

Shader "Unlit URP Shader"
{
Properties
{
//_BaseColor("Base Color",color) = (1,1,1,1)
_MainTex("MainTex", 2D) = "white" {}
}
SubShader
{
Tags { "Queue"="Geometry" "RenderType" = "Opaque" "IgnoreProjector" = "True" "RenderPipeline" = "UniversalPipeline" }
LOD 100
Pass
{
Name "Unlit"
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
struct Attributes
{
float4 positionOS : POSITION;
float2 uv : TEXCOORD0;
};
struct Varyings
{
float4 positionCS : SV_POSITION;
float2 uv : TEXCOORD0;
float fogCoord : TEXCOORD1;
};
TEXTURE2D (_MainTex);SAMPLER(sampler_MainTex);
float _BurStength;
Varyings vert(Attributes v)
{
Varyings o = (Varyings)0;
o.positionCS = TransformObjectToHClip(v.positionOS.xyz);
o.uv = v.uv;//TRANSFORM_TEX(v.uv, _BaseMap);
return o;
}
half4 frag(Varyings i) : SV_Target
{
float2 offset= 1/i.positionCS.xy;
half3 baseMap = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
baseMap += SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv+offset*float2(0,1)*_BurStength);
baseMap += SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv+offset*float2(1,0)*_BurStength);
baseMap += SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv+offset*float2(0,-1)*_BurStength);
baseMap += SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv+offset*float2(-1,0)*_BurStength);
return float4(baseMap*0.2,1);
}
ENDHLSL
}
}
}