-
Notifications
You must be signed in to change notification settings - Fork 202
Expand file tree
/
Copy pathTestWaterSSR.shader
More file actions
55 lines (40 loc) · 1.68 KB
/
TestWaterSSR.shader
File metadata and controls
55 lines (40 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Pass
{
Name "TestWaterSSR"
HLSLPROGRAM
#pragma target 4.5
#pragma vertex vert
#pragma fragment frag
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
// #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#include "WaterSSR.cginc"
struct Attributes
{
float4 positionOS : POSITION;
};
struct Varyings
{
float4 positionCS : SV_POSITION;
float3 positionWS : TEXCOORD0;
float4 screenUV :TEXCOORD4;
};
Varyings vert(Attributes input)
{
Varyings output = (Varyings)0;
output.positionCS = TransformObjectToHClip(input.positionOS);
output.positionWS = TransformObjectToWorld(input.positionOS);
output.screenUV =ComputeScreenPos(output.positionCS);
return output;
}
half4 frag(Varyings input) : SV_Target
{
float3 positionWS = input.positionWS;
float3 V = normalize( GetWorldSpaceViewDir(positionWS));
float3 R = reflect(-V,float3(0,1,0));
float2 screenUV = input.screenUV.xy / input.screenUV.w;//直接在VS中做了除法,效果会出错
float4 ssr = GetWaterSSR(screenUV,input.positionCS, positionWS,R,V.y );
ssr.rgb *= ssr.a;
return ssr;
}
ENDHLSL
}