备份CatanBuilding瘦身独立工程
This commit is contained in:
97
LocalPackages/zzwater/shaders/horizon_ocean.shader
Normal file
97
LocalPackages/zzwater/shaders/horizon_ocean.shader
Normal file
@@ -0,0 +1,97 @@
|
||||
Shader "zzwater/horizon_ocean"
|
||||
{
|
||||
|
||||
Properties
|
||||
{
|
||||
[HDR]_Color("Color", Color) = (0, 0.44, 0.62, 1)
|
||||
_ReflectionStrength("Reflection Strength", Range(0, 2)) = 1
|
||||
_ReflectionBlur("Probe Blur Factor", Range(0, 1)) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"RenderType" = "Transparent"
|
||||
"RenderPipeline" = "UniversalPipeline"
|
||||
"UniversalMaterialType" = "Unlit"
|
||||
"IgnoreProjector" = "True"
|
||||
"Queue" = "Transparent+0"
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "ForwardLit"
|
||||
Tags { "LightMode"="UniversalForward" }
|
||||
|
||||
Blend SrcAlpha OneMinusSrcAlpha, One OneMinusSrcAlpha
|
||||
ZWrite On
|
||||
Cull Back
|
||||
ZTest LEqual
|
||||
ZClip On
|
||||
|
||||
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"
|
||||
|
||||
//Fog rendering (integration)
|
||||
#define UnityFog
|
||||
#pragma multi_compile_fog
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
|
||||
float _ReflectionBlur;
|
||||
float _ReflectionStrength;
|
||||
half4 _Color;
|
||||
|
||||
CBUFFER_END
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float3 positionWS : TEXCOORD0;
|
||||
float4 positionNDC : TEXCOORD1;
|
||||
float fogFactor : TEXCOORD2;
|
||||
};
|
||||
|
||||
Varyings vert(Attributes IN)
|
||||
{
|
||||
Varyings OUT;
|
||||
|
||||
// Get the position of the vertex in different spaces
|
||||
VertexPositionInputs positions = GetVertexPositionInputs(IN.positionOS);
|
||||
|
||||
OUT.positionCS = positions.positionCS;
|
||||
OUT.positionWS = positions.positionWS.xyz;
|
||||
OUT.positionNDC = positions.positionNDC;
|
||||
OUT.fogFactor = ComputeFogFactor(positions.positionCS.z);
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
half4 frag(Varyings IN) : SV_Target
|
||||
{
|
||||
float3 viewDir = normalize(_WorldSpaceCameraPos - IN.positionWS);
|
||||
half3 reflectionVector = reflect(-viewDir, float3(0, 1, 0));
|
||||
float2 screenPos = IN.positionNDC.xy / IN.positionNDC.w;
|
||||
float3 reflections = GlossyEnvironmentReflection(reflectionVector, IN.positionWS, _ReflectionBlur, 1 ,screenPos) * _ReflectionStrength;
|
||||
|
||||
//Apply fog
|
||||
half fogCoord = InitializeInputDataFog(float4(IN.positionWS,1), IN.fogFactor);
|
||||
half3 finalColor = MixFog(_Color.rgb * reflections, fogCoord);
|
||||
return half4(finalColor, _Color.a);
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user