portals and dash. Also a bit of terrain building and level design

This commit is contained in:
2022-03-13 00:26:35 +02:00
parent 813cd0c451
commit e82799c36a
6242 changed files with 2160679 additions and 188245 deletions

View File

@@ -0,0 +1,125 @@
Shader "Poseidon/URP/RiverURP"
{
Properties
{
[HideInInspector] _Color("Color", Color) = (0.0, 0.8, 1.0, 0.5)
[HideInInspector] _Specular("Specular Color", Color) = (0.1, 0.1, 0.1, 1)
[HideInInspector] _Smoothness("Smoothness", Range(0.0, 1.0)) = 1
[HideInInspector] _DepthColor("Depth Color", Color) = (0.0, 0.45, 0.65, 0.85)
[HideInInspector] _MaxDepth("Max Depth", Float) = 5
[HideInInspector] _FoamColor("Foam Color", Color) = (1, 1, 1, 1)
[HideInInspector] _FoamDistance("Foam Distance", Float) = 1.2
[HideInInspector] _FoamNoiseScaleHQ("Foam Noise Scale HQ", Float) = 3
[HideInInspector] _FoamNoiseSpeedHQ("Foam Noise Speed HQ", Float) = 1
[HideInInspector] _ShorelineFoamStrength("Shoreline Foam Strength", Float) = 1
[HideInInspector] _CrestFoamStrength("Crest Foam Strength", Float) = 1
[HideInInspector] _CrestMaxDepth("Crest Max Depth", Float) = 1
[HideInInspector] _SlopeFoamStrength("Slope Foam Strength", Float) = 0.5
[HideInInspector] _SlopeFoamFlowSpeed("Slope Foam Flow Speed", Float) = 20
[HideInInspector] _SlopeFoamDistance("Slope Foam Distance", Float) = 100
[HideInInspector] _RippleHeight("Ripple Height", Range(0, 1)) = 0.1
[HideInInspector] _RippleSpeed("Ripple Speed", Float) = 5
[HideInInspector] _RippleNoiseScale("Ripple Noise Scale", Float) = 1
[HideInInspector] _WaveDirection("Wave Direction", Vector) = (1, 0, 0, 0)
[HideInInspector] _WaveSpeed("Wave Speed", Float) = 1
[HideInInspector] _WaveHeight("Wave Height", Float) = 1
[HideInInspector] _WaveLength("Wave Length", Float) = 1
[HideInInspector] _WaveSteepness("Wave Steepness", Float) = 1
[HideInInspector] _WaveDeform("Wave Deform", Float) = 0.3
[HideInInspector] _WaveMask("Wave Mask", 2D) = "white" {}
[HideInInspector] _WaveMaskBounds("Wave Mask", Vector) = (0, 0, 0, 0)
[HideInInspector] _FresnelStrength("Fresnel Strength", Range(0.0, 5.0)) = 1
[HideInInspector] _FresnelBias("Fresnel Bias", Range(0.0, 1.0)) = 0
[HideInInspector] _RefractionTex("Refraction Texture", 2D) = "black" { }
[HideInInspector] _RefractionDistortionStrength("Refraction Distortion Strength", Float) = 1
[HideInInspector] _CausticTex("Caustic Texture", 2D) = "black" { }
[HideInInspector] _CausticSize("Caustic Size", Float) = 1
[HideInInspector] _CausticStrength("Caustic Strength", Range(0.0, 1.0)) = 1
[HideInInspector] _CausticDistortionStrength("Caustic Distortion Strength", Float) = 1
}
SubShader
{
Tags { "RenderPipeline" = "UniversalPipeline" "RenderType" = "Transparent" "Queue" = "Transparent+0" }
Pass
{
Name "Universal Forward"
Tags { "LightMode" = "UniversalForward" }
Blend SrcAlpha OneMinusSrcAlpha, One OneMinusSrcAlpha
Cull Back
ZTest LEqual
ZWrite On
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma prefer_hlslcc gles
#pragma exclude_renderers d3d11_9x
#pragma target 2.0
#pragma multi_compile_fog
#pragma multi_compile_instancing
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
#pragma multi_compile _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS _ADDITIONAL_OFF
#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile _ _SHADOWS_SOFT
#define _SURFACE_TYPE_TRANSPARENT 1
#define _SPECULAR_SETUP
#define SHADERPASS_FORWARD
#pragma shader_feature_local WAVE
#pragma shader_feature_local WAVE_MASK
#pragma shader_feature_local LIGHT_ABSORPTION
#pragma shader_feature_local FOAM
#pragma shader_feature_local FOAM_HQ
#pragma shader_feature_local FOAM_CREST
#pragma shader_feature_local FOAM_SLOPE
#pragma shader_feature_local CAUSTIC
#pragma shader_feature_local LIGHTING_BLINN_PHONG
#pragma shader_feature_local LIGHTING_LAMBERT
#pragma shader_feature_local FLAT_LIGHTING
#if LIGHT_ABSORPTION || FOAM
#define REQUIRE_DEPTH_TEXTURE
#endif
#define REQUIRE_OPAQUE_TEXTURE
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
#undef POSEIDON_WATER_ADVANCED
#undef POSEIDON_BACK_FACE
#define POSEIDON_RIVER
#define POSEIDON_SRP
#include "../CGIncludes/PUniforms.cginc"
#include "../CGIncludes/PRipple.cginc"
#include "../CGIncludes/PWave.cginc"
#include "../CGIncludes/PDepth.cginc"
#include "../CGIncludes/PLightAbsorption.cginc"
#include "../CGIncludes/PFresnel.cginc"
#include "../CGIncludes/PFoam.cginc"
#include "../CGIncludes/PRefraction.cginc"
#include "../CGIncludes/PCaustic.cginc"
#include "../CGIncludes/PCommon.cginc"
#include "UniversalRP_SurfaceFunction.cginc"
#include "UniversalRP_Forward.cginc"
ENDHLSL
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: a28007ab32e56c04eac88cb43da3ae07
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,167 @@
#ifndef UNIVERSAL_RP_FORWARD_INCLUDED
#define UNIVERSAL_RP_FORWARD_INCLUDED
#include "UniversalRP_Lighting.cginc"
struct Attributes
{
float4 positionOS: POSITION;
float4 texcoord: TEXCOORD0;
float4 color : COLOR;
#if defined(POSEIDON_RIVER)
float4 texcoord1 : TEXCOORD1;
#endif
#if UNITY_ANY_INSTANCING_ENABLED
uint instanceID: INSTANCEID_SEMANTIC;
#endif
};
struct Varyings
{
float4 positionCS : SV_POSITION;
float3 positionWS : TEXCOORD0;
#if FLAT_LIGHTING
float3 positionLS : TEXCOORD1;
#endif
float3 normalWS : NORMAL;
float3 viewDirectionWS : TEXCOORD2;
float4 positionSS : TEXCOORD3;
float3 sh : TEXCOORD4;
float4 fogFactorAndVertexLight : TEXCOORD5;
float4 shadowCoord : TEXCOORD6;
#if WAVE
float crestMask : TEXCOORD7;
#endif
#if UNITY_ANY_INSTANCING_ENABLED
uint instanceID: CUSTOM_INSTANCE_ID;
#endif
#if (defined(UNITY_STEREO_INSTANCING_ENABLED))
uint stereoTargetEyeIndexAsRTArrayIdx: SV_RenderTargetArrayIndex;
#endif
#if(defined(UNITY_STEREO_MULTIVIEW_ENABLED)) || (defined(UNITY_STEREO_INSTANCING_ENABLED) && (defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE)))
uint stereoTargetEyeIndexAsBlendIdx0: BLENDINDICES0;
#endif
};
Varyings vert(Attributes v)
{
Varyings o = (Varyings)0;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
#if MESH_NOISE && !defined(POSEIDON_RIVER)
ApplyMeshNoise(v.positionOS, v.texcoord, v.color);
#endif
#if WAVE
ApplyWaveHQ(v.positionOS, v.texcoord, v.color, o.crestMask);
#endif
#if defined(POSEIDON_RIVER)
ApplyRipple(v.positionOS, v.texcoord, v.color, v.texcoord1);
#else
ApplyRipple(v.positionOS, v.texcoord, v.color);
#endif
float3 normalOS;
CalculateNormal(v.positionOS, v.texcoord, v.color, normalOS);
o.positionWS = TransformObjectToWorld(v.positionOS.xyz);
#if FLAT_LIGHTING
float3 centerVertex = (v.positionOS.xyz + v.texcoord.xyz + v.color.xyz) / 3.0;
o.positionLS = TransformObjectToWorld(centerVertex);
#endif
o.normalWS = TransformObjectToWorldNormal(normalOS);
o.positionSS = ComputeScreenPos(o.positionCS);
o.positionCS = TransformWorldToHClip(o.positionWS);
#if FLAT_LIGHTING
float3 positionLS = o.positionLS;
#else
float3 positionLS = o.positionWS;
#endif
o.viewDirectionWS = _WorldSpaceCameraPos.xyz - positionLS;
o.positionSS = ComputeScreenPos(o.positionCS, _ProjectionParams.x);
OUTPUT_SH(o.normalWS, o.sh);
half3 vertexLight = VertexLighting(positionLS, o.normalWS);
half fogFactor = ComputeFogFactor(o.positionCS.z);
o.fogFactorAndVertexLight = half4(fogFactor, vertexLight);
VertexPositionInputs vertexInput = GetVertexPositionInputs(v.positionOS.xyz);
o.shadowCoord = GetShadowCoord(vertexInput);
return o;
}
void BuildInputData(Varyings input, out InputData inputData)
{
inputData = (InputData)0;
#if FLAT_LIGHTING
inputData.positionWS = input.positionLS;
#else
inputData.positionWS = input.positionWS;
#endif
inputData.normalWS = NormalizeNormalPerPixel(input.normalWS);
inputData.viewDirectionWS = SafeNormalize(input.viewDirectionWS);
#if defined(MAIN_LIGHT_CALCULATE_SHADOWS)
inputData.shadowCoord = TransformWorldToShadowCoord(input.positionWS);
#else
inputData.shadowCoord = float4(0, 0, 0, 0);
#endif
inputData.fogCoord = input.fogFactorAndVertexLight.x;
inputData.vertexLighting = input.fogFactorAndVertexLight.yzw;
inputData.bakedGI = SAMPLE_GI(0, input.sh, inputData.normalWS);
}
half4 frag(Varyings i) : SV_TARGET
{
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
SurfaceInput surfIn = (SurfaceInput)0;
surfIn.positionWS = i.positionWS;
surfIn.positionSS = i.positionSS;
surfIn.normalWS = i.normalWS;
#if WAVE
surfIn.crestMask = i.crestMask;
#endif
SurfaceOutput surfOut = (SurfaceOutput)0;
surfOut.Albedo = 0;
surfOut.Specular = 0;
surfOut.Smoothness = 0;
surfOut.Alpha = 1;
SURFACE_FUNCTION(surfIn, surfOut);
InputData inputData;
BuildInputData(i, inputData);
half4 color;
#if LIGHTING_BLINN_PHONG
color = PoseidonFragmentBlinnPhong(
inputData,
surfOut.Albedo,
half4(surfOut.Specular, 1),
surfOut.Smoothness,
surfOut.Alpha);
#elif LIGHTING_LAMBERT
color = PoseidonFragmentLambert(
inputData,
surfOut.Albedo,
surfOut.Alpha);
#else
color = PoseidonFragmentPBR(
inputData,
surfOut.Albedo,
surfOut.Specular,
surfOut.Smoothness,
surfOut.Alpha);
#endif
color.rgb = MixFog(color.rgb, inputData.fogCoord);
return color;
}
#endif

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 69cde3559dfec78478e4bf0c0314dfe8
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,86 @@
#ifndef LIGHTING_SRP_INCLUDED
#define LIGHTING_SRP_INCLUDED
half4 PoseidonFragmentPBR(InputData inputData, half3 albedo, half3 specular,
half smoothness, half alpha)
{
BRDFData brdfData;
InitializeBRDFData(albedo, /*metallic*/0, specular, smoothness, alpha, brdfData);
Light mainLight = GetMainLight(inputData.shadowCoord);
half3 color = GlobalIllumination(brdfData, inputData.bakedGI, /*occlusion*/1, inputData.normalWS, inputData.viewDirectionWS);
color += LightingPhysicallyBased(brdfData, mainLight, inputData.normalWS, inputData.viewDirectionWS);
#ifdef _ADDITIONAL_LIGHTS
int pixelLightCount = GetAdditionalLightsCount();
for (int i = 0; i < pixelLightCount; ++i)
{
Light light = GetAdditionalLight(i, inputData.positionWS);
color += LightingPhysicallyBased(brdfData, light, inputData.normalWS, inputData.viewDirectionWS);
}
#endif
#ifdef _ADDITIONAL_LIGHTS_VERTEX
color += inputData.vertexLighting * brdfData.diffuse;
#endif
return half4(color, alpha);
}
half4 PoseidonFragmentBlinnPhong(InputData inputData, half3 diffuse, half4 specular, half smoothness, half alpha)
{
smoothness *= 1000;
Light mainLight = GetMainLight(inputData.shadowCoord);
half3 attenuatedLightColor = mainLight.color * (mainLight.distanceAttenuation * mainLight.shadowAttenuation);
half3 diffuseColor = inputData.bakedGI + LightingLambert(attenuatedLightColor, mainLight.direction, inputData.normalWS);
half3 specularColor = LightingSpecular(attenuatedLightColor, mainLight.direction, inputData.normalWS, inputData.viewDirectionWS, specular, smoothness);
#ifdef _ADDITIONAL_LIGHTS
int pixelLightCount = GetAdditionalLightsCount();
for (int i = 0; i < pixelLightCount; ++i)
{
Light light = GetAdditionalLight(i, inputData.positionWS);
half3 attenuatedLightColor = light.color * (light.distanceAttenuation * light.shadowAttenuation);
diffuseColor += LightingLambert(attenuatedLightColor, light.direction, inputData.normalWS);
specularColor += LightingSpecular(attenuatedLightColor, light.direction, inputData.normalWS, inputData.viewDirectionWS, specular, smoothness);
}
#endif
#ifdef _ADDITIONAL_LIGHTS_VERTEX
diffuseColor += inputData.vertexLighting;
#endif
half3 finalColor = diffuseColor * diffuse;
finalColor += specularColor;
return half4(finalColor, alpha);
}
half4 PoseidonFragmentLambert(InputData inputData, half3 diffuse, half alpha)
{
Light mainLight = GetMainLight(inputData.shadowCoord);
half3 attenuatedLightColor = mainLight.color * (mainLight.distanceAttenuation * mainLight.shadowAttenuation);
half3 diffuseColor = inputData.bakedGI + LightingLambert(attenuatedLightColor, mainLight.direction, inputData.normalWS);
#ifdef _ADDITIONAL_LIGHTS
int pixelLightCount = GetAdditionalLightsCount();
for (int i = 0; i < pixelLightCount; ++i)
{
Light light = GetAdditionalLight(i, inputData.positionWS);
half3 attenuatedLightColor = light.color * (light.distanceAttenuation * light.shadowAttenuation);
diffuseColor += LightingLambert(attenuatedLightColor, light.direction, inputData.normalWS);
}
#endif
#ifdef _ADDITIONAL_LIGHTS_VERTEX
diffuseColor += inputData.vertexLighting;
#endif
half3 finalColor = diffuseColor * diffuse;
return half4(finalColor, alpha);
}
#endif

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: eb22e766219139b4a8caa7243274d7e6
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,235 @@
#ifndef UNIVERSAL_RP_SURFACE_FUNCTION_INCLUDED
#define UNIVERSAL_RP_SURFACE_FUNCTION_INCLUDED
struct SurfaceInput
{
float3 positionWS;
float4 positionSS;
float3 normalWS;
float crestMask;
};
struct SurfaceOutput
{
float3 Albedo;
float3 Specular;
float Smoothness;
float Alpha;
};
#if defined(POSEIDON_WATER_ADVANCED)
#if defined (POSEIDON_BACK_FACE)
#define SURFACE_FUNCTION(i, o) SurfBackFace(i, o);
#else
#define SURFACE_FUNCTION(i, o) SurfAdvanced(i, o);
#endif
#elif defined(POSEIDON_RIVER)
#define SURFACE_FUNCTION(i, o) SurfRiver(i, o);
#else
#define SURFACE_FUNCTION(i, o) SurfBasic(i, o);
#endif
#ifndef POSEIDON_WATER_ADVANCED
void SurfBasic(SurfaceInput i, inout SurfaceOutput o)
{
half fresnel;
CalculateFresnelFactor(i.positionWS, i.normalWS, fresnel);
#if LIGHT_ABSORPTION || FOAM
float sceneDepth = GetSceneDepth(i.positionSS);
float surfaceDepth = GetSurfaceDepth(float4(i.positionWS, 1));
#endif
half4 tintColor = _Color;
#if LIGHT_ABSORPTION
CalculateDeepWaterColor(sceneDepth, surfaceDepth, tintColor);
#endif
half4 waterColor = lerp(_Color, tintColor, fresnel);
waterColor = saturate(waterColor);
half4 foamColor = float4(0, 0, 0, 0);
#if FOAM
#if FOAM_HQ
CalculateFoamColorHQ(sceneDepth, surfaceDepth, i.positionWS, i.normalWS, i.crestMask, foamColor);
#else
CalculateFoamColor(sceneDepth, surfaceDepth, i.positionWS, i.normalWS, i.crestMask, foamColor);
#endif
#endif
half3 Albedo = lerp(waterColor.rgb, foamColor.rgb * 1.5, foamColor.a);
half3 Specular = _Specular.rgb;
half Smoothness = saturate(_Smoothness - foamColor.a);
half Alpha = lerp(waterColor.a, foamColor.a, foamColor.a);
o.Albedo = IsGammaSpace() ? Albedo : SRGBToLinear(Albedo);
o.Specular = IsGammaSpace() ? Specular : SRGBToLinear(Specular);
o.Smoothness = Smoothness;
o.Alpha = Alpha;
}
#endif //!POSEIDON_WATER_ADVANCED
#if defined(POSEIDON_WATER_ADVANCED)
void SurfAdvanced(SurfaceInput i, inout SurfaceOutput o)
{
half fresnel;
CalculateFresnelFactor(i.positionWS, i.normalWS, fresnel);
#if LIGHT_ABSORPTION || FOAM || CAUSTIC
float sceneDepth = GetSceneDepth(i.positionSS);
float surfaceDepth = GetSurfaceDepth(float4(i.positionWS, 1));
#if LIGHT_ABSORPTION
float depthFade = GetDepthFade(sceneDepth, surfaceDepth, _MaxDepth);
#endif
#endif
half4 waterColor;
half4 tintColor = _Color;
#if LIGHT_ABSORPTION
CalculateDeepWaterColor(sceneDepth, surfaceDepth, tintColor);
#endif
half4 reflColor = _Color;
#if REFLECTION && !UNITY_SINGLE_PASS_STEREO && !STEREO_INSTANCING_ON && !UNITY_STEREO_MULTIVIEW_ENABLED
SampleReflectionTexture(i.positionSS, i.normalWS, reflColor);
#endif
half4 refrColor = _DepthColor;
#if REFRACTION
SampleRefractionTexture(i.positionSS, i.normalWS, refrColor);
#if LIGHT_ABSORPTION
refrColor = lerp(_DepthColor, refrColor, depthFade);
#endif
#endif
half4 causticColor = half4(0, 0, 0, 0);
#if CAUSTIC
SampleCausticTexture(sceneDepth, surfaceDepth, i.positionWS, i.normalWS, causticColor);
#if LIGHT_ABSORPTION
causticColor *= depthFade;
#endif
#endif
refrColor += causticColor;
waterColor = tintColor * lerp(refrColor, reflColor, fresnel);
waterColor = waterColor * tintColor.a + (1 - tintColor.a) * refrColor;
waterColor = saturate(waterColor);
half4 foamColor = float4(0, 0, 0, 0);
#if FOAM
#if FOAM_HQ
CalculateFoamColorHQ(sceneDepth, surfaceDepth, i.positionWS, i.normalWS, i.crestMask, foamColor);
#else
CalculateFoamColor(sceneDepth, surfaceDepth, i.positionWS, i.normalWS, i.crestMask, foamColor);
#endif
#endif
half3 Albedo = lerp(waterColor.rgb, foamColor.rgb * 1.5, foamColor.a);
half3 Specular = _Specular.rgb;
half Smoothness = saturate(_Smoothness - foamColor.a);
o.Albedo = IsGammaSpace() ? Albedo : SRGBToLinear(Albedo);
o.Specular = IsGammaSpace() ? Specular : SRGBToLinear(Specular);
o.Smoothness = Smoothness;
o.Alpha = 1;
}
void SurfBackFace(SurfaceInput i, inout SurfaceOutput o)
{
half fresnel;
CalculateFresnelFactor(i.positionWS, -i.normalWS, fresnel);
#if FOAM
float sceneDepth = GetSceneDepth(i.positionSS);
float surfaceDepth = GetSurfaceDepth(float4(i.positionWS, 1));
#endif
half4 waterColor;
half4 tintColor = _Color;
half4 refrColor = _Color;
SampleRefractionTexture(i.positionSS, i.normalWS, refrColor);
waterColor = lerp(refrColor, _Color, fresnel);
waterColor = waterColor * tintColor.a + (1 - tintColor.a) * refrColor;
waterColor = saturate(waterColor);
half4 foamColor = float4(0, 0, 0, 0);
#if FOAM
#if FOAM_HQ
CalculateFoamColorHQ(sceneDepth, surfaceDepth, i.positionWS, i.normalWS, i.crestMask, foamColor);
#else
CalculateFoamColor(sceneDepth, surfaceDepth, i.positionWS, i.normalWS, i.crestMask, foamColor);
#endif
foamColor.a *= 0.5;
#endif
half3 Albedo = lerp(waterColor.rgb, foamColor.rgb * 1.5, foamColor.a);
half3 Specular = _Specular.rgb;
half Smoothness = saturate(_Smoothness - foamColor.a);
o.Albedo = IsGammaSpace() ? Albedo : SRGBToLinear(Albedo);
o.Specular = IsGammaSpace() ? Specular : SRGBToLinear(Specular);
o.Smoothness = Smoothness;
o.Alpha = 1;
}
#endif //POSEIDON_WATER_ADVANCED
#if defined(POSEIDON_RIVER)
void SurfRiver(SurfaceInput i, inout SurfaceOutput o)
{
half fresnel;
CalculateFresnelFactor(i.positionWS, i.normalWS, fresnel);
#if LIGHT_ABSORPTION || FOAM || CAUSTIC
float sceneDepth = GetSceneDepth(i.positionSS);
float surfaceDepth = GetSurfaceDepth(float4(i.positionWS, 1));
#if LIGHT_ABSORPTION
float depthFade = GetDepthFade(sceneDepth, surfaceDepth, _MaxDepth);
#endif
#endif
half4 waterColor;
half4 tintColor = _Color;
#if LIGHT_ABSORPTION
CalculateDeepWaterColor(sceneDepth, surfaceDepth, tintColor);
#endif
half4 refrColor = _DepthColor;
SampleRefractionTexture(i.positionSS, i.normalWS, refrColor);
#if LIGHT_ABSORPTION
refrColor = lerp(_DepthColor, refrColor, depthFade);
#endif
half4 causticColor = half4(0, 0, 0, 0);
#if CAUSTIC
SampleCausticTexture(sceneDepth, surfaceDepth, i.positionWS, i.normalWS, causticColor);
#if LIGHT_ABSORPTION
causticColor *= depthFade;
#endif
#endif
refrColor += causticColor;
waterColor = lerp(refrColor, tintColor, tintColor.a * fresnel);
half4 foamColor = float4(0, 0, 0, 0);
#if FOAM
#if FOAM_HQ
CalculateFoamColorHQ(sceneDepth, surfaceDepth, i.positionWS, i.normalWS, i.crestMask, foamColor);
#else
CalculateFoamColor(sceneDepth, surfaceDepth, i.positionWS, i.normalWS, i.crestMask, foamColor);
#endif
#endif
half3 Albedo = lerp(waterColor.rgb, foamColor.rgb * 1.5, foamColor.a);
half3 Specular = _Specular.rgb;
half Smoothness = saturate(_Smoothness - foamColor.a);
o.Albedo = IsGammaSpace() ? Albedo : SRGBToLinear(Albedo);
o.Specular = IsGammaSpace() ? Specular : SRGBToLinear(Specular);
o.Smoothness = Smoothness;
o.Alpha = 1;
}
#endif //POSEIDON_RIVER
#endif //UNIVERSAL_RP_SURFACE_FUNCTION_INCLUDED

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: d2a634fc30754b440a0f0e0a8fc24c38
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,132 @@
Shader "Poseidon/URP/WaterAdvancedURP"
{
Properties
{
[HideInInspector] _MeshNoise("Mesh Noise", Range(0.0, 1.0)) = 0
[HideInInspector] _Color("Color", Color) = (0.0, 0.8, 1.0, 0.5)
[HideInInspector] _Specular("Specular Color", Color) = (0.1, 0.1, 0.1, 1)
[HideInInspector] _Smoothness("Smoothness", Range(0.0, 1.0)) = 1
[HideInInspector] _DepthColor("Depth Color", Color) = (0.0, 0.45, 0.65, 0.85)
[HideInInspector] _MaxDepth("Max Depth", Float) = 5
[HideInInspector] _FoamColor("Foam Color", Color) = (1, 1, 1, 1)
[HideInInspector] _FoamDistance("Foam Distance", Float) = 1.2
[HideInInspector] _FoamNoiseScaleHQ("Foam Noise Scale HQ", Float) = 3
[HideInInspector] _FoamNoiseSpeedHQ("Foam Noise Speed HQ", Float) = 1
[HideInInspector] _ShorelineFoamStrength("Shoreline Foam Strength", Float) = 1
[HideInInspector] _CrestFoamStrength("Crest Foam Strength", Float) = 1
[HideInInspector] _CrestMaxDepth("Crest Max Depth", Float) = 1
[HideInInspector] _RippleHeight("Ripple Height", Range(0, 1)) = 0.1
[HideInInspector] _RippleSpeed("Ripple Speed", Float) = 5
[HideInInspector] _RippleNoiseScale("Ripple Noise Scale", Float) = 1
[HideInInspector] _WaveDirection("Wave Direction", Vector) = (1, 0, 0, 0)
[HideInInspector] _WaveSpeed("Wave Speed", Float) = 1
[HideInInspector] _WaveHeight("Wave Height", Float) = 1
[HideInInspector] _WaveLength("Wave Length", Float) = 1
[HideInInspector] _WaveSteepness("Wave Steepness", Float) = 1
[HideInInspector] _WaveDeform("Wave Deform", Float) = 0.3
[HideInInspector] _WaveMask("Wave Mask", 2D) = "white" {}
[HideInInspector] _WaveMaskBounds("Wave Mask", Vector) = (0, 0, 0, 0)
[HideInInspector] _FresnelStrength("Fresnel Strength", Range(0.0, 5.0)) = 1
[HideInInspector] _FresnelBias("Fresnel Bias", Range(0.0, 1.0)) = 0
[HideInInspector] _ReflectionTex("Reflection Texture", 2D) = "black" {}
[HideInInspector] _ReflectionDistortionStrength("Reflection Distortion Strength", Float) = 1
[HideInInspector] _RefractionTex("Refraction Texture", 2D) = "black" {}
[HideInInspector] _RefractionDistortionStrength("Refraction Distortion Strength", Float) = 1
[HideInInspector] _CausticTex("Caustic Texture", 2D) = "black" {}
[HideInInspector] _CausticSize("Caustic Size", Float) = 1
[HideInInspector] _CausticStrength("Caustic Strength", Range(0.0, 1.0)) = 1
[HideInInspector] _CausticDistortionStrength("Caustic Distortion Strength", Float) = 1
}
SubShader
{
Tags { "RenderPipeline" = "UniversalPipeline" "RenderType" = "Transparent" "Queue" = "Transparent+0" }
Pass
{
Name "Universal Forward"
Tags { "LightMode" = "UniversalForward" }
Blend One Zero
Cull Back
ZTest LEqual
ZWrite On
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma prefer_hlslcc gles
#pragma exclude_renderers d3d11_9x
#pragma target 2.0
#pragma multi_compile_fog
#pragma multi_compile_instancing
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
#pragma multi_compile _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS _ADDITIONAL_OFF
#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile _ _SHADOWS_SOFT
#define _SURFACE_TYPE_TRANSPARENT 1
#define _SPECULAR_SETUP
#define SHADERPASS_FORWARD
#pragma shader_feature_local MESH_NOISE
#pragma shader_feature_local WAVE
#pragma shader_feature_local WAVE_MASK
#pragma shader_feature_local LIGHT_ABSORPTION
#pragma shader_feature_local FOAM
#pragma shader_feature_local FOAM_HQ
#pragma shader_feature_local FOAM_CREST
#pragma shader_feature_local REFLECTION
#pragma shader_feature_local REFRACTION
#pragma shader_feature_local CAUSTIC
#pragma shader_feature_local LIGHTING_BLINN_PHONG
#pragma shader_feature_local LIGHTING_LAMBERT
#pragma shader_feature_local FLAT_LIGHTING
#if LIGHT_ABSORPTION || FOAM
#define REQUIRE_DEPTH_TEXTURE
#endif
#if REFRACTION
#define REQUIRE_OPAQUE_TEXTURE
#endif
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
#define POSEIDON_WATER_ADVANCED
#undef POSEIDON_BACK_FACE
#undef POSEIDON_RIVER
#define POSEIDON_SRP
#include "../CGIncludes/PUniforms.cginc"
#include "../CGIncludes/PMeshNoise.cginc"
#include "../CGIncludes/PRipple.cginc"
#include "../CGIncludes/PWave.cginc"
#include "../CGIncludes/PDepth.cginc"
#include "../CGIncludes/PLightAbsorption.cginc"
#include "../CGIncludes/PFresnel.cginc"
#include "../CGIncludes/PFoam.cginc"
#include "../CGIncludes/PReflection.cginc"
#include "../CGIncludes/PRefraction.cginc"
#include "../CGIncludes/PCaustic.cginc"
#include "UniversalRP_SurfaceFunction.cginc"
#include "UniversalRP_Forward.cginc"
ENDHLSL
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 3834a7d55ad9ff24b839d7d0de8bb057
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,111 @@
Shader "Poseidon/URP/WaterBackFaceURP"
{
Properties
{
[HideInInspector] _MeshNoise("Mesh Noise", Range(0.0, 1.0)) = 0
[HideInInspector] _Color("Color", Color) = (0.0, 0.8, 1.0, 0.5)
[HideInInspector] _Specular("Specular Color", Color) = (0.1, 0.1, 0.1, 1)
[HideInInspector] _Smoothness("Smoothness", Range(0.0, 1.0)) = 1
[HideInInspector] _FoamColor("Foam Color", Color) = (1, 1, 1, 1)
[HideInInspector] _FoamDistance("Foam Distance", Float) = 1.2
[HideInInspector] _FoamNoiseScaleHQ("Foam Noise Scale HQ", Float) = 3
[HideInInspector] _FoamNoiseSpeedHQ("Foam Noise Speed HQ", Float) = 1
[HideInInspector] _ShorelineFoamStrength("Shoreline Foam Strength", Float) = 1
[HideInInspector] _CrestFoamStrength("Crest Foam Strength", Float) = 1
[HideInInspector] _CrestMaxDepth("Crest Max Depth", Float) = 1
[HideInInspector] _RippleHeight("Ripple Height", Range(0, 1)) = 0.1
[HideInInspector] _RippleSpeed("Ripple Speed", Float) = 5
[HideInInspector] _RippleNoiseScale("Ripple Noise Scale", Float) = 1
[HideInInspector] _WaveDirection("Wave Direction", Vector) = (1, 0, 0, 0)
[HideInInspector] _WaveSpeed("Wave Speed", Float) = 1
[HideInInspector] _WaveHeight("Wave Height", Float) = 1
[HideInInspector] _WaveLength("Wave Length", Float) = 1
[HideInInspector] _WaveSteepness("Wave Steepness", Float) = 1
[HideInInspector] _WaveDeform("Wave Deform", Float) = 0.3
[HideInInspector] _WaveMask("Wave Mask", 2D) = "white" {}
[HideInInspector] _WaveMaskBounds("Wave Mask", Vector) = (0, 0, 0, 0)
[HideInInspector] _FresnelStrength("Fresnel Strength", Range(0.0, 5.0)) = 1
[HideInInspector] _FresnelBias("Fresnel Bias", Range(0.0, 1.0)) = 0
[HideInInspector] _RefractionTex("Refraction Texture", 2D) = "black" {}
[HideInInspector] _RefractionDistortionStrength("Refraction Distortion Strength", Float) = 1
}
SubShader
{
Tags { "RenderPipeline" = "UniversalPipeline" "RenderType" = "Transparent" "Queue" = "Transparent+0" }
Pass
{
Name "Universal Forward"
Tags { "LightMode" = "UniversalForward" }
Cull Front
ZTest LEqual
ZWrite On
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma prefer_hlslcc gles
#pragma exclude_renderers d3d11_9x
#pragma target 2.0
#pragma multi_compile_fog
#pragma multi_compile_instancing
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
#pragma multi_compile _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS _ADDITIONAL_OFF
#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile _ _SHADOWS_SOFT
#define _SURFACE_TYPE_TRANSPARENT 1
#define _SPECULAR_SETUP
#define SHADERPASS_FORWARD
#pragma shader_feature_local MESH_NOISE
#pragma shader_feature_local WAVE
#pragma shader_feature_local WAVE_MASK
#pragma shader_feature_local FOAM
#pragma shader_feature_local FOAM_HQ
#pragma shader_feature_local FOAM_CREST
#pragma shader_feature_local LIGHTING_BLINN_PHONG
#pragma shader_feature_local LIGHTING_LAMBERT
#pragma shader_feature_local FLAT_LIGHTING
#if LIGHT_ABSORPTION || FOAM
#define REQUIRE_DEPTH_TEXTURE
#endif
#define REQUIRE_OPAQUE_TEXTURE
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
#define POSEIDON_WATER_ADVANCED
#define POSEIDON_BACK_FACE
#undef POSEIDON_RIVER
#define POSEIDON_SRP
#include "../CGIncludes/PUniforms.cginc"
#include "../CGIncludes/PMeshNoise.cginc"
#include "../CGIncludes/PRipple.cginc"
#include "../CGIncludes/PWave.cginc"
#include "../CGIncludes/PDepth.cginc"
#include "../CGIncludes/PFresnel.cginc"
#include "../CGIncludes/PFoam.cginc"
#include "../CGIncludes/PRefraction.cginc"
#include "UniversalRP_SurfaceFunction.cginc"
#include "UniversalRP_Forward.cginc"
ENDHLSL
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 59d3c4f6b0aca0340a64c081a7b0dc1e
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,113 @@
Shader "Poseidon/URP/WaterBasicURP"
{
Properties
{
[HideInInspector] _MeshNoise("Mesh Noise", Range(0.0, 1.0)) = 0
[HideInInspector] _Color("Color", Color) = (0.0, 0.8, 1.0, 0.5)
[HideInInspector] _Specular("Specular Color", Color) = (0.1, 0.1, 0.1, 1)
[HideInInspector] _Smoothness("Smoothness", Range(0.0, 1.0)) = 1
[HideInInspector] _DepthColor("Depth Color", Color) = (0.0, 0.45, 0.65, 0.85)
[HideInInspector] _MaxDepth("Max Depth", Float) = 5
[HideInInspector] _FoamColor("Foam Color", Color) = (1, 1, 1, 1)
[HideInInspector] _FoamDistance("Foam Distance", Float) = 1.2
[HideInInspector] _FoamNoiseScaleHQ("Foam Noise Scale HQ", Float) = 3
[HideInInspector] _FoamNoiseSpeedHQ("Foam Noise Speed HQ", Float) = 1
[HideInInspector] _ShorelineFoamStrength("Shoreline Foam Strength", Float) = 1
[HideInInspector] _CrestFoamStrength("Crest Foam Strength", Float) = 1
[HideInInspector] _CrestMaxDepth("Crest Max Depth", Float) = 1
[HideInInspector] _RippleHeight("Ripple Height", Range(0, 1)) = 0.1
[HideInInspector] _RippleSpeed("Ripple Speed", Float) = 5
[HideInInspector] _RippleNoiseScale("Ripple Noise Scale", Float) = 1
[HideInInspector] _WaveDirection("Wave Direction", Vector) = (1, 0, 0, 0)
[HideInInspector] _WaveSpeed("Wave Speed", Float) = 1
[HideInInspector] _WaveHeight("Wave Height", Float) = 1
[HideInInspector] _WaveLength("Wave Length", Float) = 1
[HideInInspector] _WaveSteepness("Wave Steepness", Float) = 1
[HideInInspector] _WaveDeform("Wave Deform", Float) = 0.3
[HideInInspector] _WaveMask("Wave Mask", 2D) = "white" {}
[HideInInspector] _WaveMaskBounds("Wave Mask", Vector) = (0, 0, 0, 0)
[HideInInspector] _FresnelStrength("Fresnel Strength", Range(0.0, 5.0)) = 1
[HideInInspector] _FresnelBias("Fresnel Bias", Range(0.0, 1.0)) = 0
}
SubShader
{
Tags { "RenderPipeline" = "UniversalPipeline" "RenderType" = "Transparent" "Queue" = "Transparent+0" }
Pass
{
Name "Universal Forward"
Tags { "LightMode" = "UniversalForward" }
Blend SrcAlpha OneMinusSrcAlpha
Cull Back
ZTest LEqual
ZWrite On
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma prefer_hlslcc gles
#pragma exclude_renderers d3d11_9x
#pragma target 2.0
#pragma multi_compile_fog
#pragma multi_compile_instancing
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
#pragma multi_compile _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS _ADDITIONAL_OFF
#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile _ _SHADOWS_SOFT
#define _SURFACE_TYPE_TRANSPARENT 1
#define _SPECULAR_SETUP
#define SHADERPASS_FORWARD
#pragma shader_feature_local MESH_NOISE
#pragma shader_feature_local WAVE
#pragma shader_feature_local WAVE_MASK
#pragma shader_feature_local LIGHT_ABSORPTION
#pragma shader_feature_local FOAM
#pragma shader_feature_local FOAM_HQ
#pragma shader_feature_local FOAM_CREST
#pragma shader_feature_local LIGHTING_BLINN_PHONG
#pragma shader_feature_local LIGHTING_LAMBERT
#pragma shader_feature_local FLAT_LIGHTING
#if LIGHT_ABSORPTION || FOAM
#define REQUIRE_DEPTH_TEXTURE
#endif
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
#undef POSEIDON_WATER_ADVANCED
#undef POSEIDON_BACK_FACE
#undef POSEIDON_RIVER
#define POSEIDON_SRP
#include "../CGIncludes/PUniforms.cginc"
#include "../CGIncludes/PMeshNoise.cginc"
#include "../CGIncludes/PRipple.cginc"
#include "../CGIncludes/PWave.cginc"
#include "../CGIncludes/PDepth.cginc"
#include "../CGIncludes/PLightAbsorption.cginc"
#include "../CGIncludes/PFresnel.cginc"
#include "../CGIncludes/PFoam.cginc"
#include "../CGIncludes/PCommon.cginc"
#include "UniversalRP_SurfaceFunction.cginc"
#include "UniversalRP_Forward.cginc"
ENDHLSL
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: aaa8f487ed9e01f4cafae89f58c53fd5
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant: