// Stylized Water 3 by Staggart Creations (http://staggart.xyz) // COPYRIGHT PROTECTED UNDER THE UNITY ASSET STORE EULA (https://unity.com/legal/as-terms) // • Copying or referencing source code for the production of new asset store, or public, content is strictly prohibited! // • Uploading this file to a public repository will subject it to an automated DMCA takedown request. %asset_version% %unity_version% %compiler_version% %shader_name% { Properties { //Rendering [Toggle] _ZWrite("Depth writing", Float) = 0 [Toggle] _ZClip("Camera frustum clipping", Float) = 1 [Enum(Both,0,Back,1,Front,2)] _Cull("Render faces", Float) = 2 [MaterialEnum(Performance, 0,Appearance, 1)] _ShadingMode("Shading mode", Float) = 1 [MaterialEnum(Mesh UV,0,World XZ projected ,1)]_WorldSpaceUV("UV Coordinates", Float) = 1 _Direction("Animation direction", Vector) = (0,-1,0,0) _Speed("Animation Speed", Float) = 1 _SlopeAngleThreshold("Angle° threshold", Range(0 , 90)) = 15 _SlopeAngleFalloff("Angle° falloff", Range(15 , 90)) = 25 _SlopeStretching("Slope UV stretch", Range(0 , 1)) = 0.5 _SlopeSpeed("Slope speed multiplier", Float) = 2 _SlopeFoam("River slope foam", Range(0 , 3)) = 1 //Color + Transparency [HDR]_BaseColor("Deep", Color) = (0, 0.44, 0.62, 1) [HDR]_ShallowColor("Shallow", Color) = (0.1, 0.9, 0.89, 0.02) [PowerSlider(3)] _ColorAbsorption("Color Absorption", Range(0 , 1)) = 0 _WaveTint("Wave tint", Range( -0.1 , 0.1)) = 0 [HDR]_HorizonColor("Horizon", Color) = (0.84, 1, 1, 0.15) _HorizonDistance("Horizon Distance", Range(0.01 , 32)) = 8 [Toggle] _VertexColorTransparency("Vertex color (G) transparency", Float) = 0 [MaterialEnum(Depth Texture,0,Vertex Color (G),1)] _FogSource("Fog source", Float) = 0 _DepthVertical("View Depth", Range(0.01 , 16)) = 4 _DepthHorizontal("Vertical Height Depth", Range(0.01 , 8)) = 1 _EdgeFade("Edge Fade", Float) = 0.1 _ShadowStrength("Shadow Strength", Range(0 , 1)) = 1 //_Smoothness("Smoothness", Range(0.0, 1.0)) = 0.9 //_Metallic("Metallic", Range(0.0, 1.0)) = 0.0 _TranslucencyStrength("Translucency Strength", Range(0 , 3)) = 1 _TranslucencyStrengthDirect("Translucency Strength (Direct)", Range(0 , 0.5)) = 0.05 _TranslucencyExp("Translucency Exponent", Range(1 , 32)) = 4 _TranslucencyCurvatureMask("Translucency Curvature mask", Range(0, 1)) = 0.75 _TranslucencyReflectionMask("Translucency Reflection mask", Range(0, 1)) = 1 //Underwater _CausticsBrightness("Brightness", Float) = 2 _CausticsChromance("Chromance", Range(0, 1)) = 1 _CausticsTiling("Tiling", Float) = 0.5 _CausticsSpeed("Speed multiplier", Float) = 0.1 _CausticsDistortion("Distortion", Range(0, 1)) = 0.15 [NoScaleOffset][SingleLineTexture]_CausticsTex("Texture", 2D) = "black" {} [Toggle] _EnableDirectionalCaustics("Directional Caustics", Float) = 0 _UnderwaterSurfaceSmoothness("Underwater Surface Smoothness", Range(0, 1)) = 0.8 _UnderwaterRefractionOffset("Underwater Refraction Offset", Range(-1, 1)) = 0.2 _UnderwaterReflectionStrength("Underwater Reflection Strength", Range(0, 1)) = 0.5 _RefractionStrength("Refraction Strength", Range(0, 1)) = 0.1 _RefractionChromaticAberration("Refraction Chromatic Aberration)", Range(0, 1)) = 1 //Intersection Foam [MaterialEnum(Depth Texture,0,Vertex Color (R),1,Depth Texture and Vertex Color,2)] _IntersectionSource("Intersection source", Float) = 0 [NoScaleOffset][SingleLineTexture]_IntersectionNoise("Intersection noise", 2D) = "white" {} _IntersectionColor("Color", Color) = (1,1,1,1) _IntersectionLength("Distance", Range(0.01 , 10)) = 3 _IntersectionFalloff("Falloff", Range(0.01 , 1)) = 0.5 [Toggle] _IntersectionSharp("Sharp", float) = 1 _IntersectionClipping("Cutoff", Range(0.01, 1)) = 0.5 _IntersectionTiling("Noise Tiling", float) = 0.2 _IntersectionSpeed("Speed multiplier", float) = 0.1 _IntersectionRippleDist("Ripple frequency", float) = 32 _IntersectionRippleStrength("Ripple Strength", Range(0 , 1)) = 0.5 _IntersectionRippleSpeed("Ripple Speed", float) = 2 _IntersectionDistortion("Distortion", Range(0 , 1)) = 0.2 //Surface Foam [NoScaleOffset][SingleLineTexture]_FoamTex("Foam Mask", 2D) = "black" {} _FoamColor("Color", Color) = (1,1,1,1) _FoamSpeed("Speed multiplier", float) = 0.1 _FoamSubSpeed("Speed multiplier (sub-layer)", float) = -0.25 _FoamBaseAmount("Base amount", Range(0 , 1)) = 0 _FoamClipping("Clipping", Range(0 , 0.999)) = 0 _FoamStrength("Strength", float) = 1 [MinMaxSlider(0, 3)] _FoamCrestMinMaxHeight("Wave crest min/max height", Vector) = (1, 2, 0, 0) [MinMaxSlider(10, 500)] _DistanceFoamFadeDist("Distance foam blend (Start/End)", Vector) = (100, 350, 0, 0) _DistanceFoamTiling("Distance foam: Tiling multiplier", Float) = 0.2 //[PowerSlider(0.1)] _FoamCrestExponent("Wave crest min/max height", Range(1, 8)) = 4 _FoamBubblesSpread("Foam bubbles spread", Range(0, 2)) = 1 _FoamBubblesStrength("Foam ubbles", Range(0, 1)) = 0.1 _FoamTiling("Tiling", Vector) = (0.1, 0.1, 0, 0) _FoamSubTiling("Tiling (sub-layer)", float) = 0.5 _FoamDistortion("Distortion", Range(0, 3)) = 0 [Toggle] _VertexColorFoam("Vertex color (A) foam", Float) = 0 [NoScaleOffset][SingleLineTexture] _FoamTexDynamic("Foam (Dynamic)", 2D) = "white" {} _FoamTilingDynamic("Tiling (Dynamic)", float) = 0.1 _FoamSubTilingDynamic("Tiling (sub-layer)", float) = 2 _FoamSpeedDynamic("Speed multiplier", float) = 0.1 _FoamSubSpeedDynamic("Speed multiplier (sub-layer)", float) = -0.1 _FoamClippingDynamic("SClipping", Range(0 , 0.999)) = 0 //Normals [NoScaleOffset][Normal][SingleLineTexture]_BumpMap("Normals", 2D) = "bump" {} [NoScaleOffset][Normal][SingleLineTexture]_BumpMapSlope("Normals (River slopes)", 2D) = "bump" {} _NormalTiling("Tiling", Vector) = (0.5, 0.5, 0, 0) _NormalSubTiling("Tiling (sub-layer)", Float) = 0.5 _NormalStrength("Strength", Range(0 , 1)) = 0.135 _NormalSpeed("Speed multiplier", Float) = 1 _NormalSubSpeed("Speed multiplier (sub-layer)", Float) = -0.5 [NoScaleOffset][Normal][SingleLineTexture]_BumpMapLarge("Normals (Distance)", 2D) = "bump" {} _DistanceNormalsFadeDist("Distance normals blend (Start/End)", Vector) = (100, 300, 0, 0) _DistanceNormalsTiling("Distance normals: Tiling multiplier", Float) = 0.15 _SparkleIntensity("Sparkle Intensity", Range(0 , 10)) = 00 _SparkleSize("Sparkle Size", Range( 0 , 1)) = 0.280 //Light Reflections [PowerSlider(0.1)] _SunReflectionSize("Sun Size", Range(0 , 1)) = 0.5 _SunReflectionStrength("Sun Strength", Float) = 10 _SunReflectionDistortion("Sun Distortion", Range(0 ,2)) = 0.49 [Toggle] _SunReflectionSharp("Sun Sharpness", Float) = 0 _PointSpotLightReflectionStrength("Point/spot light strength", Float) = 10 [PowerSlider(0.1)] _PointSpotLightReflectionSize("Point/spot light size", Range(0 , 1)) = 0 _PointSpotLightReflectionDistortion("Point/spot light distortion", Range(0, 1)) = 0.5 [Toggle] _PointSpotLightReflectionSharp("Point/spot light Sharp", Float) = 0 //World Reflections _ReflectionStrength("Strength", Range(0, 1)) = 1 _ReflectionDistortion("Distortion", Range(0, 1)) = 0.05 _ReflectionBlur("Probe Blur Factor", Range(0, 1)) = 0 _ReflectionFresnel("Curvature mask", Range(0.01, 20)) = 5 _ReflectionLighting("Lighting influence", Range(0, 1)) = 0 _PlanarReflection("Planar Reflections", 2D) = "" {} //Instanced [Toggle] _ScreenSpaceReflectionsEnabled("Screen-space Reflections", float) = 0 _PlanarReflectionsEnabled("Planar Enabled", float) = 0 //Instanced //Waves [WaveProfile] _WaveProfile("Wave Profile", 2D) = "black" {} _WaveSpeed("Speed", Float) = 2 _WaveFrequency("Frequency", Float) = 1 _WaveHeight("Height Scale", Range(0 , 2)) = 0.15 [Toggle] _VertexColorWaveFlattening("Vertex color (B) wave flattening", Float) = 0 _WaveNormalStr("Normal Strength", Range(0 , 32)) = 0.1 _WaveFadeDistance("Wave fade distance (Start/End)", Vector) = (150, 500, 0, 0) _WaveSteepness("Steepness", Range(0 , 5)) = 0.1 _WaveMaxLayers("Maximum Layers", Range(1 , 64)) = 64 _WaveDirection("Direction", vector) = (1,1,1,1) //Keyword states [ToggleOff(_UNLIT)] _LightingOn("Enable lighting", Float) = 1 [ToggleOff(_RECEIVE_SHADOWS_OFF)] _ReceiveShadows("Recieve Shadows", Float) = 1 [Toggle(_FLAT_SHADING)] _FlatShadingOn("Flat shading", Float) = 0 [Toggle(_TRANSLUCENCY)] _TranslucencyOn("Enable translucency shading", Float) = 1 [Toggle(_REFRACTION)] _RefractionOn("Refraction", Float) = 1 [Toggle(_RIVER)] _RiverModeOn("River Mode", Float) = 0 [Toggle(_CAUSTICS)] _CausticsOn("Caustics ON", Float) = 1 [ToggleOff(_SPECULARHIGHLIGHTS_OFF)] _SpecularReflectionsOn("Specular Reflections", Float) = 1 [ToggleOff(_ENVIRONMENTREFLECTIONS_OFF)] _EnvironmentReflectionsOn("Environment Reflections", Float) = 1 [Toggle(_NORMALMAP)] _NormalMapOn("Normal maps", Float) = 1 [Toggle(_INTERSECTION_FOAM)] _IntersectionFoamOn("Enable intersection foam", float) = 1 [Toggle(_DISTANCE_NORMALS)] _DistanceNormalsOn("Distance normal map", Float) = 0 [Toggle] _FoamOn("Surface Foam", Float) = 1 [Toggle] _FoamDistanceOn("Surface Foam Distance", Float) = 0 [Toggle(_DISABLE_DEPTH_TEX)] _DisableDepthTexture("Disable depth texture", Float) = 0 [Toggle(_WAVES)] _WavesOn("Waves", Float) = 0 [Toggle] _ReceiveDynamicEffectsHeight("Receive Dynamic Effects Height", Float) = 1 _ReceiveDynamicEffectsFoam("Receive Dynamic Effects Foam", Float) = 1 [Toggle] _ReceiveDynamicEffectsNormal("Receive Dynamic Effects Normals", Float) = 1 %tessellation_properties% //[CurvedWorldBendSettings] _CurvedWorldBendSettings("0,5|1|1", Vector) = (0, 0, 0, 0) //Purely here so the _BaseColor gets multiplied with a white color during lightmapping [MainTexture] [HideInInspector] _BaseMap("Albedo", 2D) = "white" {} [HideInInspector][NoScaleOffset]unity_Lightmaps("unity_Lightmaps", 2DArray) = "" {} [HideInInspector][NoScaleOffset]unity_LightmapsInd("unity_LightmapsInd", 2DArray) = "" {} [HideInInspector][NoScaleOffset]unity_ShadowMasks("unity_ShadowMasks", 2DArray) = "" {} } SubShader { Tags { "RenderType" = "Transparent" "RenderPipeline" = "UniversalPipeline" "UniversalMaterialType" = "Lit" "IgnoreProjector" = "True" "Queue" = "Transparent+%render_queue_offset%" } HLSLINCLUDE //Custom directives: %custom_directives% %global_defines% //Curved World 2020 directives: //#pragma shader_feature_local CURVEDWORLD_BEND_TYPE_CLASSICRUNNER_X_POSITIVE CURVEDWORLD_BEND_TYPE_LITTLEPLANET_Y //#define CURVEDWORLD_BEND_ID_1 //#pragma shader_feature_local CURVEDWORLD_DISABLED_ON //#pragma shader_feature_local CURVEDWORLD_NORMAL_TRANSFORMATION_ON ENDHLSL Pass { Name "ForwardLit" Tags { "LightMode"="UniversalForwardOnly" } Blend SrcAlpha OneMinusSrcAlpha, One OneMinusSrcAlpha ZWrite [_ZWrite] Cull [_Cull] ZTest LEqual ZClip [_ZClip] Stencil { Ref %stencilID% Comp Always Pass Replace } HLSLPROGRAM %pragma_target% %pragma_renderers% #pragma multi_compile_instancing #pragma instancing_options renderinglayer #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" #define _SURFACE_TYPE_TRANSPARENT 1 #define SHADERPASS_FORWARD //#define _FLOWMAP 1 %defines% // Material Keywords #pragma shader_feature_local _NORMALMAP #pragma shader_feature_local _WAVES #pragma shader_feature_local _RECEIVE_SHADOWS_OFF #pragma shader_feature_local _RIVER #pragma shader_feature_local _REFRACTION #pragma shader_feature_local_fragment _DISABLE_DEPTH_TEX #pragma shader_feature_local_fragment _ADVANCED_SHADING #pragma shader_feature_local_fragment _UNLIT #pragma shader_feature_local_fragment _CAUSTICS #pragma shader_feature_local_fragment _DISTANCE_NORMALS #pragma shader_feature_local_fragment _SURFACE_FOAM_SINGLE #pragma shader_feature_local_fragment _SURFACE_FOAM_DUAL #pragma shader_feature_local_fragment _TRANSLUCENCY #pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF #pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF #pragma shader_feature_local_fragment _INTERSECTION_FOAM #pragma shader_feature_local_fragment _FLAT_SHADING //Multi-compile variants for installed extensions %multi_compile underwater rendering% %multi_compile dynamic effects% #if UNDERWATER_ENABLED && _RIVER #define UNDERWATER_ENABLED 0 #endif #include_library "Libraries/URP.hlsl" //#include "Assets/Amazing Assets/Curved World/Shaders/Core/CurvedWorldTransform.cginc" #if _SURFACE_FOAM_SINGLE || _SURFACE_FOAM_DUAL #define _SURFACE_FOAM 1 #endif //Tying specific features and operations to advanced shading #if _ADVANCED_SHADING #define RESAMPLE_REFRACTION_DEPTH 1 #define PHYSICAL_REFRACTION 1 #if _CAUSTICS #define RECONSTRUCT_WORLD_NORMAL #endif //#define HQ_CAUSTICS 1 #if _REFRACTION //Requires opaque texture #define COLOR_ABSORPTION 1 #endif //Mask caustics by shadows cast on scene geometry. Doubles the shadow sampling cost //Note: needs depth texture to reconstruct the world position from depth #if _CAUSTICS && defined(MAIN_LIGHT_CALCULATE_SHADOWS) && !_DISABLE_DEPTH_TEX #define SCENE_SHADOWMASK 1 #endif #if !_DISABLE_DEPTH_TEX && _CAUSTICS || UNDERWATER_ENABLED //Compose a mask for pixels against the skybox #define DEPTH_MASK 1 #endif #endif #if _NORMALMAP || _WAVES #define REQUIRES_TANGENT_TO_WORLD 1 #endif //Universal Pipeline keywords %multi_compile_light_cookies% #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS #pragma multi_compile_fragment _ _SHADOWS_SOFT #pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS //URP 11+ //URP 12+ only (2021.2+) #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING #pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION #pragma multi_compile_fragment _ DEBUG_DISPLAY #pragma multi_compile _ _LIGHT_LAYERS //Unity 6.0 #if (UNITY_VERSION >= 60000023) && (UNITY_VERSION < 60010000) #pragma multi_compile _ _CLUSTERED_RENDERING #pragma multi_compile _ _FORWARD_PLUS #endif //Unity 6.1+ #if (UNITY_VERSION >= 60010000) #pragma multi_compile _ _CLUSTER_LIGHT_LOOP #pragma multi_compile_fragment _ _REFLECTION_PROBE_ATLAS #endif //URP 15+ (2023.1+) #pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX //Unity defined keywords #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING #pragma multi_compile _ SHADOWS_SHADOWMASK #pragma multi_compile _ DIRLIGHTMAP_COMBINED #pragma multi_compile _ LIGHTMAP_ON #pragma multi_compile _ DYNAMICLIGHTMAP_ON #if (UNITY_VERSION >= 60010000) #pragma multi_compile_fragment _ LIGHTMAP_BICUBIC_SAMPLING #pragma multi_compile _ USE_LEGACY_LIGHTMAPS #endif #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl" %tessellation_directives% #include_library "Libraries/Input.hlsl" #include_library "Libraries/Common.hlsl" //Fog rendering (integration) %define_fog_integration% %include_fog_integration_library% #include_library "Libraries/Fog.hlsl" #include_library "Libraries/Terrain.hlsl" #include_library "Libraries/Waves.hlsl" //Not needed, but registers it as a dependency #include_library "Libraries/Gerstner.hlsl" #include_library "Libraries/Lighting.hlsl" #include_library "Libraries/Reflections.hlsl" #include_library "Libraries/Refraction.hlsl" #ifdef DYNAMIC_EFFECTS_ENABLED #include_library "DynamicEffects/DynamicEffects.hlsl" #endif #ifdef UNDERWATER_ENABLED #include_library "Underwater/UnderwaterFog.hlsl" #include_library "Underwater/UnderwaterShading.hlsl" #include_library "Underwater/UnderwaterMask.hlsl" #include_library "Underwater/UnderwaterLighting.hlsl" #endif #include_library "Libraries/Normals.hlsl" #include_library "Libraries/Foam.hlsl" #include_library "Libraries/Caustics.hlsl" #include_library "Libraries/Vertex.hlsl" #if defined(TESSELLATION_ON) #include_library "Libraries/Tesselation.hlsl" #define VertexOutput VertexControl #else #define VertexOutput Varyings #endif #pragma vertex Vertex VertexOutput Vertex(Attributes v) { #if defined(TESSELLATION_ON) return VertexTessellation(v); #else return LitPassVertex(v); #endif } #pragma fragment ForwardPassFragment #include_library "Passes/ForwardPass.hlsl" //#include "UnityCG.cginc" //Test #if defined(UNITY_SHADER_VARIABLES_INCLUDED) || defined(UNITY_CG_INCLUDED) #error "Fatal error: a shader library from the Built-in Render Pipeline was compiled into the shader. This is most likely caused by the fog integration, make absolutely sure it is URP-compatible!" #endif ENDHLSL } //Currently not used, but may be used by custom transparency-depth passes Pass { Name "Depth" Tags { "LightMode" = "DepthOnly" } ZWrite On //ColorMask R Cull Off HLSLPROGRAM %pragma_target% %pragma_renderers% #pragma multi_compile_instancing #pragma instancing_options renderinglayer #include_library "Libraries/URP.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" //#include "Assets/Amazing Assets/Curved World/Shaders/Core/CurvedWorldTransform.cginc" #pragma shader_feature_local _WAVES #define SHADERPASS_DEPTHONLY #include_library "Libraries/Input.hlsl" #include_library "Libraries/Common.hlsl" #include_library "Libraries/Waves.hlsl" %multi_compile dynamic effects% #ifdef DYNAMIC_EFFECTS_ENABLED #include_library "DynamicEffects/DynamicEffects.hlsl" #endif #include_library "Passes/HeightPrePass.hlsl" #pragma vertex HeightPassVertex #pragma fragment DepthOnlyFragment float4 DepthOnlyFragment(HeightPassVaryings input) : SV_TARGET { UNITY_SETUP_INSTANCE_ID(input); UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); return float4(input.positionCS.z, 0, 0, 1); } ENDHLSL } Pass { Name "Height" Tags { "LightMode" = "WaterHeight" } ZWrite On //ColorMask RG Cull Off HLSLPROGRAM %pragma_target% %pragma_renderers% #pragma multi_compile_instancing #pragma instancing_options renderinglayer #include_library "Libraries/URP.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" //#include "Assets/Amazing Assets/Curved World/Shaders/Core/CurvedWorldTransform.cginc" #pragma shader_feature_local _WAVES %multi_compile dynamic effects% #pragma multi_compile _ WATER_HEIGHT_PASS //If set, the displacement effects are not calculated in the vertex shader, which would be a waste. #define SHADERPASS_HEIGHT #include_library "Libraries/Input.hlsl" #include_library "Libraries/Common.hlsl" #include_library "Libraries/Waves.hlsl" #ifdef DYNAMIC_EFFECTS_ENABLED #include_library "DynamicEffects/DynamicEffects.hlsl" #endif #pragma vertex HeightPassVertex #pragma fragment HeightFragment #include_library "Passes/HeightPrePass.hlsl" ENDHLSL } %passes% } CustomEditor "StylizedWater3.MaterialUI" Fallback "Hidden/Universal Render Pipeline/FallbackError" }