6203 lines
253 KiB
GLSL
6203 lines
253 KiB
GLSL
// Made with Amplify Shader Editor v1.9.2.2
|
|
// Available at the Unity Asset Store - http://u3d.as/y3X
|
|
Shader "TerrainAmplifyFirstPass"
|
|
{
|
|
Properties
|
|
{
|
|
[HideInInspector] _AlphaCutoff("Alpha Cutoff ", Range(0, 1)) = 0.5
|
|
[HideInInspector]_TerrainHolesTexture("_TerrainHolesTexture", 2D) = "white" {}
|
|
[HideInInspector]_Control("Control", 2D) = "white" {}
|
|
[HideInInspector]_Splat3("Splat3", 2D) = "white" {}
|
|
[HideInInspector]_Splat2("Splat2", 2D) = "white" {}
|
|
[HideInInspector]_Splat1("Splat1", 2D) = "white" {}
|
|
[HideInInspector]_Splat0("Splat0", 2D) = "white" {}
|
|
[HideInInspector]_Normal0("Normal0", 2D) = "white" {}
|
|
[HideInInspector]_Normal1("Normal1", 2D) = "white" {}
|
|
[HideInInspector]_Normal2("Normal2", 2D) = "white" {}
|
|
[HideInInspector]_Normal3("Normal3", 2D) = "white" {}
|
|
[HideInInspector]_Smoothness3("Smoothness3", Range( 0 , 1)) = 1
|
|
[HideInInspector]_Smoothness1("Smoothness1", Range( 0 , 1)) = 1
|
|
[HideInInspector]_Smoothness0("Smoothness0", Range( 0 , 1)) = 1
|
|
[HideInInspector]_Smoothness2("Smoothness2", Range( 0 , 1)) = 1
|
|
[HideInInspector]_Mask2("_Mask2", 2D) = "white" {}
|
|
[HideInInspector]_Mask0("_Mask0", 2D) = "white" {}
|
|
[HideInInspector]_Mask1("_Mask1", 2D) = "white" {}
|
|
[HideInInspector]_Mask3("_Mask3", 2D) = "white" {}
|
|
_RippleNormalStrength("RippleNormalStrength", Float) = 0.5
|
|
_RippleTextureCoordinatesTilling("RippleTextureCoordinatesTilling", Vector) = (1,1,0,0)
|
|
_NormalMapStrength("NormalMapStrength", Float) = 1
|
|
_RippleNormal("RippleNormal", 2D) = "bump" {}
|
|
_RippleFPS("RippleFPS", Float) = 0.001
|
|
_RainOpacity("RainOpacity", Float) = 0.6
|
|
_Smoothness("Smoothness", Float) = 0.5
|
|
_RainReflections1("RainReflections1", Vector) = (15,15,0,0)
|
|
_RainReflections("RainReflections", Vector) = (15,15,0,0)
|
|
_WaterFlowSpeed("WaterFlowSpeed", Float) = 1
|
|
_RainScale("RainScale", Float) = 3.13
|
|
_WaterFlowSpeed1("WaterFlowSpeed1", Float) = -1
|
|
_Normal1Tilling("Normal1Tilling", Vector) = (1,1,0,0)
|
|
_Normal2Tilling("Normal2Tilling", Vector) = (1,1,0,0)
|
|
_WaterFlowNormal("WaterFlowNormal", 2D) = "bump" {}
|
|
_WaterFlowNormal1("WaterFlowNormal1", 2D) = "bump" {}
|
|
_Float10("Float 10", Float) = 0.5
|
|
[HideInInspector] _texcoord( "", 2D ) = "white" {}
|
|
|
|
[HideInInspector] _RenderQueueType("Render Queue Type", Float) = 1
|
|
//[HideInInspector][ToggleUI] _AddPrecomputedVelocity("Add Precomputed Velocity", Float) = 1
|
|
[HideInInspector][ToggleUI] _SupportDecals("Support Decals", Float) = 1.0
|
|
[HideInInspector] _StencilRef("Stencil Ref", Int) = 0 // StencilUsage.Clear
|
|
[HideInInspector] _StencilWriteMask("Stencil Write Mask", Int) = 3 // StencilUsage.RequiresDeferredLighting | StencilUsage.SubsurfaceScattering
|
|
[HideInInspector] _StencilRefDepth("Stencil Ref Depth", Int) = 0 // Nothing
|
|
[HideInInspector] _StencilWriteMaskDepth("Stencil Write Mask Depth", Int) = 8 // StencilUsage.TraceReflectionRay
|
|
[HideInInspector] _StencilRefMV("Stencil Ref MV", Int) = 32 // StencilUsage.ObjectMotionVector
|
|
[HideInInspector] _StencilWriteMaskMV("Stencil Write Mask MV", Int) = 32 // StencilUsage.ObjectMotionVector
|
|
[HideInInspector] _StencilRefDistortionVec("Stencil Ref Distortion Vec", Int) = 4 // DEPRECATED
|
|
[HideInInspector] _StencilWriteMaskDistortionVec("Stencil Write Mask Distortion Vec", Int) = 4 // DEPRECATED
|
|
[HideInInspector] _StencilWriteMaskGBuffer("Stencil Write Mask GBuffer", Int) = 3 // StencilUsage.RequiresDeferredLighting | StencilUsage.SubsurfaceScattering
|
|
[HideInInspector] _StencilRefGBuffer("Stencil Ref GBuffer", Int) = 2 // StencilUsage.RequiresDeferredLighting
|
|
[HideInInspector] _ZTestGBuffer("ZTest GBuffer", Int) = 4
|
|
[HideInInspector][ToggleUI] _RequireSplitLighting("Require Split Lighting", Float) = 0
|
|
[HideInInspector][ToggleUI] _ReceivesSSR("Receives SSR", Float) = 1
|
|
[HideInInspector][ToggleUI] _ReceivesSSRTransparent("Receives SSR Transparent", Float) = 0
|
|
[HideInInspector] _SurfaceType("Surface Type", Float) = 0
|
|
[HideInInspector] _BlendMode("Blend Mode", Float) = 0
|
|
[HideInInspector] _SrcBlend("Src Blend", Float) = 1
|
|
[HideInInspector] _DstBlend("Dst Blend", Float) = 0
|
|
[HideInInspector] _AlphaSrcBlend("Alpha Src Blend", Float) = 1
|
|
[HideInInspector] _AlphaDstBlend("Alpha Dst Blend", Float) = 0
|
|
[HideInInspector][ToggleUI] _ZWrite("ZWrite", Float) = 1
|
|
[HideInInspector][ToggleUI] _TransparentZWrite("Transparent ZWrite", Float) = 0
|
|
[HideInInspector] _CullMode("Cull Mode", Float) = 2
|
|
[HideInInspector] _TransparentSortPriority("Transparent Sort Priority", Float) = 0
|
|
[HideInInspector][ToggleUI] _EnableFogOnTransparent("Enable Fog", Float) = 1
|
|
[HideInInspector] _CullModeForward("Cull Mode Forward", Float) = 2 // This mode is dedicated to Forward to correctly handle backface then front face rendering thin transparent
|
|
[HideInInspector][Enum(UnityEditor.Rendering.HighDefinition.TransparentCullMode)] _TransparentCullMode("Transparent Cull Mode", Int) = 2 // Back culling by default
|
|
[HideInInspector] _ZTestDepthEqualForOpaque("ZTest Depth Equal For Opaque", Int) = 4 // Less equal
|
|
[HideInInspector][Enum(UnityEngine.Rendering.CompareFunction)] _ZTestTransparent("ZTest Transparent", Int) = 4 // Less equal
|
|
[HideInInspector][ToggleUI] _TransparentBackfaceEnable("Transparent Backface Enable", Float) = 0
|
|
[HideInInspector][ToggleUI] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0
|
|
[HideInInspector][ToggleUI] _UseShadowThreshold("Use Shadow Threshold", Float) = 0
|
|
[HideInInspector][ToggleUI] _DoubleSidedEnable("Double Sided Enable", Float) = 0
|
|
[HideInInspector][Enum(Flip, 0, Mirror, 1, None, 2)] _DoubleSidedNormalMode("Double Sided Normal Mode", Float) = 2
|
|
[HideInInspector] _DoubleSidedConstants("DoubleSidedConstants", Vector) = (1,1,-1,0)
|
|
|
|
//_TessPhongStrength( "Tess Phong Strength", Range( 0, 1 ) ) = 0.5
|
|
//_TessValue( "Tess Max Tessellation", Range( 1, 32 ) ) = 16
|
|
//_TessMin( "Tess Min Distance", Float ) = 10
|
|
//_TessMax( "Tess Max Distance", Float ) = 25
|
|
//_TessEdgeLength ( "Tess Edge length", Range( 2, 50 ) ) = 16
|
|
//_TessMaxDisp( "Tess Max Displacement", Float ) = 25
|
|
|
|
[HideInInspector][ToggleUI] _TransparentWritingMotionVec("Transparent Writing MotionVec", Float) = 0
|
|
[HideInInspector][Enum(UnityEditor.Rendering.HighDefinition.OpaqueCullMode)] _OpaqueCullMode("Opaque Cull Mode", Int) = 2 // Back culling by default
|
|
[HideInInspector][ToggleUI] _EnableBlendModePreserveSpecularLighting("Enable Blend Mode Preserve Specular Lighting", Float) = 1
|
|
[HideInInspector] _EmissionColor("Color", Color) = (1, 1, 1)
|
|
|
|
[HideInInspector][NoScaleOffset] unity_Lightmaps("unity_Lightmaps", 2DArray) = "" {}
|
|
[HideInInspector][NoScaleOffset] unity_LightmapsInd("unity_LightmapsInd", 2DArray) = "" {}
|
|
[HideInInspector][NoScaleOffset] unity_ShadowMasks("unity_ShadowMasks", 2DArray) = "" {}
|
|
|
|
[HideInInspector][Enum(Auto, 0, On, 1, Off, 2)] _DoubleSidedGIMode("Double sided GI mode", Float) = 0 //DoubleSidedGIMode added in api 12x and higher
|
|
|
|
[HideInInspector][ToggleUI] _AlphaToMaskInspectorValue("_AlphaToMaskInspectorValue", Float) = 0 // Property used to save the alpha to mask state in the inspector
|
|
[HideInInspector][ToggleUI] _AlphaToMask("__alphaToMask", Float) = 0
|
|
}
|
|
|
|
SubShader
|
|
{
|
|
LOD 0
|
|
|
|
|
|
|
|
Tags { "RenderPipeline"="HDRenderPipeline" "RenderType"="Opaque" "Queue"="Geometry" }
|
|
|
|
HLSLINCLUDE
|
|
#pragma target 4.5
|
|
#pragma exclude_renderers glcore gles gles3 ps4 ps5
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Filtering.hlsl"
|
|
|
|
struct GlobalSurfaceDescription // GBuffer Forward META TransparentBackface
|
|
{
|
|
float3 BaseColor;
|
|
float3 Normal;
|
|
float3 BentNormal;
|
|
float3 Specular;
|
|
float CoatMask;
|
|
float Metallic;
|
|
float3 Emission;
|
|
float Smoothness;
|
|
float Occlusion;
|
|
float Alpha;
|
|
float AlphaClipThreshold;
|
|
float AlphaClipThresholdShadow;
|
|
float AlphaClipThresholdDepthPrepass;
|
|
float AlphaClipThresholdDepthPostpass;
|
|
float SpecularAAScreenSpaceVariance;
|
|
float SpecularAAThreshold;
|
|
float SpecularOcclusion;
|
|
float DepthOffset;
|
|
//Refraction
|
|
float RefractionIndex;
|
|
float3 RefractionColor;
|
|
float RefractionDistance;
|
|
//SSS/Translucent
|
|
float DiffusionProfile;
|
|
// Transmission + Diffusion Profile
|
|
float Thickness;
|
|
float SubsurfaceMask;
|
|
//Anisotropy
|
|
float Anisotropy;
|
|
float3 Tangent;
|
|
//Iridescent
|
|
float IridescenceMask;
|
|
float IridescenceThickness;
|
|
//BakedGI
|
|
float3 BakedGI;
|
|
float3 BakedBackGI;
|
|
//Virtual Texturing
|
|
float4 VTPackedFeedback;
|
|
};
|
|
|
|
struct AlphaSurfaceDescription // ShadowCaster
|
|
{
|
|
float Alpha;
|
|
float AlphaClipThreshold;
|
|
float AlphaClipThresholdShadow;
|
|
float DepthOffset;
|
|
};
|
|
|
|
struct SceneSurfaceDescription // SceneSelection
|
|
{
|
|
float Alpha;
|
|
float AlphaClipThreshold;
|
|
float DepthOffset;
|
|
};
|
|
|
|
struct PrePassSurfaceDescription // DepthPrePass
|
|
{
|
|
float3 Normal;
|
|
float Smoothness;
|
|
float Alpha;
|
|
float AlphaClipThresholdDepthPrepass;
|
|
float DepthOffset;
|
|
};
|
|
|
|
struct PostPassSurfaceDescription //DepthPostPass
|
|
{
|
|
float Alpha;
|
|
float AlphaClipThresholdDepthPostpass;
|
|
float DepthOffset;
|
|
};
|
|
|
|
struct SmoothSurfaceDescription // MotionVectors DepthOnly
|
|
{
|
|
float3 Normal;
|
|
float Smoothness;
|
|
float Alpha;
|
|
float AlphaClipThreshold;
|
|
float DepthOffset;
|
|
};
|
|
|
|
#ifndef ASE_TESS_FUNCS
|
|
#define ASE_TESS_FUNCS
|
|
float4 FixedTess( float tessValue )
|
|
{
|
|
return tessValue;
|
|
}
|
|
|
|
float CalcDistanceTessFactor (float4 vertex, float minDist, float maxDist, float tess, float4x4 o2w, float3 cameraPos )
|
|
{
|
|
float3 wpos = mul(o2w,vertex).xyz;
|
|
float dist = distance (wpos, cameraPos);
|
|
float f = clamp(1.0 - (dist - minDist) / (maxDist - minDist), 0.01, 1.0) * tess;
|
|
return f;
|
|
}
|
|
|
|
float4 CalcTriEdgeTessFactors (float3 triVertexFactors)
|
|
{
|
|
float4 tess;
|
|
tess.x = 0.5 * (triVertexFactors.y + triVertexFactors.z);
|
|
tess.y = 0.5 * (triVertexFactors.x + triVertexFactors.z);
|
|
tess.z = 0.5 * (triVertexFactors.x + triVertexFactors.y);
|
|
tess.w = (triVertexFactors.x + triVertexFactors.y + triVertexFactors.z) / 3.0f;
|
|
return tess;
|
|
}
|
|
|
|
float CalcEdgeTessFactor (float3 wpos0, float3 wpos1, float edgeLen, float3 cameraPos, float4 scParams )
|
|
{
|
|
float dist = distance (0.5 * (wpos0+wpos1), cameraPos);
|
|
float len = distance(wpos0, wpos1);
|
|
float f = max(len * scParams.y / (edgeLen * dist), 1.0);
|
|
return f;
|
|
}
|
|
|
|
float DistanceFromPlaneASE (float3 pos, float4 plane)
|
|
{
|
|
return dot (float4(pos,1.0f), plane);
|
|
}
|
|
|
|
bool WorldViewFrustumCull (float3 wpos0, float3 wpos1, float3 wpos2, float cullEps, float4 planes[6] )
|
|
{
|
|
float4 planeTest;
|
|
planeTest.x = (( DistanceFromPlaneASE(wpos0, planes[0]) > -cullEps) ? 1.0f : 0.0f ) +
|
|
(( DistanceFromPlaneASE(wpos1, planes[0]) > -cullEps) ? 1.0f : 0.0f ) +
|
|
(( DistanceFromPlaneASE(wpos2, planes[0]) > -cullEps) ? 1.0f : 0.0f );
|
|
planeTest.y = (( DistanceFromPlaneASE(wpos0, planes[1]) > -cullEps) ? 1.0f : 0.0f ) +
|
|
(( DistanceFromPlaneASE(wpos1, planes[1]) > -cullEps) ? 1.0f : 0.0f ) +
|
|
(( DistanceFromPlaneASE(wpos2, planes[1]) > -cullEps) ? 1.0f : 0.0f );
|
|
planeTest.z = (( DistanceFromPlaneASE(wpos0, planes[2]) > -cullEps) ? 1.0f : 0.0f ) +
|
|
(( DistanceFromPlaneASE(wpos1, planes[2]) > -cullEps) ? 1.0f : 0.0f ) +
|
|
(( DistanceFromPlaneASE(wpos2, planes[2]) > -cullEps) ? 1.0f : 0.0f );
|
|
planeTest.w = (( DistanceFromPlaneASE(wpos0, planes[3]) > -cullEps) ? 1.0f : 0.0f ) +
|
|
(( DistanceFromPlaneASE(wpos1, planes[3]) > -cullEps) ? 1.0f : 0.0f ) +
|
|
(( DistanceFromPlaneASE(wpos2, planes[3]) > -cullEps) ? 1.0f : 0.0f );
|
|
return !all (planeTest);
|
|
}
|
|
|
|
float4 DistanceBasedTess( float4 v0, float4 v1, float4 v2, float tess, float minDist, float maxDist, float4x4 o2w, float3 cameraPos )
|
|
{
|
|
float3 f;
|
|
f.x = CalcDistanceTessFactor (v0,minDist,maxDist,tess,o2w,cameraPos);
|
|
f.y = CalcDistanceTessFactor (v1,minDist,maxDist,tess,o2w,cameraPos);
|
|
f.z = CalcDistanceTessFactor (v2,minDist,maxDist,tess,o2w,cameraPos);
|
|
|
|
return CalcTriEdgeTessFactors (f);
|
|
}
|
|
|
|
float4 EdgeLengthBasedTess( float4 v0, float4 v1, float4 v2, float edgeLength, float4x4 o2w, float3 cameraPos, float4 scParams )
|
|
{
|
|
float3 pos0 = mul(o2w,v0).xyz;
|
|
float3 pos1 = mul(o2w,v1).xyz;
|
|
float3 pos2 = mul(o2w,v2).xyz;
|
|
float4 tess;
|
|
tess.x = CalcEdgeTessFactor (pos1, pos2, edgeLength, cameraPos, scParams);
|
|
tess.y = CalcEdgeTessFactor (pos2, pos0, edgeLength, cameraPos, scParams);
|
|
tess.z = CalcEdgeTessFactor (pos0, pos1, edgeLength, cameraPos, scParams);
|
|
tess.w = (tess.x + tess.y + tess.z) / 3.0f;
|
|
return tess;
|
|
}
|
|
|
|
float4 EdgeLengthBasedTessCull( float4 v0, float4 v1, float4 v2, float edgeLength, float maxDisplacement, float4x4 o2w, float3 cameraPos, float4 scParams, float4 planes[6] )
|
|
{
|
|
float3 pos0 = mul(o2w,v0).xyz;
|
|
float3 pos1 = mul(o2w,v1).xyz;
|
|
float3 pos2 = mul(o2w,v2).xyz;
|
|
float4 tess;
|
|
|
|
if (WorldViewFrustumCull(pos0, pos1, pos2, maxDisplacement, planes))
|
|
{
|
|
tess = 0.0f;
|
|
}
|
|
else
|
|
{
|
|
tess.x = CalcEdgeTessFactor (pos1, pos2, edgeLength, cameraPos, scParams);
|
|
tess.y = CalcEdgeTessFactor (pos2, pos0, edgeLength, cameraPos, scParams);
|
|
tess.z = CalcEdgeTessFactor (pos0, pos1, edgeLength, cameraPos, scParams);
|
|
tess.w = (tess.x + tess.y + tess.z) / 3.0f;
|
|
}
|
|
return tess;
|
|
}
|
|
#endif //ASE_TESS_FUNCS
|
|
ENDHLSL
|
|
|
|
UsePass "Hidden/Nature/Terrain/Utilities/PICKING"
|
|
UsePass "Hidden/Nature/Terrain/Utilities/SELECTION"
|
|
|
|
Pass
|
|
{
|
|
|
|
Name "GBuffer"
|
|
Tags { "LightMode"="GBuffer" }
|
|
|
|
Cull [_CullMode]
|
|
ZTest [_ZTestGBuffer]
|
|
|
|
Stencil
|
|
{
|
|
Ref [_StencilRefGBuffer]
|
|
WriteMask [_StencilWriteMaskGBuffer]
|
|
Comp Always
|
|
Pass Replace
|
|
}
|
|
|
|
|
|
|
|
|
|
HLSLPROGRAM
|
|
|
|
#define _SPECULAR_OCCLUSION_FROM_AO 1
|
|
#pragma instancing_options renderinglayer
|
|
#define shader_feature_local _DISABLE_DECALS
|
|
#define shader_feature_local_raytracing _DISABLE_SSR
|
|
#define shader_feature_local_fragment _DISABLE_SSR
|
|
#define ASE_SRP_VERSION 170003
|
|
|
|
|
|
#pragma shader_feature _SURFACE_TYPE_TRANSPARENT
|
|
#pragma shader_feature_local _TRANSPARENT_WRITES_MOTION_VEC
|
|
#pragma shader_feature_local_fragment _ENABLE_FOG_ON_TRANSPARENT
|
|
|
|
#pragma multi_compile_fragment _ SHADOWS_SHADOWMASK
|
|
#pragma multi_compile_fragment _ LIGHT_LAYERS
|
|
#pragma multi_compile_fragment PROBE_VOLUMES_OFF PROBE_VOLUMES_L1 PROBE_VOLUMES_L2
|
|
#pragma multi_compile _ DEBUG_DISPLAY
|
|
#pragma multi_compile _ LIGHTMAP_ON
|
|
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
|
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
|
|
#pragma multi_compile_fragment DECALS_OFF DECALS_3RT DECALS_4RT
|
|
#pragma multi_compile_fragment _ DECAL_SURFACE_GRADIENT
|
|
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/GeometricTools.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Tessellation.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
|
|
#include "Packages/com.unity.shadergraph/ShaderGraphLibrary/Functions.hlsl"
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
|
|
#define SHADERPASS SHADERPASS_GBUFFER
|
|
|
|
#ifndef SHADER_UNLIT
|
|
#if defined(_DOUBLESIDED_ON) && !defined(VARYINGS_NEED_CULLFACE)
|
|
#define VARYINGS_NEED_CULLFACE
|
|
#endif
|
|
#endif
|
|
|
|
#if defined(_MATERIAL_FEATURE_SUBSURFACE_SCATTERING) && !defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define OUTPUT_SPLIT_LIGHTING
|
|
#endif
|
|
|
|
#if (SHADERPASS == SHADERPASS_PATH_TRACING) && !defined(_DOUBLESIDED_ON) && (defined(_REFRACTION_PLANE) || defined(_REFRACTION_SPHERE))
|
|
#undef _REFRACTION_PLANE
|
|
#undef _REFRACTION_SPHERE
|
|
#define _REFRACTION_THIN
|
|
#endif
|
|
|
|
#if SHADERPASS == SHADERPASS_TRANSPARENT_DEPTH_PREPASS
|
|
#if !defined(_DISABLE_SSR_TRANSPARENT) && !defined(SHADER_UNLIT)
|
|
#define WRITE_NORMAL_BUFFER
|
|
#endif
|
|
#endif
|
|
|
|
#ifndef DEBUG_DISPLAY
|
|
#if !defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#if SHADERPASS == SHADERPASS_FORWARD
|
|
#define SHADERPASS_FORWARD_BYPASS_ALPHA_TEST
|
|
#elif SHADERPASS == SHADERPASS_GBUFFER
|
|
#define SHADERPASS_GBUFFER_BYPASS_ALPHA_TEST
|
|
#endif
|
|
#endif
|
|
#endif
|
|
|
|
#if defined(SHADER_LIT) && !defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define _DEFERRED_CAPABLE_MATERIAL
|
|
#endif
|
|
|
|
#if defined(_TRANSPARENT_WRITES_MOTION_VEC) && defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define _WRITE_TRANSPARENT_MOTION_VECTOR
|
|
#endif
|
|
|
|
CBUFFER_START( UnityPerMaterial )
|
|
float2 _RainReflections;
|
|
float2 _Normal1Tilling;
|
|
float2 _RippleTextureCoordinatesTilling;
|
|
float2 _Normal2Tilling;
|
|
float2 _RainReflections1;
|
|
float _Smoothness0;
|
|
float _Float10;
|
|
float _RippleNormalStrength;
|
|
float _RippleFPS;
|
|
float _RainScale;
|
|
float _WaterFlowSpeed1;
|
|
float _NormalMapStrength;
|
|
float _WaterFlowSpeed;
|
|
float _Smoothness3;
|
|
float _Smoothness2;
|
|
float _Smoothness1;
|
|
float _RainOpacity;
|
|
float _Smoothness;
|
|
float4 _EmissionColor;
|
|
float _AlphaCutoff;
|
|
float _RenderQueueType;
|
|
#ifdef _ADD_PRECOMPUTED_VELOCITY
|
|
float _AddPrecomputedVelocity;
|
|
#endif
|
|
float _StencilRef;
|
|
float _StencilWriteMask;
|
|
float _StencilRefDepth;
|
|
float _StencilWriteMaskDepth;
|
|
float _StencilRefMV;
|
|
float _StencilWriteMaskMV;
|
|
float _StencilWriteMaskGBuffer;
|
|
float _StencilRefGBuffer;
|
|
float _ZTestGBuffer;
|
|
float _RequireSplitLighting;
|
|
float _ReceivesSSR;
|
|
float _SurfaceType;
|
|
float _BlendMode;
|
|
#ifdef SUPPORT_BLENDMODE_PRESERVE_SPECULAR_LIGHTING
|
|
float _EnableBlendModePreserveSpecularLighting;
|
|
#endif
|
|
float _SrcBlend;
|
|
float _DstBlend;
|
|
float _AlphaSrcBlend;
|
|
float _AlphaDstBlend;
|
|
float _ZWrite;
|
|
float _TransparentZWrite;
|
|
float _CullMode;
|
|
float _TransparentSortPriority;
|
|
float _EnableFogOnTransparent;
|
|
float _CullModeForward;
|
|
float _TransparentCullMode;
|
|
float _ZTestDepthEqualForOpaque;
|
|
float _ZTestTransparent;
|
|
float _TransparentBackfaceEnable;
|
|
float _AlphaCutoffEnable;
|
|
float _UseShadowThreshold;
|
|
float _DoubleSidedEnable;
|
|
float _DoubleSidedNormalMode;
|
|
float4 _DoubleSidedConstants;
|
|
#ifdef ASE_TESSELLATION
|
|
float _TessPhongStrength;
|
|
float _TessValue;
|
|
float _TessMin;
|
|
float _TessMax;
|
|
float _TessEdgeLength;
|
|
float _TessMaxDisp;
|
|
#endif
|
|
CBUFFER_END
|
|
|
|
// Property used by ScenePickingPass
|
|
#ifdef SCENEPICKINGPASS
|
|
float4 _SelectionID;
|
|
#endif
|
|
|
|
// Properties used by SceneSelectionPass
|
|
#ifdef SCENESELECTIONPASS
|
|
int _ObjectId;
|
|
int _PassValue;
|
|
#endif
|
|
|
|
sampler2D _Mask2;
|
|
sampler2D _Mask0;
|
|
sampler2D _Mask1;
|
|
sampler2D _Mask3;
|
|
float4 _MaskMapRemapScale0;
|
|
float4 _MaskMapRemapOffset2;
|
|
float4 _MaskMapRemapScale2;
|
|
float4 _MaskMapRemapScale1;
|
|
float4 _MaskMapRemapOffset1;
|
|
float4 _MaskMapRemapScale3;
|
|
float4 _MaskMapRemapOffset3;
|
|
float4 _MaskMapRemapOffset0;
|
|
sampler2D _Control;
|
|
sampler2D _Splat0;
|
|
sampler2D _Splat1;
|
|
sampler2D _Splat2;
|
|
sampler2D _Splat3;
|
|
sampler2D _TerrainHolesTexture;
|
|
sampler2D _Normal0;
|
|
sampler2D _Normal1;
|
|
sampler2D _Normal2;
|
|
sampler2D _Normal3;
|
|
sampler2D _WaterFlowNormal;
|
|
sampler2D _WaterFlowNormal1;
|
|
sampler2D _RippleNormal;
|
|
#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing
|
|
TEXTURE2D(_TerrainHeightmapTexture);//ASE Terrain Instancing
|
|
TEXTURE2D( _TerrainNormalmapTexture);//ASE Terrain Instancing
|
|
SAMPLER(sampler_TerrainNormalmapTexture);//ASE Terrain Instancing
|
|
#endif//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_START( Terrain )//ASE Terrain Instancing
|
|
UNITY_DEFINE_INSTANCED_PROP( float4, _TerrainPatchInstanceData )//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_END( Terrain)//ASE Terrain Instancing
|
|
CBUFFER_START( UnityTerrain)//ASE Terrain Instancing
|
|
#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing
|
|
float4 _TerrainHeightmapRecipSize;//ASE Terrain Instancing
|
|
float4 _TerrainHeightmapScale;//ASE Terrain Instancing
|
|
#endif//ASE Terrain Instancing
|
|
CBUFFER_END//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_START(TerrainAmplifyFirstPass)
|
|
UNITY_DEFINE_INSTANCED_PROP(float4, _Control_ST)
|
|
UNITY_DEFINE_INSTANCED_PROP(float4, _Splat0_ST)
|
|
UNITY_DEFINE_INSTANCED_PROP(float4, _Splat1_ST)
|
|
UNITY_DEFINE_INSTANCED_PROP(float4, _Splat2_ST)
|
|
UNITY_DEFINE_INSTANCED_PROP(float4, _Splat3_ST)
|
|
UNITY_DEFINE_INSTANCED_PROP(float4, _TerrainHolesTexture_ST)
|
|
UNITY_INSTANCING_BUFFER_END(TerrainAmplifyFirstPass)
|
|
|
|
|
|
#ifdef DEBUG_DISPLAY
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
|
|
#endif
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/NormalSurfaceGradient.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
|
|
// Setup DECALS_OFF so the shader stripper can remove variants
|
|
#define HAVE_DECALS ( (defined(DECALS_3RT) || defined(DECALS_4RT)) && !defined(_DISABLE_DECALS) )
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitDecalData.hlsl"
|
|
|
|
#define ASE_NEEDS_VERT_NORMAL
|
|
#define ASE_NEEDS_VERT_POSITION
|
|
#pragma multi_compile_instancing
|
|
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap forwardadd
|
|
#pragma multi_compile_local __ _ALPHATEST_ON
|
|
#pragma shader_feature_local _MASKMAP
|
|
|
|
|
|
#if defined(_DOUBLESIDED_ON) && !defined(ASE_NEED_CULLFACE)
|
|
#define ASE_NEED_CULLFACE 1
|
|
#endif
|
|
|
|
struct AttributesMesh
|
|
{
|
|
float3 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
float4 tangentOS : TANGENT;
|
|
float4 uv1 : TEXCOORD1;
|
|
float4 uv2 : TEXCOORD2;
|
|
float4 ase_texcoord : TEXCOORD0;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct PackedVaryingsMeshToPS
|
|
{
|
|
SV_POSITION_QUALIFIERS float4 positionCS : SV_Position;
|
|
float3 positionRWS : TEXCOORD0;
|
|
float3 normalWS : TEXCOORD1;
|
|
float4 tangentWS : TEXCOORD2;
|
|
float4 uv1 : TEXCOORD3;
|
|
float4 uv2 : TEXCOORD4;
|
|
float4 ase_texcoord5 : TEXCOORD5;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
#if defined(SHADER_STAGE_FRAGMENT) && defined(ASE_NEED_CULLFACE)
|
|
FRONT_FACE_TYPE cullFace : FRONT_FACE_SEMANTIC;
|
|
#endif
|
|
};
|
|
|
|
|
|
inline float noise_randomValue (float2 uv) { return frac(sin(dot(uv, float2(12.9898, 78.233)))*43758.5453); }
|
|
inline float noise_interpolate (float a, float b, float t) { return (1.0-t)*a + (t*b); }
|
|
inline float valueNoise (float2 uv)
|
|
{
|
|
float2 i = floor(uv);
|
|
float2 f = frac( uv );
|
|
f = f* f * (3.0 - 2.0 * f);
|
|
uv = abs( frac(uv) - 0.5);
|
|
float2 c0 = i + float2( 0.0, 0.0 );
|
|
float2 c1 = i + float2( 1.0, 0.0 );
|
|
float2 c2 = i + float2( 0.0, 1.0 );
|
|
float2 c3 = i + float2( 1.0, 1.0 );
|
|
float r0 = noise_randomValue( c0 );
|
|
float r1 = noise_randomValue( c1 );
|
|
float r2 = noise_randomValue( c2 );
|
|
float r3 = noise_randomValue( c3 );
|
|
float bottomOfGrid = noise_interpolate( r0, r1, f.x );
|
|
float topOfGrid = noise_interpolate( r2, r3, f.x );
|
|
float t = noise_interpolate( bottomOfGrid, topOfGrid, f.y );
|
|
return t;
|
|
}
|
|
|
|
float SimpleNoise(float2 UV)
|
|
{
|
|
float t = 0.0;
|
|
float freq = pow( 2.0, float( 0 ) );
|
|
float amp = pow( 0.5, float( 3 - 0 ) );
|
|
t += valueNoise( UV/freq )*amp;
|
|
freq = pow(2.0, float(1));
|
|
amp = pow(0.5, float(3-1));
|
|
t += valueNoise( UV/freq )*amp;
|
|
freq = pow(2.0, float(2));
|
|
amp = pow(0.5, float(3-2));
|
|
t += valueNoise( UV/freq )*amp;
|
|
return t;
|
|
}
|
|
|
|
AttributesMesh ApplyMeshModification( AttributesMesh inputMesh )
|
|
{
|
|
#ifdef UNITY_INSTANCING_ENABLED
|
|
float2 patchVertex = inputMesh.positionOS.xy;
|
|
float4 instanceData = UNITY_ACCESS_INSTANCED_PROP( Terrain, _TerrainPatchInstanceData );
|
|
float2 sampleCoords = ( patchVertex.xy + instanceData.xy ) * instanceData.z;
|
|
float height = UnpackHeightmap( _TerrainHeightmapTexture.Load( int3( sampleCoords, 0 ) ) );
|
|
inputMesh.positionOS.xz = sampleCoords* _TerrainHeightmapScale.xz;
|
|
inputMesh.positionOS.y = height* _TerrainHeightmapScale.y;
|
|
#ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL
|
|
inputMesh.normalOS = float3(0, 1, 0);
|
|
#else
|
|
inputMesh.normalOS = _TerrainNormalmapTexture.Load(int3(sampleCoords, 0)).rgb* 2 - 1;
|
|
#endif
|
|
inputMesh.ase_texcoord.xy = sampleCoords* _TerrainHeightmapRecipSize.zw;
|
|
#endif
|
|
return inputMesh;
|
|
}
|
|
|
|
|
|
void BuildSurfaceData(FragInputs fragInputs, inout GlobalSurfaceDescription surfaceDescription, float3 V, PositionInputs posInput, out SurfaceData surfaceData, out float3 bentNormalWS)
|
|
{
|
|
ZERO_INITIALIZE(SurfaceData, surfaceData);
|
|
|
|
surfaceData.specularOcclusion = 1.0;
|
|
|
|
// surface data
|
|
surfaceData.baseColor = surfaceDescription.BaseColor;
|
|
surfaceData.perceptualSmoothness = surfaceDescription.Smoothness;
|
|
surfaceData.ambientOcclusion = surfaceDescription.Occlusion;
|
|
surfaceData.metallic = surfaceDescription.Metallic;
|
|
surfaceData.coatMask = surfaceDescription.CoatMask;
|
|
|
|
#ifdef _SPECULAR_OCCLUSION_CUSTOM
|
|
surfaceData.specularOcclusion = surfaceDescription.SpecularOcclusion;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
|
|
surfaceData.subsurfaceMask = surfaceDescription.SubsurfaceMask;
|
|
#endif
|
|
#if defined(_HAS_REFRACTION) || defined(_MATERIAL_FEATURE_TRANSMISSION)
|
|
surfaceData.thickness = surfaceDescription.Thickness;
|
|
#endif
|
|
#if defined( _MATERIAL_FEATURE_SUBSURFACE_SCATTERING ) || defined( _MATERIAL_FEATURE_TRANSMISSION )
|
|
surfaceData.diffusionProfileHash = asuint(surfaceDescription.DiffusionProfile);
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_SPECULAR_COLOR
|
|
surfaceData.specularColor = surfaceDescription.Specular;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_ANISOTROPY
|
|
surfaceData.anisotropy = surfaceDescription.Anisotropy;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_IRIDESCENCE
|
|
surfaceData.iridescenceMask = surfaceDescription.IridescenceMask;
|
|
surfaceData.iridescenceThickness = surfaceDescription.IridescenceThickness;
|
|
#endif
|
|
|
|
// refraction
|
|
#ifdef _HAS_REFRACTION
|
|
if( _EnableSSRefraction )
|
|
{
|
|
surfaceData.ior = surfaceDescription.RefractionIndex;
|
|
surfaceData.transmittanceColor = surfaceDescription.RefractionColor;
|
|
surfaceData.atDistance = surfaceDescription.RefractionDistance;
|
|
|
|
surfaceData.transmittanceMask = ( 1.0 - surfaceDescription.Alpha );
|
|
surfaceDescription.Alpha = 1.0;
|
|
}
|
|
else
|
|
{
|
|
surfaceData.ior = 1.0;
|
|
surfaceData.transmittanceColor = float3( 1.0, 1.0, 1.0 );
|
|
surfaceData.atDistance = 1.0;
|
|
surfaceData.transmittanceMask = 0.0;
|
|
surfaceDescription.Alpha = 1.0;
|
|
}
|
|
#else
|
|
surfaceData.ior = 1.0;
|
|
surfaceData.transmittanceColor = float3( 1.0, 1.0, 1.0 );
|
|
surfaceData.atDistance = 1.0;
|
|
surfaceData.transmittanceMask = 0.0;
|
|
#endif
|
|
|
|
|
|
// material features
|
|
surfaceData.materialFeatures = MATERIALFEATUREFLAGS_LIT_STANDARD;
|
|
#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SUBSURFACE_SCATTERING;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_TRANSMISSION
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_TRANSMISSION;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_ANISOTROPY
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_ANISOTROPY;
|
|
surfaceData.normalWS = float3(0, 1, 0);
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_CLEAR_COAT
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_CLEAR_COAT;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_IRIDESCENCE
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_IRIDESCENCE;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_SPECULAR_COLOR
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SPECULAR_COLOR;
|
|
#endif
|
|
|
|
// others
|
|
#if defined (_MATERIAL_FEATURE_SPECULAR_COLOR) && defined (_ENERGY_CONSERVING_SPECULAR)
|
|
surfaceData.baseColor *= ( 1.0 - Max3( surfaceData.specularColor.r, surfaceData.specularColor.g, surfaceData.specularColor.b ) );
|
|
#endif
|
|
|
|
#ifdef _DOUBLESIDED_ON
|
|
float3 doubleSidedConstants = _DoubleSidedConstants.xyz;
|
|
#else
|
|
float3 doubleSidedConstants = float3( 1.0, 1.0, 1.0 );
|
|
#endif
|
|
|
|
// normals
|
|
float3 normalTS = float3(0.0f, 0.0f, 1.0f);
|
|
normalTS = surfaceDescription.Normal;
|
|
GetNormalWS( fragInputs, normalTS, surfaceData.normalWS, doubleSidedConstants );
|
|
|
|
surfaceData.geomNormalWS = fragInputs.tangentToWorld[2];
|
|
surfaceData.tangentWS = normalize( fragInputs.tangentToWorld[ 0 ].xyz );
|
|
|
|
// decals
|
|
#if HAVE_DECALS
|
|
if( _EnableDecals )
|
|
{
|
|
DecalSurfaceData decalSurfaceData = GetDecalSurfaceData(posInput, fragInputs, surfaceDescription.Alpha);
|
|
ApplyDecalToSurfaceData(decalSurfaceData, fragInputs.tangentToWorld[2], surfaceData);
|
|
}
|
|
#endif
|
|
|
|
bentNormalWS = surfaceData.normalWS;
|
|
|
|
#ifdef ASE_BENT_NORMAL
|
|
GetNormalWS( fragInputs, surfaceDescription.BentNormal, bentNormalWS, doubleSidedConstants );
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_ANISOTROPY
|
|
surfaceData.tangentWS = TransformTangentToWorld( surfaceDescription.Tangent, fragInputs.tangentToWorld );
|
|
#endif
|
|
surfaceData.tangentWS = Orthonormalize( surfaceData.tangentWS, surfaceData.normalWS );
|
|
|
|
#if defined(_SPECULAR_OCCLUSION_CUSTOM)
|
|
#elif defined(_SPECULAR_OCCLUSION_FROM_AO_BENT_NORMAL)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromBentAO(V, bentNormalWS, surfaceData.normalWS, surfaceData.ambientOcclusion, PerceptualSmoothnessToPerceptualRoughness(surfaceData.perceptualSmoothness));
|
|
#elif defined(_AMBIENT_OCCLUSION) && defined(_SPECULAR_OCCLUSION_FROM_AO)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromAmbientOcclusion(ClampNdotV(dot(surfaceData.normalWS, V)), surfaceData.ambientOcclusion, PerceptualSmoothnessToRoughness(surfaceData.perceptualSmoothness));
|
|
#endif
|
|
|
|
#ifdef _ENABLE_GEOMETRIC_SPECULAR_AA
|
|
surfaceData.perceptualSmoothness = GeometricNormalFiltering( surfaceData.perceptualSmoothness, fragInputs.tangentToWorld[ 2 ], surfaceDescription.SpecularAAScreenSpaceVariance, surfaceDescription.SpecularAAThreshold );
|
|
#endif
|
|
|
|
#if defined(DEBUG_DISPLAY)
|
|
if (_DebugMipMapMode != DEBUGMIPMAPMODE_NONE)
|
|
{
|
|
surfaceData.metallic = 0;
|
|
}
|
|
ApplyDebugToSurfaceData(fragInputs.tangentToWorld, surfaceData);
|
|
#endif
|
|
}
|
|
|
|
void GetSurfaceAndBuiltinData(GlobalSurfaceDescription surfaceDescription, FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
|
|
{
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
LODDitheringTransition(ComputeFadeMaskSeed(V, posInput.positionSS), unity_LODFade.x);
|
|
#endif
|
|
|
|
#ifdef _DOUBLESIDED_ON
|
|
float3 doubleSidedConstants = _DoubleSidedConstants.xyz;
|
|
#else
|
|
float3 doubleSidedConstants = float3( 1.0, 1.0, 1.0 );
|
|
#endif
|
|
|
|
ApplyDoubleSidedFlipOrMirror( fragInputs, doubleSidedConstants );
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
DoAlphaTest( surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold );
|
|
#endif
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
ApplyDepthOffsetPositionInput( V, surfaceDescription.DepthOffset, GetViewForwardDir(), GetWorldToHClipMatrix(), posInput );
|
|
#endif
|
|
|
|
float3 bentNormalWS;
|
|
BuildSurfaceData( fragInputs, surfaceDescription, V, posInput, surfaceData, bentNormalWS );
|
|
|
|
InitBuiltinData( posInput, surfaceDescription.Alpha, bentNormalWS, -fragInputs.tangentToWorld[ 2 ], fragInputs.texCoord1, fragInputs.texCoord2, builtinData );
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
builtinData.depthOffset = surfaceDescription.DepthOffset;
|
|
#endif
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
builtinData.alphaClipTreshold = surfaceDescription.AlphaClipThreshold;
|
|
#endif
|
|
|
|
#ifdef UNITY_VIRTUAL_TEXTURING
|
|
builtinData.vtPackedFeedback = surfaceDescription.VTPackedFeedback;
|
|
#endif
|
|
|
|
#ifdef ASE_BAKEDGI
|
|
builtinData.bakeDiffuseLighting = surfaceDescription.BakedGI;
|
|
#endif
|
|
|
|
#ifdef ASE_BAKEDBACKGI
|
|
builtinData.backBakeDiffuseLighting = surfaceDescription.BakedBackGI;
|
|
#endif
|
|
|
|
builtinData.emissiveColor = surfaceDescription.Emission;
|
|
|
|
PostInitBuiltinData(V, posInput, surfaceData, builtinData);
|
|
}
|
|
|
|
PackedVaryingsMeshToPS VertexFunction(AttributesMesh inputMesh )
|
|
{
|
|
PackedVaryingsMeshToPS outputPackedVaryingsMeshToPS;
|
|
|
|
UNITY_SETUP_INSTANCE_ID(inputMesh);
|
|
UNITY_TRANSFER_INSTANCE_ID(inputMesh, outputPackedVaryingsMeshToPS);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( outputPackedVaryingsMeshToPS );
|
|
|
|
inputMesh = ApplyMeshModification(inputMesh);
|
|
outputPackedVaryingsMeshToPS.ase_texcoord5.xy = inputMesh.ase_texcoord.xy;
|
|
|
|
//setting value to unused interpolator channels and avoid initialization warnings
|
|
outputPackedVaryingsMeshToPS.ase_texcoord5.zw = 0;
|
|
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = inputMesh.positionOS.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3( 0, 0, 0 );
|
|
#endif
|
|
float3 vertexValue = defaultVertexValue ;
|
|
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
inputMesh.positionOS.xyz = vertexValue;
|
|
#else
|
|
inputMesh.positionOS.xyz += vertexValue;
|
|
#endif
|
|
|
|
inputMesh.normalOS = inputMesh.normalOS ;
|
|
inputMesh.tangentOS = inputMesh.tangentOS ;
|
|
|
|
float3 positionRWS = TransformObjectToWorld(inputMesh.positionOS);
|
|
float3 normalWS = TransformObjectToWorldNormal(inputMesh.normalOS);
|
|
float4 tangentWS = float4(TransformObjectToWorldDir(inputMesh.tangentOS.xyz), inputMesh.tangentOS.w);
|
|
|
|
outputPackedVaryingsMeshToPS.positionCS = TransformWorldToHClip(positionRWS);
|
|
outputPackedVaryingsMeshToPS.positionRWS.xyz = positionRWS;
|
|
outputPackedVaryingsMeshToPS.normalWS.xyz = normalWS;
|
|
outputPackedVaryingsMeshToPS.tangentWS.xyzw = tangentWS;
|
|
outputPackedVaryingsMeshToPS.uv1.xyzw = inputMesh.uv1;
|
|
outputPackedVaryingsMeshToPS.uv2.xyzw = inputMesh.uv2;
|
|
return outputPackedVaryingsMeshToPS;
|
|
}
|
|
|
|
#if defined(ASE_TESSELLATION)
|
|
struct VertexControl
|
|
{
|
|
float3 positionOS : INTERNALTESSPOS;
|
|
float3 normalOS : NORMAL;
|
|
float4 tangentOS : TANGENT;
|
|
float4 uv1 : TEXCOORD1;
|
|
float4 uv2 : TEXCOORD2;
|
|
float4 ase_texcoord : TEXCOORD0;
|
|
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct TessellationFactors
|
|
{
|
|
float edge[3] : SV_TessFactor;
|
|
float inside : SV_InsideTessFactor;
|
|
};
|
|
|
|
VertexControl Vert ( AttributesMesh v )
|
|
{
|
|
VertexControl o;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
o.positionOS = v.positionOS;
|
|
o.normalOS = v.normalOS;
|
|
o.tangentOS = v.tangentOS;
|
|
o.uv1 = v.uv1;
|
|
o.uv2 = v.uv2;
|
|
o.ase_texcoord = v.ase_texcoord;
|
|
return o;
|
|
}
|
|
|
|
TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
|
|
{
|
|
TessellationFactors o;
|
|
float4 tf = 1;
|
|
float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
|
|
float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
|
|
#if (SHADEROPTIONS_CAMERA_RELATIVE_RENDERING != 0)
|
|
float3 cameraPos = 0;
|
|
#else
|
|
float3 cameraPos = _WorldSpaceCameraPos;
|
|
#endif
|
|
#if defined(ASE_FIXED_TESSELLATION)
|
|
tf = FixedTess( tessValue );
|
|
#elif defined(ASE_DISTANCE_TESSELLATION)
|
|
tf = DistanceBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), cameraPos );
|
|
#elif defined(ASE_LENGTH_TESSELLATION)
|
|
tf = EdgeLengthBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, GetObjectToWorldMatrix(), cameraPos, _ScreenParams );
|
|
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
|
tf = EdgeLengthBasedTessCull(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), cameraPos, _ScreenParams, _FrustumPlanes );
|
|
#endif
|
|
o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
|
|
return o;
|
|
}
|
|
|
|
[domain("tri")]
|
|
[partitioning("fractional_odd")]
|
|
[outputtopology("triangle_cw")]
|
|
[patchconstantfunc("TessellationFunction")]
|
|
[outputcontrolpoints(3)]
|
|
VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
|
|
{
|
|
return patch[id];
|
|
}
|
|
|
|
[domain("tri")]
|
|
PackedVaryingsMeshToPS DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
|
{
|
|
AttributesMesh o = (AttributesMesh) 0;
|
|
o.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
|
|
o.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
|
|
o.tangentOS = patch[0].tangentOS * bary.x + patch[1].tangentOS * bary.y + patch[2].tangentOS * bary.z;
|
|
o.uv1 = patch[0].uv1 * bary.x + patch[1].uv1 * bary.y + patch[2].uv1 * bary.z;
|
|
o.uv2 = patch[0].uv2 * bary.x + patch[1].uv2 * bary.y + patch[2].uv2 * bary.z;
|
|
o.ase_texcoord = patch[0].ase_texcoord * bary.x + patch[1].ase_texcoord * bary.y + patch[2].ase_texcoord * bary.z;
|
|
#if defined(ASE_PHONG_TESSELLATION)
|
|
float3 pp[3];
|
|
for (int i = 0; i < 3; ++i)
|
|
pp[i] = o.positionOS.xyz - patch[i].normalOS * (dot(o.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
|
|
float phongStrength = _TessPhongStrength;
|
|
o.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.positionOS.xyz;
|
|
#endif
|
|
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
|
return VertexFunction(o);
|
|
}
|
|
#else
|
|
PackedVaryingsMeshToPS Vert ( AttributesMesh v )
|
|
{
|
|
return VertexFunction( v );
|
|
}
|
|
#endif
|
|
|
|
void Frag( PackedVaryingsMeshToPS packedInput,
|
|
OUTPUT_GBUFFER(outGBuffer)
|
|
#ifdef _DEPTHOFFSET_ON
|
|
, out float outputDepth : DEPTH_OFFSET_SEMANTIC
|
|
#endif
|
|
|
|
)
|
|
{
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( packedInput );
|
|
UNITY_SETUP_INSTANCE_ID( packedInput );
|
|
FragInputs input;
|
|
ZERO_INITIALIZE(FragInputs, input);
|
|
input.tangentToWorld = k_identity3x3;
|
|
float3 positionRWS = packedInput.positionRWS.xyz;
|
|
float3 normalWS = packedInput.normalWS.xyz;
|
|
float4 tangentWS = packedInput.tangentWS.xyzw;
|
|
|
|
input.positionSS = packedInput.positionCS;
|
|
input.positionRWS = positionRWS;
|
|
input.tangentToWorld = BuildTangentToWorld(tangentWS, normalWS);
|
|
input.texCoord1 = packedInput.uv1.xyzw;
|
|
input.texCoord2 = packedInput.uv2.xyzw;
|
|
|
|
#if _DOUBLESIDED_ON && SHADER_STAGE_FRAGMENT
|
|
input.isFrontFace = IS_FRONT_VFACE( packedInput.cullFace, true, false);
|
|
#elif SHADER_STAGE_FRAGMENT
|
|
#if defined(ASE_NEED_CULLFACE)
|
|
input.isFrontFace = IS_FRONT_VFACE( packedInput.cullFace, true, false );
|
|
#endif
|
|
#endif
|
|
half isFrontFace = input.isFrontFace;
|
|
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS);
|
|
float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS);
|
|
SurfaceData surfaceData;
|
|
BuiltinData builtinData;
|
|
|
|
GlobalSurfaceDescription surfaceDescription = (GlobalSurfaceDescription)0;
|
|
float4 _Control_ST_Instance = UNITY_ACCESS_INSTANCED_PROP(TerrainAmplifyFirstPass,_Control_ST);
|
|
float2 uv_Control = packedInput.ase_texcoord5.xy * _Control_ST_Instance.xy + _Control_ST_Instance.zw;
|
|
float4 tex2DNode5_g4 = tex2D( _Control, uv_Control );
|
|
float dotResult20_g4 = dot( tex2DNode5_g4 , float4(1,1,1,1) );
|
|
float SplatWeight22_g4 = dotResult20_g4;
|
|
float localSplatClip74_g4 = ( SplatWeight22_g4 );
|
|
float SplatWeight74_g4 = SplatWeight22_g4;
|
|
{
|
|
#if !defined(SHADER_API_MOBILE) && defined(TERRAIN_SPLAT_ADDPASS)
|
|
clip(SplatWeight74_g4 == 0.0f ? -1 : 1);
|
|
#endif
|
|
}
|
|
float4 SplatControl26_g4 = ( tex2DNode5_g4 / ( localSplatClip74_g4 + 0.001 ) );
|
|
float4 temp_output_59_0_g4 = SplatControl26_g4;
|
|
float4 appendResult33_g4 = (float4(1.0 , 1.0 , 1.0 , _Smoothness0));
|
|
float4 _Splat0_ST_Instance = UNITY_ACCESS_INSTANCED_PROP(TerrainAmplifyFirstPass,_Splat0_ST);
|
|
float2 uv_Splat0 = packedInput.ase_texcoord5.xy * _Splat0_ST_Instance.xy + _Splat0_ST_Instance.zw;
|
|
float4 tex2DNode4_g4 = tex2D( _Splat0, uv_Splat0 );
|
|
float3 _Vector1 = float3(1,1,1);
|
|
float4 appendResult258_g4 = (float4(_Vector1 , 1.0));
|
|
float4 tintLayer0253_g4 = appendResult258_g4;
|
|
float4 appendResult36_g4 = (float4(1.0 , 1.0 , 1.0 , _Smoothness1));
|
|
float4 _Splat1_ST_Instance = UNITY_ACCESS_INSTANCED_PROP(TerrainAmplifyFirstPass,_Splat1_ST);
|
|
float2 uv_Splat1 = packedInput.ase_texcoord5.xy * _Splat1_ST_Instance.xy + _Splat1_ST_Instance.zw;
|
|
float4 tex2DNode3_g4 = tex2D( _Splat1, uv_Splat1 );
|
|
float3 _Vector2 = float3(1,1,1);
|
|
float4 appendResult261_g4 = (float4(_Vector2 , 1.0));
|
|
float4 tintLayer1254_g4 = appendResult261_g4;
|
|
float4 appendResult39_g4 = (float4(1.0 , 1.0 , 1.0 , _Smoothness2));
|
|
float4 _Splat2_ST_Instance = UNITY_ACCESS_INSTANCED_PROP(TerrainAmplifyFirstPass,_Splat2_ST);
|
|
float2 uv_Splat2 = packedInput.ase_texcoord5.xy * _Splat2_ST_Instance.xy + _Splat2_ST_Instance.zw;
|
|
float4 tex2DNode6_g4 = tex2D( _Splat2, uv_Splat2 );
|
|
float3 _Vector3 = float3(1,1,1);
|
|
float4 appendResult263_g4 = (float4(_Vector3 , 1.0));
|
|
float4 tintLayer2255_g4 = appendResult263_g4;
|
|
float4 appendResult42_g4 = (float4(1.0 , 1.0 , 1.0 , _Smoothness3));
|
|
float4 _Splat3_ST_Instance = UNITY_ACCESS_INSTANCED_PROP(TerrainAmplifyFirstPass,_Splat3_ST);
|
|
float2 uv_Splat3 = packedInput.ase_texcoord5.xy * _Splat3_ST_Instance.xy + _Splat3_ST_Instance.zw;
|
|
float4 tex2DNode7_g4 = tex2D( _Splat3, uv_Splat3 );
|
|
float3 _Vector4 = float3(1,1,1);
|
|
float4 appendResult265_g4 = (float4(_Vector4 , 1.0));
|
|
float4 tintLayer3256_g4 = appendResult265_g4;
|
|
float4 weightedBlendVar9_g4 = temp_output_59_0_g4;
|
|
float4 weightedBlend9_g4 = ( weightedBlendVar9_g4.x*( appendResult33_g4 * tex2DNode4_g4 * tintLayer0253_g4 ) + weightedBlendVar9_g4.y*( appendResult36_g4 * tex2DNode3_g4 * tintLayer1254_g4 ) + weightedBlendVar9_g4.z*( appendResult39_g4 * tex2DNode6_g4 * tintLayer2255_g4 ) + weightedBlendVar9_g4.w*( appendResult42_g4 * tex2DNode7_g4 * tintLayer3256_g4 ) );
|
|
float4 MixDiffuse28_g4 = weightedBlend9_g4;
|
|
float4 temp_output_60_0_g4 = MixDiffuse28_g4;
|
|
float4 localClipHoles100_g4 = ( temp_output_60_0_g4 );
|
|
float4 _TerrainHolesTexture_ST_Instance = UNITY_ACCESS_INSTANCED_PROP(TerrainAmplifyFirstPass,_TerrainHolesTexture_ST);
|
|
float2 uv_TerrainHolesTexture = packedInput.ase_texcoord5.xy * _TerrainHolesTexture_ST_Instance.xy + _TerrainHolesTexture_ST_Instance.zw;
|
|
float holeClipValue99_g4 = tex2D( _TerrainHolesTexture, uv_TerrainHolesTexture ).r;
|
|
float Hole100_g4 = holeClipValue99_g4;
|
|
{
|
|
#ifdef _ALPHATEST_ON
|
|
clip(Hole100_g4 == 0.0f ? -1 : 1);
|
|
#endif
|
|
}
|
|
|
|
float4 weightedBlendVar8_g4 = temp_output_59_0_g4;
|
|
float4 weightedBlend8_g4 = ( weightedBlendVar8_g4.x*tex2D( _Normal0, uv_Splat0 ) + weightedBlendVar8_g4.y*tex2D( _Normal1, uv_Splat1 ) + weightedBlendVar8_g4.z*tex2D( _Normal2, uv_Splat2 ) + weightedBlendVar8_g4.w*tex2D( _Normal3, uv_Splat3 ) );
|
|
float3 temp_output_61_0_g4 = UnpackNormalScale( weightedBlend8_g4, 1.0 );
|
|
float2 temp_cast_8 = (( _TimeParameters.x * _WaterFlowSpeed )).xx;
|
|
float2 texCoord76 = packedInput.ase_texcoord5.xy * _Normal1Tilling + temp_cast_8;
|
|
float3 unpack59 = UnpackNormalScale( tex2D( _WaterFlowNormal, texCoord76 ), _NormalMapStrength );
|
|
unpack59.z = lerp( 1, unpack59.z, saturate(_NormalMapStrength) );
|
|
float2 temp_cast_9 = (( _TimeParameters.x * _WaterFlowSpeed1 )).xx;
|
|
float2 texCoord77 = packedInput.ase_texcoord5.xy * _Normal2Tilling + temp_cast_9;
|
|
float3 unpack66 = UnpackNormalScale( tex2D( _WaterFlowNormal1, texCoord77 ), _NormalMapStrength );
|
|
unpack66.z = lerp( 1, unpack66.z, saturate(_NormalMapStrength) );
|
|
float2 texCoord43 = packedInput.ase_texcoord5.xy * _RainReflections1 + float2( 0,0 );
|
|
float simpleNoise42 = SimpleNoise( texCoord43*_RainScale );
|
|
float smoothstepResult48 = smoothstep( 0.38 , 1.0 , simpleNoise42);
|
|
float2 texCoord117 = packedInput.ase_texcoord5.xy * _RippleTextureCoordinatesTilling + float2( 0,0 );
|
|
float2 break135_g5 = texCoord117;
|
|
float2 appendResult136_g5 = (float2(break135_g5.x , ( 1.0 - break135_g5.y )));
|
|
float2 FlipBookUV141_g5 = appendResult136_g5;
|
|
float FlipBookColumns143_g5 = 4.0;
|
|
float FlipBookRows144_g5 = 4.0;
|
|
float2 appendResult83_g5 = (float2(FlipBookColumns143_g5 , FlipBookRows144_g5));
|
|
float temp_output_104_0_g5 = ( FlipBookColumns143_g5 * FlipBookRows144_g5 );
|
|
float2 appendResult95_g5 = (float2(temp_output_104_0_g5 , FlipBookRows144_g5));
|
|
float mulTime99 = _TimeParameters.x * _RippleFPS;
|
|
float FlipBookSpeed145_g5 = ( _TimeParameters.x * mulTime99 );
|
|
float FlipBookID142_g5 = 0.0;
|
|
float clampResult108_g5 = clamp( FlipBookID142_g5 , 0.0001 , ( temp_output_104_0_g5 - 1.0 ) );
|
|
float temp_output_92_0_g5 = frac( ( ( FlipBookSpeed145_g5 + clampResult108_g5 ) / temp_output_104_0_g5 ) );
|
|
float2 appendResult93_g5 = (float2(temp_output_92_0_g5 , ( temp_output_92_0_g5 - -0.01 )));
|
|
float2 break105_g5 = ( ( FlipBookUV141_g5 / appendResult83_g5 ) + ( floor( ( appendResult95_g5 * appendResult93_g5 ) ) / appendResult83_g5 ) );
|
|
float2 appendResult139_g5 = (float2(break105_g5.x , ( 1.0 - break105_g5.y )));
|
|
float3 unpack98 = UnpackNormalScale( tex2D( _RippleNormal, appendResult139_g5 ), _RippleNormalStrength );
|
|
unpack98.z = lerp( 1, unpack98.z, saturate(_RippleNormalStrength) );
|
|
|
|
float2 texCoord80 = packedInput.ase_texcoord5.xy * _RainReflections + float2( 0,0 );
|
|
float simpleNoise82 = SimpleNoise( texCoord80*_RainScale );
|
|
float smoothstepResult81 = smoothstep( 0.38 , 1.0 , simpleNoise82);
|
|
|
|
surfaceDescription.BaseColor = localClipHoles100_g4.xyz;
|
|
surfaceDescription.Normal = ( ( temp_output_61_0_g4 + ( ( unpack59 + unpack66 ) * smoothstepResult48 ) ) + unpack98 );
|
|
surfaceDescription.BentNormal = float3( 0, 0, 1 );
|
|
surfaceDescription.CoatMask = 0;
|
|
surfaceDescription.Metallic = _Float10;
|
|
|
|
#ifdef _MATERIAL_FEATURE_SPECULAR_COLOR
|
|
surfaceDescription.Specular = 0;
|
|
#endif
|
|
|
|
surfaceDescription.Emission = 0;
|
|
surfaceDescription.Smoothness = ( 0.0 + ( ( smoothstepResult81 * _RainOpacity ) + _Smoothness ) );
|
|
surfaceDescription.Occlusion = 1;
|
|
surfaceDescription.Alpha = 1;
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
surfaceDescription.AlphaClipThreshold = _AlphaCutoff;
|
|
#endif
|
|
|
|
#ifdef _ALPHATEST_SHADOW_ON
|
|
surfaceDescription.AlphaClipThresholdShadow = 0.5;
|
|
#endif
|
|
|
|
surfaceDescription.AlphaClipThresholdDepthPrepass = 0.5;
|
|
surfaceDescription.AlphaClipThresholdDepthPostpass = 0.5;
|
|
|
|
#ifdef _ENABLE_GEOMETRIC_SPECULAR_AA
|
|
surfaceDescription.SpecularAAScreenSpaceVariance = 0;
|
|
surfaceDescription.SpecularAAThreshold = 0;
|
|
#endif
|
|
|
|
#ifdef _SPECULAR_OCCLUSION_CUSTOM
|
|
surfaceDescription.SpecularOcclusion = 0;
|
|
#endif
|
|
|
|
#if defined(_HAS_REFRACTION) || defined(_MATERIAL_FEATURE_TRANSMISSION)
|
|
surfaceDescription.Thickness = 0;
|
|
#endif
|
|
|
|
#ifdef _HAS_REFRACTION
|
|
surfaceDescription.RefractionIndex = 1;
|
|
surfaceDescription.RefractionColor = float3( 1, 1, 1 );
|
|
surfaceDescription.RefractionDistance = 0;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
|
|
surfaceDescription.SubsurfaceMask = 1;
|
|
#endif
|
|
|
|
#if defined( _MATERIAL_FEATURE_SUBSURFACE_SCATTERING ) || defined( _MATERIAL_FEATURE_TRANSMISSION )
|
|
surfaceDescription.DiffusionProfile = 0;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_ANISOTROPY
|
|
surfaceDescription.Anisotropy = 1;
|
|
surfaceDescription.Tangent = float3( 1, 0, 0 );
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_IRIDESCENCE
|
|
surfaceDescription.IridescenceMask = 0;
|
|
surfaceDescription.IridescenceThickness = 0;
|
|
#endif
|
|
|
|
#ifdef ASE_BAKEDGI
|
|
surfaceDescription.BakedGI = 0;
|
|
#endif
|
|
#ifdef ASE_BAKEDBACKGI
|
|
surfaceDescription.BakedBackGI = 0;
|
|
#endif
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
surfaceDescription.DepthOffset = 0;
|
|
#endif
|
|
|
|
#ifdef UNITY_VIRTUAL_TEXTURING
|
|
surfaceDescription.VTPackedFeedback = float4(1.0f,1.0f,1.0f,1.0f);
|
|
#endif
|
|
|
|
GetSurfaceAndBuiltinData( surfaceDescription, input, V, posInput, surfaceData, builtinData );
|
|
ENCODE_INTO_GBUFFER( surfaceData, builtinData, posInput.positionSS, outGBuffer );
|
|
#ifdef _DEPTHOFFSET_ON
|
|
outputDepth = posInput.deviceDepth;
|
|
#endif
|
|
}
|
|
|
|
ENDHLSL
|
|
}
|
|
|
|
UsePass "Hidden/Nature/Terrain/Utilities/PICKING"
|
|
UsePass "Hidden/Nature/Terrain/Utilities/SELECTION"
|
|
|
|
Pass
|
|
{
|
|
|
|
Name "META"
|
|
Tags { "LightMode"="Meta" }
|
|
|
|
Cull Off
|
|
|
|
HLSLPROGRAM
|
|
|
|
#define _SPECULAR_OCCLUSION_FROM_AO 1
|
|
#pragma instancing_options renderinglayer
|
|
#define shader_feature_local _DISABLE_DECALS
|
|
#define shader_feature_local_raytracing _DISABLE_SSR
|
|
#define shader_feature_local_fragment _DISABLE_SSR
|
|
#define ASE_SRP_VERSION 170003
|
|
|
|
|
|
#pragma shader_feature _SURFACE_TYPE_TRANSPARENT
|
|
#pragma shader_feature_local _TRANSPARENT_WRITES_MOTION_VEC
|
|
#pragma shader_feature_local_fragment _ENABLE_FOG_ON_TRANSPARENT
|
|
|
|
#pragma shader_feature EDITOR_VISUALIZATION
|
|
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/GeometricTools.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Tessellation.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
|
|
#include "Packages/com.unity.shadergraph/ShaderGraphLibrary/Functions.hlsl"
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
|
|
#define SHADERPASS SHADERPASS_LIGHT_TRANSPORT
|
|
|
|
#ifndef SHADER_UNLIT
|
|
#if defined(_DOUBLESIDED_ON) && !defined(VARYINGS_NEED_CULLFACE)
|
|
#define VARYINGS_NEED_CULLFACE
|
|
#endif
|
|
#endif
|
|
|
|
#if defined(_MATERIAL_FEATURE_SUBSURFACE_SCATTERING) && !defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define OUTPUT_SPLIT_LIGHTING
|
|
#endif
|
|
|
|
#if SHADERPASS == SHADERPASS_TRANSPARENT_DEPTH_PREPASS
|
|
#if !defined(_DISABLE_SSR_TRANSPARENT) && !defined(SHADER_UNLIT)
|
|
#define WRITE_NORMAL_BUFFER
|
|
#endif
|
|
#endif
|
|
|
|
#ifndef DEBUG_DISPLAY
|
|
#if !defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#if SHADERPASS == SHADERPASS_FORWARD
|
|
#define SHADERPASS_FORWARD_BYPASS_ALPHA_TEST
|
|
#elif SHADERPASS == SHADERPASS_GBUFFER
|
|
#define SHADERPASS_GBUFFER_BYPASS_ALPHA_TEST
|
|
#endif
|
|
#endif
|
|
#endif
|
|
|
|
#if defined(SHADER_LIT) && !defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define _DEFERRED_CAPABLE_MATERIAL
|
|
#endif
|
|
|
|
#if defined(_TRANSPARENT_WRITES_MOTION_VEC) && defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define _WRITE_TRANSPARENT_MOTION_VECTOR
|
|
#endif
|
|
|
|
CBUFFER_START( UnityPerMaterial )
|
|
float2 _RainReflections;
|
|
float2 _Normal1Tilling;
|
|
float2 _RippleTextureCoordinatesTilling;
|
|
float2 _Normal2Tilling;
|
|
float2 _RainReflections1;
|
|
float _Smoothness0;
|
|
float _Float10;
|
|
float _RippleNormalStrength;
|
|
float _RippleFPS;
|
|
float _RainScale;
|
|
float _WaterFlowSpeed1;
|
|
float _NormalMapStrength;
|
|
float _WaterFlowSpeed;
|
|
float _Smoothness3;
|
|
float _Smoothness2;
|
|
float _Smoothness1;
|
|
float _RainOpacity;
|
|
float _Smoothness;
|
|
float4 _EmissionColor;
|
|
float _AlphaCutoff;
|
|
float _RenderQueueType;
|
|
#ifdef _ADD_PRECOMPUTED_VELOCITY
|
|
float _AddPrecomputedVelocity;
|
|
#endif
|
|
float _StencilRef;
|
|
float _StencilWriteMask;
|
|
float _StencilRefDepth;
|
|
float _StencilWriteMaskDepth;
|
|
float _StencilRefMV;
|
|
float _StencilWriteMaskMV;
|
|
float _StencilWriteMaskGBuffer;
|
|
float _StencilRefGBuffer;
|
|
float _ZTestGBuffer;
|
|
float _RequireSplitLighting;
|
|
float _ReceivesSSR;
|
|
float _SurfaceType;
|
|
float _BlendMode;
|
|
#ifdef SUPPORT_BLENDMODE_PRESERVE_SPECULAR_LIGHTING
|
|
float _EnableBlendModePreserveSpecularLighting;
|
|
#endif
|
|
float _SrcBlend;
|
|
float _DstBlend;
|
|
float _AlphaSrcBlend;
|
|
float _AlphaDstBlend;
|
|
float _ZWrite;
|
|
float _TransparentZWrite;
|
|
float _CullMode;
|
|
float _TransparentSortPriority;
|
|
float _EnableFogOnTransparent;
|
|
float _CullModeForward;
|
|
float _TransparentCullMode;
|
|
float _ZTestDepthEqualForOpaque;
|
|
float _ZTestTransparent;
|
|
float _TransparentBackfaceEnable;
|
|
float _AlphaCutoffEnable;
|
|
float _UseShadowThreshold;
|
|
float _DoubleSidedEnable;
|
|
float _DoubleSidedNormalMode;
|
|
float4 _DoubleSidedConstants;
|
|
#ifdef ASE_TESSELLATION
|
|
float _TessPhongStrength;
|
|
float _TessValue;
|
|
float _TessMin;
|
|
float _TessMax;
|
|
float _TessEdgeLength;
|
|
float _TessMaxDisp;
|
|
#endif
|
|
CBUFFER_END
|
|
|
|
// Property used by ScenePickingPass
|
|
#ifdef SCENEPICKINGPASS
|
|
float4 _SelectionID;
|
|
#endif
|
|
|
|
// Properties used by SceneSelectionPass
|
|
#ifdef SCENESELECTIONPASS
|
|
int _ObjectId;
|
|
int _PassValue;
|
|
#endif
|
|
|
|
sampler2D _Mask2;
|
|
sampler2D _Mask0;
|
|
sampler2D _Mask1;
|
|
sampler2D _Mask3;
|
|
float4 _MaskMapRemapScale0;
|
|
float4 _MaskMapRemapOffset2;
|
|
float4 _MaskMapRemapScale2;
|
|
float4 _MaskMapRemapScale1;
|
|
float4 _MaskMapRemapOffset1;
|
|
float4 _MaskMapRemapScale3;
|
|
float4 _MaskMapRemapOffset3;
|
|
float4 _MaskMapRemapOffset0;
|
|
sampler2D _Control;
|
|
sampler2D _Splat0;
|
|
sampler2D _Splat1;
|
|
sampler2D _Splat2;
|
|
sampler2D _Splat3;
|
|
sampler2D _TerrainHolesTexture;
|
|
sampler2D _Normal0;
|
|
sampler2D _Normal1;
|
|
sampler2D _Normal2;
|
|
sampler2D _Normal3;
|
|
sampler2D _WaterFlowNormal;
|
|
sampler2D _WaterFlowNormal1;
|
|
sampler2D _RippleNormal;
|
|
#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing
|
|
TEXTURE2D(_TerrainHeightmapTexture);//ASE Terrain Instancing
|
|
TEXTURE2D( _TerrainNormalmapTexture);//ASE Terrain Instancing
|
|
SAMPLER(sampler_TerrainNormalmapTexture);//ASE Terrain Instancing
|
|
#endif//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_START( Terrain )//ASE Terrain Instancing
|
|
UNITY_DEFINE_INSTANCED_PROP( float4, _TerrainPatchInstanceData )//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_END( Terrain)//ASE Terrain Instancing
|
|
CBUFFER_START( UnityTerrain)//ASE Terrain Instancing
|
|
#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing
|
|
float4 _TerrainHeightmapRecipSize;//ASE Terrain Instancing
|
|
float4 _TerrainHeightmapScale;//ASE Terrain Instancing
|
|
#endif//ASE Terrain Instancing
|
|
CBUFFER_END//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_START(TerrainAmplifyFirstPass)
|
|
UNITY_DEFINE_INSTANCED_PROP(float4, _Control_ST)
|
|
UNITY_DEFINE_INSTANCED_PROP(float4, _Splat0_ST)
|
|
UNITY_DEFINE_INSTANCED_PROP(float4, _Splat1_ST)
|
|
UNITY_DEFINE_INSTANCED_PROP(float4, _Splat2_ST)
|
|
UNITY_DEFINE_INSTANCED_PROP(float4, _Splat3_ST)
|
|
UNITY_DEFINE_INSTANCED_PROP(float4, _TerrainHolesTexture_ST)
|
|
UNITY_INSTANCING_BUFFER_END(TerrainAmplifyFirstPass)
|
|
|
|
|
|
#ifdef DEBUG_DISPLAY
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
|
|
#endif
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/NormalSurfaceGradient.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
|
|
// Setup DECALS_OFF so the shader stripper can remove variants
|
|
#define HAVE_DECALS ( (defined(DECALS_3RT) || defined(DECALS_4RT)) && !defined(_DISABLE_DECALS) )
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitDecalData.hlsl"
|
|
|
|
#define ASE_NEEDS_VERT_NORMAL
|
|
#define ASE_NEEDS_VERT_POSITION
|
|
#pragma multi_compile_instancing
|
|
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap forwardadd
|
|
#pragma multi_compile_local __ _ALPHATEST_ON
|
|
#pragma shader_feature_local _MASKMAP
|
|
|
|
|
|
#if defined(_DOUBLESIDED_ON) && !defined(ASE_NEED_CULLFACE)
|
|
#define ASE_NEED_CULLFACE 1
|
|
#endif
|
|
|
|
struct AttributesMesh
|
|
{
|
|
float3 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
float4 tangentOS : TANGENT;
|
|
float4 uv0 : TEXCOORD0;
|
|
float4 uv1 : TEXCOORD1;
|
|
float4 uv2 : TEXCOORD2;
|
|
float4 uv3 : TEXCOORD3;
|
|
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct PackedVaryingsMeshToPS
|
|
{
|
|
SV_POSITION_QUALIFIERS float4 positionCS : SV_Position;
|
|
#ifdef EDITOR_VISUALIZATION
|
|
float2 VizUV : TEXCOORD0;
|
|
float4 LightCoord : TEXCOORD1;
|
|
#endif
|
|
float4 ase_texcoord2 : TEXCOORD2;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
#if defined(SHADER_STAGE_FRAGMENT) && defined(ASE_NEED_CULLFACE)
|
|
FRONT_FACE_TYPE cullFace : FRONT_FACE_SEMANTIC;
|
|
#endif
|
|
};
|
|
|
|
inline float noise_randomValue (float2 uv) { return frac(sin(dot(uv, float2(12.9898, 78.233)))*43758.5453); }
|
|
inline float noise_interpolate (float a, float b, float t) { return (1.0-t)*a + (t*b); }
|
|
inline float valueNoise (float2 uv)
|
|
{
|
|
float2 i = floor(uv);
|
|
float2 f = frac( uv );
|
|
f = f* f * (3.0 - 2.0 * f);
|
|
uv = abs( frac(uv) - 0.5);
|
|
float2 c0 = i + float2( 0.0, 0.0 );
|
|
float2 c1 = i + float2( 1.0, 0.0 );
|
|
float2 c2 = i + float2( 0.0, 1.0 );
|
|
float2 c3 = i + float2( 1.0, 1.0 );
|
|
float r0 = noise_randomValue( c0 );
|
|
float r1 = noise_randomValue( c1 );
|
|
float r2 = noise_randomValue( c2 );
|
|
float r3 = noise_randomValue( c3 );
|
|
float bottomOfGrid = noise_interpolate( r0, r1, f.x );
|
|
float topOfGrid = noise_interpolate( r2, r3, f.x );
|
|
float t = noise_interpolate( bottomOfGrid, topOfGrid, f.y );
|
|
return t;
|
|
}
|
|
|
|
float SimpleNoise(float2 UV)
|
|
{
|
|
float t = 0.0;
|
|
float freq = pow( 2.0, float( 0 ) );
|
|
float amp = pow( 0.5, float( 3 - 0 ) );
|
|
t += valueNoise( UV/freq )*amp;
|
|
freq = pow(2.0, float(1));
|
|
amp = pow(0.5, float(3-1));
|
|
t += valueNoise( UV/freq )*amp;
|
|
freq = pow(2.0, float(2));
|
|
amp = pow(0.5, float(3-2));
|
|
t += valueNoise( UV/freq )*amp;
|
|
return t;
|
|
}
|
|
|
|
AttributesMesh ApplyMeshModification( AttributesMesh inputMesh )
|
|
{
|
|
#ifdef UNITY_INSTANCING_ENABLED
|
|
float2 patchVertex = inputMesh.positionOS.xy;
|
|
float4 instanceData = UNITY_ACCESS_INSTANCED_PROP( Terrain, _TerrainPatchInstanceData );
|
|
float2 sampleCoords = ( patchVertex.xy + instanceData.xy ) * instanceData.z;
|
|
float height = UnpackHeightmap( _TerrainHeightmapTexture.Load( int3( sampleCoords, 0 ) ) );
|
|
inputMesh.positionOS.xz = sampleCoords* _TerrainHeightmapScale.xz;
|
|
inputMesh.positionOS.y = height* _TerrainHeightmapScale.y;
|
|
#ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL
|
|
inputMesh.normalOS = float3(0, 1, 0);
|
|
#else
|
|
inputMesh.normalOS = _TerrainNormalmapTexture.Load(int3(sampleCoords, 0)).rgb* 2 - 1;
|
|
#endif
|
|
inputMesh.uv0.xy = sampleCoords* _TerrainHeightmapRecipSize.zw;
|
|
#endif
|
|
return inputMesh;
|
|
}
|
|
|
|
|
|
void BuildSurfaceData(FragInputs fragInputs, inout GlobalSurfaceDescription surfaceDescription, float3 V, PositionInputs posInput, out SurfaceData surfaceData, out float3 bentNormalWS)
|
|
{
|
|
ZERO_INITIALIZE(SurfaceData, surfaceData);
|
|
|
|
surfaceData.specularOcclusion = 1.0;
|
|
|
|
// surface data
|
|
surfaceData.baseColor = surfaceDescription.BaseColor;
|
|
surfaceData.perceptualSmoothness = surfaceDescription.Smoothness;
|
|
surfaceData.ambientOcclusion = surfaceDescription.Occlusion;
|
|
surfaceData.metallic = surfaceDescription.Metallic;
|
|
surfaceData.coatMask = surfaceDescription.CoatMask;
|
|
|
|
#ifdef _SPECULAR_OCCLUSION_CUSTOM
|
|
surfaceData.specularOcclusion = surfaceDescription.SpecularOcclusion;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
|
|
surfaceData.subsurfaceMask = surfaceDescription.SubsurfaceMask;
|
|
#endif
|
|
#if defined(_HAS_REFRACTION) || defined(_MATERIAL_FEATURE_TRANSMISSION)
|
|
surfaceData.thickness = surfaceDescription.Thickness;
|
|
#endif
|
|
#if defined( _MATERIAL_FEATURE_SUBSURFACE_SCATTERING ) || defined( _MATERIAL_FEATURE_TRANSMISSION )
|
|
surfaceData.diffusionProfileHash = asuint(surfaceDescription.DiffusionProfile);
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_SPECULAR_COLOR
|
|
surfaceData.specularColor = surfaceDescription.Specular;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_ANISOTROPY
|
|
surfaceData.anisotropy = surfaceDescription.Anisotropy;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_IRIDESCENCE
|
|
surfaceData.iridescenceMask = surfaceDescription.IridescenceMask;
|
|
surfaceData.iridescenceThickness = surfaceDescription.IridescenceThickness;
|
|
#endif
|
|
|
|
// refraction
|
|
#ifdef _HAS_REFRACTION
|
|
if( _EnableSSRefraction )
|
|
{
|
|
surfaceData.ior = surfaceDescription.RefractionIndex;
|
|
surfaceData.transmittanceColor = surfaceDescription.RefractionColor;
|
|
surfaceData.atDistance = surfaceDescription.RefractionDistance;
|
|
|
|
surfaceData.transmittanceMask = ( 1.0 - surfaceDescription.Alpha );
|
|
surfaceDescription.Alpha = 1.0;
|
|
}
|
|
else
|
|
{
|
|
surfaceData.ior = 1.0;
|
|
surfaceData.transmittanceColor = float3( 1.0, 1.0, 1.0 );
|
|
surfaceData.atDistance = 1.0;
|
|
surfaceData.transmittanceMask = 0.0;
|
|
surfaceDescription.Alpha = 1.0;
|
|
}
|
|
#else
|
|
surfaceData.ior = 1.0;
|
|
surfaceData.transmittanceColor = float3( 1.0, 1.0, 1.0 );
|
|
surfaceData.atDistance = 1.0;
|
|
surfaceData.transmittanceMask = 0.0;
|
|
#endif
|
|
|
|
// material features
|
|
surfaceData.materialFeatures = MATERIALFEATUREFLAGS_LIT_STANDARD;
|
|
#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SUBSURFACE_SCATTERING;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_TRANSMISSION
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_TRANSMISSION;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_ANISOTROPY
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_ANISOTROPY;
|
|
surfaceData.normalWS = float3(0, 1, 0);
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_CLEAR_COAT
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_CLEAR_COAT;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_IRIDESCENCE
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_IRIDESCENCE;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_SPECULAR_COLOR
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SPECULAR_COLOR;
|
|
#endif
|
|
|
|
// others
|
|
#if defined (_MATERIAL_FEATURE_SPECULAR_COLOR) && defined (_ENERGY_CONSERVING_SPECULAR)
|
|
surfaceData.baseColor *= ( 1.0 - Max3( surfaceData.specularColor.r, surfaceData.specularColor.g, surfaceData.specularColor.b ) );
|
|
#endif
|
|
#ifdef _DOUBLESIDED_ON
|
|
float3 doubleSidedConstants = _DoubleSidedConstants.xyz;
|
|
#else
|
|
float3 doubleSidedConstants = float3( 1.0, 1.0, 1.0 );
|
|
#endif
|
|
|
|
// normals
|
|
float3 normalTS = float3(0.0f, 0.0f, 1.0f);
|
|
normalTS = surfaceDescription.Normal;
|
|
GetNormalWS( fragInputs, normalTS, surfaceData.normalWS, doubleSidedConstants );
|
|
|
|
surfaceData.geomNormalWS = fragInputs.tangentToWorld[2];
|
|
surfaceData.tangentWS = normalize( fragInputs.tangentToWorld[ 0 ].xyz );
|
|
|
|
// decals
|
|
#if HAVE_DECALS
|
|
if( _EnableDecals )
|
|
{
|
|
DecalSurfaceData decalSurfaceData = GetDecalSurfaceData(posInput, fragInputs, surfaceDescription.Alpha);
|
|
ApplyDecalToSurfaceData(decalSurfaceData, fragInputs.tangentToWorld[2], surfaceData);
|
|
}
|
|
#endif
|
|
|
|
bentNormalWS = surfaceData.normalWS;
|
|
|
|
#ifdef ASE_BENT_NORMAL
|
|
GetNormalWS( fragInputs, surfaceDescription.BentNormal, bentNormalWS, doubleSidedConstants );
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_ANISOTROPY
|
|
surfaceData.tangentWS = TransformTangentToWorld( surfaceDescription.Tangent, fragInputs.tangentToWorld );
|
|
#endif
|
|
surfaceData.tangentWS = Orthonormalize( surfaceData.tangentWS, surfaceData.normalWS );
|
|
|
|
#if defined(_SPECULAR_OCCLUSION_CUSTOM)
|
|
#elif defined(_SPECULAR_OCCLUSION_FROM_AO_BENT_NORMAL)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromBentAO(V, bentNormalWS, surfaceData.normalWS, surfaceData.ambientOcclusion, PerceptualSmoothnessToPerceptualRoughness(surfaceData.perceptualSmoothness));
|
|
#elif defined(_AMBIENT_OCCLUSION) && defined(_SPECULAR_OCCLUSION_FROM_AO)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromAmbientOcclusion(ClampNdotV(dot(surfaceData.normalWS, V)), surfaceData.ambientOcclusion, PerceptualSmoothnessToRoughness(surfaceData.perceptualSmoothness));
|
|
#endif
|
|
|
|
#ifdef _ENABLE_GEOMETRIC_SPECULAR_AA
|
|
surfaceData.perceptualSmoothness = GeometricNormalFiltering( surfaceData.perceptualSmoothness, fragInputs.tangentToWorld[ 2 ], surfaceDescription.SpecularAAScreenSpaceVariance, surfaceDescription.SpecularAAThreshold );
|
|
#endif
|
|
|
|
// debug
|
|
#if defined(DEBUG_DISPLAY)
|
|
if (_DebugMipMapMode != DEBUGMIPMAPMODE_NONE)
|
|
{
|
|
surfaceData.metallic = 0;
|
|
}
|
|
ApplyDebugToSurfaceData(fragInputs.tangentToWorld, surfaceData);
|
|
#endif
|
|
}
|
|
|
|
void GetSurfaceAndBuiltinData(GlobalSurfaceDescription surfaceDescription, FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
|
|
{
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
LODDitheringTransition(ComputeFadeMaskSeed(V, posInput.positionSS), unity_LODFade.x);
|
|
#endif
|
|
|
|
#ifdef _DOUBLESIDED_ON
|
|
float3 doubleSidedConstants = _DoubleSidedConstants.xyz;
|
|
#else
|
|
float3 doubleSidedConstants = float3( 1.0, 1.0, 1.0 );
|
|
#endif
|
|
|
|
ApplyDoubleSidedFlipOrMirror( fragInputs, doubleSidedConstants );
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
DoAlphaTest( surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold );
|
|
#endif
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
builtinData.depthOffset = surfaceDescription.DepthOffset;
|
|
ApplyDepthOffsetPositionInput( V, surfaceDescription.DepthOffset, GetViewForwardDir(), GetWorldToHClipMatrix(), posInput );
|
|
#endif
|
|
|
|
float3 bentNormalWS;
|
|
BuildSurfaceData( fragInputs, surfaceDescription, V, posInput, surfaceData, bentNormalWS );
|
|
|
|
InitBuiltinData( posInput, surfaceDescription.Alpha, bentNormalWS, -fragInputs.tangentToWorld[ 2 ], fragInputs.texCoord1, fragInputs.texCoord2, builtinData );
|
|
|
|
builtinData.emissiveColor = surfaceDescription.Emission;
|
|
|
|
PostInitBuiltinData(V, posInput, surfaceData, builtinData);
|
|
}
|
|
|
|
#if SHADERPASS == SHADERPASS_LIGHT_TRANSPORT
|
|
#define SCENEPICKINGPASS
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/PickingSpaceTransforms.hlsl"
|
|
#endif
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/MetaPass.hlsl"
|
|
|
|
PackedVaryingsMeshToPS VertexFunction(AttributesMesh inputMesh )
|
|
{
|
|
PackedVaryingsMeshToPS outputPackedVaryingsMeshToPS;
|
|
|
|
UNITY_SETUP_INSTANCE_ID(inputMesh);
|
|
UNITY_TRANSFER_INSTANCE_ID(inputMesh, outputPackedVaryingsMeshToPS);
|
|
|
|
inputMesh = ApplyMeshModification(inputMesh);
|
|
outputPackedVaryingsMeshToPS.ase_texcoord2.xy = inputMesh.uv0.xy;
|
|
|
|
//setting value to unused interpolator channels and avoid initialization warnings
|
|
outputPackedVaryingsMeshToPS.ase_texcoord2.zw = 0;
|
|
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = inputMesh.positionOS.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3( 0, 0, 0 );
|
|
#endif
|
|
float3 vertexValue = defaultVertexValue ;
|
|
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
inputMesh.positionOS.xyz = vertexValue;
|
|
#else
|
|
inputMesh.positionOS.xyz += vertexValue;
|
|
#endif
|
|
|
|
inputMesh.normalOS = inputMesh.normalOS ;
|
|
inputMesh.tangentOS = inputMesh.tangentOS ;
|
|
|
|
outputPackedVaryingsMeshToPS.positionCS = UnityMetaVertexPosition(inputMesh.positionOS, inputMesh.uv1.xy, inputMesh.uv2.xy, unity_LightmapST, unity_DynamicLightmapST);
|
|
|
|
|
|
#ifdef EDITOR_VISUALIZATION
|
|
float2 vizUV = 0;
|
|
float4 lightCoord = 0;
|
|
UnityEditorVizData(inputMesh.positionOS.xyz, inputMesh.uv0.xy, inputMesh.uv1.xy, inputMesh.uv2.xy, vizUV, lightCoord);
|
|
|
|
outputPackedVaryingsMeshToPS.VizUV.xy = vizUV;
|
|
outputPackedVaryingsMeshToPS.LightCoord = lightCoord;
|
|
#endif
|
|
|
|
return outputPackedVaryingsMeshToPS;
|
|
}
|
|
|
|
#if defined(ASE_TESSELLATION)
|
|
struct VertexControl
|
|
{
|
|
float3 positionOS : INTERNALTESSPOS;
|
|
float3 normalOS : NORMAL;
|
|
float4 tangentOS : TANGENT;
|
|
float4 uv0 : TEXCOORD0;
|
|
float4 uv1 : TEXCOORD1;
|
|
float4 uv2 : TEXCOORD2;
|
|
float4 uv3 : TEXCOORD3;
|
|
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct TessellationFactors
|
|
{
|
|
float edge[3] : SV_TessFactor;
|
|
float inside : SV_InsideTessFactor;
|
|
};
|
|
|
|
VertexControl Vert ( AttributesMesh v )
|
|
{
|
|
VertexControl o;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
o.positionOS = v.positionOS;
|
|
o.normalOS = v.normalOS;
|
|
o.tangentOS = v.tangentOS;
|
|
o.uv0 = v.uv0;
|
|
o.uv1 = v.uv1;
|
|
o.uv2 = v.uv2;
|
|
o.uv3 = v.uv3;
|
|
|
|
return o;
|
|
}
|
|
|
|
TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
|
|
{
|
|
TessellationFactors o;
|
|
float4 tf = 1;
|
|
float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
|
|
float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
|
|
#if (SHADEROPTIONS_CAMERA_RELATIVE_RENDERING != 0)
|
|
float3 cameraPos = 0;
|
|
#else
|
|
float3 cameraPos = _WorldSpaceCameraPos;
|
|
#endif
|
|
#if defined(ASE_FIXED_TESSELLATION)
|
|
tf = FixedTess( tessValue );
|
|
#elif defined(ASE_DISTANCE_TESSELLATION)
|
|
tf = DistanceBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), cameraPos );
|
|
#elif defined(ASE_LENGTH_TESSELLATION)
|
|
tf = EdgeLengthBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, GetObjectToWorldMatrix(), cameraPos, _ScreenParams );
|
|
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
|
tf = EdgeLengthBasedTessCull(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), cameraPos, _ScreenParams, _FrustumPlanes );
|
|
#endif
|
|
o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
|
|
return o;
|
|
}
|
|
|
|
[domain("tri")]
|
|
[partitioning("fractional_odd")]
|
|
[outputtopology("triangle_cw")]
|
|
[patchconstantfunc("TessellationFunction")]
|
|
[outputcontrolpoints(3)]
|
|
VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
|
|
{
|
|
return patch[id];
|
|
}
|
|
|
|
[domain("tri")]
|
|
PackedVaryingsMeshToPS DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
|
{
|
|
AttributesMesh o = (AttributesMesh) 0;
|
|
o.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
|
|
o.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
|
|
o.tangentOS = patch[0].tangentOS * bary.x + patch[1].tangentOS * bary.y + patch[2].tangentOS * bary.z;
|
|
o.uv0 = patch[0].uv0 * bary.x + patch[1].uv0 * bary.y + patch[2].uv0 * bary.z;
|
|
o.uv1 = patch[0].uv1 * bary.x + patch[1].uv1 * bary.y + patch[2].uv1 * bary.z;
|
|
o.uv2 = patch[0].uv2 * bary.x + patch[1].uv2 * bary.y + patch[2].uv2 * bary.z;
|
|
o.uv3 = patch[0].uv3 * bary.x + patch[1].uv3 * bary.y + patch[2].uv3 * bary.z;
|
|
|
|
#if defined(ASE_PHONG_TESSELLATION)
|
|
float3 pp[3];
|
|
for (int i = 0; i < 3; ++i)
|
|
pp[i] = o.positionOS.xyz - patch[i].normalOS * (dot(o.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
|
|
float phongStrength = _TessPhongStrength;
|
|
o.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.positionOS.xyz;
|
|
#endif
|
|
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
|
return VertexFunction(o);
|
|
}
|
|
#else
|
|
PackedVaryingsMeshToPS Vert ( AttributesMesh v )
|
|
{
|
|
return VertexFunction( v );
|
|
}
|
|
#endif
|
|
|
|
float4 Frag(PackedVaryingsMeshToPS packedInput ) : SV_Target
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID( packedInput );
|
|
FragInputs input;
|
|
ZERO_INITIALIZE(FragInputs, input);
|
|
input.tangentToWorld = k_identity3x3;
|
|
input.positionSS = packedInput.positionCS;
|
|
|
|
#if _DOUBLESIDED_ON && SHADER_STAGE_FRAGMENT
|
|
input.isFrontFace = IS_FRONT_VFACE( packedInput.cullFace, true, false);
|
|
#elif SHADER_STAGE_FRAGMENT
|
|
#if defined(ASE_NEED_CULLFACE)
|
|
input.isFrontFace = IS_FRONT_VFACE(packedInput.cullFace, true, false);
|
|
#endif
|
|
#endif
|
|
half isFrontFace = input.isFrontFace;
|
|
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS);
|
|
float3 V = float3(1.0, 1.0, 1.0);
|
|
|
|
SurfaceData surfaceData;
|
|
BuiltinData builtinData;
|
|
GlobalSurfaceDescription surfaceDescription = (GlobalSurfaceDescription)0;
|
|
float4 _Control_ST_Instance = UNITY_ACCESS_INSTANCED_PROP(TerrainAmplifyFirstPass,_Control_ST);
|
|
float2 uv_Control = packedInput.ase_texcoord2.xy * _Control_ST_Instance.xy + _Control_ST_Instance.zw;
|
|
float4 tex2DNode5_g4 = tex2D( _Control, uv_Control );
|
|
float dotResult20_g4 = dot( tex2DNode5_g4 , float4(1,1,1,1) );
|
|
float SplatWeight22_g4 = dotResult20_g4;
|
|
float localSplatClip74_g4 = ( SplatWeight22_g4 );
|
|
float SplatWeight74_g4 = SplatWeight22_g4;
|
|
{
|
|
#if !defined(SHADER_API_MOBILE) && defined(TERRAIN_SPLAT_ADDPASS)
|
|
clip(SplatWeight74_g4 == 0.0f ? -1 : 1);
|
|
#endif
|
|
}
|
|
float4 SplatControl26_g4 = ( tex2DNode5_g4 / ( localSplatClip74_g4 + 0.001 ) );
|
|
float4 temp_output_59_0_g4 = SplatControl26_g4;
|
|
float4 appendResult33_g4 = (float4(1.0 , 1.0 , 1.0 , _Smoothness0));
|
|
float4 _Splat0_ST_Instance = UNITY_ACCESS_INSTANCED_PROP(TerrainAmplifyFirstPass,_Splat0_ST);
|
|
float2 uv_Splat0 = packedInput.ase_texcoord2.xy * _Splat0_ST_Instance.xy + _Splat0_ST_Instance.zw;
|
|
float4 tex2DNode4_g4 = tex2D( _Splat0, uv_Splat0 );
|
|
float3 _Vector1 = float3(1,1,1);
|
|
float4 appendResult258_g4 = (float4(_Vector1 , 1.0));
|
|
float4 tintLayer0253_g4 = appendResult258_g4;
|
|
float4 appendResult36_g4 = (float4(1.0 , 1.0 , 1.0 , _Smoothness1));
|
|
float4 _Splat1_ST_Instance = UNITY_ACCESS_INSTANCED_PROP(TerrainAmplifyFirstPass,_Splat1_ST);
|
|
float2 uv_Splat1 = packedInput.ase_texcoord2.xy * _Splat1_ST_Instance.xy + _Splat1_ST_Instance.zw;
|
|
float4 tex2DNode3_g4 = tex2D( _Splat1, uv_Splat1 );
|
|
float3 _Vector2 = float3(1,1,1);
|
|
float4 appendResult261_g4 = (float4(_Vector2 , 1.0));
|
|
float4 tintLayer1254_g4 = appendResult261_g4;
|
|
float4 appendResult39_g4 = (float4(1.0 , 1.0 , 1.0 , _Smoothness2));
|
|
float4 _Splat2_ST_Instance = UNITY_ACCESS_INSTANCED_PROP(TerrainAmplifyFirstPass,_Splat2_ST);
|
|
float2 uv_Splat2 = packedInput.ase_texcoord2.xy * _Splat2_ST_Instance.xy + _Splat2_ST_Instance.zw;
|
|
float4 tex2DNode6_g4 = tex2D( _Splat2, uv_Splat2 );
|
|
float3 _Vector3 = float3(1,1,1);
|
|
float4 appendResult263_g4 = (float4(_Vector3 , 1.0));
|
|
float4 tintLayer2255_g4 = appendResult263_g4;
|
|
float4 appendResult42_g4 = (float4(1.0 , 1.0 , 1.0 , _Smoothness3));
|
|
float4 _Splat3_ST_Instance = UNITY_ACCESS_INSTANCED_PROP(TerrainAmplifyFirstPass,_Splat3_ST);
|
|
float2 uv_Splat3 = packedInput.ase_texcoord2.xy * _Splat3_ST_Instance.xy + _Splat3_ST_Instance.zw;
|
|
float4 tex2DNode7_g4 = tex2D( _Splat3, uv_Splat3 );
|
|
float3 _Vector4 = float3(1,1,1);
|
|
float4 appendResult265_g4 = (float4(_Vector4 , 1.0));
|
|
float4 tintLayer3256_g4 = appendResult265_g4;
|
|
float4 weightedBlendVar9_g4 = temp_output_59_0_g4;
|
|
float4 weightedBlend9_g4 = ( weightedBlendVar9_g4.x*( appendResult33_g4 * tex2DNode4_g4 * tintLayer0253_g4 ) + weightedBlendVar9_g4.y*( appendResult36_g4 * tex2DNode3_g4 * tintLayer1254_g4 ) + weightedBlendVar9_g4.z*( appendResult39_g4 * tex2DNode6_g4 * tintLayer2255_g4 ) + weightedBlendVar9_g4.w*( appendResult42_g4 * tex2DNode7_g4 * tintLayer3256_g4 ) );
|
|
float4 MixDiffuse28_g4 = weightedBlend9_g4;
|
|
float4 temp_output_60_0_g4 = MixDiffuse28_g4;
|
|
float4 localClipHoles100_g4 = ( temp_output_60_0_g4 );
|
|
float4 _TerrainHolesTexture_ST_Instance = UNITY_ACCESS_INSTANCED_PROP(TerrainAmplifyFirstPass,_TerrainHolesTexture_ST);
|
|
float2 uv_TerrainHolesTexture = packedInput.ase_texcoord2.xy * _TerrainHolesTexture_ST_Instance.xy + _TerrainHolesTexture_ST_Instance.zw;
|
|
float holeClipValue99_g4 = tex2D( _TerrainHolesTexture, uv_TerrainHolesTexture ).r;
|
|
float Hole100_g4 = holeClipValue99_g4;
|
|
{
|
|
#ifdef _ALPHATEST_ON
|
|
clip(Hole100_g4 == 0.0f ? -1 : 1);
|
|
#endif
|
|
}
|
|
|
|
float4 weightedBlendVar8_g4 = temp_output_59_0_g4;
|
|
float4 weightedBlend8_g4 = ( weightedBlendVar8_g4.x*tex2D( _Normal0, uv_Splat0 ) + weightedBlendVar8_g4.y*tex2D( _Normal1, uv_Splat1 ) + weightedBlendVar8_g4.z*tex2D( _Normal2, uv_Splat2 ) + weightedBlendVar8_g4.w*tex2D( _Normal3, uv_Splat3 ) );
|
|
float3 temp_output_61_0_g4 = UnpackNormalScale( weightedBlend8_g4, 1.0 );
|
|
float2 temp_cast_8 = (( _TimeParameters.x * _WaterFlowSpeed )).xx;
|
|
float2 texCoord76 = packedInput.ase_texcoord2.xy * _Normal1Tilling + temp_cast_8;
|
|
float3 unpack59 = UnpackNormalScale( tex2D( _WaterFlowNormal, texCoord76 ), _NormalMapStrength );
|
|
unpack59.z = lerp( 1, unpack59.z, saturate(_NormalMapStrength) );
|
|
float2 temp_cast_9 = (( _TimeParameters.x * _WaterFlowSpeed1 )).xx;
|
|
float2 texCoord77 = packedInput.ase_texcoord2.xy * _Normal2Tilling + temp_cast_9;
|
|
float3 unpack66 = UnpackNormalScale( tex2D( _WaterFlowNormal1, texCoord77 ), _NormalMapStrength );
|
|
unpack66.z = lerp( 1, unpack66.z, saturate(_NormalMapStrength) );
|
|
float2 texCoord43 = packedInput.ase_texcoord2.xy * _RainReflections1 + float2( 0,0 );
|
|
float simpleNoise42 = SimpleNoise( texCoord43*_RainScale );
|
|
float smoothstepResult48 = smoothstep( 0.38 , 1.0 , simpleNoise42);
|
|
float2 texCoord117 = packedInput.ase_texcoord2.xy * _RippleTextureCoordinatesTilling + float2( 0,0 );
|
|
float2 break135_g5 = texCoord117;
|
|
float2 appendResult136_g5 = (float2(break135_g5.x , ( 1.0 - break135_g5.y )));
|
|
float2 FlipBookUV141_g5 = appendResult136_g5;
|
|
float FlipBookColumns143_g5 = 4.0;
|
|
float FlipBookRows144_g5 = 4.0;
|
|
float2 appendResult83_g5 = (float2(FlipBookColumns143_g5 , FlipBookRows144_g5));
|
|
float temp_output_104_0_g5 = ( FlipBookColumns143_g5 * FlipBookRows144_g5 );
|
|
float2 appendResult95_g5 = (float2(temp_output_104_0_g5 , FlipBookRows144_g5));
|
|
float mulTime99 = _TimeParameters.x * _RippleFPS;
|
|
float FlipBookSpeed145_g5 = ( _TimeParameters.x * mulTime99 );
|
|
float FlipBookID142_g5 = 0.0;
|
|
float clampResult108_g5 = clamp( FlipBookID142_g5 , 0.0001 , ( temp_output_104_0_g5 - 1.0 ) );
|
|
float temp_output_92_0_g5 = frac( ( ( FlipBookSpeed145_g5 + clampResult108_g5 ) / temp_output_104_0_g5 ) );
|
|
float2 appendResult93_g5 = (float2(temp_output_92_0_g5 , ( temp_output_92_0_g5 - -0.01 )));
|
|
float2 break105_g5 = ( ( FlipBookUV141_g5 / appendResult83_g5 ) + ( floor( ( appendResult95_g5 * appendResult93_g5 ) ) / appendResult83_g5 ) );
|
|
float2 appendResult139_g5 = (float2(break105_g5.x , ( 1.0 - break105_g5.y )));
|
|
float3 unpack98 = UnpackNormalScale( tex2D( _RippleNormal, appendResult139_g5 ), _RippleNormalStrength );
|
|
unpack98.z = lerp( 1, unpack98.z, saturate(_RippleNormalStrength) );
|
|
|
|
float2 texCoord80 = packedInput.ase_texcoord2.xy * _RainReflections + float2( 0,0 );
|
|
float simpleNoise82 = SimpleNoise( texCoord80*_RainScale );
|
|
float smoothstepResult81 = smoothstep( 0.38 , 1.0 , simpleNoise82);
|
|
|
|
surfaceDescription.BaseColor = localClipHoles100_g4.xyz;
|
|
surfaceDescription.Normal = ( ( temp_output_61_0_g4 + ( ( unpack59 + unpack66 ) * smoothstepResult48 ) ) + unpack98 );
|
|
surfaceDescription.BentNormal = float3( 0, 0, 1 );
|
|
surfaceDescription.CoatMask = 0;
|
|
surfaceDescription.Metallic = _Float10;
|
|
|
|
#ifdef _MATERIAL_FEATURE_SPECULAR_COLOR
|
|
surfaceDescription.Specular = 0;
|
|
#endif
|
|
|
|
surfaceDescription.Emission = 0;
|
|
surfaceDescription.Smoothness = ( 0.0 + ( ( smoothstepResult81 * _RainOpacity ) + _Smoothness ) );
|
|
surfaceDescription.Occlusion = 1;
|
|
surfaceDescription.Alpha = 1;
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
surfaceDescription.AlphaClipThreshold = _AlphaCutoff;
|
|
#endif
|
|
|
|
#ifdef _ENABLE_GEOMETRIC_SPECULAR_AA
|
|
surfaceDescription.SpecularAAScreenSpaceVariance = 0;
|
|
surfaceDescription.SpecularAAThreshold = 0;
|
|
#endif
|
|
|
|
#ifdef _SPECULAR_OCCLUSION_CUSTOM
|
|
surfaceDescription.SpecularOcclusion = 0;
|
|
#endif
|
|
|
|
#if defined(_HAS_REFRACTION) || defined(_MATERIAL_FEATURE_TRANSMISSION)
|
|
surfaceDescription.Thickness = 1;
|
|
#endif
|
|
|
|
#ifdef _HAS_REFRACTION
|
|
surfaceDescription.RefractionIndex = 1;
|
|
surfaceDescription.RefractionColor = float3( 1, 1, 1 );
|
|
surfaceDescription.RefractionDistance = 0;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
|
|
surfaceDescription.SubsurfaceMask = 1;
|
|
#endif
|
|
|
|
#if defined( _MATERIAL_FEATURE_SUBSURFACE_SCATTERING ) || defined( _MATERIAL_FEATURE_TRANSMISSION )
|
|
surfaceDescription.DiffusionProfile = 0;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_ANISOTROPY
|
|
surfaceDescription.Anisotropy = 1;
|
|
surfaceDescription.Tangent = float3( 1, 0, 0 );
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_IRIDESCENCE
|
|
surfaceDescription.IridescenceMask = 0;
|
|
surfaceDescription.IridescenceThickness = 0;
|
|
#endif
|
|
|
|
GetSurfaceAndBuiltinData(surfaceDescription,input, V, posInput, surfaceData, builtinData);
|
|
|
|
BSDFData bsdfData = ConvertSurfaceDataToBSDFData(input.positionSS.xy, surfaceData);
|
|
LightTransportData lightTransportData = GetLightTransportData(surfaceData, builtinData, bsdfData);
|
|
|
|
float4 res = float4( 0.0, 0.0, 0.0, 1.0 );
|
|
UnityMetaInput metaInput;
|
|
metaInput.Albedo = lightTransportData.diffuseColor.rgb;
|
|
metaInput.Emission = lightTransportData.emissiveColor;
|
|
|
|
#ifdef EDITOR_VISUALIZATION
|
|
metaInput.VizUV = packedInput.VizUV;
|
|
metaInput.LightCoord = packedInput.LightCoord;
|
|
#endif
|
|
res = UnityMetaFragment(metaInput);
|
|
|
|
return res;
|
|
}
|
|
|
|
ENDHLSL
|
|
}
|
|
|
|
UsePass "Hidden/Nature/Terrain/Utilities/PICKING"
|
|
UsePass "Hidden/Nature/Terrain/Utilities/SELECTION"
|
|
|
|
Pass
|
|
{
|
|
|
|
Name "ShadowCaster"
|
|
Tags { "LightMode"="ShadowCaster" }
|
|
|
|
Cull [_CullMode]
|
|
ZWrite On
|
|
ZClip [_ZClip]
|
|
ZTest LEqual
|
|
ColorMask 0
|
|
|
|
HLSLPROGRAM
|
|
|
|
#define _SPECULAR_OCCLUSION_FROM_AO 1
|
|
#pragma instancing_options renderinglayer
|
|
#define shader_feature_local _DISABLE_DECALS
|
|
#define shader_feature_local_raytracing _DISABLE_SSR
|
|
#define shader_feature_local_fragment _DISABLE_SSR
|
|
#define ASE_SRP_VERSION 170003
|
|
|
|
|
|
#pragma shader_feature _SURFACE_TYPE_TRANSPARENT
|
|
#pragma shader_feature_local _TRANSPARENT_WRITES_MOTION_VEC
|
|
#pragma shader_feature_local_fragment _ENABLE_FOG_ON_TRANSPARENT
|
|
|
|
#pragma multi_compile_fragment _ SHADOWS_SHADOWMASK
|
|
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/GeometricTools.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Tessellation.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
|
|
#include "Packages/com.unity.shadergraph/ShaderGraphLibrary/Functions.hlsl"
|
|
|
|
//#define USE_LEGACY_UNITY_MATRIX_VARIABLES
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
|
|
#define SHADERPASS SHADERPASS_SHADOWS
|
|
|
|
#ifndef SHADER_UNLIT
|
|
#if defined(_DOUBLESIDED_ON) && !defined(VARYINGS_NEED_CULLFACE)
|
|
#define VARYINGS_NEED_CULLFACE
|
|
#endif
|
|
#endif
|
|
|
|
#if defined(_MATERIAL_FEATURE_SUBSURFACE_SCATTERING) && !defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define OUTPUT_SPLIT_LIGHTING
|
|
#endif
|
|
|
|
#if (SHADERPASS == SHADERPASS_PATH_TRACING) && !defined(_DOUBLESIDED_ON) && (defined(_REFRACTION_PLANE) || defined(_REFRACTION_SPHERE))
|
|
#undef _REFRACTION_PLANE
|
|
#undef _REFRACTION_SPHERE
|
|
#define _REFRACTION_THIN
|
|
#endif
|
|
|
|
#if SHADERPASS == SHADERPASS_TRANSPARENT_DEPTH_PREPASS
|
|
#if !defined(_DISABLE_SSR_TRANSPARENT) && !defined(SHADER_UNLIT)
|
|
#define WRITE_NORMAL_BUFFER
|
|
#endif
|
|
#endif
|
|
|
|
#ifndef DEBUG_DISPLAY
|
|
#if !defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#if SHADERPASS == SHADERPASS_FORWARD
|
|
#define SHADERPASS_FORWARD_BYPASS_ALPHA_TEST
|
|
#elif SHADERPASS == SHADERPASS_GBUFFER
|
|
#define SHADERPASS_GBUFFER_BYPASS_ALPHA_TEST
|
|
#endif
|
|
#endif
|
|
#endif
|
|
|
|
#if defined(SHADER_LIT) && !defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define _DEFERRED_CAPABLE_MATERIAL
|
|
#endif
|
|
|
|
#if defined(_TRANSPARENT_WRITES_MOTION_VEC) && defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define _WRITE_TRANSPARENT_MOTION_VECTOR
|
|
#endif
|
|
|
|
CBUFFER_START( UnityPerMaterial )
|
|
float2 _RainReflections;
|
|
float2 _Normal1Tilling;
|
|
float2 _RippleTextureCoordinatesTilling;
|
|
float2 _Normal2Tilling;
|
|
float2 _RainReflections1;
|
|
float _Smoothness0;
|
|
float _Float10;
|
|
float _RippleNormalStrength;
|
|
float _RippleFPS;
|
|
float _RainScale;
|
|
float _WaterFlowSpeed1;
|
|
float _NormalMapStrength;
|
|
float _WaterFlowSpeed;
|
|
float _Smoothness3;
|
|
float _Smoothness2;
|
|
float _Smoothness1;
|
|
float _RainOpacity;
|
|
float _Smoothness;
|
|
float4 _EmissionColor;
|
|
float _AlphaCutoff;
|
|
float _RenderQueueType;
|
|
#ifdef _ADD_PRECOMPUTED_VELOCITY
|
|
float _AddPrecomputedVelocity;
|
|
#endif
|
|
float _StencilRef;
|
|
float _StencilWriteMask;
|
|
float _StencilRefDepth;
|
|
float _StencilWriteMaskDepth;
|
|
float _StencilRefMV;
|
|
float _StencilWriteMaskMV;
|
|
float _StencilWriteMaskGBuffer;
|
|
float _StencilRefGBuffer;
|
|
float _ZTestGBuffer;
|
|
float _RequireSplitLighting;
|
|
float _ReceivesSSR;
|
|
float _SurfaceType;
|
|
float _BlendMode;
|
|
#ifdef SUPPORT_BLENDMODE_PRESERVE_SPECULAR_LIGHTING
|
|
float _EnableBlendModePreserveSpecularLighting;
|
|
#endif
|
|
float _SrcBlend;
|
|
float _DstBlend;
|
|
float _AlphaSrcBlend;
|
|
float _AlphaDstBlend;
|
|
float _ZWrite;
|
|
float _TransparentZWrite;
|
|
float _CullMode;
|
|
float _TransparentSortPriority;
|
|
float _EnableFogOnTransparent;
|
|
float _CullModeForward;
|
|
float _TransparentCullMode;
|
|
float _ZTestDepthEqualForOpaque;
|
|
float _ZTestTransparent;
|
|
float _TransparentBackfaceEnable;
|
|
float _AlphaCutoffEnable;
|
|
float _UseShadowThreshold;
|
|
float _DoubleSidedEnable;
|
|
float _DoubleSidedNormalMode;
|
|
float4 _DoubleSidedConstants;
|
|
#ifdef ASE_TESSELLATION
|
|
float _TessPhongStrength;
|
|
float _TessValue;
|
|
float _TessMin;
|
|
float _TessMax;
|
|
float _TessEdgeLength;
|
|
float _TessMaxDisp;
|
|
#endif
|
|
CBUFFER_END
|
|
|
|
// Property used by ScenePickingPass
|
|
#ifdef SCENEPICKINGPASS
|
|
float4 _SelectionID;
|
|
#endif
|
|
|
|
// Properties used by SceneSelectionPass
|
|
#ifdef SCENESELECTIONPASS
|
|
int _ObjectId;
|
|
int _PassValue;
|
|
#endif
|
|
|
|
sampler2D _Mask2;
|
|
sampler2D _Mask0;
|
|
sampler2D _Mask1;
|
|
sampler2D _Mask3;
|
|
float4 _MaskMapRemapScale0;
|
|
float4 _MaskMapRemapOffset2;
|
|
float4 _MaskMapRemapScale2;
|
|
float4 _MaskMapRemapScale1;
|
|
float4 _MaskMapRemapOffset1;
|
|
float4 _MaskMapRemapScale3;
|
|
float4 _MaskMapRemapOffset3;
|
|
float4 _MaskMapRemapOffset0;
|
|
#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing
|
|
TEXTURE2D(_TerrainHeightmapTexture);//ASE Terrain Instancing
|
|
TEXTURE2D( _TerrainNormalmapTexture);//ASE Terrain Instancing
|
|
SAMPLER(sampler_TerrainNormalmapTexture);//ASE Terrain Instancing
|
|
#endif//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_START( Terrain )//ASE Terrain Instancing
|
|
UNITY_DEFINE_INSTANCED_PROP( float4, _TerrainPatchInstanceData )//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_END( Terrain)//ASE Terrain Instancing
|
|
CBUFFER_START( UnityTerrain)//ASE Terrain Instancing
|
|
#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing
|
|
float4 _TerrainHeightmapRecipSize;//ASE Terrain Instancing
|
|
float4 _TerrainHeightmapScale;//ASE Terrain Instancing
|
|
#endif//ASE Terrain Instancing
|
|
CBUFFER_END//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_START(TerrainAmplifyFirstPass)
|
|
UNITY_INSTANCING_BUFFER_END(TerrainAmplifyFirstPass)
|
|
|
|
|
|
#ifdef DEBUG_DISPLAY
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
|
|
#endif
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/NormalSurfaceGradient.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
|
|
// Setup DECALS_OFF so the shader stripper can remove variants
|
|
#define HAVE_DECALS ( (defined(DECALS_3RT) || defined(DECALS_4RT)) && !defined(_DISABLE_DECALS) )
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitDecalData.hlsl"
|
|
|
|
#define ASE_NEEDS_VERT_NORMAL
|
|
#define ASE_NEEDS_VERT_POSITION
|
|
#pragma multi_compile_instancing
|
|
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap forwardadd
|
|
#pragma multi_compile_local __ _ALPHATEST_ON
|
|
#pragma shader_feature_local _MASKMAP
|
|
|
|
|
|
#if defined(_DOUBLESIDED_ON) && !defined(ASE_NEED_CULLFACE)
|
|
#define ASE_NEED_CULLFACE 1
|
|
#endif
|
|
|
|
struct AttributesMesh
|
|
{
|
|
float3 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
float4 ase_texcoord : TEXCOORD0;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct PackedVaryingsMeshToPS
|
|
{
|
|
SV_POSITION_QUALIFIERS float4 positionCS : SV_Position;
|
|
float3 positionRWS : TEXCOORD0;
|
|
float4 ase_texcoord1 : TEXCOORD1;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
#if defined(SHADER_STAGE_FRAGMENT) && defined(ASE_NEED_CULLFACE)
|
|
FRONT_FACE_TYPE cullFace : FRONT_FACE_SEMANTIC;
|
|
#endif
|
|
};
|
|
|
|
AttributesMesh ApplyMeshModification( AttributesMesh inputMesh )
|
|
{
|
|
#ifdef UNITY_INSTANCING_ENABLED
|
|
float2 patchVertex = inputMesh.positionOS.xy;
|
|
float4 instanceData = UNITY_ACCESS_INSTANCED_PROP( Terrain, _TerrainPatchInstanceData );
|
|
float2 sampleCoords = ( patchVertex.xy + instanceData.xy ) * instanceData.z;
|
|
float height = UnpackHeightmap( _TerrainHeightmapTexture.Load( int3( sampleCoords, 0 ) ) );
|
|
inputMesh.positionOS.xz = sampleCoords* _TerrainHeightmapScale.xz;
|
|
inputMesh.positionOS.y = height* _TerrainHeightmapScale.y;
|
|
#ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL
|
|
inputMesh.normalOS = float3(0, 1, 0);
|
|
#else
|
|
inputMesh.normalOS = _TerrainNormalmapTexture.Load(int3(sampleCoords, 0)).rgb* 2 - 1;
|
|
#endif
|
|
inputMesh.ase_texcoord.xy = sampleCoords* _TerrainHeightmapRecipSize.zw;
|
|
#endif
|
|
return inputMesh;
|
|
}
|
|
|
|
|
|
void BuildSurfaceData(FragInputs fragInputs, inout AlphaSurfaceDescription surfaceDescription, float3 V, PositionInputs posInput, out SurfaceData surfaceData, out float3 bentNormalWS)
|
|
{
|
|
ZERO_INITIALIZE(SurfaceData, surfaceData);
|
|
|
|
surfaceData.specularOcclusion = 1.0;
|
|
|
|
// surface data
|
|
|
|
// refraction
|
|
#ifdef _HAS_REFRACTION
|
|
if( _EnableSSRefraction )
|
|
{
|
|
surfaceData.transmittanceMask = ( 1.0 - surfaceDescription.Alpha );
|
|
surfaceDescription.Alpha = 1.0;
|
|
}
|
|
else
|
|
{
|
|
surfaceData.ior = 1.0;
|
|
surfaceData.transmittanceColor = float3( 1.0, 1.0, 1.0 );
|
|
surfaceData.atDistance = 1.0;
|
|
surfaceData.transmittanceMask = 0.0;
|
|
surfaceDescription.Alpha = 1.0;
|
|
}
|
|
#else
|
|
surfaceData.ior = 1.0;
|
|
surfaceData.transmittanceColor = float3( 1.0, 1.0, 1.0 );
|
|
surfaceData.atDistance = 1.0;
|
|
surfaceData.transmittanceMask = 0.0;
|
|
#endif
|
|
|
|
|
|
// material features
|
|
surfaceData.materialFeatures = MATERIALFEATUREFLAGS_LIT_STANDARD;
|
|
#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SUBSURFACE_SCATTERING;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_TRANSMISSION
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_TRANSMISSION;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_ANISOTROPY
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_ANISOTROPY;
|
|
surfaceData.normalWS = float3(0, 1, 0);
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_CLEAR_COAT
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_CLEAR_COAT;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_IRIDESCENCE
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_IRIDESCENCE;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_SPECULAR_COLOR
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SPECULAR_COLOR;
|
|
#endif
|
|
|
|
// others
|
|
#if defined (_MATERIAL_FEATURE_SPECULAR_COLOR) && defined (_ENERGY_CONSERVING_SPECULAR)
|
|
surfaceData.baseColor *= ( 1.0 - Max3( surfaceData.specularColor.r, surfaceData.specularColor.g, surfaceData.specularColor.b ) );
|
|
#endif
|
|
#ifdef _DOUBLESIDED_ON
|
|
float3 doubleSidedConstants = _DoubleSidedConstants.xyz;
|
|
#else
|
|
float3 doubleSidedConstants = float3( 1.0, 1.0, 1.0 );
|
|
#endif
|
|
|
|
// normals
|
|
float3 normalTS = float3(0.0f, 0.0f, 1.0f);
|
|
GetNormalWS( fragInputs, normalTS, surfaceData.normalWS, doubleSidedConstants );
|
|
|
|
surfaceData.geomNormalWS = fragInputs.tangentToWorld[2];
|
|
surfaceData.tangentWS = normalize( fragInputs.tangentToWorld[ 0 ].xyz );
|
|
|
|
// decals
|
|
#if HAVE_DECALS
|
|
if( _EnableDecals )
|
|
{
|
|
DecalSurfaceData decalSurfaceData = GetDecalSurfaceData(posInput, fragInputs, surfaceDescription.Alpha);
|
|
ApplyDecalToSurfaceData(decalSurfaceData, fragInputs.tangentToWorld[2], surfaceData);
|
|
}
|
|
#endif
|
|
|
|
bentNormalWS = surfaceData.normalWS;
|
|
surfaceData.tangentWS = Orthonormalize( surfaceData.tangentWS, surfaceData.normalWS );
|
|
|
|
#if defined(_SPECULAR_OCCLUSION_CUSTOM)
|
|
#elif defined(_SPECULAR_OCCLUSION_FROM_AO_BENT_NORMAL)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromBentAO(V, bentNormalWS, surfaceData.normalWS, surfaceData.ambientOcclusion, PerceptualSmoothnessToPerceptualRoughness(surfaceData.perceptualSmoothness));
|
|
#elif defined(_AMBIENT_OCCLUSION) && defined(_SPECULAR_OCCLUSION_FROM_AO)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromAmbientOcclusion(ClampNdotV(dot(surfaceData.normalWS, V)), surfaceData.ambientOcclusion, PerceptualSmoothnessToRoughness(surfaceData.perceptualSmoothness));
|
|
#endif
|
|
|
|
// debug
|
|
#if defined(DEBUG_DISPLAY)
|
|
if (_DebugMipMapMode != DEBUGMIPMAPMODE_NONE)
|
|
{
|
|
surfaceData.metallic = 0;
|
|
}
|
|
ApplyDebugToSurfaceData(fragInputs.tangentToWorld, surfaceData);
|
|
#endif
|
|
}
|
|
|
|
void GetSurfaceAndBuiltinData(AlphaSurfaceDescription surfaceDescription, FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
|
|
{
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
LODDitheringTransition(ComputeFadeMaskSeed(V, posInput.positionSS), unity_LODFade.x);
|
|
#endif
|
|
|
|
#ifdef _DOUBLESIDED_ON
|
|
float3 doubleSidedConstants = _DoubleSidedConstants.xyz;
|
|
#else
|
|
float3 doubleSidedConstants = float3( 1.0, 1.0, 1.0 );
|
|
#endif
|
|
|
|
ApplyDoubleSidedFlipOrMirror( fragInputs, doubleSidedConstants );
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
#ifdef _ALPHATEST_SHADOW_ON
|
|
DoAlphaTest( surfaceDescription.Alpha, surfaceDescription.AlphaClipThresholdShadow );
|
|
#else
|
|
DoAlphaTest( surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold );
|
|
#endif
|
|
#endif
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
builtinData.depthOffset = surfaceDescription.DepthOffset;
|
|
ApplyDepthOffsetPositionInput( V, surfaceDescription.DepthOffset, GetViewForwardDir(), GetWorldToHClipMatrix(), posInput );
|
|
#endif
|
|
|
|
float3 bentNormalWS;
|
|
BuildSurfaceData( fragInputs, surfaceDescription, V, posInput, surfaceData, bentNormalWS );
|
|
|
|
InitBuiltinData( posInput, surfaceDescription.Alpha, bentNormalWS, -fragInputs.tangentToWorld[ 2 ], fragInputs.texCoord1, fragInputs.texCoord2, builtinData );
|
|
|
|
PostInitBuiltinData(V, posInput, surfaceData, builtinData);
|
|
}
|
|
|
|
PackedVaryingsMeshToPS VertexFunction(AttributesMesh inputMesh )
|
|
{
|
|
PackedVaryingsMeshToPS outputPackedVaryingsMeshToPS;
|
|
UNITY_SETUP_INSTANCE_ID(inputMesh);
|
|
UNITY_TRANSFER_INSTANCE_ID(inputMesh, outputPackedVaryingsMeshToPS);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( outputPackedVaryingsMeshToPS );
|
|
|
|
inputMesh = ApplyMeshModification(inputMesh);
|
|
outputPackedVaryingsMeshToPS.ase_texcoord1 = inputMesh.ase_texcoord;
|
|
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = inputMesh.positionOS.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3( 0, 0, 0 );
|
|
#endif
|
|
float3 vertexValue = defaultVertexValue ;
|
|
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
inputMesh.positionOS.xyz = vertexValue;
|
|
#else
|
|
inputMesh.positionOS.xyz += vertexValue;
|
|
#endif
|
|
|
|
inputMesh.normalOS = inputMesh.normalOS ;
|
|
|
|
float3 positionRWS = TransformObjectToWorld(inputMesh.positionOS);
|
|
outputPackedVaryingsMeshToPS.positionCS = TransformWorldToHClip(positionRWS);
|
|
outputPackedVaryingsMeshToPS.positionRWS.xyz = positionRWS;
|
|
return outputPackedVaryingsMeshToPS;
|
|
}
|
|
|
|
#if defined(ASE_TESSELLATION)
|
|
struct VertexControl
|
|
{
|
|
float3 positionOS : INTERNALTESSPOS;
|
|
float3 normalOS : NORMAL;
|
|
float4 ase_texcoord : TEXCOORD0;
|
|
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct TessellationFactors
|
|
{
|
|
float edge[3] : SV_TessFactor;
|
|
float inside : SV_InsideTessFactor;
|
|
};
|
|
|
|
VertexControl Vert ( AttributesMesh v )
|
|
{
|
|
VertexControl o;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
o.positionOS = v.positionOS;
|
|
o.normalOS = v.normalOS;
|
|
o.ase_texcoord = v.ase_texcoord;
|
|
return o;
|
|
}
|
|
|
|
TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
|
|
{
|
|
TessellationFactors o;
|
|
float4 tf = 1;
|
|
float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
|
|
float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
|
|
#if (SHADEROPTIONS_CAMERA_RELATIVE_RENDERING != 0)
|
|
float3 cameraPos = 0;
|
|
#else
|
|
float3 cameraPos = _WorldSpaceCameraPos;
|
|
#endif
|
|
#if defined(ASE_FIXED_TESSELLATION)
|
|
tf = FixedTess( tessValue );
|
|
#elif defined(ASE_DISTANCE_TESSELLATION)
|
|
tf = DistanceBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), cameraPos );
|
|
#elif defined(ASE_LENGTH_TESSELLATION)
|
|
tf = EdgeLengthBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, GetObjectToWorldMatrix(), cameraPos, _ScreenParams );
|
|
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
|
tf = EdgeLengthBasedTessCull(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), cameraPos, _ScreenParams, _FrustumPlanes );
|
|
#endif
|
|
o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
|
|
return o;
|
|
}
|
|
|
|
[domain("tri")]
|
|
[partitioning("fractional_odd")]
|
|
[outputtopology("triangle_cw")]
|
|
[patchconstantfunc("TessellationFunction")]
|
|
[outputcontrolpoints(3)]
|
|
VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
|
|
{
|
|
return patch[id];
|
|
}
|
|
|
|
[domain("tri")]
|
|
PackedVaryingsMeshToPS DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
|
{
|
|
AttributesMesh o = (AttributesMesh) 0;
|
|
o.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
|
|
o.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
|
|
o.ase_texcoord = patch[0].ase_texcoord * bary.x + patch[1].ase_texcoord * bary.y + patch[2].ase_texcoord * bary.z;
|
|
#if defined(ASE_PHONG_TESSELLATION)
|
|
float3 pp[3];
|
|
for (int i = 0; i < 3; ++i)
|
|
pp[i] = o.positionOS.xyz - patch[i].normalOS * (dot(o.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
|
|
float phongStrength = _TessPhongStrength;
|
|
o.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.positionOS.xyz;
|
|
#endif
|
|
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
|
return VertexFunction(o);
|
|
}
|
|
#else
|
|
PackedVaryingsMeshToPS Vert ( AttributesMesh v )
|
|
{
|
|
return VertexFunction( v );
|
|
}
|
|
#endif
|
|
|
|
#if defined(WRITE_NORMAL_BUFFER) && defined(WRITE_MSAA_DEPTH)
|
|
#define SV_TARGET_DECAL SV_Target2
|
|
#elif defined(WRITE_NORMAL_BUFFER) || defined(WRITE_MSAA_DEPTH)
|
|
#define SV_TARGET_DECAL SV_Target1
|
|
#else
|
|
#define SV_TARGET_DECAL SV_Target0
|
|
#endif
|
|
|
|
void Frag( PackedVaryingsMeshToPS packedInput
|
|
#if defined(SCENESELECTIONPASS) || defined(SCENEPICKINGPASS)
|
|
, out float4 outColor : SV_Target0
|
|
#else
|
|
#ifdef WRITE_MSAA_DEPTH
|
|
, out float4 depthColor : SV_Target0
|
|
#ifdef WRITE_NORMAL_BUFFER
|
|
, out float4 outNormalBuffer : SV_Target1
|
|
#endif
|
|
#else
|
|
#ifdef WRITE_NORMAL_BUFFER
|
|
, out float4 outNormalBuffer : SV_Target0
|
|
#endif
|
|
#endif
|
|
|
|
#if defined(WRITE_DECAL_BUFFER) && !defined(_DISABLE_DECALS)
|
|
, out float4 outDecalBuffer : SV_TARGET_DECAL
|
|
#endif
|
|
#endif
|
|
|
|
#if defined(_DEPTHOFFSET_ON) && !defined(SCENEPICKINGPASS)
|
|
, out float outputDepth : DEPTH_OFFSET_SEMANTIC
|
|
#endif
|
|
|
|
)
|
|
{
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( packedInput );
|
|
UNITY_SETUP_INSTANCE_ID( packedInput );
|
|
|
|
float3 positionRWS = packedInput.positionRWS.xyz;
|
|
|
|
FragInputs input;
|
|
ZERO_INITIALIZE(FragInputs, input);
|
|
|
|
input.tangentToWorld = k_identity3x3;
|
|
input.positionSS = packedInput.positionCS;
|
|
|
|
input.positionRWS = positionRWS;
|
|
|
|
#if _DOUBLESIDED_ON && SHADER_STAGE_FRAGMENT
|
|
input.isFrontFace = IS_FRONT_VFACE( packedInput.cullFace, true, false);
|
|
#elif SHADER_STAGE_FRAGMENT
|
|
#if defined(ASE_NEED_CULLFACE)
|
|
input.isFrontFace = IS_FRONT_VFACE( packedInput.cullFace, true, false );
|
|
#endif
|
|
#endif
|
|
half isFrontFace = input.isFrontFace;
|
|
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS);
|
|
|
|
float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS);
|
|
|
|
AlphaSurfaceDescription surfaceDescription = (AlphaSurfaceDescription)0;
|
|
|
|
surfaceDescription.Alpha = 1;
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
surfaceDescription.AlphaClipThreshold = _AlphaCutoff;
|
|
#endif
|
|
|
|
#ifdef _ALPHATEST_SHADOW_ON
|
|
surfaceDescription.AlphaClipThresholdShadow = 0.5;
|
|
#endif
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
surfaceDescription.DepthOffset = 0;
|
|
#endif
|
|
|
|
SurfaceData surfaceData;
|
|
BuiltinData builtinData;
|
|
GetSurfaceAndBuiltinData(surfaceDescription, input, V, posInput, surfaceData, builtinData);
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
outputDepth = posInput.deviceDepth;
|
|
float bias = max(abs(ddx(posInput.deviceDepth)), abs(ddy(posInput.deviceDepth))) * _SlopeScaleDepthBias;
|
|
outputDepth += bias;
|
|
#endif
|
|
|
|
#ifdef WRITE_MSAA_DEPTH
|
|
depthColor = packedInput.vmesh.positionCS.z;
|
|
|
|
#ifdef _ALPHATOMASK_ON
|
|
depthColor.a = SharpenAlpha(builtinData.opacity, builtinData.alphaClipTreshold);
|
|
#endif
|
|
#endif
|
|
|
|
#if defined(WRITE_NORMAL_BUFFER)
|
|
EncodeIntoNormalBuffer(ConvertSurfaceDataToNormalData(surfaceData), outNormalBuffer);
|
|
#endif
|
|
|
|
#if defined(WRITE_DECAL_BUFFER) && !defined(_DISABLE_DECALS)
|
|
DecalPrepassData decalPrepassData;
|
|
decalPrepassData.geomNormalWS = surfaceData.geomNormalWS;
|
|
decalPrepassData.decalLayerMask = GetMeshRenderingDecalLayer();
|
|
EncodeIntoDecalPrepassBuffer(decalPrepassData, outDecalBuffer);
|
|
#endif
|
|
}
|
|
ENDHLSL
|
|
}
|
|
|
|
UsePass "Hidden/Nature/Terrain/Utilities/PICKING"
|
|
UsePass "Hidden/Nature/Terrain/Utilities/SELECTION"
|
|
|
|
Pass
|
|
{
|
|
|
|
Name "SceneSelectionPass"
|
|
Tags { "LightMode"="SceneSelectionPass" }
|
|
|
|
Cull Off
|
|
|
|
HLSLPROGRAM
|
|
|
|
#define _SPECULAR_OCCLUSION_FROM_AO 1
|
|
#pragma instancing_options renderinglayer
|
|
#define shader_feature_local _DISABLE_DECALS
|
|
#define shader_feature_local_raytracing _DISABLE_SSR
|
|
#define shader_feature_local_fragment _DISABLE_SSR
|
|
#define ASE_SRP_VERSION 170003
|
|
|
|
|
|
#pragma shader_feature _SURFACE_TYPE_TRANSPARENT
|
|
#pragma shader_feature_local _TRANSPARENT_WRITES_MOTION_VEC
|
|
#pragma shader_feature_local_fragment _ENABLE_FOG_ON_TRANSPARENT
|
|
|
|
#pragma editor_sync_compilation
|
|
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/GeometricTools.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Tessellation.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
|
|
#include "Packages/com.unity.shadergraph/ShaderGraphLibrary/Functions.hlsl"
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
|
|
#define SHADERPASS SHADERPASS_DEPTH_ONLY
|
|
#define SCENESELECTIONPASS 1
|
|
|
|
#ifndef SHADER_UNLIT
|
|
#if defined(_DOUBLESIDED_ON) && !defined(VARYINGS_NEED_CULLFACE)
|
|
#define VARYINGS_NEED_CULLFACE
|
|
#endif
|
|
#endif
|
|
|
|
#if defined(_MATERIAL_FEATURE_SUBSURFACE_SCATTERING) && !defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define OUTPUT_SPLIT_LIGHTING
|
|
#endif
|
|
|
|
#if (SHADERPASS == SHADERPASS_PATH_TRACING) && !defined(_DOUBLESIDED_ON) && (defined(_REFRACTION_PLANE) || defined(_REFRACTION_SPHERE))
|
|
#undef _REFRACTION_PLANE
|
|
#undef _REFRACTION_SPHERE
|
|
#define _REFRACTION_THIN
|
|
#endif
|
|
|
|
#if SHADERPASS == SHADERPASS_TRANSPARENT_DEPTH_PREPASS
|
|
#if !defined(_DISABLE_SSR_TRANSPARENT) && !defined(SHADER_UNLIT)
|
|
#define WRITE_NORMAL_BUFFER
|
|
#endif
|
|
#endif
|
|
|
|
#ifndef DEBUG_DISPLAY
|
|
#if !defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#if SHADERPASS == SHADERPASS_FORWARD
|
|
#define SHADERPASS_FORWARD_BYPASS_ALPHA_TEST
|
|
#elif SHADERPASS == SHADERPASS_GBUFFER
|
|
#define SHADERPASS_GBUFFER_BYPASS_ALPHA_TEST
|
|
#endif
|
|
#endif
|
|
#endif
|
|
|
|
#if defined(SHADER_LIT) && !defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define _DEFERRED_CAPABLE_MATERIAL
|
|
#endif
|
|
|
|
#if defined(_TRANSPARENT_WRITES_MOTION_VEC) && defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define _WRITE_TRANSPARENT_MOTION_VECTOR
|
|
#endif
|
|
|
|
CBUFFER_START( UnityPerMaterial )
|
|
float2 _RainReflections;
|
|
float2 _Normal1Tilling;
|
|
float2 _RippleTextureCoordinatesTilling;
|
|
float2 _Normal2Tilling;
|
|
float2 _RainReflections1;
|
|
float _Smoothness0;
|
|
float _Float10;
|
|
float _RippleNormalStrength;
|
|
float _RippleFPS;
|
|
float _RainScale;
|
|
float _WaterFlowSpeed1;
|
|
float _NormalMapStrength;
|
|
float _WaterFlowSpeed;
|
|
float _Smoothness3;
|
|
float _Smoothness2;
|
|
float _Smoothness1;
|
|
float _RainOpacity;
|
|
float _Smoothness;
|
|
float4 _EmissionColor;
|
|
float _AlphaCutoff;
|
|
float _RenderQueueType;
|
|
#ifdef _ADD_PRECOMPUTED_VELOCITY
|
|
float _AddPrecomputedVelocity;
|
|
#endif
|
|
float _StencilRef;
|
|
float _StencilWriteMask;
|
|
float _StencilRefDepth;
|
|
float _StencilWriteMaskDepth;
|
|
float _StencilRefMV;
|
|
float _StencilWriteMaskMV;
|
|
float _StencilWriteMaskGBuffer;
|
|
float _StencilRefGBuffer;
|
|
float _ZTestGBuffer;
|
|
float _RequireSplitLighting;
|
|
float _ReceivesSSR;
|
|
float _SurfaceType;
|
|
float _BlendMode;
|
|
#ifdef SUPPORT_BLENDMODE_PRESERVE_SPECULAR_LIGHTING
|
|
float _EnableBlendModePreserveSpecularLighting;
|
|
#endif
|
|
float _SrcBlend;
|
|
float _DstBlend;
|
|
float _AlphaSrcBlend;
|
|
float _AlphaDstBlend;
|
|
float _ZWrite;
|
|
float _TransparentZWrite;
|
|
float _CullMode;
|
|
float _TransparentSortPriority;
|
|
float _EnableFogOnTransparent;
|
|
float _CullModeForward;
|
|
float _TransparentCullMode;
|
|
float _ZTestDepthEqualForOpaque;
|
|
float _ZTestTransparent;
|
|
float _TransparentBackfaceEnable;
|
|
float _AlphaCutoffEnable;
|
|
float _UseShadowThreshold;
|
|
float _DoubleSidedEnable;
|
|
float _DoubleSidedNormalMode;
|
|
float4 _DoubleSidedConstants;
|
|
#ifdef ASE_TESSELLATION
|
|
float _TessPhongStrength;
|
|
float _TessValue;
|
|
float _TessMin;
|
|
float _TessMax;
|
|
float _TessEdgeLength;
|
|
float _TessMaxDisp;
|
|
#endif
|
|
CBUFFER_END
|
|
|
|
// Property used by ScenePickingPass
|
|
#ifdef SCENEPICKINGPASS
|
|
float4 _SelectionID;
|
|
#endif
|
|
|
|
// Properties used by SceneSelectionPass
|
|
#ifdef SCENESELECTIONPASS
|
|
int _ObjectId;
|
|
int _PassValue;
|
|
#endif
|
|
|
|
sampler2D _Mask2;
|
|
sampler2D _Mask0;
|
|
sampler2D _Mask1;
|
|
sampler2D _Mask3;
|
|
float4 _MaskMapRemapScale0;
|
|
float4 _MaskMapRemapOffset2;
|
|
float4 _MaskMapRemapScale2;
|
|
float4 _MaskMapRemapScale1;
|
|
float4 _MaskMapRemapOffset1;
|
|
float4 _MaskMapRemapScale3;
|
|
float4 _MaskMapRemapOffset3;
|
|
float4 _MaskMapRemapOffset0;
|
|
#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing
|
|
TEXTURE2D(_TerrainHeightmapTexture);//ASE Terrain Instancing
|
|
TEXTURE2D( _TerrainNormalmapTexture);//ASE Terrain Instancing
|
|
SAMPLER(sampler_TerrainNormalmapTexture);//ASE Terrain Instancing
|
|
#endif//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_START( Terrain )//ASE Terrain Instancing
|
|
UNITY_DEFINE_INSTANCED_PROP( float4, _TerrainPatchInstanceData )//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_END( Terrain)//ASE Terrain Instancing
|
|
CBUFFER_START( UnityTerrain)//ASE Terrain Instancing
|
|
#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing
|
|
float4 _TerrainHeightmapRecipSize;//ASE Terrain Instancing
|
|
float4 _TerrainHeightmapScale;//ASE Terrain Instancing
|
|
#endif//ASE Terrain Instancing
|
|
CBUFFER_END//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_START(TerrainAmplifyFirstPass)
|
|
UNITY_INSTANCING_BUFFER_END(TerrainAmplifyFirstPass)
|
|
|
|
|
|
#ifdef DEBUG_DISPLAY
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
|
|
#endif
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/PickingSpaceTransforms.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/NormalSurfaceGradient.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
|
|
// Setup DECALS_OFF so the shader stripper can remove variants
|
|
#define HAVE_DECALS ( (defined(DECALS_3RT) || defined(DECALS_4RT)) && !defined(_DISABLE_DECALS) )
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitDecalData.hlsl"
|
|
|
|
#define ASE_NEEDS_VERT_NORMAL
|
|
#define ASE_NEEDS_VERT_POSITION
|
|
#pragma multi_compile_instancing
|
|
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap forwardadd
|
|
#pragma multi_compile_local __ _ALPHATEST_ON
|
|
#pragma shader_feature_local _MASKMAP
|
|
|
|
|
|
#if defined(_DOUBLESIDED_ON) && !defined(ASE_NEED_CULLFACE)
|
|
#define ASE_NEED_CULLFACE 1
|
|
#endif
|
|
|
|
struct AttributesMesh
|
|
{
|
|
float3 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
float4 ase_texcoord : TEXCOORD0;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct PackedVaryingsMeshToPS
|
|
{
|
|
SV_POSITION_QUALIFIERS float4 positionCS : SV_Position;
|
|
float3 positionRWS : TEXCOORD0;
|
|
float4 ase_texcoord1 : TEXCOORD1;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
#if defined(SHADER_STAGE_FRAGMENT) && defined(ASE_NEED_CULLFACE)
|
|
FRONT_FACE_TYPE cullFace : FRONT_FACE_SEMANTIC;
|
|
#endif
|
|
};
|
|
|
|
AttributesMesh ApplyMeshModification( AttributesMesh inputMesh )
|
|
{
|
|
#ifdef UNITY_INSTANCING_ENABLED
|
|
float2 patchVertex = inputMesh.positionOS.xy;
|
|
float4 instanceData = UNITY_ACCESS_INSTANCED_PROP( Terrain, _TerrainPatchInstanceData );
|
|
float2 sampleCoords = ( patchVertex.xy + instanceData.xy ) * instanceData.z;
|
|
float height = UnpackHeightmap( _TerrainHeightmapTexture.Load( int3( sampleCoords, 0 ) ) );
|
|
inputMesh.positionOS.xz = sampleCoords* _TerrainHeightmapScale.xz;
|
|
inputMesh.positionOS.y = height* _TerrainHeightmapScale.y;
|
|
#ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL
|
|
inputMesh.normalOS = float3(0, 1, 0);
|
|
#else
|
|
inputMesh.normalOS = _TerrainNormalmapTexture.Load(int3(sampleCoords, 0)).rgb* 2 - 1;
|
|
#endif
|
|
inputMesh.ase_texcoord.xy = sampleCoords* _TerrainHeightmapRecipSize.zw;
|
|
#endif
|
|
return inputMesh;
|
|
}
|
|
|
|
|
|
void BuildSurfaceData(FragInputs fragInputs, inout SceneSurfaceDescription surfaceDescription, float3 V, PositionInputs posInput, out SurfaceData surfaceData, out float3 bentNormalWS)
|
|
{
|
|
ZERO_INITIALIZE(SurfaceData, surfaceData);
|
|
|
|
surfaceData.specularOcclusion = 1.0;
|
|
|
|
// surface data
|
|
|
|
// refraction
|
|
#ifdef _HAS_REFRACTION
|
|
if( _EnableSSRefraction )
|
|
{
|
|
surfaceData.transmittanceMask = ( 1.0 - surfaceDescription.Alpha );
|
|
surfaceDescription.Alpha = 1.0;
|
|
}
|
|
else
|
|
{
|
|
surfaceData.ior = 1.0;
|
|
surfaceData.transmittanceColor = float3( 1.0, 1.0, 1.0 );
|
|
surfaceData.atDistance = 1.0;
|
|
surfaceData.transmittanceMask = 0.0;
|
|
surfaceDescription.Alpha = 1.0;
|
|
}
|
|
#else
|
|
surfaceData.ior = 1.0;
|
|
surfaceData.transmittanceColor = float3( 1.0, 1.0, 1.0 );
|
|
surfaceData.atDistance = 1.0;
|
|
surfaceData.transmittanceMask = 0.0;
|
|
#endif
|
|
|
|
|
|
// material features
|
|
surfaceData.materialFeatures = MATERIALFEATUREFLAGS_LIT_STANDARD;
|
|
#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SUBSURFACE_SCATTERING;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_TRANSMISSION
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_TRANSMISSION;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_ANISOTROPY
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_ANISOTROPY;
|
|
surfaceData.normalWS = float3(0, 1, 0);
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_CLEAR_COAT
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_CLEAR_COAT;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_IRIDESCENCE
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_IRIDESCENCE;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_SPECULAR_COLOR
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SPECULAR_COLOR;
|
|
#endif
|
|
|
|
// others
|
|
#if defined (_MATERIAL_FEATURE_SPECULAR_COLOR) && defined (_ENERGY_CONSERVING_SPECULAR)
|
|
surfaceData.baseColor *= ( 1.0 - Max3( surfaceData.specularColor.r, surfaceData.specularColor.g, surfaceData.specularColor.b ) );
|
|
#endif
|
|
#ifdef _DOUBLESIDED_ON
|
|
float3 doubleSidedConstants = _DoubleSidedConstants.xyz;
|
|
#else
|
|
float3 doubleSidedConstants = float3( 1.0, 1.0, 1.0 );
|
|
#endif
|
|
|
|
// normals
|
|
float3 normalTS = float3(0.0f, 0.0f, 1.0f);
|
|
GetNormalWS( fragInputs, normalTS, surfaceData.normalWS, doubleSidedConstants );
|
|
|
|
surfaceData.geomNormalWS = fragInputs.tangentToWorld[2];
|
|
surfaceData.tangentWS = normalize( fragInputs.tangentToWorld[ 0 ].xyz );
|
|
|
|
// decals
|
|
#if HAVE_DECALS
|
|
if( _EnableDecals )
|
|
{
|
|
DecalSurfaceData decalSurfaceData = GetDecalSurfaceData(posInput, fragInputs, surfaceDescription.Alpha);
|
|
ApplyDecalToSurfaceData(decalSurfaceData, fragInputs.tangentToWorld[2], surfaceData);
|
|
}
|
|
#endif
|
|
|
|
bentNormalWS = surfaceData.normalWS;
|
|
surfaceData.tangentWS = Orthonormalize( surfaceData.tangentWS, surfaceData.normalWS );
|
|
|
|
#if defined(_SPECULAR_OCCLUSION_CUSTOM)
|
|
#elif defined(_SPECULAR_OCCLUSION_FROM_AO_BENT_NORMAL)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromBentAO(V, bentNormalWS, surfaceData.normalWS, surfaceData.ambientOcclusion, PerceptualSmoothnessToPerceptualRoughness(surfaceData.perceptualSmoothness));
|
|
#elif defined(_AMBIENT_OCCLUSION) && defined(_SPECULAR_OCCLUSION_FROM_AO)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromAmbientOcclusion(ClampNdotV(dot(surfaceData.normalWS, V)), surfaceData.ambientOcclusion, PerceptualSmoothnessToRoughness(surfaceData.perceptualSmoothness));
|
|
#endif
|
|
|
|
// debug
|
|
#if defined(DEBUG_DISPLAY)
|
|
if (_DebugMipMapMode != DEBUGMIPMAPMODE_NONE)
|
|
{
|
|
surfaceData.metallic = 0;
|
|
}
|
|
ApplyDebugToSurfaceData(fragInputs.tangentToWorld, surfaceData);
|
|
#endif
|
|
}
|
|
|
|
void GetSurfaceAndBuiltinData(SceneSurfaceDescription surfaceDescription, FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
|
|
{
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
LODDitheringTransition(ComputeFadeMaskSeed(V, posInput.positionSS), unity_LODFade.x);
|
|
#endif
|
|
|
|
#ifdef _DOUBLESIDED_ON
|
|
float3 doubleSidedConstants = _DoubleSidedConstants.xyz;
|
|
#else
|
|
float3 doubleSidedConstants = float3( 1.0, 1.0, 1.0 );
|
|
#endif
|
|
|
|
ApplyDoubleSidedFlipOrMirror( fragInputs, doubleSidedConstants );
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
DoAlphaTest( surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold );
|
|
#endif
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
builtinData.depthOffset = surfaceDescription.DepthOffset;
|
|
ApplyDepthOffsetPositionInput( V, surfaceDescription.DepthOffset, GetViewForwardDir(), GetWorldToHClipMatrix(), posInput );
|
|
#endif
|
|
|
|
float3 bentNormalWS;
|
|
BuildSurfaceData( fragInputs, surfaceDescription, V, posInput, surfaceData, bentNormalWS );
|
|
|
|
InitBuiltinData( posInput, surfaceDescription.Alpha, bentNormalWS, -fragInputs.tangentToWorld[ 2 ], fragInputs.texCoord1, fragInputs.texCoord2, builtinData );
|
|
|
|
PostInitBuiltinData(V, posInput, surfaceData, builtinData);
|
|
}
|
|
|
|
PackedVaryingsMeshToPS VertexFunction(AttributesMesh inputMesh )
|
|
{
|
|
PackedVaryingsMeshToPS outputPackedVaryingsMeshToPS;
|
|
UNITY_SETUP_INSTANCE_ID(inputMesh);
|
|
UNITY_TRANSFER_INSTANCE_ID(inputMesh, outputPackedVaryingsMeshToPS);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( outputPackedVaryingsMeshToPS );
|
|
|
|
inputMesh = ApplyMeshModification(inputMesh);
|
|
outputPackedVaryingsMeshToPS.ase_texcoord1 = inputMesh.ase_texcoord;
|
|
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = inputMesh.positionOS.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3( 0, 0, 0 );
|
|
#endif
|
|
float3 vertexValue = defaultVertexValue ;
|
|
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
inputMesh.positionOS.xyz = vertexValue;
|
|
#else
|
|
inputMesh.positionOS.xyz += vertexValue;
|
|
#endif
|
|
|
|
inputMesh.normalOS = inputMesh.normalOS ;
|
|
|
|
float3 positionRWS = TransformObjectToWorld(inputMesh.positionOS);
|
|
outputPackedVaryingsMeshToPS.positionCS = TransformWorldToHClip(positionRWS);
|
|
outputPackedVaryingsMeshToPS.positionRWS.xyz = positionRWS;
|
|
return outputPackedVaryingsMeshToPS;
|
|
}
|
|
|
|
#if defined(ASE_TESSELLATION)
|
|
struct VertexControl
|
|
{
|
|
float3 positionOS : INTERNALTESSPOS;
|
|
float3 normalOS : NORMAL;
|
|
float4 ase_texcoord : TEXCOORD0;
|
|
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct TessellationFactors
|
|
{
|
|
float edge[3] : SV_TessFactor;
|
|
float inside : SV_InsideTessFactor;
|
|
};
|
|
|
|
VertexControl Vert ( AttributesMesh v )
|
|
{
|
|
VertexControl o;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
o.positionOS = v.positionOS;
|
|
o.normalOS = v.normalOS;
|
|
o.ase_texcoord = v.ase_texcoord;
|
|
return o;
|
|
}
|
|
|
|
TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
|
|
{
|
|
TessellationFactors o;
|
|
float4 tf = 1;
|
|
float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
|
|
float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
|
|
#if (SHADEROPTIONS_CAMERA_RELATIVE_RENDERING != 0)
|
|
float3 cameraPos = 0;
|
|
#else
|
|
float3 cameraPos = _WorldSpaceCameraPos;
|
|
#endif
|
|
#if defined(ASE_FIXED_TESSELLATION)
|
|
tf = FixedTess( tessValue );
|
|
#elif defined(ASE_DISTANCE_TESSELLATION)
|
|
tf = DistanceBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), cameraPos );
|
|
#elif defined(ASE_LENGTH_TESSELLATION)
|
|
tf = EdgeLengthBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, GetObjectToWorldMatrix(), cameraPos, _ScreenParams );
|
|
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
|
tf = EdgeLengthBasedTessCull(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), cameraPos, _ScreenParams, _FrustumPlanes );
|
|
#endif
|
|
o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
|
|
return o;
|
|
}
|
|
|
|
[domain("tri")]
|
|
[partitioning("fractional_odd")]
|
|
[outputtopology("triangle_cw")]
|
|
[patchconstantfunc("TessellationFunction")]
|
|
[outputcontrolpoints(3)]
|
|
VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
|
|
{
|
|
return patch[id];
|
|
}
|
|
|
|
[domain("tri")]
|
|
PackedVaryingsMeshToPS DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
|
{
|
|
AttributesMesh o = (AttributesMesh) 0;
|
|
o.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
|
|
o.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
|
|
o.ase_texcoord = patch[0].ase_texcoord * bary.x + patch[1].ase_texcoord * bary.y + patch[2].ase_texcoord * bary.z;
|
|
#if defined(ASE_PHONG_TESSELLATION)
|
|
float3 pp[3];
|
|
for (int i = 0; i < 3; ++i)
|
|
pp[i] = o.positionOS.xyz - patch[i].normalOS * (dot(o.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
|
|
float phongStrength = _TessPhongStrength;
|
|
o.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.positionOS.xyz;
|
|
#endif
|
|
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
|
return VertexFunction(o);
|
|
}
|
|
#else
|
|
PackedVaryingsMeshToPS Vert ( AttributesMesh v )
|
|
{
|
|
return VertexFunction( v );
|
|
}
|
|
#endif
|
|
|
|
#if defined(WRITE_NORMAL_BUFFER) && defined(WRITE_MSAA_DEPTH)
|
|
#define SV_TARGET_DECAL SV_Target2
|
|
#elif defined(WRITE_NORMAL_BUFFER) || defined(WRITE_MSAA_DEPTH)
|
|
#define SV_TARGET_DECAL SV_Target1
|
|
#else
|
|
#define SV_TARGET_DECAL SV_Target0
|
|
#endif
|
|
|
|
void Frag( PackedVaryingsMeshToPS packedInput
|
|
, out float4 outColor : SV_Target0
|
|
#if defined(_DEPTHOFFSET_ON) && !defined(SCENEPICKINGPASS)
|
|
, out float outputDepth : DEPTH_OFFSET_SEMANTIC
|
|
#endif
|
|
|
|
)
|
|
{
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( packedInput );
|
|
UNITY_SETUP_INSTANCE_ID( packedInput );
|
|
|
|
float3 positionRWS = packedInput.positionRWS.xyz;
|
|
|
|
FragInputs input;
|
|
ZERO_INITIALIZE(FragInputs, input);
|
|
|
|
input.tangentToWorld = k_identity3x3;
|
|
input.positionSS = packedInput.positionCS;
|
|
|
|
input.positionRWS = positionRWS;
|
|
|
|
#if _DOUBLESIDED_ON && SHADER_STAGE_FRAGMENT
|
|
input.isFrontFace = IS_FRONT_VFACE( packedInput.cullFace, true, false);
|
|
#elif SHADER_STAGE_FRAGMENT
|
|
#if defined(ASE_NEED_CULLFACE)
|
|
input.isFrontFace = IS_FRONT_VFACE( packedInput.cullFace, true, false );
|
|
#endif
|
|
#endif
|
|
half isFrontFace = input.isFrontFace;
|
|
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS);
|
|
|
|
float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS);
|
|
|
|
SceneSurfaceDescription surfaceDescription = (SceneSurfaceDescription)0;
|
|
|
|
surfaceDescription.Alpha = 1;
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
surfaceDescription.AlphaClipThreshold = _AlphaCutoff;
|
|
#endif
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
surfaceDescription.DepthOffset = 0;
|
|
#endif
|
|
|
|
SurfaceData surfaceData;
|
|
BuiltinData builtinData;
|
|
GetSurfaceAndBuiltinData(surfaceDescription, input, V, posInput, surfaceData, builtinData);
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
outputDepth = posInput.deviceDepth;
|
|
#endif
|
|
|
|
outColor = float4( _ObjectId, _PassValue, 1.0, 1.0 );
|
|
}
|
|
ENDHLSL
|
|
}
|
|
|
|
UsePass "Hidden/Nature/Terrain/Utilities/PICKING"
|
|
UsePass "Hidden/Nature/Terrain/Utilities/SELECTION"
|
|
|
|
Pass
|
|
{
|
|
|
|
Name "DepthOnly"
|
|
Tags { "LightMode"="DepthOnly" }
|
|
|
|
Cull [_CullMode]
|
|
|
|
ZWrite On
|
|
|
|
Stencil
|
|
{
|
|
Ref [_StencilRefDepth]
|
|
WriteMask [_StencilWriteMaskDepth]
|
|
Comp Always
|
|
Pass Replace
|
|
}
|
|
|
|
|
|
HLSLPROGRAM
|
|
|
|
#define _SPECULAR_OCCLUSION_FROM_AO 1
|
|
#pragma instancing_options renderinglayer
|
|
#define shader_feature_local _DISABLE_DECALS
|
|
#define shader_feature_local_raytracing _DISABLE_SSR
|
|
#define shader_feature_local_fragment _DISABLE_SSR
|
|
#define ASE_SRP_VERSION 170003
|
|
|
|
|
|
#pragma shader_feature _SURFACE_TYPE_TRANSPARENT
|
|
#pragma shader_feature_local _TRANSPARENT_WRITES_MOTION_VEC
|
|
#pragma shader_feature_local_fragment _ENABLE_FOG_ON_TRANSPARENT
|
|
|
|
#pragma multi_compile _ WRITE_NORMAL_BUFFER
|
|
#pragma multi_compile_fragment _ WRITE_MSAA_DEPTH
|
|
#pragma multi_compile _ WRITE_DECAL_BUFFER
|
|
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/GeometricTools.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Tessellation.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
|
|
#include "Packages/com.unity.shadergraph/ShaderGraphLibrary/Functions.hlsl"
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
|
|
#define SHADERPASS SHADERPASS_DEPTH_ONLY
|
|
|
|
#ifndef SHADER_UNLIT
|
|
#if defined(_DOUBLESIDED_ON) && !defined(VARYINGS_NEED_CULLFACE)
|
|
#define VARYINGS_NEED_CULLFACE
|
|
#endif
|
|
#endif
|
|
|
|
#if defined(_MATERIAL_FEATURE_SUBSURFACE_SCATTERING) && !defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define OUTPUT_SPLIT_LIGHTING
|
|
#endif
|
|
|
|
#if (SHADERPASS == SHADERPASS_PATH_TRACING) && !defined(_DOUBLESIDED_ON) && (defined(_REFRACTION_PLANE) || defined(_REFRACTION_SPHERE))
|
|
#undef _REFRACTION_PLANE
|
|
#undef _REFRACTION_SPHERE
|
|
#define _REFRACTION_THIN
|
|
#endif
|
|
|
|
#if SHADERPASS == SHADERPASS_TRANSPARENT_DEPTH_PREPASS
|
|
#if !defined(_DISABLE_SSR_TRANSPARENT) && !defined(SHADER_UNLIT)
|
|
#define WRITE_NORMAL_BUFFER
|
|
#endif
|
|
#endif
|
|
|
|
#ifndef DEBUG_DISPLAY
|
|
#if !defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#if SHADERPASS == SHADERPASS_FORWARD
|
|
#define SHADERPASS_FORWARD_BYPASS_ALPHA_TEST
|
|
#elif SHADERPASS == SHADERPASS_GBUFFER
|
|
#define SHADERPASS_GBUFFER_BYPASS_ALPHA_TEST
|
|
#endif
|
|
#endif
|
|
#endif
|
|
|
|
#if defined(SHADER_LIT) && !defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define _DEFERRED_CAPABLE_MATERIAL
|
|
#endif
|
|
|
|
#if defined(_TRANSPARENT_WRITES_MOTION_VEC) && defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define _WRITE_TRANSPARENT_MOTION_VECTOR
|
|
#endif
|
|
|
|
CBUFFER_START( UnityPerMaterial )
|
|
float2 _RainReflections;
|
|
float2 _Normal1Tilling;
|
|
float2 _RippleTextureCoordinatesTilling;
|
|
float2 _Normal2Tilling;
|
|
float2 _RainReflections1;
|
|
float _Smoothness0;
|
|
float _Float10;
|
|
float _RippleNormalStrength;
|
|
float _RippleFPS;
|
|
float _RainScale;
|
|
float _WaterFlowSpeed1;
|
|
float _NormalMapStrength;
|
|
float _WaterFlowSpeed;
|
|
float _Smoothness3;
|
|
float _Smoothness2;
|
|
float _Smoothness1;
|
|
float _RainOpacity;
|
|
float _Smoothness;
|
|
float4 _EmissionColor;
|
|
float _AlphaCutoff;
|
|
float _RenderQueueType;
|
|
#ifdef _ADD_PRECOMPUTED_VELOCITY
|
|
float _AddPrecomputedVelocity;
|
|
#endif
|
|
float _StencilRef;
|
|
float _StencilWriteMask;
|
|
float _StencilRefDepth;
|
|
float _StencilWriteMaskDepth;
|
|
float _StencilRefMV;
|
|
float _StencilWriteMaskMV;
|
|
float _StencilWriteMaskGBuffer;
|
|
float _StencilRefGBuffer;
|
|
float _ZTestGBuffer;
|
|
float _RequireSplitLighting;
|
|
float _ReceivesSSR;
|
|
float _SurfaceType;
|
|
float _BlendMode;
|
|
#ifdef SUPPORT_BLENDMODE_PRESERVE_SPECULAR_LIGHTING
|
|
float _EnableBlendModePreserveSpecularLighting;
|
|
#endif
|
|
float _SrcBlend;
|
|
float _DstBlend;
|
|
float _AlphaSrcBlend;
|
|
float _AlphaDstBlend;
|
|
float _ZWrite;
|
|
float _TransparentZWrite;
|
|
float _CullMode;
|
|
float _TransparentSortPriority;
|
|
float _EnableFogOnTransparent;
|
|
float _CullModeForward;
|
|
float _TransparentCullMode;
|
|
float _ZTestDepthEqualForOpaque;
|
|
float _ZTestTransparent;
|
|
float _TransparentBackfaceEnable;
|
|
float _AlphaCutoffEnable;
|
|
float _UseShadowThreshold;
|
|
float _DoubleSidedEnable;
|
|
float _DoubleSidedNormalMode;
|
|
float4 _DoubleSidedConstants;
|
|
#ifdef ASE_TESSELLATION
|
|
float _TessPhongStrength;
|
|
float _TessValue;
|
|
float _TessMin;
|
|
float _TessMax;
|
|
float _TessEdgeLength;
|
|
float _TessMaxDisp;
|
|
#endif
|
|
CBUFFER_END
|
|
|
|
// Property used by ScenePickingPass
|
|
#ifdef SCENEPICKINGPASS
|
|
float4 _SelectionID;
|
|
#endif
|
|
|
|
// Properties used by SceneSelectionPass
|
|
#ifdef SCENESELECTIONPASS
|
|
int _ObjectId;
|
|
int _PassValue;
|
|
#endif
|
|
|
|
sampler2D _Mask2;
|
|
sampler2D _Mask0;
|
|
sampler2D _Mask1;
|
|
sampler2D _Mask3;
|
|
float4 _MaskMapRemapScale0;
|
|
float4 _MaskMapRemapOffset2;
|
|
float4 _MaskMapRemapScale2;
|
|
float4 _MaskMapRemapScale1;
|
|
float4 _MaskMapRemapOffset1;
|
|
float4 _MaskMapRemapScale3;
|
|
float4 _MaskMapRemapOffset3;
|
|
float4 _MaskMapRemapOffset0;
|
|
sampler2D _Control;
|
|
sampler2D _Normal0;
|
|
sampler2D _Splat0;
|
|
sampler2D _Normal1;
|
|
sampler2D _Splat1;
|
|
sampler2D _Normal2;
|
|
sampler2D _Splat2;
|
|
sampler2D _Normal3;
|
|
sampler2D _Splat3;
|
|
sampler2D _WaterFlowNormal;
|
|
sampler2D _WaterFlowNormal1;
|
|
sampler2D _RippleNormal;
|
|
#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing
|
|
TEXTURE2D(_TerrainHeightmapTexture);//ASE Terrain Instancing
|
|
TEXTURE2D( _TerrainNormalmapTexture);//ASE Terrain Instancing
|
|
SAMPLER(sampler_TerrainNormalmapTexture);//ASE Terrain Instancing
|
|
#endif//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_START( Terrain )//ASE Terrain Instancing
|
|
UNITY_DEFINE_INSTANCED_PROP( float4, _TerrainPatchInstanceData )//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_END( Terrain)//ASE Terrain Instancing
|
|
CBUFFER_START( UnityTerrain)//ASE Terrain Instancing
|
|
#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing
|
|
float4 _TerrainHeightmapRecipSize;//ASE Terrain Instancing
|
|
float4 _TerrainHeightmapScale;//ASE Terrain Instancing
|
|
#endif//ASE Terrain Instancing
|
|
CBUFFER_END//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_START(TerrainAmplifyFirstPass)
|
|
UNITY_DEFINE_INSTANCED_PROP(float4, _Control_ST)
|
|
UNITY_DEFINE_INSTANCED_PROP(float4, _Splat0_ST)
|
|
UNITY_DEFINE_INSTANCED_PROP(float4, _Splat1_ST)
|
|
UNITY_DEFINE_INSTANCED_PROP(float4, _Splat2_ST)
|
|
UNITY_DEFINE_INSTANCED_PROP(float4, _Splat3_ST)
|
|
UNITY_INSTANCING_BUFFER_END(TerrainAmplifyFirstPass)
|
|
|
|
|
|
#ifdef DEBUG_DISPLAY
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
|
|
#endif
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/NormalSurfaceGradient.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
|
|
// Setup DECALS_OFF so the shader stripper can remove variants
|
|
#define HAVE_DECALS ( (defined(DECALS_3RT) || defined(DECALS_4RT)) && !defined(_DISABLE_DECALS) )
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitDecalData.hlsl"
|
|
|
|
#define ASE_NEEDS_VERT_NORMAL
|
|
#define ASE_NEEDS_VERT_POSITION
|
|
#pragma multi_compile_instancing
|
|
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap forwardadd
|
|
#pragma multi_compile_local __ _ALPHATEST_ON
|
|
#pragma shader_feature_local _MASKMAP
|
|
|
|
|
|
#if defined(_DOUBLESIDED_ON) && !defined(ASE_NEED_CULLFACE)
|
|
#define ASE_NEED_CULLFACE 1
|
|
#endif
|
|
|
|
struct AttributesMesh
|
|
{
|
|
float3 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
float4 tangentOS : TANGENT;
|
|
float4 ase_texcoord : TEXCOORD0;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct PackedVaryingsMeshToPS
|
|
{
|
|
SV_POSITION_QUALIFIERS float4 positionCS : SV_Position;
|
|
float3 positionRWS : TEXCOORD0;
|
|
float3 normalWS : TEXCOORD1;
|
|
float4 tangentWS : TEXCOORD2;
|
|
float4 ase_texcoord3 : TEXCOORD3;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
#if defined(SHADER_STAGE_FRAGMENT) && defined(ASE_NEED_CULLFACE)
|
|
FRONT_FACE_TYPE cullFace : FRONT_FACE_SEMANTIC;
|
|
#endif
|
|
};
|
|
|
|
inline float noise_randomValue (float2 uv) { return frac(sin(dot(uv, float2(12.9898, 78.233)))*43758.5453); }
|
|
inline float noise_interpolate (float a, float b, float t) { return (1.0-t)*a + (t*b); }
|
|
inline float valueNoise (float2 uv)
|
|
{
|
|
float2 i = floor(uv);
|
|
float2 f = frac( uv );
|
|
f = f* f * (3.0 - 2.0 * f);
|
|
uv = abs( frac(uv) - 0.5);
|
|
float2 c0 = i + float2( 0.0, 0.0 );
|
|
float2 c1 = i + float2( 1.0, 0.0 );
|
|
float2 c2 = i + float2( 0.0, 1.0 );
|
|
float2 c3 = i + float2( 1.0, 1.0 );
|
|
float r0 = noise_randomValue( c0 );
|
|
float r1 = noise_randomValue( c1 );
|
|
float r2 = noise_randomValue( c2 );
|
|
float r3 = noise_randomValue( c3 );
|
|
float bottomOfGrid = noise_interpolate( r0, r1, f.x );
|
|
float topOfGrid = noise_interpolate( r2, r3, f.x );
|
|
float t = noise_interpolate( bottomOfGrid, topOfGrid, f.y );
|
|
return t;
|
|
}
|
|
|
|
float SimpleNoise(float2 UV)
|
|
{
|
|
float t = 0.0;
|
|
float freq = pow( 2.0, float( 0 ) );
|
|
float amp = pow( 0.5, float( 3 - 0 ) );
|
|
t += valueNoise( UV/freq )*amp;
|
|
freq = pow(2.0, float(1));
|
|
amp = pow(0.5, float(3-1));
|
|
t += valueNoise( UV/freq )*amp;
|
|
freq = pow(2.0, float(2));
|
|
amp = pow(0.5, float(3-2));
|
|
t += valueNoise( UV/freq )*amp;
|
|
return t;
|
|
}
|
|
|
|
AttributesMesh ApplyMeshModification( AttributesMesh inputMesh )
|
|
{
|
|
#ifdef UNITY_INSTANCING_ENABLED
|
|
float2 patchVertex = inputMesh.positionOS.xy;
|
|
float4 instanceData = UNITY_ACCESS_INSTANCED_PROP( Terrain, _TerrainPatchInstanceData );
|
|
float2 sampleCoords = ( patchVertex.xy + instanceData.xy ) * instanceData.z;
|
|
float height = UnpackHeightmap( _TerrainHeightmapTexture.Load( int3( sampleCoords, 0 ) ) );
|
|
inputMesh.positionOS.xz = sampleCoords* _TerrainHeightmapScale.xz;
|
|
inputMesh.positionOS.y = height* _TerrainHeightmapScale.y;
|
|
#ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL
|
|
inputMesh.normalOS = float3(0, 1, 0);
|
|
#else
|
|
inputMesh.normalOS = _TerrainNormalmapTexture.Load(int3(sampleCoords, 0)).rgb* 2 - 1;
|
|
#endif
|
|
inputMesh.ase_texcoord.xy = sampleCoords* _TerrainHeightmapRecipSize.zw;
|
|
#endif
|
|
return inputMesh;
|
|
}
|
|
|
|
|
|
void BuildSurfaceData(FragInputs fragInputs, inout SmoothSurfaceDescription surfaceDescription, float3 V, PositionInputs posInput, out SurfaceData surfaceData, out float3 bentNormalWS)
|
|
{
|
|
ZERO_INITIALIZE(SurfaceData, surfaceData);
|
|
|
|
surfaceData.specularOcclusion = 1.0;
|
|
|
|
// surface data
|
|
surfaceData.perceptualSmoothness = surfaceDescription.Smoothness;
|
|
|
|
// refraction
|
|
#ifdef _HAS_REFRACTION
|
|
if( _EnableSSRefraction )
|
|
{
|
|
surfaceData.transmittanceMask = ( 1.0 - surfaceDescription.Alpha );
|
|
surfaceDescription.Alpha = 1.0;
|
|
}
|
|
else
|
|
{
|
|
surfaceData.ior = 1.0;
|
|
surfaceData.transmittanceColor = float3( 1.0, 1.0, 1.0 );
|
|
surfaceData.atDistance = 1.0;
|
|
surfaceData.transmittanceMask = 0.0;
|
|
surfaceDescription.Alpha = 1.0;
|
|
}
|
|
#else
|
|
surfaceData.ior = 1.0;
|
|
surfaceData.transmittanceColor = float3( 1.0, 1.0, 1.0 );
|
|
surfaceData.atDistance = 1.0;
|
|
surfaceData.transmittanceMask = 0.0;
|
|
#endif
|
|
|
|
|
|
// material features
|
|
surfaceData.materialFeatures = MATERIALFEATUREFLAGS_LIT_STANDARD;
|
|
#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SUBSURFACE_SCATTERING;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_TRANSMISSION
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_TRANSMISSION;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_ANISOTROPY
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_ANISOTROPY;
|
|
surfaceData.normalWS = float3(0, 1, 0);
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_CLEAR_COAT
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_CLEAR_COAT;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_IRIDESCENCE
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_IRIDESCENCE;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_SPECULAR_COLOR
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SPECULAR_COLOR;
|
|
#endif
|
|
|
|
// others
|
|
#if defined (_MATERIAL_FEATURE_SPECULAR_COLOR) && defined (_ENERGY_CONSERVING_SPECULAR)
|
|
surfaceData.baseColor *= ( 1.0 - Max3( surfaceData.specularColor.r, surfaceData.specularColor.g, surfaceData.specularColor.b ) );
|
|
#endif
|
|
#ifdef _DOUBLESIDED_ON
|
|
float3 doubleSidedConstants = _DoubleSidedConstants.xyz;
|
|
#else
|
|
float3 doubleSidedConstants = float3( 1.0, 1.0, 1.0 );
|
|
#endif
|
|
|
|
// normals
|
|
float3 normalTS = float3(0.0f, 0.0f, 1.0f);
|
|
normalTS = surfaceDescription.Normal;
|
|
GetNormalWS( fragInputs, normalTS, surfaceData.normalWS, doubleSidedConstants );
|
|
|
|
surfaceData.geomNormalWS = fragInputs.tangentToWorld[2];
|
|
surfaceData.tangentWS = normalize( fragInputs.tangentToWorld[ 0 ].xyz );
|
|
|
|
// decals
|
|
#if HAVE_DECALS
|
|
if( _EnableDecals )
|
|
{
|
|
DecalSurfaceData decalSurfaceData = GetDecalSurfaceData(posInput, fragInputs, surfaceDescription.Alpha);
|
|
ApplyDecalToSurfaceData(decalSurfaceData, fragInputs.tangentToWorld[2], surfaceData);
|
|
}
|
|
#endif
|
|
|
|
bentNormalWS = surfaceData.normalWS;
|
|
surfaceData.tangentWS = Orthonormalize( surfaceData.tangentWS, surfaceData.normalWS );
|
|
|
|
#if defined(_SPECULAR_OCCLUSION_CUSTOM)
|
|
#elif defined(_SPECULAR_OCCLUSION_FROM_AO_BENT_NORMAL)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromBentAO(V, bentNormalWS, surfaceData.normalWS, surfaceData.ambientOcclusion, PerceptualSmoothnessToPerceptualRoughness(surfaceData.perceptualSmoothness));
|
|
#elif defined(_AMBIENT_OCCLUSION) && defined(_SPECULAR_OCCLUSION_FROM_AO)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromAmbientOcclusion(ClampNdotV(dot(surfaceData.normalWS, V)), surfaceData.ambientOcclusion, PerceptualSmoothnessToRoughness(surfaceData.perceptualSmoothness));
|
|
#endif
|
|
|
|
// debug
|
|
#if defined(DEBUG_DISPLAY)
|
|
if (_DebugMipMapMode != DEBUGMIPMAPMODE_NONE)
|
|
{
|
|
surfaceData.metallic = 0;
|
|
}
|
|
ApplyDebugToSurfaceData(fragInputs.tangentToWorld, surfaceData);
|
|
#endif
|
|
}
|
|
|
|
void GetSurfaceAndBuiltinData(SmoothSurfaceDescription surfaceDescription, FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
|
|
{
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
LODDitheringTransition(ComputeFadeMaskSeed(V, posInput.positionSS), unity_LODFade.x);
|
|
#endif
|
|
|
|
#ifdef _DOUBLESIDED_ON
|
|
float3 doubleSidedConstants = _DoubleSidedConstants.xyz;
|
|
#else
|
|
float3 doubleSidedConstants = float3( 1.0, 1.0, 1.0 );
|
|
#endif
|
|
|
|
ApplyDoubleSidedFlipOrMirror( fragInputs, doubleSidedConstants );
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
DoAlphaTest( surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold );
|
|
#endif
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
builtinData.depthOffset = surfaceDescription.DepthOffset;
|
|
ApplyDepthOffsetPositionInput( V, surfaceDescription.DepthOffset, GetViewForwardDir(), GetWorldToHClipMatrix(), posInput );
|
|
#endif
|
|
|
|
float3 bentNormalWS;
|
|
BuildSurfaceData( fragInputs, surfaceDescription, V, posInput, surfaceData, bentNormalWS );
|
|
|
|
InitBuiltinData( posInput, surfaceDescription.Alpha, bentNormalWS, -fragInputs.tangentToWorld[ 2 ], fragInputs.texCoord1, fragInputs.texCoord2, builtinData );
|
|
|
|
PostInitBuiltinData(V, posInput, surfaceData, builtinData);
|
|
}
|
|
|
|
#if defined(WRITE_DECAL_BUFFER) && !defined(_DISABLE_DECALS)
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalPrepassBuffer.hlsl"
|
|
#endif
|
|
PackedVaryingsMeshToPS VertexFunction(AttributesMesh inputMesh )
|
|
{
|
|
PackedVaryingsMeshToPS outputPackedVaryingsMeshToPS;
|
|
|
|
UNITY_SETUP_INSTANCE_ID(inputMesh);
|
|
UNITY_TRANSFER_INSTANCE_ID(inputMesh, outputPackedVaryingsMeshToPS);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( outputPackedVaryingsMeshToPS );
|
|
|
|
inputMesh = ApplyMeshModification(inputMesh);
|
|
outputPackedVaryingsMeshToPS.ase_texcoord3.xy = inputMesh.ase_texcoord.xy;
|
|
|
|
//setting value to unused interpolator channels and avoid initialization warnings
|
|
outputPackedVaryingsMeshToPS.ase_texcoord3.zw = 0;
|
|
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = inputMesh.positionOS.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3( 0, 0, 0 );
|
|
#endif
|
|
float3 vertexValue = defaultVertexValue ;
|
|
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
inputMesh.positionOS.xyz = vertexValue;
|
|
#else
|
|
inputMesh.positionOS.xyz += vertexValue;
|
|
#endif
|
|
|
|
inputMesh.normalOS = inputMesh.normalOS ;
|
|
inputMesh.tangentOS = inputMesh.tangentOS ;
|
|
|
|
float3 positionRWS = TransformObjectToWorld(inputMesh.positionOS);
|
|
float3 normalWS = TransformObjectToWorldNormal(inputMesh.normalOS);
|
|
float4 tangentWS = float4(TransformObjectToWorldDir(inputMesh.tangentOS.xyz), inputMesh.tangentOS.w);
|
|
|
|
outputPackedVaryingsMeshToPS.positionCS = TransformWorldToHClip(positionRWS);
|
|
outputPackedVaryingsMeshToPS.positionRWS.xyz = positionRWS;
|
|
outputPackedVaryingsMeshToPS.normalWS.xyz = normalWS;
|
|
outputPackedVaryingsMeshToPS.tangentWS.xyzw = tangentWS;
|
|
return outputPackedVaryingsMeshToPS;
|
|
}
|
|
|
|
#if defined(ASE_TESSELLATION)
|
|
struct VertexControl
|
|
{
|
|
float3 positionOS : INTERNALTESSPOS;
|
|
float3 normalOS : NORMAL;
|
|
float4 tangentOS : TANGENT;
|
|
float4 ase_texcoord : TEXCOORD0;
|
|
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct TessellationFactors
|
|
{
|
|
float edge[3] : SV_TessFactor;
|
|
float inside : SV_InsideTessFactor;
|
|
};
|
|
|
|
VertexControl Vert ( AttributesMesh v )
|
|
{
|
|
VertexControl o;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
o.positionOS = v.positionOS;
|
|
o.normalOS = v.normalOS;
|
|
o.tangentOS = v.tangentOS;
|
|
o.ase_texcoord = v.ase_texcoord;
|
|
return o;
|
|
}
|
|
|
|
TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
|
|
{
|
|
TessellationFactors o;
|
|
float4 tf = 1;
|
|
float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
|
|
float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
|
|
#if (SHADEROPTIONS_CAMERA_RELATIVE_RENDERING != 0)
|
|
float3 cameraPos = 0;
|
|
#else
|
|
float3 cameraPos = _WorldSpaceCameraPos;
|
|
#endif
|
|
#if defined(ASE_FIXED_TESSELLATION)
|
|
tf = FixedTess( tessValue );
|
|
#elif defined(ASE_DISTANCE_TESSELLATION)
|
|
tf = DistanceBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), cameraPos );
|
|
#elif defined(ASE_LENGTH_TESSELLATION)
|
|
tf = EdgeLengthBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, GetObjectToWorldMatrix(), cameraPos, _ScreenParams );
|
|
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
|
tf = EdgeLengthBasedTessCull(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), cameraPos, _ScreenParams, _FrustumPlanes );
|
|
#endif
|
|
o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
|
|
return o;
|
|
}
|
|
|
|
[domain("tri")]
|
|
[partitioning("fractional_odd")]
|
|
[outputtopology("triangle_cw")]
|
|
[patchconstantfunc("TessellationFunction")]
|
|
[outputcontrolpoints(3)]
|
|
VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
|
|
{
|
|
return patch[id];
|
|
}
|
|
|
|
[domain("tri")]
|
|
PackedVaryingsMeshToPS DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
|
{
|
|
AttributesMesh o = (AttributesMesh) 0;
|
|
o.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
|
|
o.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
|
|
o.tangentOS = patch[0].tangentOS * bary.x + patch[1].tangentOS * bary.y + patch[2].tangentOS * bary.z;
|
|
o.ase_texcoord = patch[0].ase_texcoord * bary.x + patch[1].ase_texcoord * bary.y + patch[2].ase_texcoord * bary.z;
|
|
#if defined(ASE_PHONG_TESSELLATION)
|
|
float3 pp[3];
|
|
for (int i = 0; i < 3; ++i)
|
|
pp[i] = o.positionOS.xyz - patch[i].normalOS * (dot(o.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
|
|
float phongStrength = _TessPhongStrength;
|
|
o.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.positionOS.xyz;
|
|
#endif
|
|
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
|
return VertexFunction(o);
|
|
}
|
|
#else
|
|
PackedVaryingsMeshToPS Vert ( AttributesMesh v )
|
|
{
|
|
return VertexFunction( v );
|
|
}
|
|
#endif
|
|
|
|
#if defined(WRITE_NORMAL_BUFFER) && defined(WRITE_MSAA_DEPTH)
|
|
#define SV_TARGET_DECAL SV_Target2
|
|
#elif defined(WRITE_NORMAL_BUFFER) || defined(WRITE_MSAA_DEPTH)
|
|
#define SV_TARGET_DECAL SV_Target1
|
|
#else
|
|
#define SV_TARGET_DECAL SV_Target0
|
|
#endif
|
|
|
|
void Frag( PackedVaryingsMeshToPS packedInput
|
|
#if defined(SCENESELECTIONPASS) || defined(SCENEPICKINGPASS)
|
|
, out float4 outColor : SV_Target0
|
|
#else
|
|
#ifdef WRITE_MSAA_DEPTH
|
|
, out float4 depthColor : SV_Target0
|
|
#ifdef WRITE_NORMAL_BUFFER
|
|
, out float4 outNormalBuffer : SV_Target1
|
|
#endif
|
|
#else
|
|
#ifdef WRITE_NORMAL_BUFFER
|
|
, out float4 outNormalBuffer : SV_Target0
|
|
#endif
|
|
#endif
|
|
|
|
#if defined(WRITE_DECAL_BUFFER) && !defined(_DISABLE_DECALS)
|
|
, out float4 outDecalBuffer : SV_TARGET_DECAL
|
|
#endif
|
|
#endif
|
|
|
|
#if defined(_DEPTHOFFSET_ON) && !defined(SCENEPICKINGPASS)
|
|
, out float outputDepth : DEPTH_OFFSET_SEMANTIC
|
|
#endif
|
|
|
|
)
|
|
{
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( packedInput );
|
|
UNITY_SETUP_INSTANCE_ID( packedInput );
|
|
|
|
float3 positionRWS = packedInput.positionRWS.xyz;
|
|
float3 normalWS = packedInput.normalWS.xyz;
|
|
float4 tangentWS = packedInput.tangentWS.xyzw;
|
|
|
|
FragInputs input;
|
|
ZERO_INITIALIZE(FragInputs, input);
|
|
|
|
input.tangentToWorld = k_identity3x3;
|
|
input.positionSS = packedInput.positionCS;
|
|
|
|
input.positionRWS = positionRWS;
|
|
input.tangentToWorld = BuildTangentToWorld(tangentWS, normalWS);
|
|
|
|
#if _DOUBLESIDED_ON && SHADER_STAGE_FRAGMENT
|
|
input.isFrontFace = IS_FRONT_VFACE( packedInput.cullFace, true, false);
|
|
#elif SHADER_STAGE_FRAGMENT
|
|
#if defined(ASE_NEED_CULLFACE)
|
|
input.isFrontFace = IS_FRONT_VFACE( packedInput.cullFace, true, false );
|
|
#endif
|
|
#endif
|
|
half isFrontFace = input.isFrontFace;
|
|
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS);
|
|
|
|
float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS);
|
|
|
|
SmoothSurfaceDescription surfaceDescription = (SmoothSurfaceDescription)0;
|
|
float4 _Control_ST_Instance = UNITY_ACCESS_INSTANCED_PROP(TerrainAmplifyFirstPass,_Control_ST);
|
|
float2 uv_Control = packedInput.ase_texcoord3.xy * _Control_ST_Instance.xy + _Control_ST_Instance.zw;
|
|
float4 tex2DNode5_g4 = tex2D( _Control, uv_Control );
|
|
float dotResult20_g4 = dot( tex2DNode5_g4 , float4(1,1,1,1) );
|
|
float SplatWeight22_g4 = dotResult20_g4;
|
|
float localSplatClip74_g4 = ( SplatWeight22_g4 );
|
|
float SplatWeight74_g4 = SplatWeight22_g4;
|
|
{
|
|
#if !defined(SHADER_API_MOBILE) && defined(TERRAIN_SPLAT_ADDPASS)
|
|
clip(SplatWeight74_g4 == 0.0f ? -1 : 1);
|
|
#endif
|
|
}
|
|
float4 SplatControl26_g4 = ( tex2DNode5_g4 / ( localSplatClip74_g4 + 0.001 ) );
|
|
float4 temp_output_59_0_g4 = SplatControl26_g4;
|
|
float4 _Splat0_ST_Instance = UNITY_ACCESS_INSTANCED_PROP(TerrainAmplifyFirstPass,_Splat0_ST);
|
|
float2 uv_Splat0 = packedInput.ase_texcoord3.xy * _Splat0_ST_Instance.xy + _Splat0_ST_Instance.zw;
|
|
float4 _Splat1_ST_Instance = UNITY_ACCESS_INSTANCED_PROP(TerrainAmplifyFirstPass,_Splat1_ST);
|
|
float2 uv_Splat1 = packedInput.ase_texcoord3.xy * _Splat1_ST_Instance.xy + _Splat1_ST_Instance.zw;
|
|
float4 _Splat2_ST_Instance = UNITY_ACCESS_INSTANCED_PROP(TerrainAmplifyFirstPass,_Splat2_ST);
|
|
float2 uv_Splat2 = packedInput.ase_texcoord3.xy * _Splat2_ST_Instance.xy + _Splat2_ST_Instance.zw;
|
|
float4 _Splat3_ST_Instance = UNITY_ACCESS_INSTANCED_PROP(TerrainAmplifyFirstPass,_Splat3_ST);
|
|
float2 uv_Splat3 = packedInput.ase_texcoord3.xy * _Splat3_ST_Instance.xy + _Splat3_ST_Instance.zw;
|
|
float4 weightedBlendVar8_g4 = temp_output_59_0_g4;
|
|
float4 weightedBlend8_g4 = ( weightedBlendVar8_g4.x*tex2D( _Normal0, uv_Splat0 ) + weightedBlendVar8_g4.y*tex2D( _Normal1, uv_Splat1 ) + weightedBlendVar8_g4.z*tex2D( _Normal2, uv_Splat2 ) + weightedBlendVar8_g4.w*tex2D( _Normal3, uv_Splat3 ) );
|
|
float3 temp_output_61_0_g4 = UnpackNormalScale( weightedBlend8_g4, 1.0 );
|
|
float2 temp_cast_3 = (( _TimeParameters.x * _WaterFlowSpeed )).xx;
|
|
float2 texCoord76 = packedInput.ase_texcoord3.xy * _Normal1Tilling + temp_cast_3;
|
|
float3 unpack59 = UnpackNormalScale( tex2D( _WaterFlowNormal, texCoord76 ), _NormalMapStrength );
|
|
unpack59.z = lerp( 1, unpack59.z, saturate(_NormalMapStrength) );
|
|
float2 temp_cast_4 = (( _TimeParameters.x * _WaterFlowSpeed1 )).xx;
|
|
float2 texCoord77 = packedInput.ase_texcoord3.xy * _Normal2Tilling + temp_cast_4;
|
|
float3 unpack66 = UnpackNormalScale( tex2D( _WaterFlowNormal1, texCoord77 ), _NormalMapStrength );
|
|
unpack66.z = lerp( 1, unpack66.z, saturate(_NormalMapStrength) );
|
|
float2 texCoord43 = packedInput.ase_texcoord3.xy * _RainReflections1 + float2( 0,0 );
|
|
float simpleNoise42 = SimpleNoise( texCoord43*_RainScale );
|
|
float smoothstepResult48 = smoothstep( 0.38 , 1.0 , simpleNoise42);
|
|
float2 texCoord117 = packedInput.ase_texcoord3.xy * _RippleTextureCoordinatesTilling + float2( 0,0 );
|
|
float2 break135_g5 = texCoord117;
|
|
float2 appendResult136_g5 = (float2(break135_g5.x , ( 1.0 - break135_g5.y )));
|
|
float2 FlipBookUV141_g5 = appendResult136_g5;
|
|
float FlipBookColumns143_g5 = 4.0;
|
|
float FlipBookRows144_g5 = 4.0;
|
|
float2 appendResult83_g5 = (float2(FlipBookColumns143_g5 , FlipBookRows144_g5));
|
|
float temp_output_104_0_g5 = ( FlipBookColumns143_g5 * FlipBookRows144_g5 );
|
|
float2 appendResult95_g5 = (float2(temp_output_104_0_g5 , FlipBookRows144_g5));
|
|
float mulTime99 = _TimeParameters.x * _RippleFPS;
|
|
float FlipBookSpeed145_g5 = ( _TimeParameters.x * mulTime99 );
|
|
float FlipBookID142_g5 = 0.0;
|
|
float clampResult108_g5 = clamp( FlipBookID142_g5 , 0.0001 , ( temp_output_104_0_g5 - 1.0 ) );
|
|
float temp_output_92_0_g5 = frac( ( ( FlipBookSpeed145_g5 + clampResult108_g5 ) / temp_output_104_0_g5 ) );
|
|
float2 appendResult93_g5 = (float2(temp_output_92_0_g5 , ( temp_output_92_0_g5 - -0.01 )));
|
|
float2 break105_g5 = ( ( FlipBookUV141_g5 / appendResult83_g5 ) + ( floor( ( appendResult95_g5 * appendResult93_g5 ) ) / appendResult83_g5 ) );
|
|
float2 appendResult139_g5 = (float2(break105_g5.x , ( 1.0 - break105_g5.y )));
|
|
float3 unpack98 = UnpackNormalScale( tex2D( _RippleNormal, appendResult139_g5 ), _RippleNormalStrength );
|
|
unpack98.z = lerp( 1, unpack98.z, saturate(_RippleNormalStrength) );
|
|
|
|
float2 texCoord80 = packedInput.ase_texcoord3.xy * _RainReflections + float2( 0,0 );
|
|
float simpleNoise82 = SimpleNoise( texCoord80*_RainScale );
|
|
float smoothstepResult81 = smoothstep( 0.38 , 1.0 , simpleNoise82);
|
|
|
|
surfaceDescription.Normal = ( ( temp_output_61_0_g4 + ( ( unpack59 + unpack66 ) * smoothstepResult48 ) ) + unpack98 );
|
|
surfaceDescription.Smoothness = ( 0.0 + ( ( smoothstepResult81 * _RainOpacity ) + _Smoothness ) );
|
|
surfaceDescription.Alpha = 1;
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
surfaceDescription.AlphaClipThreshold = _AlphaCutoff;
|
|
#endif
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
surfaceDescription.DepthOffset = 0;
|
|
#endif
|
|
|
|
SurfaceData surfaceData;
|
|
BuiltinData builtinData;
|
|
GetSurfaceAndBuiltinData(surfaceDescription, input, V, posInput, surfaceData, builtinData);
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
outputDepth = posInput.deviceDepth;
|
|
#endif
|
|
|
|
#ifdef WRITE_MSAA_DEPTH
|
|
depthColor = packedInput.positionCS.z;
|
|
#ifdef _ALPHATOMASK_ON
|
|
depthColor.a = SharpenAlpha(builtinData.opacity, builtinData.alphaClipTreshold);
|
|
#endif
|
|
#endif
|
|
|
|
#if defined(WRITE_NORMAL_BUFFER)
|
|
EncodeIntoNormalBuffer(ConvertSurfaceDataToNormalData(surfaceData), outNormalBuffer);
|
|
#endif
|
|
|
|
#if defined(WRITE_DECAL_BUFFER) && !defined(_DISABLE_DECALS)
|
|
DecalPrepassData decalPrepassData;
|
|
decalPrepassData.geomNormalWS = surfaceData.geomNormalWS;
|
|
decalPrepassData.decalLayerMask = GetMeshRenderingDecalLayer();
|
|
EncodeIntoDecalPrepassBuffer(decalPrepassData, outDecalBuffer);
|
|
#endif
|
|
}
|
|
|
|
ENDHLSL
|
|
}
|
|
|
|
UsePass "Hidden/Nature/Terrain/Utilities/PICKING"
|
|
UsePass "Hidden/Nature/Terrain/Utilities/SELECTION"
|
|
|
|
Pass
|
|
{
|
|
|
|
Name "Forward"
|
|
Tags { "LightMode"="Forward" }
|
|
|
|
Blend [_SrcBlend] [_DstBlend], [_AlphaSrcBlend] [_AlphaDstBlend]
|
|
|
|
|
|
|
|
Cull [_CullModeForward]
|
|
ZTest [_ZTestDepthEqualForOpaque]
|
|
ZWrite [_ZWrite]
|
|
|
|
Stencil
|
|
{
|
|
Ref [_StencilRef]
|
|
WriteMask [_StencilWriteMask]
|
|
Comp Always
|
|
Pass Replace
|
|
}
|
|
|
|
|
|
|
|
ColorMask [_ColorMaskTransparentVelOne] 1
|
|
|
|
|
|
|
|
|
|
HLSLPROGRAM
|
|
|
|
#define _SPECULAR_OCCLUSION_FROM_AO 1
|
|
#pragma instancing_options renderinglayer
|
|
#define shader_feature_local _DISABLE_DECALS
|
|
#define shader_feature_local_raytracing _DISABLE_SSR
|
|
#define shader_feature_local_fragment _DISABLE_SSR
|
|
#define ASE_SRP_VERSION 170003
|
|
|
|
|
|
#pragma shader_feature _SURFACE_TYPE_TRANSPARENT
|
|
#pragma shader_feature_local _TRANSPARENT_WRITES_MOTION_VEC
|
|
#pragma shader_feature_local_fragment _ENABLE_FOG_ON_TRANSPARENT
|
|
|
|
#pragma multi_compile_fragment _ SHADOWS_SHADOWMASK
|
|
#pragma multi_compile_fragment SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH SHADOW_VERY_HIGH
|
|
#pragma multi_compile_fragment PROBE_VOLUMES_OFF PROBE_VOLUMES_L1 PROBE_VOLUMES_L2
|
|
#pragma multi_compile_fragment SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON
|
|
#pragma multi_compile_fragment USE_FPTL_LIGHTLIST USE_CLUSTERED_LIGHTLIST
|
|
#pragma multi_compile _ DEBUG_DISPLAY
|
|
#pragma multi_compile _ LIGHTMAP_ON
|
|
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
|
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
|
|
#pragma multi_compile_fragment DECALS_OFF DECALS_3RT DECALS_4RT
|
|
#pragma multi_compile_fragment _ DECAL_SURFACE_GRADIENT
|
|
|
|
#ifndef SHADER_STAGE_FRAGMENT
|
|
#define SHADOW_LOW
|
|
#define USE_FPTL_LIGHTLIST
|
|
#endif
|
|
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/GeometricTools.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Tessellation.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
|
|
#include "Packages/com.unity.shadergraph/ShaderGraphLibrary/Functions.hlsl"
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
|
|
#define SHADERPASS SHADERPASS_FORWARD
|
|
#define HAS_LIGHTLOOP 1
|
|
|
|
// Setup for Fog Enabled to apply in sky refletions in LightLoopDef.hlsl
|
|
#define APPLY_FOG_ON_SKY_REFLECTIONS
|
|
|
|
#ifndef SHADER_UNLIT
|
|
#if defined(_DOUBLESIDED_ON) && !defined(VARYINGS_NEED_CULLFACE)
|
|
#define VARYINGS_NEED_CULLFACE
|
|
#endif
|
|
#endif
|
|
|
|
#if defined(_MATERIAL_FEATURE_SUBSURFACE_SCATTERING) && !defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define OUTPUT_SPLIT_LIGHTING
|
|
#endif
|
|
|
|
#if (SHADERPASS == SHADERPASS_PATH_TRACING) && !defined(_DOUBLESIDED_ON) && (defined(_REFRACTION_PLANE) || defined(_REFRACTION_SPHERE))
|
|
#undef _REFRACTION_PLANE
|
|
#undef _REFRACTION_SPHERE
|
|
#define _REFRACTION_THIN
|
|
#endif
|
|
|
|
#if SHADERPASS == SHADERPASS_TRANSPARENT_DEPTH_PREPASS
|
|
#if !defined(_DISABLE_SSR_TRANSPARENT) && !defined(SHADER_UNLIT)
|
|
#define WRITE_NORMAL_BUFFER
|
|
#endif
|
|
#endif
|
|
|
|
#ifndef DEBUG_DISPLAY
|
|
#if !defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#if SHADERPASS == SHADERPASS_FORWARD
|
|
#define SHADERPASS_FORWARD_BYPASS_ALPHA_TEST
|
|
#elif SHADERPASS == SHADERPASS_GBUFFER
|
|
#define SHADERPASS_GBUFFER_BYPASS_ALPHA_TEST
|
|
#endif
|
|
#endif
|
|
#endif
|
|
|
|
#if defined(SHADER_LIT) && !defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define _DEFERRED_CAPABLE_MATERIAL
|
|
#endif
|
|
|
|
#if defined(_TRANSPARENT_WRITES_MOTION_VEC) && defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define _WRITE_TRANSPARENT_MOTION_VECTOR
|
|
#endif
|
|
|
|
CBUFFER_START( UnityPerMaterial )
|
|
float2 _RainReflections;
|
|
float2 _Normal1Tilling;
|
|
float2 _RippleTextureCoordinatesTilling;
|
|
float2 _Normal2Tilling;
|
|
float2 _RainReflections1;
|
|
float _Smoothness0;
|
|
float _Float10;
|
|
float _RippleNormalStrength;
|
|
float _RippleFPS;
|
|
float _RainScale;
|
|
float _WaterFlowSpeed1;
|
|
float _NormalMapStrength;
|
|
float _WaterFlowSpeed;
|
|
float _Smoothness3;
|
|
float _Smoothness2;
|
|
float _Smoothness1;
|
|
float _RainOpacity;
|
|
float _Smoothness;
|
|
float4 _EmissionColor;
|
|
float _AlphaCutoff;
|
|
float _RenderQueueType;
|
|
#ifdef _ADD_PRECOMPUTED_VELOCITY
|
|
float _AddPrecomputedVelocity;
|
|
#endif
|
|
float _StencilRef;
|
|
float _StencilWriteMask;
|
|
float _StencilRefDepth;
|
|
float _StencilWriteMaskDepth;
|
|
float _StencilRefMV;
|
|
float _StencilWriteMaskMV;
|
|
float _StencilWriteMaskGBuffer;
|
|
float _StencilRefGBuffer;
|
|
float _ZTestGBuffer;
|
|
float _RequireSplitLighting;
|
|
float _ReceivesSSR;
|
|
float _SurfaceType;
|
|
float _BlendMode;
|
|
#ifdef SUPPORT_BLENDMODE_PRESERVE_SPECULAR_LIGHTING
|
|
float _EnableBlendModePreserveSpecularLighting;
|
|
#endif
|
|
float _SrcBlend;
|
|
float _DstBlend;
|
|
float _AlphaSrcBlend;
|
|
float _AlphaDstBlend;
|
|
float _ZWrite;
|
|
float _TransparentZWrite;
|
|
float _CullMode;
|
|
float _TransparentSortPriority;
|
|
float _EnableFogOnTransparent;
|
|
float _CullModeForward;
|
|
float _TransparentCullMode;
|
|
float _ZTestDepthEqualForOpaque;
|
|
float _ZTestTransparent;
|
|
float _TransparentBackfaceEnable;
|
|
float _AlphaCutoffEnable;
|
|
float _UseShadowThreshold;
|
|
float _DoubleSidedEnable;
|
|
float _DoubleSidedNormalMode;
|
|
float4 _DoubleSidedConstants;
|
|
#ifdef ASE_TESSELLATION
|
|
float _TessPhongStrength;
|
|
float _TessValue;
|
|
float _TessMin;
|
|
float _TessMax;
|
|
float _TessEdgeLength;
|
|
float _TessMaxDisp;
|
|
#endif
|
|
CBUFFER_END
|
|
|
|
// Property used by ScenePickingPass
|
|
#ifdef SCENEPICKINGPASS
|
|
float4 _SelectionID;
|
|
#endif
|
|
|
|
// Properties used by SceneSelectionPass
|
|
#ifdef SCENESELECTIONPASS
|
|
int _ObjectId;
|
|
int _PassValue;
|
|
#endif
|
|
|
|
sampler2D _Mask2;
|
|
sampler2D _Mask0;
|
|
sampler2D _Mask1;
|
|
sampler2D _Mask3;
|
|
float4 _MaskMapRemapScale0;
|
|
float4 _MaskMapRemapOffset2;
|
|
float4 _MaskMapRemapScale2;
|
|
float4 _MaskMapRemapScale1;
|
|
float4 _MaskMapRemapOffset1;
|
|
float4 _MaskMapRemapScale3;
|
|
float4 _MaskMapRemapOffset3;
|
|
float4 _MaskMapRemapOffset0;
|
|
sampler2D _Control;
|
|
sampler2D _Splat0;
|
|
sampler2D _Splat1;
|
|
sampler2D _Splat2;
|
|
sampler2D _Splat3;
|
|
sampler2D _TerrainHolesTexture;
|
|
sampler2D _Normal0;
|
|
sampler2D _Normal1;
|
|
sampler2D _Normal2;
|
|
sampler2D _Normal3;
|
|
sampler2D _WaterFlowNormal;
|
|
sampler2D _WaterFlowNormal1;
|
|
sampler2D _RippleNormal;
|
|
#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing
|
|
TEXTURE2D(_TerrainHeightmapTexture);//ASE Terrain Instancing
|
|
TEXTURE2D( _TerrainNormalmapTexture);//ASE Terrain Instancing
|
|
SAMPLER(sampler_TerrainNormalmapTexture);//ASE Terrain Instancing
|
|
#endif//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_START( Terrain )//ASE Terrain Instancing
|
|
UNITY_DEFINE_INSTANCED_PROP( float4, _TerrainPatchInstanceData )//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_END( Terrain)//ASE Terrain Instancing
|
|
CBUFFER_START( UnityTerrain)//ASE Terrain Instancing
|
|
#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing
|
|
float4 _TerrainHeightmapRecipSize;//ASE Terrain Instancing
|
|
float4 _TerrainHeightmapScale;//ASE Terrain Instancing
|
|
#endif//ASE Terrain Instancing
|
|
CBUFFER_END//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_START(TerrainAmplifyFirstPass)
|
|
UNITY_DEFINE_INSTANCED_PROP(float4, _Control_ST)
|
|
UNITY_DEFINE_INSTANCED_PROP(float4, _Splat0_ST)
|
|
UNITY_DEFINE_INSTANCED_PROP(float4, _Splat1_ST)
|
|
UNITY_DEFINE_INSTANCED_PROP(float4, _Splat2_ST)
|
|
UNITY_DEFINE_INSTANCED_PROP(float4, _Splat3_ST)
|
|
UNITY_DEFINE_INSTANCED_PROP(float4, _TerrainHolesTexture_ST)
|
|
UNITY_INSTANCING_BUFFER_END(TerrainAmplifyFirstPass)
|
|
|
|
|
|
#ifdef DEBUG_DISPLAY
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
|
|
#endif
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/NormalSurfaceGradient.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
|
|
// Setup DECALS_OFF so the shader stripper can remove variants
|
|
#define HAVE_DECALS ( (defined(DECALS_3RT) || defined(DECALS_4RT)) && !defined(_DISABLE_DECALS) )
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitDecalData.hlsl"
|
|
|
|
#define ASE_NEEDS_VERT_NORMAL
|
|
#define ASE_NEEDS_VERT_POSITION
|
|
#pragma multi_compile_instancing
|
|
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap forwardadd
|
|
#pragma multi_compile_local __ _ALPHATEST_ON
|
|
#pragma shader_feature_local _MASKMAP
|
|
|
|
|
|
#if defined(_DOUBLESIDED_ON) && !defined(ASE_NEED_CULLFACE)
|
|
#define ASE_NEED_CULLFACE 1
|
|
#endif
|
|
|
|
struct AttributesMesh
|
|
{
|
|
float3 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
float4 tangentOS : TANGENT;
|
|
float4 uv1 : TEXCOORD1;
|
|
float4 uv2 : TEXCOORD2;
|
|
float3 previousPositionOS : TEXCOORD4;
|
|
float3 precomputedVelocity : TEXCOORD5;
|
|
float4 ase_texcoord : TEXCOORD0;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct PackedVaryingsMeshToPS
|
|
{
|
|
SV_POSITION_QUALIFIERS float4 positionCS : SV_Position;
|
|
float3 positionRWS : TEXCOORD0;
|
|
float3 normalWS : TEXCOORD1;
|
|
float4 tangentWS : TEXCOORD2;
|
|
float4 uv1 : TEXCOORD3;
|
|
float4 uv2 : TEXCOORD4;
|
|
#ifdef _WRITE_TRANSPARENT_MOTION_VECTOR
|
|
float3 vpassPositionCS : TEXCOORD5;
|
|
float3 vpassPreviousPositionCS : TEXCOORD6;
|
|
#endif
|
|
float4 ase_texcoord7 : TEXCOORD7;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
#if defined(SHADER_STAGE_FRAGMENT) && defined(ASE_NEED_CULLFACE)
|
|
FRONT_FACE_TYPE cullFace : FRONT_FACE_SEMANTIC;
|
|
#endif
|
|
};
|
|
|
|
inline float noise_randomValue (float2 uv) { return frac(sin(dot(uv, float2(12.9898, 78.233)))*43758.5453); }
|
|
inline float noise_interpolate (float a, float b, float t) { return (1.0-t)*a + (t*b); }
|
|
inline float valueNoise (float2 uv)
|
|
{
|
|
float2 i = floor(uv);
|
|
float2 f = frac( uv );
|
|
f = f* f * (3.0 - 2.0 * f);
|
|
uv = abs( frac(uv) - 0.5);
|
|
float2 c0 = i + float2( 0.0, 0.0 );
|
|
float2 c1 = i + float2( 1.0, 0.0 );
|
|
float2 c2 = i + float2( 0.0, 1.0 );
|
|
float2 c3 = i + float2( 1.0, 1.0 );
|
|
float r0 = noise_randomValue( c0 );
|
|
float r1 = noise_randomValue( c1 );
|
|
float r2 = noise_randomValue( c2 );
|
|
float r3 = noise_randomValue( c3 );
|
|
float bottomOfGrid = noise_interpolate( r0, r1, f.x );
|
|
float topOfGrid = noise_interpolate( r2, r3, f.x );
|
|
float t = noise_interpolate( bottomOfGrid, topOfGrid, f.y );
|
|
return t;
|
|
}
|
|
|
|
float SimpleNoise(float2 UV)
|
|
{
|
|
float t = 0.0;
|
|
float freq = pow( 2.0, float( 0 ) );
|
|
float amp = pow( 0.5, float( 3 - 0 ) );
|
|
t += valueNoise( UV/freq )*amp;
|
|
freq = pow(2.0, float(1));
|
|
amp = pow(0.5, float(3-1));
|
|
t += valueNoise( UV/freq )*amp;
|
|
freq = pow(2.0, float(2));
|
|
amp = pow(0.5, float(3-2));
|
|
t += valueNoise( UV/freq )*amp;
|
|
return t;
|
|
}
|
|
|
|
AttributesMesh ApplyMeshModification( AttributesMesh inputMesh )
|
|
{
|
|
#ifdef UNITY_INSTANCING_ENABLED
|
|
float2 patchVertex = inputMesh.positionOS.xy;
|
|
float4 instanceData = UNITY_ACCESS_INSTANCED_PROP( Terrain, _TerrainPatchInstanceData );
|
|
float2 sampleCoords = ( patchVertex.xy + instanceData.xy ) * instanceData.z;
|
|
float height = UnpackHeightmap( _TerrainHeightmapTexture.Load( int3( sampleCoords, 0 ) ) );
|
|
inputMesh.positionOS.xz = sampleCoords* _TerrainHeightmapScale.xz;
|
|
inputMesh.positionOS.y = height* _TerrainHeightmapScale.y;
|
|
#ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL
|
|
inputMesh.normalOS = float3(0, 1, 0);
|
|
#else
|
|
inputMesh.normalOS = _TerrainNormalmapTexture.Load(int3(sampleCoords, 0)).rgb* 2 - 1;
|
|
#endif
|
|
inputMesh.ase_texcoord.xy = sampleCoords* _TerrainHeightmapRecipSize.zw;
|
|
#endif
|
|
return inputMesh;
|
|
}
|
|
|
|
|
|
void BuildSurfaceData(FragInputs fragInputs, inout GlobalSurfaceDescription surfaceDescription, float3 V, PositionInputs posInput, out SurfaceData surfaceData, out float3 bentNormalWS)
|
|
{
|
|
ZERO_INITIALIZE(SurfaceData, surfaceData);
|
|
|
|
surfaceData.specularOcclusion = 1.0;
|
|
|
|
// surface data
|
|
surfaceData.baseColor = surfaceDescription.BaseColor;
|
|
surfaceData.perceptualSmoothness = surfaceDescription.Smoothness;
|
|
surfaceData.ambientOcclusion = surfaceDescription.Occlusion;
|
|
surfaceData.metallic = surfaceDescription.Metallic;
|
|
surfaceData.coatMask = surfaceDescription.CoatMask;
|
|
|
|
#ifdef _SPECULAR_OCCLUSION_CUSTOM
|
|
surfaceData.specularOcclusion = surfaceDescription.SpecularOcclusion;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
|
|
surfaceData.subsurfaceMask = surfaceDescription.SubsurfaceMask;
|
|
#endif
|
|
#if defined(_HAS_REFRACTION) || defined(_MATERIAL_FEATURE_TRANSMISSION)
|
|
surfaceData.thickness = surfaceDescription.Thickness;
|
|
#endif
|
|
#if defined( _MATERIAL_FEATURE_SUBSURFACE_SCATTERING ) || defined( _MATERIAL_FEATURE_TRANSMISSION )
|
|
surfaceData.diffusionProfileHash = asuint(surfaceDescription.DiffusionProfile);
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_SPECULAR_COLOR
|
|
surfaceData.specularColor = surfaceDescription.Specular;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_ANISOTROPY
|
|
surfaceData.anisotropy = surfaceDescription.Anisotropy;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_IRIDESCENCE
|
|
surfaceData.iridescenceMask = surfaceDescription.IridescenceMask;
|
|
surfaceData.iridescenceThickness = surfaceDescription.IridescenceThickness;
|
|
#endif
|
|
|
|
// refraction
|
|
#ifdef _HAS_REFRACTION
|
|
if( _EnableSSRefraction )
|
|
{
|
|
surfaceData.ior = surfaceDescription.RefractionIndex;
|
|
surfaceData.transmittanceColor = surfaceDescription.RefractionColor;
|
|
surfaceData.atDistance = surfaceDescription.RefractionDistance;
|
|
|
|
surfaceData.transmittanceMask = ( 1.0 - surfaceDescription.Alpha );
|
|
surfaceDescription.Alpha = 1.0;
|
|
}
|
|
else
|
|
{
|
|
surfaceData.ior = 1.0;
|
|
surfaceData.transmittanceColor = float3( 1.0, 1.0, 1.0 );
|
|
surfaceData.atDistance = 1.0;
|
|
surfaceData.transmittanceMask = 0.0;
|
|
surfaceDescription.Alpha = 1.0;
|
|
}
|
|
#else
|
|
surfaceData.ior = 1.0;
|
|
surfaceData.transmittanceColor = float3( 1.0, 1.0, 1.0 );
|
|
surfaceData.atDistance = 1.0;
|
|
surfaceData.transmittanceMask = 0.0;
|
|
#endif
|
|
|
|
|
|
// material features
|
|
surfaceData.materialFeatures = MATERIALFEATUREFLAGS_LIT_STANDARD;
|
|
#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SUBSURFACE_SCATTERING;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_TRANSMISSION
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_TRANSMISSION;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_ANISOTROPY
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_ANISOTROPY;
|
|
surfaceData.normalWS = float3(0, 1, 0);
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_CLEAR_COAT
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_CLEAR_COAT;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_IRIDESCENCE
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_IRIDESCENCE;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_SPECULAR_COLOR
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SPECULAR_COLOR;
|
|
#endif
|
|
|
|
// others
|
|
#if defined (_MATERIAL_FEATURE_SPECULAR_COLOR) && defined (_ENERGY_CONSERVING_SPECULAR)
|
|
surfaceData.baseColor *= ( 1.0 - Max3( surfaceData.specularColor.r, surfaceData.specularColor.g, surfaceData.specularColor.b ) );
|
|
#endif
|
|
#ifdef _DOUBLESIDED_ON
|
|
float3 doubleSidedConstants = _DoubleSidedConstants.xyz;
|
|
#else
|
|
float3 doubleSidedConstants = float3( 1.0, 1.0, 1.0 );
|
|
#endif
|
|
|
|
// normals
|
|
float3 normalTS = float3(0.0f, 0.0f, 1.0f);
|
|
normalTS = surfaceDescription.Normal;
|
|
GetNormalWS( fragInputs, normalTS, surfaceData.normalWS, doubleSidedConstants );
|
|
|
|
surfaceData.geomNormalWS = fragInputs.tangentToWorld[2];
|
|
surfaceData.tangentWS = normalize( fragInputs.tangentToWorld[ 0 ].xyz );
|
|
|
|
// decals
|
|
#if HAVE_DECALS
|
|
if( _EnableDecals )
|
|
{
|
|
DecalSurfaceData decalSurfaceData = GetDecalSurfaceData(posInput, fragInputs, surfaceDescription.Alpha);
|
|
ApplyDecalToSurfaceData(decalSurfaceData, fragInputs.tangentToWorld[2], surfaceData);
|
|
}
|
|
#endif
|
|
|
|
bentNormalWS = surfaceData.normalWS;
|
|
|
|
#ifdef ASE_BENT_NORMAL
|
|
GetNormalWS( fragInputs, surfaceDescription.BentNormal, bentNormalWS, doubleSidedConstants );
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_ANISOTROPY
|
|
surfaceData.tangentWS = TransformTangentToWorld( surfaceDescription.Tangent, fragInputs.tangentToWorld );
|
|
#endif
|
|
surfaceData.tangentWS = Orthonormalize( surfaceData.tangentWS, surfaceData.normalWS );
|
|
|
|
|
|
#if defined(_SPECULAR_OCCLUSION_CUSTOM)
|
|
#elif defined(_SPECULAR_OCCLUSION_FROM_AO_BENT_NORMAL)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromBentAO(V, bentNormalWS, surfaceData.normalWS, surfaceData.ambientOcclusion, PerceptualSmoothnessToPerceptualRoughness(surfaceData.perceptualSmoothness));
|
|
#elif defined(_AMBIENT_OCCLUSION) && defined(_SPECULAR_OCCLUSION_FROM_AO)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromAmbientOcclusion(ClampNdotV(dot(surfaceData.normalWS, V)), surfaceData.ambientOcclusion, PerceptualSmoothnessToRoughness(surfaceData.perceptualSmoothness));
|
|
#endif
|
|
|
|
#ifdef _ENABLE_GEOMETRIC_SPECULAR_AA
|
|
surfaceData.perceptualSmoothness = GeometricNormalFiltering( surfaceData.perceptualSmoothness, fragInputs.tangentToWorld[ 2 ], surfaceDescription.SpecularAAScreenSpaceVariance, surfaceDescription.SpecularAAThreshold );
|
|
#endif
|
|
|
|
// debug
|
|
#if defined(DEBUG_DISPLAY)
|
|
if (_DebugMipMapMode != DEBUGMIPMAPMODE_NONE)
|
|
{
|
|
surfaceData.metallic = 0;
|
|
}
|
|
ApplyDebugToSurfaceData(fragInputs.tangentToWorld, surfaceData);
|
|
#endif
|
|
}
|
|
|
|
void GetSurfaceAndBuiltinData(GlobalSurfaceDescription surfaceDescription, FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
|
|
{
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
LODDitheringTransition(ComputeFadeMaskSeed(V, posInput.positionSS), unity_LODFade.x);
|
|
#endif
|
|
|
|
#ifdef _DOUBLESIDED_ON
|
|
float3 doubleSidedConstants = _DoubleSidedConstants.xyz;
|
|
#else
|
|
float3 doubleSidedConstants = float3( 1.0, 1.0, 1.0 );
|
|
#endif
|
|
|
|
ApplyDoubleSidedFlipOrMirror( fragInputs, doubleSidedConstants );
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
DoAlphaTest( surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold );
|
|
#endif
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
ApplyDepthOffsetPositionInput( V, surfaceDescription.DepthOffset, GetViewForwardDir(), GetWorldToHClipMatrix(), posInput );
|
|
#endif
|
|
|
|
float3 bentNormalWS;
|
|
BuildSurfaceData( fragInputs, surfaceDescription, V, posInput, surfaceData, bentNormalWS );
|
|
|
|
InitBuiltinData( posInput, surfaceDescription.Alpha, bentNormalWS, -fragInputs.tangentToWorld[ 2 ], fragInputs.texCoord1, fragInputs.texCoord2, builtinData );
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
builtinData.depthOffset = surfaceDescription.DepthOffset;
|
|
#endif
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
builtinData.alphaClipTreshold = surfaceDescription.AlphaClipThreshold;
|
|
#endif
|
|
|
|
#ifdef UNITY_VIRTUAL_TEXTURING
|
|
builtinData.vtPackedFeedback = surfaceDescription.VTPackedFeedback;
|
|
#endif
|
|
|
|
#ifdef ASE_BAKEDGI
|
|
builtinData.bakeDiffuseLighting = surfaceDescription.BakedGI;
|
|
#endif
|
|
|
|
#ifdef ASE_BAKEDBACKGI
|
|
builtinData.backBakeDiffuseLighting = surfaceDescription.BakedBackGI;
|
|
#endif
|
|
|
|
builtinData.emissiveColor = surfaceDescription.Emission;
|
|
|
|
PostInitBuiltinData(V, posInput, surfaceData, builtinData);
|
|
}
|
|
|
|
AttributesMesh ApplyMeshModification(AttributesMesh inputMesh, float3 timeParameters, inout PackedVaryingsMeshToPS outputPackedVaryingsMeshToPS )
|
|
{
|
|
_TimeParameters.xyz = timeParameters;
|
|
inputMesh = ApplyMeshModification(inputMesh);
|
|
outputPackedVaryingsMeshToPS.ase_texcoord7.xy = inputMesh.ase_texcoord.xy;
|
|
|
|
//setting value to unused interpolator channels and avoid initialization warnings
|
|
outputPackedVaryingsMeshToPS.ase_texcoord7.zw = 0;
|
|
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = inputMesh.positionOS.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3( 0, 0, 0 );
|
|
#endif
|
|
float3 vertexValue = defaultVertexValue;
|
|
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
inputMesh.positionOS.xyz = vertexValue;
|
|
#else
|
|
inputMesh.positionOS.xyz += vertexValue;
|
|
#endif
|
|
inputMesh.normalOS = inputMesh.normalOS;
|
|
inputMesh.tangentOS = inputMesh.tangentOS;
|
|
return inputMesh;
|
|
}
|
|
|
|
PackedVaryingsMeshToPS VertexFunction(AttributesMesh inputMesh)
|
|
{
|
|
PackedVaryingsMeshToPS outputPackedVaryingsMeshToPS = (PackedVaryingsMeshToPS)0;
|
|
AttributesMesh defaultMesh = inputMesh;
|
|
|
|
UNITY_SETUP_INSTANCE_ID(inputMesh);
|
|
UNITY_TRANSFER_INSTANCE_ID(inputMesh, outputPackedVaryingsMeshToPS);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( outputPackedVaryingsMeshToPS );
|
|
|
|
inputMesh = ApplyMeshModification( inputMesh, _TimeParameters.xyz, outputPackedVaryingsMeshToPS);
|
|
|
|
float3 positionRWS = TransformObjectToWorld(inputMesh.positionOS);
|
|
float3 normalWS = TransformObjectToWorldNormal(inputMesh.normalOS);
|
|
float4 tangentWS = float4(TransformObjectToWorldDir(inputMesh.tangentOS.xyz), inputMesh.tangentOS.w);
|
|
|
|
#ifdef _WRITE_TRANSPARENT_MOTION_VECTOR
|
|
float4 VPASSpreviousPositionCS;
|
|
float4 VPASSpositionCS = mul(UNITY_MATRIX_UNJITTERED_VP, float4(positionRWS, 1.0));
|
|
|
|
bool forceNoMotion = unity_MotionVectorsParams.y == 0.0;
|
|
if (forceNoMotion)
|
|
{
|
|
VPASSpreviousPositionCS = float4(0.0, 0.0, 0.0, 1.0);
|
|
}
|
|
else
|
|
{
|
|
bool hasDeformation = unity_MotionVectorsParams.x > 0.0;
|
|
float3 effectivePositionOS = (hasDeformation ? inputMesh.previousPositionOS : defaultMesh.positionOS);
|
|
#if defined(_ADD_PRECOMPUTED_VELOCITY)
|
|
effectivePositionOS -= inputMesh.precomputedVelocity;
|
|
#endif
|
|
|
|
#if defined(HAVE_MESH_MODIFICATION)
|
|
AttributesMesh previousMesh = defaultMesh;
|
|
previousMesh.positionOS = effectivePositionOS ;
|
|
PackedVaryingsMeshToPS test = (PackedVaryingsMeshToPS)0;
|
|
float3 curTime = _TimeParameters.xyz;
|
|
previousMesh = ApplyMeshModification(previousMesh, _LastTimeParameters.xyz, test);
|
|
_TimeParameters.xyz = curTime;
|
|
float3 previousPositionRWS = TransformPreviousObjectToWorld(previousMesh.positionOS);
|
|
#else
|
|
float3 previousPositionRWS = TransformPreviousObjectToWorld(effectivePositionOS);
|
|
#endif
|
|
|
|
#ifdef ATTRIBUTES_NEED_NORMAL
|
|
float3 normalWS = TransformPreviousObjectToWorldNormal(defaultMesh.normalOS);
|
|
#else
|
|
float3 normalWS = float3(0.0, 0.0, 0.0);
|
|
#endif
|
|
|
|
#if defined(HAVE_VERTEX_MODIFICATION)
|
|
ApplyVertexModification(inputMesh, normalWS, previousPositionRWS, _LastTimeParameters.xyz);
|
|
#endif
|
|
|
|
VPASSpreviousPositionCS = mul(UNITY_MATRIX_PREV_VP, float4(previousPositionRWS, 1.0));
|
|
}
|
|
#endif
|
|
|
|
outputPackedVaryingsMeshToPS.positionCS = TransformWorldToHClip(positionRWS);
|
|
outputPackedVaryingsMeshToPS.positionRWS.xyz = positionRWS;
|
|
outputPackedVaryingsMeshToPS.normalWS.xyz = normalWS;
|
|
outputPackedVaryingsMeshToPS.tangentWS.xyzw = tangentWS;
|
|
outputPackedVaryingsMeshToPS.uv1.xyzw = inputMesh.uv1;
|
|
outputPackedVaryingsMeshToPS.uv2.xyzw = inputMesh.uv2;
|
|
|
|
#ifdef _WRITE_TRANSPARENT_MOTION_VECTOR
|
|
outputPackedVaryingsMeshToPS.vpassPositionCS = float3(VPASSpositionCS.xyw);
|
|
outputPackedVaryingsMeshToPS.vpassPreviousPositionCS = float3(VPASSpreviousPositionCS.xyw);
|
|
#endif
|
|
return outputPackedVaryingsMeshToPS;
|
|
}
|
|
|
|
#if defined(ASE_TESSELLATION)
|
|
struct VertexControl
|
|
{
|
|
float3 positionOS : INTERNALTESSPOS;
|
|
float3 normalOS : NORMAL;
|
|
float4 tangentOS : TANGENT;
|
|
float4 uv1 : TEXCOORD1;
|
|
float4 uv2 : TEXCOORD2;
|
|
float4 ase_texcoord : TEXCOORD0;
|
|
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct TessellationFactors
|
|
{
|
|
float edge[3] : SV_TessFactor;
|
|
float inside : SV_InsideTessFactor;
|
|
};
|
|
|
|
VertexControl Vert ( AttributesMesh v )
|
|
{
|
|
VertexControl o;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
o.positionOS = v.positionOS;
|
|
o.normalOS = v.normalOS;
|
|
o.tangentOS = v.tangentOS;
|
|
o.uv1 = v.uv1;
|
|
o.uv2 = v.uv2;
|
|
o.ase_texcoord = v.ase_texcoord;
|
|
return o;
|
|
}
|
|
|
|
TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
|
|
{
|
|
TessellationFactors o;
|
|
float4 tf = 1;
|
|
float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
|
|
float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
|
|
#if (SHADEROPTIONS_CAMERA_RELATIVE_RENDERING != 0)
|
|
float3 cameraPos = 0;
|
|
#else
|
|
float3 cameraPos = _WorldSpaceCameraPos;
|
|
#endif
|
|
#if defined(ASE_FIXED_TESSELLATION)
|
|
tf = FixedTess( tessValue );
|
|
#elif defined(ASE_DISTANCE_TESSELLATION)
|
|
tf = DistanceBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), cameraPos );
|
|
#elif defined(ASE_LENGTH_TESSELLATION)
|
|
tf = EdgeLengthBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, GetObjectToWorldMatrix(), cameraPos, _ScreenParams );
|
|
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
|
tf = EdgeLengthBasedTessCull(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), cameraPos, _ScreenParams, _FrustumPlanes );
|
|
#endif
|
|
o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
|
|
return o;
|
|
}
|
|
|
|
[domain("tri")]
|
|
[partitioning("fractional_odd")]
|
|
[outputtopology("triangle_cw")]
|
|
[patchconstantfunc("TessellationFunction")]
|
|
[outputcontrolpoints(3)]
|
|
VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
|
|
{
|
|
return patch[id];
|
|
}
|
|
|
|
[domain("tri")]
|
|
PackedVaryingsMeshToPS DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
|
{
|
|
AttributesMesh o = (AttributesMesh) 0;
|
|
o.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
|
|
o.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
|
|
o.tangentOS = patch[0].tangentOS * bary.x + patch[1].tangentOS * bary.y + patch[2].tangentOS * bary.z;
|
|
o.uv1 = patch[0].uv1 * bary.x + patch[1].uv1 * bary.y + patch[2].uv1 * bary.z;
|
|
o.uv2 = patch[0].uv2 * bary.x + patch[1].uv2 * bary.y + patch[2].uv2 * bary.z;
|
|
o.ase_texcoord = patch[0].ase_texcoord * bary.x + patch[1].ase_texcoord * bary.y + patch[2].ase_texcoord * bary.z;
|
|
#if defined(ASE_PHONG_TESSELLATION)
|
|
float3 pp[3];
|
|
for (int i = 0; i < 3; ++i)
|
|
pp[i] = o.positionOS.xyz - patch[i].normalOS * (dot(o.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
|
|
float phongStrength = _TessPhongStrength;
|
|
o.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.positionOS.xyz;
|
|
#endif
|
|
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
|
return VertexFunction(o);
|
|
}
|
|
#else
|
|
PackedVaryingsMeshToPS Vert ( AttributesMesh v )
|
|
{
|
|
return VertexFunction( v );
|
|
}
|
|
#endif
|
|
|
|
#ifdef UNITY_VIRTUAL_TEXTURING
|
|
#ifdef OUTPUT_SPLIT_LIGHTING
|
|
#define DIFFUSE_LIGHTING_TARGET SV_Target2
|
|
#define SSS_BUFFER_TARGET SV_Target3
|
|
#elif defined(_WRITE_TRANSPARENT_MOTION_VECTOR)
|
|
#define MOTION_VECTOR_TARGET SV_Target2
|
|
#endif
|
|
|
|
|
|
#else
|
|
#ifdef OUTPUT_SPLIT_LIGHTING
|
|
#define DIFFUSE_LIGHTING_TARGET SV_Target1
|
|
#define SSS_BUFFER_TARGET SV_Target2
|
|
#elif defined(_WRITE_TRANSPARENT_MOTION_VECTOR)
|
|
#define MOTION_VECTOR_TARGET SV_Target1
|
|
#endif
|
|
#endif
|
|
|
|
void Frag(PackedVaryingsMeshToPS packedInput
|
|
, out float4 outColor:SV_Target0
|
|
#ifdef UNITY_VIRTUAL_TEXTURING
|
|
, out float4 outVTFeedback : SV_Target1
|
|
#endif
|
|
#ifdef OUTPUT_SPLIT_LIGHTING
|
|
, out float4 outDiffuseLighting : DIFFUSE_LIGHTING_TARGET
|
|
, OUTPUT_SSSBUFFER(outSSSBuffer) : SSS_BUFFER_TARGET
|
|
#elif defined(_WRITE_TRANSPARENT_MOTION_VECTOR)
|
|
, out float4 outMotionVec : MOTION_VECTOR_TARGET
|
|
#endif
|
|
#ifdef _DEPTHOFFSET_ON
|
|
, out float outputDepth : DEPTH_OFFSET_SEMANTIC
|
|
#endif
|
|
|
|
)
|
|
{
|
|
|
|
#ifdef _WRITE_TRANSPARENT_MOTION_VECTOR
|
|
outMotionVec = float4(2.0, 0.0, 0.0, 0.0);
|
|
#endif
|
|
|
|
|
|
|
|
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( packedInput );
|
|
UNITY_SETUP_INSTANCE_ID( packedInput );
|
|
float3 positionRWS = packedInput.positionRWS.xyz;
|
|
float3 normalWS = packedInput.normalWS.xyz;
|
|
float4 tangentWS = packedInput.tangentWS.xyzw;
|
|
|
|
FragInputs input;
|
|
ZERO_INITIALIZE(FragInputs, input);
|
|
input.tangentToWorld = k_identity3x3;
|
|
input.positionSS = packedInput.positionCS;
|
|
input.positionRWS = positionRWS;
|
|
input.tangentToWorld = BuildTangentToWorld(tangentWS, normalWS);
|
|
input.texCoord1 = packedInput.uv1.xyzw;
|
|
input.texCoord2 = packedInput.uv2.xyzw;
|
|
|
|
#if _DOUBLESIDED_ON && SHADER_STAGE_FRAGMENT
|
|
input.isFrontFace = IS_FRONT_VFACE( packedInput.cullFace, true, false);
|
|
#elif SHADER_STAGE_FRAGMENT
|
|
#if defined(ASE_NEED_CULLFACE)
|
|
input.isFrontFace = IS_FRONT_VFACE(packedInput.cullFace, true, false);
|
|
#endif
|
|
#endif
|
|
half isFrontFace = input.isFrontFace;
|
|
|
|
input.positionSS.xy = _OffScreenRendering > 0 ? (uint2)round(input.positionSS.xy * _OffScreenDownsampleFactor) : input.positionSS.xy;
|
|
uint2 tileIndex = uint2(input.positionSS.xy) / GetTileSize ();
|
|
|
|
PositionInputs posInput = GetPositionInput( input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS.xyz, tileIndex );
|
|
|
|
float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS);
|
|
|
|
GlobalSurfaceDescription surfaceDescription = (GlobalSurfaceDescription)0;
|
|
float4 _Control_ST_Instance = UNITY_ACCESS_INSTANCED_PROP(TerrainAmplifyFirstPass,_Control_ST);
|
|
float2 uv_Control = packedInput.ase_texcoord7.xy * _Control_ST_Instance.xy + _Control_ST_Instance.zw;
|
|
float4 tex2DNode5_g4 = tex2D( _Control, uv_Control );
|
|
float dotResult20_g4 = dot( tex2DNode5_g4 , float4(1,1,1,1) );
|
|
float SplatWeight22_g4 = dotResult20_g4;
|
|
float localSplatClip74_g4 = ( SplatWeight22_g4 );
|
|
float SplatWeight74_g4 = SplatWeight22_g4;
|
|
{
|
|
#if !defined(SHADER_API_MOBILE) && defined(TERRAIN_SPLAT_ADDPASS)
|
|
clip(SplatWeight74_g4 == 0.0f ? -1 : 1);
|
|
#endif
|
|
}
|
|
float4 SplatControl26_g4 = ( tex2DNode5_g4 / ( localSplatClip74_g4 + 0.001 ) );
|
|
float4 temp_output_59_0_g4 = SplatControl26_g4;
|
|
float4 appendResult33_g4 = (float4(1.0 , 1.0 , 1.0 , _Smoothness0));
|
|
float4 _Splat0_ST_Instance = UNITY_ACCESS_INSTANCED_PROP(TerrainAmplifyFirstPass,_Splat0_ST);
|
|
float2 uv_Splat0 = packedInput.ase_texcoord7.xy * _Splat0_ST_Instance.xy + _Splat0_ST_Instance.zw;
|
|
float4 tex2DNode4_g4 = tex2D( _Splat0, uv_Splat0 );
|
|
float3 _Vector1 = float3(1,1,1);
|
|
float4 appendResult258_g4 = (float4(_Vector1 , 1.0));
|
|
float4 tintLayer0253_g4 = appendResult258_g4;
|
|
float4 appendResult36_g4 = (float4(1.0 , 1.0 , 1.0 , _Smoothness1));
|
|
float4 _Splat1_ST_Instance = UNITY_ACCESS_INSTANCED_PROP(TerrainAmplifyFirstPass,_Splat1_ST);
|
|
float2 uv_Splat1 = packedInput.ase_texcoord7.xy * _Splat1_ST_Instance.xy + _Splat1_ST_Instance.zw;
|
|
float4 tex2DNode3_g4 = tex2D( _Splat1, uv_Splat1 );
|
|
float3 _Vector2 = float3(1,1,1);
|
|
float4 appendResult261_g4 = (float4(_Vector2 , 1.0));
|
|
float4 tintLayer1254_g4 = appendResult261_g4;
|
|
float4 appendResult39_g4 = (float4(1.0 , 1.0 , 1.0 , _Smoothness2));
|
|
float4 _Splat2_ST_Instance = UNITY_ACCESS_INSTANCED_PROP(TerrainAmplifyFirstPass,_Splat2_ST);
|
|
float2 uv_Splat2 = packedInput.ase_texcoord7.xy * _Splat2_ST_Instance.xy + _Splat2_ST_Instance.zw;
|
|
float4 tex2DNode6_g4 = tex2D( _Splat2, uv_Splat2 );
|
|
float3 _Vector3 = float3(1,1,1);
|
|
float4 appendResult263_g4 = (float4(_Vector3 , 1.0));
|
|
float4 tintLayer2255_g4 = appendResult263_g4;
|
|
float4 appendResult42_g4 = (float4(1.0 , 1.0 , 1.0 , _Smoothness3));
|
|
float4 _Splat3_ST_Instance = UNITY_ACCESS_INSTANCED_PROP(TerrainAmplifyFirstPass,_Splat3_ST);
|
|
float2 uv_Splat3 = packedInput.ase_texcoord7.xy * _Splat3_ST_Instance.xy + _Splat3_ST_Instance.zw;
|
|
float4 tex2DNode7_g4 = tex2D( _Splat3, uv_Splat3 );
|
|
float3 _Vector4 = float3(1,1,1);
|
|
float4 appendResult265_g4 = (float4(_Vector4 , 1.0));
|
|
float4 tintLayer3256_g4 = appendResult265_g4;
|
|
float4 weightedBlendVar9_g4 = temp_output_59_0_g4;
|
|
float4 weightedBlend9_g4 = ( weightedBlendVar9_g4.x*( appendResult33_g4 * tex2DNode4_g4 * tintLayer0253_g4 ) + weightedBlendVar9_g4.y*( appendResult36_g4 * tex2DNode3_g4 * tintLayer1254_g4 ) + weightedBlendVar9_g4.z*( appendResult39_g4 * tex2DNode6_g4 * tintLayer2255_g4 ) + weightedBlendVar9_g4.w*( appendResult42_g4 * tex2DNode7_g4 * tintLayer3256_g4 ) );
|
|
float4 MixDiffuse28_g4 = weightedBlend9_g4;
|
|
float4 temp_output_60_0_g4 = MixDiffuse28_g4;
|
|
float4 localClipHoles100_g4 = ( temp_output_60_0_g4 );
|
|
float4 _TerrainHolesTexture_ST_Instance = UNITY_ACCESS_INSTANCED_PROP(TerrainAmplifyFirstPass,_TerrainHolesTexture_ST);
|
|
float2 uv_TerrainHolesTexture = packedInput.ase_texcoord7.xy * _TerrainHolesTexture_ST_Instance.xy + _TerrainHolesTexture_ST_Instance.zw;
|
|
float holeClipValue99_g4 = tex2D( _TerrainHolesTexture, uv_TerrainHolesTexture ).r;
|
|
float Hole100_g4 = holeClipValue99_g4;
|
|
{
|
|
#ifdef _ALPHATEST_ON
|
|
clip(Hole100_g4 == 0.0f ? -1 : 1);
|
|
#endif
|
|
}
|
|
|
|
float4 weightedBlendVar8_g4 = temp_output_59_0_g4;
|
|
float4 weightedBlend8_g4 = ( weightedBlendVar8_g4.x*tex2D( _Normal0, uv_Splat0 ) + weightedBlendVar8_g4.y*tex2D( _Normal1, uv_Splat1 ) + weightedBlendVar8_g4.z*tex2D( _Normal2, uv_Splat2 ) + weightedBlendVar8_g4.w*tex2D( _Normal3, uv_Splat3 ) );
|
|
float3 temp_output_61_0_g4 = UnpackNormalScale( weightedBlend8_g4, 1.0 );
|
|
float2 temp_cast_8 = (( _TimeParameters.x * _WaterFlowSpeed )).xx;
|
|
float2 texCoord76 = packedInput.ase_texcoord7.xy * _Normal1Tilling + temp_cast_8;
|
|
float3 unpack59 = UnpackNormalScale( tex2D( _WaterFlowNormal, texCoord76 ), _NormalMapStrength );
|
|
unpack59.z = lerp( 1, unpack59.z, saturate(_NormalMapStrength) );
|
|
float2 temp_cast_9 = (( _TimeParameters.x * _WaterFlowSpeed1 )).xx;
|
|
float2 texCoord77 = packedInput.ase_texcoord7.xy * _Normal2Tilling + temp_cast_9;
|
|
float3 unpack66 = UnpackNormalScale( tex2D( _WaterFlowNormal1, texCoord77 ), _NormalMapStrength );
|
|
unpack66.z = lerp( 1, unpack66.z, saturate(_NormalMapStrength) );
|
|
float2 texCoord43 = packedInput.ase_texcoord7.xy * _RainReflections1 + float2( 0,0 );
|
|
float simpleNoise42 = SimpleNoise( texCoord43*_RainScale );
|
|
float smoothstepResult48 = smoothstep( 0.38 , 1.0 , simpleNoise42);
|
|
float2 texCoord117 = packedInput.ase_texcoord7.xy * _RippleTextureCoordinatesTilling + float2( 0,0 );
|
|
float2 break135_g5 = texCoord117;
|
|
float2 appendResult136_g5 = (float2(break135_g5.x , ( 1.0 - break135_g5.y )));
|
|
float2 FlipBookUV141_g5 = appendResult136_g5;
|
|
float FlipBookColumns143_g5 = 4.0;
|
|
float FlipBookRows144_g5 = 4.0;
|
|
float2 appendResult83_g5 = (float2(FlipBookColumns143_g5 , FlipBookRows144_g5));
|
|
float temp_output_104_0_g5 = ( FlipBookColumns143_g5 * FlipBookRows144_g5 );
|
|
float2 appendResult95_g5 = (float2(temp_output_104_0_g5 , FlipBookRows144_g5));
|
|
float mulTime99 = _TimeParameters.x * _RippleFPS;
|
|
float FlipBookSpeed145_g5 = ( _TimeParameters.x * mulTime99 );
|
|
float FlipBookID142_g5 = 0.0;
|
|
float clampResult108_g5 = clamp( FlipBookID142_g5 , 0.0001 , ( temp_output_104_0_g5 - 1.0 ) );
|
|
float temp_output_92_0_g5 = frac( ( ( FlipBookSpeed145_g5 + clampResult108_g5 ) / temp_output_104_0_g5 ) );
|
|
float2 appendResult93_g5 = (float2(temp_output_92_0_g5 , ( temp_output_92_0_g5 - -0.01 )));
|
|
float2 break105_g5 = ( ( FlipBookUV141_g5 / appendResult83_g5 ) + ( floor( ( appendResult95_g5 * appendResult93_g5 ) ) / appendResult83_g5 ) );
|
|
float2 appendResult139_g5 = (float2(break105_g5.x , ( 1.0 - break105_g5.y )));
|
|
float3 unpack98 = UnpackNormalScale( tex2D( _RippleNormal, appendResult139_g5 ), _RippleNormalStrength );
|
|
unpack98.z = lerp( 1, unpack98.z, saturate(_RippleNormalStrength) );
|
|
|
|
float2 texCoord80 = packedInput.ase_texcoord7.xy * _RainReflections + float2( 0,0 );
|
|
float simpleNoise82 = SimpleNoise( texCoord80*_RainScale );
|
|
float smoothstepResult81 = smoothstep( 0.38 , 1.0 , simpleNoise82);
|
|
|
|
surfaceDescription.BaseColor = localClipHoles100_g4.xyz;
|
|
surfaceDescription.Normal = ( ( temp_output_61_0_g4 + ( ( unpack59 + unpack66 ) * smoothstepResult48 ) ) + unpack98 );
|
|
surfaceDescription.BentNormal = float3( 0, 0, 1 );
|
|
surfaceDescription.CoatMask = 0;
|
|
surfaceDescription.Metallic = _Float10;
|
|
|
|
#ifdef _MATERIAL_FEATURE_SPECULAR_COLOR
|
|
surfaceDescription.Specular = 0;
|
|
#endif
|
|
|
|
surfaceDescription.Emission = 0;
|
|
surfaceDescription.Smoothness = ( 0.0 + ( ( smoothstepResult81 * _RainOpacity ) + _Smoothness ) );
|
|
surfaceDescription.Occlusion = 1;
|
|
surfaceDescription.Alpha = 1;
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
surfaceDescription.AlphaClipThreshold = _AlphaCutoff;
|
|
#endif
|
|
|
|
#ifdef _ENABLE_GEOMETRIC_SPECULAR_AA
|
|
surfaceDescription.SpecularAAScreenSpaceVariance = 0;
|
|
surfaceDescription.SpecularAAThreshold = 0;
|
|
#endif
|
|
|
|
#ifdef _SPECULAR_OCCLUSION_CUSTOM
|
|
surfaceDescription.SpecularOcclusion = 0;
|
|
#endif
|
|
|
|
#if defined(_HAS_REFRACTION) || defined(_MATERIAL_FEATURE_TRANSMISSION)
|
|
surfaceDescription.Thickness = 1;
|
|
#endif
|
|
|
|
#ifdef _HAS_REFRACTION
|
|
surfaceDescription.RefractionIndex = 1;
|
|
surfaceDescription.RefractionColor = float3( 1, 1, 1 );
|
|
surfaceDescription.RefractionDistance = 0;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
|
|
surfaceDescription.SubsurfaceMask = 1;
|
|
#endif
|
|
|
|
#if defined( _MATERIAL_FEATURE_SUBSURFACE_SCATTERING ) || defined( _MATERIAL_FEATURE_TRANSMISSION )
|
|
surfaceDescription.DiffusionProfile = 0;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_ANISOTROPY
|
|
surfaceDescription.Anisotropy = 1;
|
|
surfaceDescription.Tangent = float3( 1, 0, 0 );
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_IRIDESCENCE
|
|
surfaceDescription.IridescenceMask = 0;
|
|
surfaceDescription.IridescenceThickness = 0;
|
|
#endif
|
|
|
|
#ifdef ASE_BAKEDGI
|
|
surfaceDescription.BakedGI = 0;
|
|
#endif
|
|
#ifdef ASE_BAKEDBACKGI
|
|
surfaceDescription.BakedBackGI = 0;
|
|
#endif
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
surfaceDescription.DepthOffset = 0;
|
|
#endif
|
|
|
|
#ifdef UNITY_VIRTUAL_TEXTURING
|
|
surfaceDescription.VTPackedFeedback = float4(1.0f,1.0f,1.0f,1.0f);
|
|
#endif
|
|
|
|
SurfaceData surfaceData;
|
|
BuiltinData builtinData;
|
|
GetSurfaceAndBuiltinData(surfaceDescription,input, V, posInput, surfaceData, builtinData);
|
|
|
|
BSDFData bsdfData = ConvertSurfaceDataToBSDFData(input.positionSS.xy, surfaceData);
|
|
|
|
PreLightData preLightData = GetPreLightData(V, posInput, bsdfData);
|
|
|
|
outColor = float4(0.0, 0.0, 0.0, 0.0);
|
|
|
|
#ifdef DEBUG_DISPLAY
|
|
#ifdef OUTPUT_SPLIT_LIGHTING
|
|
outDiffuseLighting = float4(0, 0, 0, 1);
|
|
ENCODE_INTO_SSSBUFFER(surfaceData, posInput.positionSS, outSSSBuffer);
|
|
#endif
|
|
|
|
bool viewMaterial = false;
|
|
int bufferSize = _DebugViewMaterialArray[0].x;
|
|
if (bufferSize != 0)
|
|
{
|
|
bool needLinearToSRGB = false;
|
|
float3 result = float3(1.0, 0.0, 1.0);
|
|
|
|
for (int index = 1; index <= bufferSize; index++)
|
|
{
|
|
int indexMaterialProperty = _DebugViewMaterialArray[index].x;
|
|
|
|
if (indexMaterialProperty != 0)
|
|
{
|
|
viewMaterial = true;
|
|
|
|
GetPropertiesDataDebug(indexMaterialProperty, result, needLinearToSRGB);
|
|
GetVaryingsDataDebug(indexMaterialProperty, input, result, needLinearToSRGB);
|
|
GetBuiltinDataDebug(indexMaterialProperty, builtinData, posInput, result, needLinearToSRGB);
|
|
GetSurfaceDataDebug(indexMaterialProperty, surfaceData, result, needLinearToSRGB);
|
|
GetBSDFDataDebug(indexMaterialProperty, bsdfData, result, needLinearToSRGB);
|
|
}
|
|
}
|
|
|
|
if (!needLinearToSRGB && _DebugAOVOutput == 0)
|
|
result = SRGBToLinear(max(0, result));
|
|
|
|
outColor = float4(result, 1.0);
|
|
}
|
|
|
|
if (!viewMaterial)
|
|
{
|
|
if (_DebugFullScreenMode == FULLSCREENDEBUGMODE_VALIDATE_DIFFUSE_COLOR || _DebugFullScreenMode == FULLSCREENDEBUGMODE_VALIDATE_SPECULAR_COLOR)
|
|
{
|
|
float3 result = float3(0.0, 0.0, 0.0);
|
|
GetPBRValidatorDebug(surfaceData, result);
|
|
outColor = float4(result, 1.0f);
|
|
}
|
|
else if (_DebugFullScreenMode == FULLSCREENDEBUGMODE_TRANSPARENCY_OVERDRAW)
|
|
{
|
|
float4 result = _DebugTransparencyOverdrawWeight * float4(TRANSPARENCY_OVERDRAW_COST, TRANSPARENCY_OVERDRAW_COST, TRANSPARENCY_OVERDRAW_COST, TRANSPARENCY_OVERDRAW_A);
|
|
outColor = result;
|
|
}
|
|
else
|
|
#endif
|
|
{
|
|
#ifdef _SURFACE_TYPE_TRANSPARENT
|
|
uint featureFlags = LIGHT_FEATURE_MASK_FLAGS_TRANSPARENT;
|
|
#else
|
|
uint featureFlags = LIGHT_FEATURE_MASK_FLAGS_OPAQUE;
|
|
#endif
|
|
LightLoopOutput lightLoopOutput;
|
|
LightLoop(V, posInput, preLightData, bsdfData, builtinData, featureFlags, lightLoopOutput);
|
|
|
|
// Alias
|
|
float3 diffuseLighting = lightLoopOutput.diffuseLighting;
|
|
float3 specularLighting = lightLoopOutput.specularLighting;
|
|
|
|
diffuseLighting *= GetCurrentExposureMultiplier();
|
|
specularLighting *= GetCurrentExposureMultiplier();
|
|
|
|
#ifdef OUTPUT_SPLIT_LIGHTING
|
|
if (_EnableSubsurfaceScattering != 0 && ShouldOutputSplitLighting(bsdfData))
|
|
{
|
|
outColor = float4(specularLighting, 1.0);
|
|
outDiffuseLighting = float4(TagLightingForSSS(diffuseLighting), 1.0);
|
|
}
|
|
else
|
|
{
|
|
outColor = float4(diffuseLighting + specularLighting, 1.0);
|
|
outDiffuseLighting = float4(0, 0, 0, 1);
|
|
}
|
|
ENCODE_INTO_SSSBUFFER(surfaceData, posInput.positionSS, outSSSBuffer);
|
|
#else
|
|
outColor = ApplyBlendMode(diffuseLighting, specularLighting, builtinData.opacity);
|
|
outColor = EvaluateAtmosphericScattering(posInput, V, outColor);
|
|
#endif
|
|
|
|
|
|
#ifdef _WRITE_TRANSPARENT_MOTION_VECTOR
|
|
float4 VPASSpositionCS = float4(packedInput.vpassPositionCS.xy, 0.0, packedInput.vpassPositionCS.z);
|
|
float4 VPASSpreviousPositionCS = float4(packedInput.vpassPreviousPositionCS.xy, 0.0, packedInput.vpassPreviousPositionCS.z);
|
|
bool forceNoMotion = any(unity_MotionVectorsParams.yw == 0.0);
|
|
if (!forceNoMotion)
|
|
{
|
|
float2 motionVec = CalculateMotionVector(VPASSpositionCS, VPASSpreviousPositionCS);
|
|
EncodeMotionVector(motionVec * 0.5, outMotionVec);
|
|
outMotionVec.zw = 1.0;
|
|
}
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
#ifdef DEBUG_DISPLAY
|
|
}
|
|
#endif
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
outputDepth = posInput.deviceDepth;
|
|
#endif
|
|
|
|
#ifdef UNITY_VIRTUAL_TEXTURING
|
|
outVTFeedback = builtinData.vtPackedFeedback;
|
|
#endif
|
|
|
|
#if ASE_SRP_VERSION >= 130000
|
|
#ifdef UNITY_VIRTUAL_TEXTURING
|
|
float vtAlphaValue = builtinData.opacity;
|
|
#if defined(HAS_REFRACTION) && HAS_REFRACTION
|
|
vtAlphaValue = 1.0f - bsdfData.transmittanceMask;
|
|
#endif
|
|
outVTFeedback = PackVTFeedbackWithAlpha(builtinData.vtPackedFeedback, input.positionSS.xy, vtAlphaValue);
|
|
#endif
|
|
#endif
|
|
}
|
|
ENDHLSL
|
|
}
|
|
|
|
UsePass "Hidden/Nature/Terrain/Utilities/PICKING"
|
|
UsePass "Hidden/Nature/Terrain/Utilities/SELECTION"
|
|
|
|
Pass
|
|
{
|
|
|
|
Name "ScenePickingPass"
|
|
Tags { "LightMode"="Picking" }
|
|
|
|
Cull [_CullMode]
|
|
|
|
HLSLPROGRAM
|
|
|
|
#define _SPECULAR_OCCLUSION_FROM_AO 1
|
|
#pragma multi_compile_instancing
|
|
#pragma instancing_options renderinglayer
|
|
#define shader_feature_local _DISABLE_DECALS
|
|
#define shader_feature_local_raytracing _DISABLE_SSR
|
|
#define shader_feature_local_fragment _DISABLE_SSR
|
|
#define ASE_SRP_VERSION 170003
|
|
|
|
|
|
#pragma editor_sync_compilation
|
|
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/GeometricTools.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Tessellation.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
|
|
#include "Packages/com.unity.shadergraph/ShaderGraphLibrary/Functions.hlsl"
|
|
|
|
#define ATTRIBUTES_NEED_NORMAL
|
|
#define ATTRIBUTES_NEED_TANGENT
|
|
#define VARYINGS_NEED_TANGENT_TO_WORLD
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
|
|
#define SHADERPASS SHADERPASS_DEPTH_ONLY
|
|
#define SCENEPICKINGPASS 1
|
|
|
|
#ifndef SHADER_UNLIT
|
|
#if defined(_DOUBLESIDED_ON) && !defined(VARYINGS_NEED_CULLFACE)
|
|
#define VARYINGS_NEED_CULLFACE
|
|
#endif
|
|
#endif
|
|
|
|
#if SHADERPASS == SHADERPASS_TRANSPARENT_DEPTH_PREPASS
|
|
#if !defined(_DISABLE_SSR_TRANSPARENT) && !defined(SHADER_UNLIT)
|
|
#define WRITE_NORMAL_BUFFER
|
|
#endif
|
|
#endif
|
|
|
|
#if defined(_MATERIAL_FEATURE_SUBSURFACE_SCATTERING) && !defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define OUTPUT_SPLIT_LIGHTING
|
|
#endif
|
|
|
|
#if defined(SHADER_LIT) && !defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define _DEFERRED_CAPABLE_MATERIAL
|
|
#endif
|
|
|
|
#if defined(_TRANSPARENT_WRITES_MOTION_VEC) && defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define _WRITE_TRANSPARENT_MOTION_VECTOR
|
|
#endif
|
|
|
|
float4 _SelectionID;
|
|
CBUFFER_START( UnityPerMaterial )
|
|
float2 _RainReflections;
|
|
float2 _Normal1Tilling;
|
|
float2 _RippleTextureCoordinatesTilling;
|
|
float2 _Normal2Tilling;
|
|
float2 _RainReflections1;
|
|
float _Smoothness0;
|
|
float _Float10;
|
|
float _RippleNormalStrength;
|
|
float _RippleFPS;
|
|
float _RainScale;
|
|
float _WaterFlowSpeed1;
|
|
float _NormalMapStrength;
|
|
float _WaterFlowSpeed;
|
|
float _Smoothness3;
|
|
float _Smoothness2;
|
|
float _Smoothness1;
|
|
float _RainOpacity;
|
|
float _Smoothness;
|
|
float4 _EmissionColor;
|
|
float _AlphaCutoff;
|
|
float _RenderQueueType;
|
|
#ifdef _ADD_PRECOMPUTED_VELOCITY
|
|
float _AddPrecomputedVelocity;
|
|
#endif
|
|
float _StencilRef;
|
|
float _StencilWriteMask;
|
|
float _StencilRefDepth;
|
|
float _StencilWriteMaskDepth;
|
|
float _StencilRefMV;
|
|
float _StencilWriteMaskMV;
|
|
float _StencilWriteMaskGBuffer;
|
|
float _StencilRefGBuffer;
|
|
float _ZTestGBuffer;
|
|
float _RequireSplitLighting;
|
|
float _ReceivesSSR;
|
|
float _SurfaceType;
|
|
float _BlendMode;
|
|
#ifdef SUPPORT_BLENDMODE_PRESERVE_SPECULAR_LIGHTING
|
|
float _EnableBlendModePreserveSpecularLighting;
|
|
#endif
|
|
float _SrcBlend;
|
|
float _DstBlend;
|
|
float _AlphaSrcBlend;
|
|
float _AlphaDstBlend;
|
|
float _ZWrite;
|
|
float _TransparentZWrite;
|
|
float _CullMode;
|
|
float _TransparentSortPriority;
|
|
float _EnableFogOnTransparent;
|
|
float _CullModeForward;
|
|
float _TransparentCullMode;
|
|
float _ZTestDepthEqualForOpaque;
|
|
float _ZTestTransparent;
|
|
float _TransparentBackfaceEnable;
|
|
float _AlphaCutoffEnable;
|
|
float _UseShadowThreshold;
|
|
float _DoubleSidedEnable;
|
|
float _DoubleSidedNormalMode;
|
|
float4 _DoubleSidedConstants;
|
|
#ifdef ASE_TESSELLATION
|
|
float _TessPhongStrength;
|
|
float _TessValue;
|
|
float _TessMin;
|
|
float _TessMax;
|
|
float _TessEdgeLength;
|
|
float _TessMaxDisp;
|
|
#endif
|
|
CBUFFER_END
|
|
|
|
sampler2D _Mask2;
|
|
sampler2D _Mask0;
|
|
sampler2D _Mask1;
|
|
sampler2D _Mask3;
|
|
float4 _MaskMapRemapScale0;
|
|
float4 _MaskMapRemapOffset2;
|
|
float4 _MaskMapRemapScale2;
|
|
float4 _MaskMapRemapScale1;
|
|
float4 _MaskMapRemapOffset1;
|
|
float4 _MaskMapRemapScale3;
|
|
float4 _MaskMapRemapOffset3;
|
|
float4 _MaskMapRemapOffset0;
|
|
#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing
|
|
TEXTURE2D(_TerrainHeightmapTexture);//ASE Terrain Instancing
|
|
TEXTURE2D( _TerrainNormalmapTexture);//ASE Terrain Instancing
|
|
SAMPLER(sampler_TerrainNormalmapTexture);//ASE Terrain Instancing
|
|
#endif//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_START( Terrain )//ASE Terrain Instancing
|
|
UNITY_DEFINE_INSTANCED_PROP( float4, _TerrainPatchInstanceData )//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_END( Terrain)//ASE Terrain Instancing
|
|
CBUFFER_START( UnityTerrain)//ASE Terrain Instancing
|
|
#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing
|
|
float4 _TerrainHeightmapRecipSize;//ASE Terrain Instancing
|
|
float4 _TerrainHeightmapScale;//ASE Terrain Instancing
|
|
#endif//ASE Terrain Instancing
|
|
CBUFFER_END//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_START(TerrainAmplifyFirstPass)
|
|
UNITY_INSTANCING_BUFFER_END(TerrainAmplifyFirstPass)
|
|
|
|
|
|
#ifdef DEBUG_DISPLAY
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
|
|
#endif
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/PickingSpaceTransforms.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/Unlit.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
|
|
#define ASE_NEEDS_VERT_NORMAL
|
|
#define ASE_NEEDS_VERT_POSITION
|
|
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap forwardadd
|
|
#pragma multi_compile_local __ _ALPHATEST_ON
|
|
#pragma shader_feature_local _MASKMAP
|
|
|
|
|
|
struct VertexInput
|
|
{
|
|
float3 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
float4 ase_texcoord : TEXCOORD0;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct VertexOutput
|
|
{
|
|
float4 positionCS : SV_POSITION;
|
|
float3 normalWS : TEXCOORD0;
|
|
float4 ase_texcoord2 : TEXCOORD2;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
VertexInput ApplyMeshModification( VertexInput inputMesh )
|
|
{
|
|
#ifdef UNITY_INSTANCING_ENABLED
|
|
float2 patchVertex = inputMesh.positionOS.xy;
|
|
float4 instanceData = UNITY_ACCESS_INSTANCED_PROP( Terrain, _TerrainPatchInstanceData );
|
|
float2 sampleCoords = ( patchVertex.xy + instanceData.xy ) * instanceData.z;
|
|
float height = UnpackHeightmap( _TerrainHeightmapTexture.Load( int3( sampleCoords, 0 ) ) );
|
|
inputMesh.positionOS.xz = sampleCoords* _TerrainHeightmapScale.xz;
|
|
inputMesh.positionOS.y = height* _TerrainHeightmapScale.y;
|
|
#ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL
|
|
inputMesh.normalOS = float3(0, 1, 0);
|
|
#else
|
|
inputMesh.normalOS = _TerrainNormalmapTexture.Load(int3(sampleCoords, 0)).rgb* 2 - 1;
|
|
#endif
|
|
inputMesh.ase_texcoord.xy = sampleCoords* _TerrainHeightmapRecipSize.zw;
|
|
#endif
|
|
return inputMesh;
|
|
}
|
|
|
|
|
|
struct SurfaceDescription
|
|
{
|
|
float Alpha;
|
|
float AlphaClipThreshold;
|
|
float DepthOffset;
|
|
};
|
|
|
|
struct SurfaceDescriptionInputs
|
|
{
|
|
float3 ObjectSpaceNormal;
|
|
float3 WorldSpaceNormal;
|
|
float3 TangentSpaceNormal;
|
|
float3 ObjectSpaceViewDirection;
|
|
float3 WorldSpaceViewDirection;
|
|
float3 ObjectSpacePosition;
|
|
};
|
|
|
|
|
|
void GetSurfaceAndBuiltinData(SurfaceDescription surfaceDescription, FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData RAY_TRACING_OPTIONAL_PARAMETERS)
|
|
{
|
|
|
|
#if !defined(SHADER_STAGE_RAY_TRACING) && !defined(_TESSELLATION_DISPLACEMENT)
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
LODDitheringTransition(ComputeFadeMaskSeed(V, posInput.positionSS), unity_LODFade.x);
|
|
#endif
|
|
#endif
|
|
|
|
#ifndef SHADER_UNLIT
|
|
#ifdef _DOUBLESIDED_ON
|
|
float3 doubleSidedConstants = _DoubleSidedConstants.xyz;
|
|
#else
|
|
float3 doubleSidedConstants = float3(1.0, 1.0, 1.0);
|
|
#endif
|
|
ApplyDoubleSidedFlipOrMirror(fragInputs, doubleSidedConstants);
|
|
#endif
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
float alphaCutoff = surfaceDescription.AlphaClipThreshold;
|
|
#if SHADERPASS == SHADERPASS_TRANSPARENT_DEPTH_PREPASS
|
|
#elif SHADERPASS == SHADERPASS_TRANSPARENT_DEPTH_POSTPASS
|
|
alphaCutoff = surfaceDescription.AlphaClipThresholdDepthPostpass;
|
|
#elif (SHADERPASS == SHADERPASS_SHADOWS) || (SHADERPASS == SHADERPASS_RAYTRACING_VISIBILITY)
|
|
#endif
|
|
GENERIC_ALPHA_TEST(surfaceDescription.Alpha, alphaCutoff);
|
|
#endif
|
|
|
|
#if !defined(SHADER_STAGE_RAY_TRACING) && _DEPTHOFFSET_ON
|
|
ApplyDepthOffsetPositionInput(V, surfaceDescription.DepthOffset, GetViewForwardDir(), GetWorldToHClipMatrix(), posInput);
|
|
#endif
|
|
|
|
#ifdef FRAG_INPUTS_USE_TEXCOORD1
|
|
float4 lightmapTexCoord1 = fragInputs.texCoord1;
|
|
#else
|
|
float4 lightmapTexCoord1 = float4(0, 0, 0, 0);
|
|
#endif
|
|
|
|
#ifdef FRAG_INPUTS_USE_TEXCOORD2
|
|
float4 lightmapTexCoord2 = fragInputs.texCoord2;
|
|
#else
|
|
float4 lightmapTexCoord2 = float4(0, 0, 0, 0);
|
|
#endif
|
|
|
|
//InitBuiltinData(posInput, surfaceDescription.Alpha, bentNormalWS, -fragInputs.tangentToWorld[2], lightmapTexCoord1, lightmapTexCoord2, builtinData);
|
|
|
|
//#else
|
|
//BuildSurfaceData(fragInputs, surfaceDescription, V, posInput, surfaceData);
|
|
|
|
ZERO_INITIALIZE(SurfaceData, surfaceData);
|
|
|
|
ZERO_BUILTIN_INITIALIZE(builtinData);
|
|
builtinData.opacity = surfaceDescription.Alpha;
|
|
|
|
#if defined(DEBUG_DISPLAY)
|
|
builtinData.renderingLayers = GetMeshRenderingLightLayer();
|
|
#endif
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
builtinData.alphaClipTreshold = alphaCutoff;
|
|
#endif
|
|
|
|
#ifdef UNITY_VIRTUAL_TEXTURING
|
|
#endif
|
|
|
|
#if _DEPTHOFFSET_ON
|
|
builtinData.depthOffset = surfaceDescription.DepthOffset;
|
|
#endif
|
|
|
|
#if (SHADERPASS == SHADERPASS_DISTORTION)
|
|
builtinData.distortion = surfaceDescription.Distortion;
|
|
builtinData.distortionBlur = surfaceDescription.DistortionBlur;
|
|
#endif
|
|
|
|
#ifndef SHADER_UNLIT
|
|
PostInitBuiltinData(V, posInput, surfaceData, builtinData);
|
|
#else
|
|
ApplyDebugToBuiltinData(builtinData);
|
|
#endif
|
|
|
|
RAY_TRACING_OPTIONAL_ALPHA_TEST_PASS
|
|
|
|
}
|
|
|
|
|
|
VertexOutput VertexFunction(VertexInput inputMesh )
|
|
{
|
|
|
|
VertexOutput o;
|
|
ZERO_INITIALIZE(VertexOutput, o);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
|
|
|
UNITY_SETUP_INSTANCE_ID(inputMesh);
|
|
UNITY_TRANSFER_INSTANCE_ID(inputMesh, o );
|
|
|
|
inputMesh = ApplyMeshModification(inputMesh);
|
|
o.ase_texcoord2 = inputMesh.ase_texcoord;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = inputMesh.positionOS.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3( 0, 0, 0 );
|
|
#endif
|
|
float3 vertexValue = defaultVertexValue ;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
inputMesh.positionOS.xyz = vertexValue;
|
|
#else
|
|
inputMesh.positionOS.xyz += vertexValue;
|
|
#endif
|
|
|
|
inputMesh.normalOS = inputMesh.normalOS ;
|
|
|
|
float3 positionRWS = TransformObjectToWorld(inputMesh.positionOS);
|
|
float3 normalWS = TransformObjectToWorldNormal(inputMesh.normalOS);
|
|
|
|
o.positionCS = TransformWorldToHClip(positionRWS);
|
|
o.normalWS.xyz = normalWS;
|
|
|
|
return o;
|
|
}
|
|
|
|
#if defined(ASE_TESSELLATION)
|
|
struct VertexControl
|
|
{
|
|
float3 positionOS : INTERNALTESSPOS;
|
|
float3 normalOS : NORMAL;
|
|
float4 ase_texcoord : TEXCOORD0;
|
|
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct TessellationFactors
|
|
{
|
|
float edge[3] : SV_TessFactor;
|
|
float inside : SV_InsideTessFactor;
|
|
};
|
|
|
|
VertexControl Vert ( VertexInput v )
|
|
{
|
|
VertexControl o;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
o.positionOS = v.positionOS;
|
|
o.normalOS = v.normalOS;
|
|
o.ase_texcoord = v.ase_texcoord;
|
|
return o;
|
|
}
|
|
|
|
TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
|
|
{
|
|
TessellationFactors o;
|
|
float4 tf = 1;
|
|
float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
|
|
float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
|
|
#if (SHADEROPTIONS_CAMERA_RELATIVE_RENDERING != 0)
|
|
float3 cameraPos = 0;
|
|
#else
|
|
float3 cameraPos = _WorldSpaceCameraPos;
|
|
#endif
|
|
#if defined(ASE_FIXED_TESSELLATION)
|
|
tf = FixedTess( tessValue );
|
|
#elif defined(ASE_DISTANCE_TESSELLATION)
|
|
tf = DistanceBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), cameraPos );
|
|
#elif defined(ASE_LENGTH_TESSELLATION)
|
|
tf = EdgeLengthBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, GetObjectToWorldMatrix(), cameraPos, _ScreenParams );
|
|
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
|
tf = EdgeLengthBasedTessCull(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), cameraPos, _ScreenParams, _FrustumPlanes );
|
|
#endif
|
|
o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
|
|
return o;
|
|
}
|
|
|
|
[domain("tri")]
|
|
[partitioning("fractional_odd")]
|
|
[outputtopology("triangle_cw")]
|
|
[patchconstantfunc("TessellationFunction")]
|
|
[outputcontrolpoints(3)]
|
|
VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
|
|
{
|
|
return patch[id];
|
|
}
|
|
|
|
[domain("tri")]
|
|
VertexOutput DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
|
{
|
|
VertexInput o = (VertexInput) 0;
|
|
o.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
|
|
o.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
|
|
o.ase_texcoord = patch[0].ase_texcoord * bary.x + patch[1].ase_texcoord * bary.y + patch[2].ase_texcoord * bary.z;
|
|
#if defined(ASE_PHONG_TESSELLATION)
|
|
float3 pp[3];
|
|
for (int i = 0; i < 3; ++i)
|
|
pp[i] = o.positionOS.xyz - patch[i].normalOS * (dot(o.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
|
|
float phongStrength = _TessPhongStrength;
|
|
o.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.positionOS.xyz;
|
|
#endif
|
|
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
|
return VertexFunction(o);
|
|
}
|
|
#else
|
|
VertexOutput Vert ( VertexInput v )
|
|
{
|
|
return VertexFunction( v );
|
|
}
|
|
#endif
|
|
|
|
void Frag( VertexOutput packedInput
|
|
, out float4 outColor : SV_Target0
|
|
|
|
)
|
|
{
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(packedInput);
|
|
UNITY_SETUP_INSTANCE_ID(packedInput);
|
|
|
|
FragInputs input;
|
|
ZERO_INITIALIZE(FragInputs, input);
|
|
input.tangentToWorld = k_identity3x3;
|
|
input.positionSS = packedInput.positionCS;
|
|
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS);
|
|
|
|
SurfaceDescription surfaceDescription = (SurfaceDescription)0;
|
|
|
|
surfaceDescription.Alpha = 1;
|
|
surfaceDescription.AlphaClipThreshold = _AlphaCutoff;
|
|
|
|
|
|
float3 V = float3(1.0, 1.0, 1.0);
|
|
|
|
SurfaceData surfaceData;
|
|
BuiltinData builtinData;
|
|
GetSurfaceAndBuiltinData(surfaceDescription, input, V, posInput, surfaceData, builtinData);
|
|
outColor = _SelectionID;
|
|
}
|
|
|
|
ENDHLSL
|
|
}
|
|
|
|
Pass
|
|
{
|
|
|
|
Name "FullScreenDebug"
|
|
Tags
|
|
{
|
|
"LightMode" = "FullScreenDebug"
|
|
}
|
|
|
|
Cull [_CullMode]
|
|
ZTest LEqual
|
|
ZWrite Off
|
|
|
|
HLSLPROGRAM
|
|
|
|
/*ase_pragma_before*/
|
|
|
|
#pragma multi_compile_instancing
|
|
#pragma instancing_options renderinglayer
|
|
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/GeometricTools.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Tessellation.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
|
|
#include "Packages/com.unity.shadergraph/ShaderGraphLibrary/Functions.hlsl"
|
|
|
|
#define ATTRIBUTES_NEED_NORMAL
|
|
#define ATTRIBUTES_NEED_TANGENT
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
|
|
#ifndef SHADER_UNLIT
|
|
#if defined(_DOUBLESIDED_ON) && !defined(VARYINGS_NEED_CULLFACE)
|
|
#define VARYINGS_NEED_CULLFACE
|
|
#endif
|
|
#endif
|
|
|
|
#if defined(_MATERIAL_FEATURE_SUBSURFACE_SCATTERING) && !defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define OUTPUT_SPLIT_LIGHTING
|
|
#endif
|
|
|
|
#if !( (SHADERPASS == SHADERPASS_FORWARD) || (SHADERPASS == SHADERPASS_LIGHT_TRANSPORT) \
|
|
|| (SHADERPASS == SHADERPASS_RAYTRACING_INDIRECT) || (SHADERPASS == SHADERPASS == SHADERPASS_RAYTRACING_INDIRECT)\
|
|
|| (SHADERPASS == SHADERPASS_PATH_TRACING) || (SHADERPASS == SHADERPASS_RAYTRACING_SUB_SURFACE) \
|
|
|| (SHADERPASS == SHADERPASS_RAYTRACING_GBUFFER) )
|
|
|
|
#define DISABLE_MODIFY_BAKED_DIFFUSE_LIGHTING
|
|
#endif
|
|
|
|
#if SHADERPASS == SHADERPASS_TRANSPARENT_DEPTH_PREPASS
|
|
#if !defined(_DISABLE_SSR_TRANSPARENT) && !defined(SHADER_UNLIT)
|
|
#define WRITE_NORMAL_BUFFER
|
|
#endif
|
|
#endif
|
|
|
|
#ifndef DEBUG_DISPLAY
|
|
#if !defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#if SHADERPASS == SHADERPASS_FORWARD
|
|
#define SHADERPASS_FORWARD_BYPASS_ALPHA_TEST
|
|
#elif SHADERPASS == SHADERPASS_GBUFFER
|
|
#define SHADERPASS_GBUFFER_BYPASS_ALPHA_TEST
|
|
#endif
|
|
#endif
|
|
#endif
|
|
|
|
#if defined(SHADER_LIT) && !defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define _DEFERRED_CAPABLE_MATERIAL
|
|
#endif
|
|
|
|
#if defined(_TRANSPARENT_WRITES_MOTION_VEC) && defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define _WRITE_TRANSPARENT_MOTION_VECTOR
|
|
#endif
|
|
|
|
#ifdef DEBUG_DISPLAY
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
|
|
#endif
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/NormalSurfaceGradient.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
|
|
struct AttributesMesh
|
|
{
|
|
float3 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
float4 tangentOS : TANGENT;
|
|
#if UNITY_ANY_INSTANCING_ENABLED
|
|
uint instanceID : INSTANCEID_SEMANTIC;
|
|
#endif
|
|
};
|
|
|
|
struct VaryingsMeshToPS
|
|
{
|
|
SV_POSITION_QUALIFIERS float4 positionCS : SV_POSITION;
|
|
#if UNITY_ANY_INSTANCING_ENABLED
|
|
uint instanceID : CUSTOM_INSTANCE_ID;
|
|
#endif
|
|
};
|
|
|
|
struct VertexDescriptionInputs
|
|
{
|
|
float3 ObjectSpaceNormal;
|
|
float3 ObjectSpaceTangent;
|
|
float3 ObjectSpacePosition;
|
|
};
|
|
|
|
struct SurfaceDescriptionInputs
|
|
{
|
|
float3 TangentSpaceNormal;
|
|
};
|
|
|
|
struct PackedVaryingsMeshToPS
|
|
{
|
|
SV_POSITION_QUALIFIERS float4 positionCS : SV_POSITION;
|
|
#if UNITY_ANY_INSTANCING_ENABLED
|
|
uint instanceID : CUSTOM_INSTANCE_ID;
|
|
#endif
|
|
};
|
|
|
|
PackedVaryingsMeshToPS PackVaryingsMeshToPS (VaryingsMeshToPS input)
|
|
{
|
|
PackedVaryingsMeshToPS output;
|
|
ZERO_INITIALIZE(PackedVaryingsMeshToPS, output);
|
|
output.positionCS = input.positionCS;
|
|
#if UNITY_ANY_INSTANCING_ENABLED
|
|
output.instanceID = input.instanceID;
|
|
#endif
|
|
return output;
|
|
}
|
|
|
|
VaryingsMeshToPS UnpackVaryingsMeshToPS (PackedVaryingsMeshToPS input)
|
|
{
|
|
VaryingsMeshToPS output;
|
|
output.positionCS = input.positionCS;
|
|
#if UNITY_ANY_INSTANCING_ENABLED
|
|
output.instanceID = input.instanceID;
|
|
#endif
|
|
return output;
|
|
}
|
|
|
|
struct VertexDescription
|
|
{
|
|
float3 Position;
|
|
float3 Normal;
|
|
float3 Tangent;
|
|
};
|
|
|
|
VertexDescription VertexDescriptionFunction(VertexDescriptionInputs IN)
|
|
{
|
|
VertexDescription description = (VertexDescription)0;
|
|
description.Position = IN.ObjectSpacePosition;
|
|
description.Normal = IN.ObjectSpaceNormal;
|
|
description.Tangent = IN.ObjectSpaceTangent;
|
|
return description;
|
|
}
|
|
|
|
struct SurfaceDescription
|
|
{
|
|
float3 BaseColor;
|
|
float3 Emission;
|
|
float Alpha;
|
|
float3 BentNormal;
|
|
float Smoothness;
|
|
float Occlusion;
|
|
float3 NormalTS;
|
|
float Metallic;
|
|
};
|
|
|
|
SurfaceDescription SurfaceDescriptionFunction(SurfaceDescriptionInputs IN)
|
|
{
|
|
SurfaceDescription surface = (SurfaceDescription)0;
|
|
surface.BaseColor = IsGammaSpace() ? float3(0.5, 0.5, 0.5) : SRGBToLinear(float3(0.5, 0.5, 0.5));
|
|
surface.Emission = float3(0, 0, 0);
|
|
surface.Alpha = 1;
|
|
surface.BentNormal = IN.TangentSpaceNormal;
|
|
surface.Smoothness = 0.5;
|
|
surface.Occlusion = 1;
|
|
surface.NormalTS = IN.TangentSpaceNormal;
|
|
surface.Metallic = 0;
|
|
return surface;
|
|
}
|
|
|
|
VertexDescriptionInputs AttributesMeshToVertexDescriptionInputs(AttributesMesh input)
|
|
{
|
|
VertexDescriptionInputs output;
|
|
ZERO_INITIALIZE(VertexDescriptionInputs, output);
|
|
|
|
output.ObjectSpaceNormal = input.normalOS;
|
|
output.ObjectSpaceTangent = input.tangentOS.xyz;
|
|
output.ObjectSpacePosition = input.positionOS;
|
|
|
|
return output;
|
|
}
|
|
|
|
AttributesMesh ApplyMeshModification(AttributesMesh input, float3 timeParameters )
|
|
{
|
|
VertexDescriptionInputs vertexDescriptionInputs = AttributesMeshToVertexDescriptionInputs(input);
|
|
|
|
VertexDescription vertexDescription = VertexDescriptionFunction(vertexDescriptionInputs);
|
|
|
|
input.positionOS = vertexDescription.Position;
|
|
input.normalOS = vertexDescription.Normal;
|
|
input.tangentOS.xyz = vertexDescription.Tangent;
|
|
return input;
|
|
}
|
|
|
|
FragInputs BuildFragInputs(VaryingsMeshToPS input)
|
|
{
|
|
FragInputs output;
|
|
ZERO_INITIALIZE(FragInputs, output);
|
|
|
|
output.tangentToWorld = k_identity3x3;
|
|
output.positionSS = input.positionCS;
|
|
|
|
return output;
|
|
}
|
|
|
|
FragInputs UnpackVaryingsMeshToFragInputs(PackedVaryingsMeshToPS input)
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID(input);
|
|
VaryingsMeshToPS unpacked = UnpackVaryingsMeshToPS(input);
|
|
return BuildFragInputs(unpacked);
|
|
}
|
|
|
|
|
|
SurfaceDescriptionInputs FragInputsToSurfaceDescriptionInputs(FragInputs input, float3 viewWS)
|
|
{
|
|
SurfaceDescriptionInputs output;
|
|
ZERO_INITIALIZE(SurfaceDescriptionInputs, output);
|
|
|
|
#if defined(SHADER_STAGE_RAY_TRACING)
|
|
#else
|
|
#endif
|
|
output.TangentSpaceNormal = float3(0.0f, 0.0f, 1.0f);
|
|
return output;
|
|
}
|
|
|
|
void BuildSurfaceData(FragInputs fragInputs, inout SurfaceDescription surfaceDescription, float3 V, PositionInputs posInput, out SurfaceData surfaceData, out float3 bentNormalWS)
|
|
{
|
|
ZERO_INITIALIZE(SurfaceData, surfaceData);
|
|
|
|
surfaceData.specularOcclusion = 1.0;
|
|
|
|
surfaceData.baseColor = surfaceDescription.BaseColor;
|
|
surfaceData.perceptualSmoothness = surfaceDescription.Smoothness;
|
|
surfaceData.ambientOcclusion = surfaceDescription.Occlusion;
|
|
surfaceData.metallic = surfaceDescription.Metallic;
|
|
|
|
#if defined(_REFRACTION_PLANE) || defined(_REFRACTION_SPHERE) || defined(_REFRACTION_THIN)
|
|
if (_EnableSSRefraction)
|
|
{
|
|
|
|
surfaceData.transmittanceMask = (1.0 - surfaceDescription.Alpha);
|
|
surfaceDescription.Alpha = 1.0;
|
|
}
|
|
else
|
|
{
|
|
surfaceData.ior = 1.0;
|
|
surfaceData.transmittanceColor = float3(1.0, 1.0, 1.0);
|
|
surfaceData.atDistance = 1.0;
|
|
surfaceData.transmittanceMask = 0.0;
|
|
surfaceDescription.Alpha = 1.0;
|
|
}
|
|
#else
|
|
surfaceData.ior = 1.0;
|
|
surfaceData.transmittanceColor = float3(1.0, 1.0, 1.0);
|
|
surfaceData.atDistance = 1.0;
|
|
surfaceData.transmittanceMask = 0.0;
|
|
#endif
|
|
|
|
|
|
surfaceData.materialFeatures = MATERIALFEATUREFLAGS_LIT_STANDARD;
|
|
#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SUBSURFACE_SCATTERING;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_TRANSMISSION
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_TRANSMISSION;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_ANISOTROPY
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_ANISOTROPY;
|
|
surfaceData.normalWS = float3(0, 1, 0);
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_IRIDESCENCE
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_IRIDESCENCE;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_SPECULAR_COLOR
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SPECULAR_COLOR;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_CLEAR_COAT
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_CLEAR_COAT;
|
|
#endif
|
|
#if defined (_MATERIAL_FEATURE_SPECULAR_COLOR) && defined (_ENERGY_CONSERVING_SPECULAR)
|
|
surfaceData.baseColor *= (1.0 - Max3(surfaceData.specularColor.r, surfaceData.specularColor.g, surfaceData.specularColor.b));
|
|
#endif
|
|
#ifdef _DOUBLESIDED_ON
|
|
float3 doubleSidedConstants = _DoubleSidedConstants.xyz;
|
|
#else
|
|
float3 doubleSidedConstants = float3(1.0, 1.0, 1.0);
|
|
#endif
|
|
|
|
|
|
GetNormalWS(fragInputs, surfaceDescription.NormalTS, surfaceData.normalWS, doubleSidedConstants);
|
|
|
|
surfaceData.geomNormalWS = fragInputs.tangentToWorld[2];
|
|
|
|
surfaceData.tangentWS = normalize(fragInputs.tangentToWorld[0].xyz);
|
|
|
|
|
|
#if HAVE_DECALS
|
|
if (_EnableDecals)
|
|
{
|
|
DecalSurfaceData decalSurfaceData = GetDecalSurfaceData(posInput, fragInputs, surfaceDescription.Alpha);
|
|
ApplyDecalToSurfaceData(decalSurfaceData, fragInputs.tangentToWorld[2], surfaceData);
|
|
}
|
|
#endif
|
|
|
|
bentNormalWS = surfaceData.normalWS;
|
|
|
|
surfaceData.tangentWS = Orthonormalize(surfaceData.tangentWS, surfaceData.normalWS);
|
|
|
|
#ifdef DEBUG_DISPLAY
|
|
if (_DebugMipMapMode != DEBUGMIPMAPMODE_NONE)
|
|
{
|
|
|
|
surfaceData.metallic = 0;
|
|
}
|
|
|
|
ApplyDebugToSurfaceData(fragInputs.tangentToWorld, surfaceData);
|
|
#endif
|
|
|
|
#if defined(_SPECULAR_OCCLUSION_CUSTOM)
|
|
#elif defined(_SPECULAR_OCCLUSION_FROM_AO_BENT_NORMAL)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromBentAO(V, bentNormalWS, surfaceData.normalWS, surfaceData.ambientOcclusion, PerceptualSmoothnessToPerceptualRoughness(surfaceData.perceptualSmoothness));
|
|
#elif defined(_AMBIENT_OCCLUSION) && defined(_SPECULAR_OCCLUSION_FROM_AO)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromAmbientOcclusion(ClampNdotV(dot(surfaceData.normalWS, V)), surfaceData.ambientOcclusion, PerceptualSmoothnessToRoughness(surfaceData.perceptualSmoothness));
|
|
#endif
|
|
}
|
|
|
|
void GetSurfaceAndBuiltinData(FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData RAY_TRACING_OPTIONAL_PARAMETERS)
|
|
{
|
|
|
|
#if !defined(SHADER_STAGE_RAY_TRACING) && !defined(_TESSELLATION_DISPLACEMENT)
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
LODDitheringTransition(ComputeFadeMaskSeed(V, posInput.positionSS), unity_LODFade.x);
|
|
#endif
|
|
#endif
|
|
|
|
#ifndef SHADER_UNLIT
|
|
#ifdef _DOUBLESIDED_ON
|
|
float3 doubleSidedConstants = _DoubleSidedConstants.xyz;
|
|
#else
|
|
float3 doubleSidedConstants = float3(1.0, 1.0, 1.0);
|
|
#endif
|
|
|
|
ApplyDoubleSidedFlipOrMirror(fragInputs, doubleSidedConstants);
|
|
#endif
|
|
|
|
SurfaceDescriptionInputs surfaceDescriptionInputs = FragInputsToSurfaceDescriptionInputs(fragInputs, V);
|
|
|
|
SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs);
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
float alphaCutoff = surfaceDescription.AlphaClipThreshold;
|
|
#if SHADERPASS == SHADERPASS_TRANSPARENT_DEPTH_PREPASS
|
|
#elif SHADERPASS == SHADERPASS_TRANSPARENT_DEPTH_POSTPASS
|
|
alphaCutoff = surfaceDescription.AlphaClipThresholdDepthPostpass;
|
|
#elif (SHADERPASS == SHADERPASS_SHADOWS) || (SHADERPASS == SHADERPASS_RAYTRACING_VISIBILITY)
|
|
#endif
|
|
GENERIC_ALPHA_TEST(surfaceDescription.Alpha, alphaCutoff);
|
|
#endif
|
|
|
|
#if !defined(SHADER_STAGE_RAY_TRACING) && _DEPTHOFFSET_ON
|
|
ApplyDepthOffsetPositionInput(V, surfaceDescription.DepthOffset, GetViewForwardDir(), GetWorldToHClipMatrix(), posInput);
|
|
#endif
|
|
|
|
#ifndef SHADER_UNLIT
|
|
float3 bentNormalWS;
|
|
BuildSurfaceData(fragInputs, surfaceDescription, V, posInput, surfaceData, bentNormalWS);
|
|
|
|
InitBuiltinData(posInput, surfaceDescription.Alpha, bentNormalWS, -fragInputs.tangentToWorld[2], fragInputs.texCoord1, fragInputs.texCoord2, builtinData);
|
|
|
|
#else
|
|
BuildSurfaceData(fragInputs, surfaceDescription, V, posInput, surfaceData);
|
|
|
|
ZERO_BUILTIN_INITIALIZE(builtinData);
|
|
builtinData.opacity = surfaceDescription.Alpha;
|
|
|
|
#if defined(DEBUG_DISPLAY)
|
|
builtinData.renderingLayers = GetMeshRenderingLightLayer();
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
|
|
builtinData.alphaClipTreshold = alphaCutoff;
|
|
#endif
|
|
|
|
|
|
builtinData.emissiveColor = surfaceDescription.Emission;
|
|
|
|
#if _DEPTHOFFSET_ON
|
|
builtinData.depthOffset = surfaceDescription.DepthOffset;
|
|
#endif
|
|
|
|
|
|
#if (SHADERPASS == SHADERPASS_DISTORTION)
|
|
builtinData.distortion = surfaceDescription.Distortion;
|
|
builtinData.distortionBlur = surfaceDescription.DistortionBlur;
|
|
#endif
|
|
|
|
#ifndef SHADER_UNLIT
|
|
|
|
PostInitBuiltinData(V, posInput, surfaceData, builtinData);
|
|
#else
|
|
ApplyDebugToBuiltinData(builtinData);
|
|
#endif
|
|
|
|
}
|
|
|
|
#define DEBUG_DISPLAY
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/FullScreenDebug.hlsl"
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl"
|
|
|
|
PackedVaryingsType Vert(AttributesMesh inputMesh)
|
|
{
|
|
VaryingsType varyingsType;
|
|
varyingsType.vmesh = VertMesh(inputMesh);
|
|
return PackVaryingsType(varyingsType);
|
|
}
|
|
|
|
#if !defined(_DEPTHOFFSET_ON)
|
|
[earlydepthstencil]
|
|
#endif
|
|
void Frag(PackedVaryingsToPS packedInput)
|
|
{
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(packedInput);
|
|
FragInputs input = UnpackVaryingsToFragInputs(packedInput);
|
|
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS.xyz);
|
|
|
|
#ifdef PLATFORM_SUPPORTS_PRIMITIVE_ID_IN_PIXEL_SHADER
|
|
if (_DebugFullScreenMode == FULLSCREENDEBUGMODE_QUAD_OVERDRAW)
|
|
{
|
|
IncrementQuadOverdrawCounter(posInput.positionSS.xy, input.primitiveID);
|
|
}
|
|
#endif
|
|
}
|
|
ENDHLSL
|
|
}
|
|
|
|
}
|
|
|
|
CustomEditor "Rendering.HighDefinition.LightingShaderGraphGUI"
|
|
|
|
Fallback Off
|
|
}
|
|
/*ASEBEGIN
|
|
Version=19202
|
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;1;0,0;Float;False;False;-1;2;Rendering.HighDefinition.LightingShaderGraphGUI;0;1;New Amplify Shader;53b46d85872c5b24c8f4f0a1c3fe4c87;True;META;0;1;META;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;3;RenderPipeline=HDRenderPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;5;True;7;d3d11;metal;vulkan;xboxone;xboxseries;playstation;switch;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;2;False;;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;1;LightMode=Meta;False;False;0;;0;0;Standard;0;False;0
|
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;2;0,0;Float;False;False;-1;2;Rendering.HighDefinition.LightingShaderGraphGUI;0;1;New Amplify Shader;53b46d85872c5b24c8f4f0a1c3fe4c87;True;ShadowCaster;0;2;ShadowCaster;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;3;RenderPipeline=HDRenderPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;5;True;7;d3d11;metal;vulkan;xboxone;xboxseries;playstation;switch;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;0;True;_CullMode;False;True;False;False;False;False;0;False;;False;False;False;False;False;False;False;False;False;True;1;False;;True;3;False;;False;True;1;LightMode=ShadowCaster;False;False;0;;0;0;Standard;0;False;0
|
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;3;0,0;Float;False;False;-1;2;Rendering.HighDefinition.LightingShaderGraphGUI;0;1;New Amplify Shader;53b46d85872c5b24c8f4f0a1c3fe4c87;True;SceneSelectionPass;0;3;SceneSelectionPass;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;3;RenderPipeline=HDRenderPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;5;True;7;d3d11;metal;vulkan;xboxone;xboxseries;playstation;switch;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;2;False;;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;1;LightMode=SceneSelectionPass;False;False;0;;0;0;Standard;0;False;0
|
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;4;0,0;Float;False;False;-1;2;Rendering.HighDefinition.LightingShaderGraphGUI;0;1;New Amplify Shader;53b46d85872c5b24c8f4f0a1c3fe4c87;True;DepthOnly;0;4;DepthOnly;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;3;RenderPipeline=HDRenderPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;5;True;7;d3d11;metal;vulkan;xboxone;xboxseries;playstation;switch;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;0;True;_CullMode;False;False;False;False;False;False;False;False;False;True;True;0;True;_StencilRefDepth;255;False;;255;True;_StencilWriteMaskDepth;7;False;;3;False;;0;False;;0;False;;7;False;;3;False;;0;False;;0;False;;False;True;1;False;;False;False;True;1;LightMode=DepthOnly;False;False;0;;0;0;Standard;0;False;0
|
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;5;0,0;Float;False;False;-1;2;Rendering.HighDefinition.LightingShaderGraphGUI;0;1;New Amplify Shader;53b46d85872c5b24c8f4f0a1c3fe4c87;True;MotionVectors;0;5;MotionVectors;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;3;RenderPipeline=HDRenderPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;5;True;7;d3d11;metal;vulkan;xboxone;xboxseries;playstation;switch;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;0;True;_CullMode;False;False;False;False;False;False;False;False;False;True;True;0;True;_StencilRefMV;255;False;;255;True;_StencilWriteMaskMV;7;False;;3;False;;0;False;;0;False;;7;False;;3;False;;0;False;;0;False;;False;True;1;False;;False;False;True;1;LightMode=MotionVectors;False;False;0;;0;0;Standard;0;False;0
|
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;6;0,0;Float;False;False;-1;2;Rendering.HighDefinition.LightingShaderGraphGUI;0;1;New Amplify Shader;53b46d85872c5b24c8f4f0a1c3fe4c87;True;TransparentBackface;0;6;TransparentBackface;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;3;RenderPipeline=HDRenderPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;5;True;7;d3d11;metal;vulkan;xboxone;xboxseries;playstation;switch;0;False;True;1;0;True;_SrcBlend;0;True;_DstBlend;1;0;True;_AlphaSrcBlend;0;True;_AlphaDstBlend;False;False;False;False;False;False;False;False;False;False;False;False;True;1;False;;False;False;False;True;True;True;True;True;0;True;_ColorMaskTransparentVelOne;False;False;False;False;False;False;False;True;0;True;_ZWrite;True;0;True;_ZTestTransparent;False;True;1;LightMode=TransparentBackface;False;False;0;;0;0;Standard;0;False;0
|
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;7;0,0;Float;False;False;-1;2;Rendering.HighDefinition.LightingShaderGraphGUI;0;1;New Amplify Shader;53b46d85872c5b24c8f4f0a1c3fe4c87;True;TransparentDepthPrepass;0;7;TransparentDepthPrepass;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;3;RenderPipeline=HDRenderPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;5;True;7;d3d11;metal;vulkan;xboxone;xboxseries;playstation;switch;0;False;True;1;1;False;;0;False;;0;1;False;;0;False;;False;False;False;False;False;False;False;False;False;False;False;False;True;0;True;_CullMode;False;False;False;False;False;False;False;False;False;True;True;0;True;_StencilRefDepth;255;False;;255;True;_StencilWriteMaskDepth;7;False;;3;False;;0;False;;0;False;;7;False;;3;False;;0;False;;0;False;;False;True;1;False;;False;False;True;1;LightMode=TransparentDepthPrepass;False;False;0;;0;0;Standard;0;False;0
|
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;8;0,0;Float;False;False;-1;2;Rendering.HighDefinition.LightingShaderGraphGUI;0;1;New Amplify Shader;53b46d85872c5b24c8f4f0a1c3fe4c87;True;TransparentDepthPostpass;0;8;TransparentDepthPostpass;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;3;RenderPipeline=HDRenderPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;5;True;7;d3d11;metal;vulkan;xboxone;xboxseries;playstation;switch;0;False;True;1;1;False;;0;False;;0;1;False;;0;False;;False;False;False;False;False;False;False;False;False;False;False;False;True;0;True;_CullMode;False;True;False;False;False;False;0;False;;False;False;False;False;False;False;False;False;False;True;1;False;;False;False;True;1;LightMode=TransparentDepthPostpass;False;False;0;;0;0;Standard;0;False;0
|
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;9;0,0;Float;False;False;-1;2;Rendering.HighDefinition.LightingShaderGraphGUI;0;1;New Amplify Shader;53b46d85872c5b24c8f4f0a1c3fe4c87;True;Forward;0;9;Forward;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;3;RenderPipeline=HDRenderPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;5;True;7;d3d11;metal;vulkan;xboxone;xboxseries;playstation;switch;0;False;True;1;0;True;_SrcBlend;0;True;_DstBlend;1;0;True;_AlphaSrcBlend;0;True;_AlphaDstBlend;False;False;False;False;False;False;False;False;False;False;False;False;True;0;True;_CullModeForward;False;False;False;True;True;True;True;True;0;True;_ColorMaskTransparentVelOne;False;False;False;False;False;True;True;0;True;_StencilRef;255;False;;255;True;_StencilWriteMask;7;False;;3;False;;0;False;;0;False;;7;False;;3;False;;0;False;;0;False;;False;True;0;True;_ZWrite;True;0;True;_ZTestDepthEqualForOpaque;False;True;1;LightMode=Forward;False;False;0;;0;0;Standard;0;False;0
|
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;10;0,0;Float;False;False;-1;2;Rendering.HighDefinition.LightingShaderGraphGUI;0;1;New Amplify Shader;53b46d85872c5b24c8f4f0a1c3fe4c87;True;ScenePickingPass;0;10;ScenePickingPass;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;3;RenderPipeline=HDRenderPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;5;True;7;d3d11;metal;vulkan;xboxone;xboxseries;playstation;switch;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;0;True;_CullMode;False;False;False;False;False;False;False;False;False;False;False;True;2;False;;True;3;False;;False;True;1;LightMode=Picking;False;False;0;;0;0;Standard;0;False;0
|
|
Node;AmplifyShaderEditor.RangedFloatNode;12;-220.3014,179.8177;Inherit;False;Property;_Float10;Float 10;41;0;Create;True;0;0;0;False;0;False;0.5;0.5;0;0;0;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;51;-2038.088,32.17508;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;63;-2043.432,467.6454;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.Vector2Node;65;-2061.082,311.1813;Inherit;False;Property;_Normal2Tilling;Normal2Tilling;37;0;Create;True;0;0;0;False;0;False;1,1;-0.15,0;0;3;FLOAT2;0;FLOAT;1;FLOAT;2
|
|
Node;AmplifyShaderEditor.Vector2Node;58;-2067.559,-147.1918;Inherit;False;Property;_Normal1Tilling;Normal1Tilling;36;0;Create;True;0;0;0;False;0;False;1,1;-0.15,0;0;3;FLOAT2;0;FLOAT;1;FLOAT;2
|
|
Node;AmplifyShaderEditor.SamplerNode;59;-1539.553,-92.09354;Inherit;True;Property;_WaterFlowNormal;WaterFlowNormal;38;0;Create;True;0;0;0;False;0;False;-1;09e350b54acf68c4ca8b3f46a5a64977;09e350b54acf68c4ca8b3f46a5a64977;True;0;True;bump;Auto;True;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.TextureCoordinatesNode;76;-1828.914,-136.3375;Inherit;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.TextureCoordinatesNode;77;-1811.742,325.3875;Inherit;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.TextureCoordinatesNode;43;-2019.6,834.0748;Inherit;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.SmoothstepOpNode;48;-1435.992,785.5128;Inherit;True;3;0;FLOAT;0;False;1;FLOAT;0.38;False;2;FLOAT;1;False;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.NoiseGeneratorNode;42;-1711.317,829.8863;Inherit;True;Simple;True;False;2;0;FLOAT2;0,0;False;1;FLOAT;1;False;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.SimpleTimeNode;61;-2341.742,435.5374;Inherit;True;1;0;FLOAT;1;False;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.SimpleTimeNode;50;-2336.397,0.06708527;Inherit;True;1;0;FLOAT;1;False;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.RangedFloatNode;62;-2269.908,703.7098;Inherit;False;Property;_WaterFlowSpeed1;WaterFlowSpeed1;35;0;Create;True;0;0;0;False;0;False;-1;0;0;0;0;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.RangedFloatNode;52;-2236.348,210.8119;Inherit;False;Property;_WaterFlowSpeed;WaterFlowSpeed;33;0;Create;True;0;0;0;False;0;False;1;1;0;0;0;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.Vector2Node;44;-2253.718,868.2935;Inherit;False;Property;_RainReflections1;RainReflections1;31;0;Create;True;0;0;0;False;0;False;15,15;15,15;0;3;FLOAT2;0;FLOAT;1;FLOAT;2
|
|
Node;AmplifyShaderEditor.RangedFloatNode;46;-1988.763,1038.453;Inherit;False;Property;_RainScale;RainScale;35;0;Create;True;0;0;0;False;0;False;3.13;0.5;0;0;0;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.FunctionNode;30;-1000.029,-82.49611;Inherit;False;Four Splats First Pass Terrain;0;;4;37452fdfb732e1443b7e39720d05b708;2,102,1,85,0;7;59;FLOAT4;0,0,0,0;False;60;FLOAT4;0,0,0,0;False;61;FLOAT3;0,0,0;False;57;FLOAT;0;False;58;FLOAT;0;False;201;FLOAT;0;False;62;FLOAT;0;False;7;FLOAT4;0;FLOAT3;14;FLOAT;56;FLOAT;45;FLOAT;200;FLOAT;19;FLOAT3;17
|
|
Node;AmplifyShaderEditor.SimpleAddOpNode;107;-672.5193,714.5716;Inherit;True;2;2;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;1;FLOAT3;0
|
|
Node;AmplifyShaderEditor.SimpleAddOpNode;78;-761.4642,442.4655;Inherit;True;2;2;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;1;FLOAT3;0
|
|
Node;AmplifyShaderEditor.SamplerNode;66;-1572.813,357.1255;Inherit;True;Property;_WaterFlowNormal1;WaterFlowNormal1;39;0;Create;True;0;0;0;False;0;False;-1;114b40810568bb14382fe003c4f290ef;114b40810568bb14382fe003c4f290ef;True;0;True;bump;Auto;True;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.SimpleAddOpNode;60;-1190.635,232.7002;Inherit;False;2;2;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;1;FLOAT3;0
|
|
Node;AmplifyShaderEditor.TextureCoordinatesNode;80;-1713.459,1885.086;Inherit;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.SmoothstepOpNode;81;-1129.851,1836.524;Inherit;True;3;0;FLOAT;0;False;1;FLOAT;0.38;False;2;FLOAT;1;False;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.NoiseGeneratorNode;82;-1405.176,1880.898;Inherit;True;Simple;True;False;2;0;FLOAT2;0,0;False;1;FLOAT;1;False;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;84;-793.6515,1888.515;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.SimpleAddOpNode;86;-483.6382,1870.239;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;90;-1840.807,2061.155;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.RangedFloatNode;85;-919.3268,2033.617;Inherit;False;Property;_RainOpacity;RainOpacity;29;0;Create;True;0;0;0;False;0;False;0.6;0.6;0;0;0;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.RangedFloatNode;87;-611.3181,2040.479;Inherit;False;Property;_Smoothness;Smoothness;30;0;Create;True;0;0;0;False;0;False;0.5;0.5;0;0;0;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.Vector2Node;96;-1940.335,1898.75;Inherit;False;Property;_RainReflections;RainReflections;32;0;Create;True;0;0;0;False;0;False;15,15;15,15;0;3;FLOAT2;0;FLOAT;1;FLOAT;2
|
|
Node;AmplifyShaderEditor.RangedFloatNode;92;-2117.145,2260.509;Inherit;False;InstancedProperty;_RainScale1;RainScale1;34;0;Create;True;0;0;0;False;0;False;1;1;0;0;0;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.SimpleAddOpNode;88;-312.8304,1151.353;Inherit;True;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.RangedFloatNode;111;-1892.399,586.4039;Inherit;False;Property;_NormalMapStrength;NormalMapStrength;26;0;Create;True;0;0;0;False;0;False;1;1;0;0;0;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;49;-1014.514,446.0612;Inherit;True;2;2;0;FLOAT3;0,0,0;False;1;FLOAT;0;False;1;FLOAT3;0
|
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;0;1.27998,-3.862024;Float;False;True;-1;2;Rendering.HighDefinition.LightingShaderGraphGUI;0;12;TerrainAmplifyFirstPass;53b46d85872c5b24c8f4f0a1c3fe4c87;True;GBuffer;0;0;GBuffer;33;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;3;RenderPipeline=HDRenderPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;5;True;7;d3d11;metal;vulkan;xboxone;xboxseries;playstation;switch;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;0;True;_CullMode;True;False;False;False;False;False;False;False;False;True;True;0;True;_StencilRefGBuffer;255;False;;255;True;_StencilWriteMaskGBuffer;7;False;;3;False;;0;False;;0;False;;7;False;;3;False;;0;False;;0;False;;False;False;True;0;True;_ZTestGBuffer;False;True;1;LightMode=GBuffer;False;False;0;;0;0;Standard;39;Surface Type;0;0; Rendering Pass;1;0; Refraction Model;0;0; Blending Mode;0;0; Blend Preserves Specular;1;0; Back Then Front Rendering;0;0; Transparent Depth Prepass;0;0; Transparent Depth Postpass;0;0; ZWrite;0;0; Z Test;4;0;Double-Sided;0;0;Alpha Clipping;0;0; Use Shadow Threshold;0;0;Material Type,InvertActionOnDeselection;0;0; Energy Conserving Specular;1;0; Transmission,InvertActionOnDeselection;0;638677143703510332;Forward Only;0;0;Receive Decals;0;638677136786525403;Receives SSR;0;638677137045511276;Receive SSR Transparent;0;0;Motion Vectors;0;0; Add Precomputed Velocity;0;0;Specular AA;0;0;Specular Occlusion Mode;1;0;Override Baked GI;0;0;Depth Offset;0;0;DOTS Instancing;0;0;GPU Instancing;1;0;LOD CrossFade;0;0;Tessellation;0;638677116227918484; Phong;0;0; Strength;0.5,False,;0; Type;0;0; Tess;16,False,;0; Min;10,False,;0; Max;25,False,;0; Edge Length;16,False,;0; Max Displacement;25,False,;0;Vertex Position;1;0;0;11;True;True;True;True;True;False;False;False;False;True;True;True;;False;0
|
|
Node;AmplifyShaderEditor.TextureCoordinatesNode;117;-2338.5,1042.069;Inherit;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.SamplerNode;98;-1614.954,1194.322;Inherit;True;Property;_RippleNormal;RippleNormal;27;0;Create;True;0;0;0;False;0;False;-1;c96636b5d8b90dc4890cbb288d0ff85b;None;True;0;True;bump;Auto;True;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.Vector2Node;118;-2717.426,1034.922;Inherit;False;Property;_RippleTextureCoordinatesTilling;RippleTextureCoordinatesTilling;25;0;Create;True;0;0;0;False;0;False;1,1;0,0;0;3;FLOAT2;0;FLOAT;1;FLOAT;2
|
|
Node;AmplifyShaderEditor.RangedFloatNode;119;-1917.468,1539.028;Inherit;False;Property;_RippleNormalStrength;RippleNormalStrength;24;0;Create;True;0;0;0;False;0;False;0.5;0.5;0;0;0;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.SimpleTimeNode;89;-2126.867,2097.4;Inherit;False;1;0;FLOAT;1;False;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.RangedFloatNode;95;-1652.483,2065.933;Inherit;False;Property;_RainScale;RainScale;40;0;Fetch;True;0;0;0;False;0;False;3.13;0.5;0;0;0;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.FunctionNode;97;-2020.763,1201.414;Inherit;True;Flipbook;-1;;5;53c2488c220f6564ca6c90721ee16673;6,161,0,71,0,68,0,164,1,162,1,163,1;10;51;SAMPLER2D;0.0;False;167;SAMPLERSTATE;0;False;13;FLOAT2;0,0;False;24;FLOAT;0;False;4;FLOAT;4;False;5;FLOAT;4;False;130;FLOAT;0;False;2;FLOAT;0;False;55;FLOAT;0;False;70;FLOAT;0;False;5;COLOR;53;FLOAT2;0;FLOAT;47;FLOAT;48;FLOAT;62
|
|
Node;AmplifyShaderEditor.SimpleTimeNode;99;-2602.328,1230.868;Inherit;False;1;0;FLOAT;0.001;False;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.RangedFloatNode;102;-2709.912,1376.665;Inherit;False;Property;_RippleFPS;RippleFPS;28;0;Create;True;0;0;0;False;0;False;0.001;60;0;0;0;1;FLOAT;0
|
|
WireConnection;51;0;50;0
|
|
WireConnection;51;1;52;0
|
|
WireConnection;63;0;61;0
|
|
WireConnection;63;1;62;0
|
|
WireConnection;59;1;76;0
|
|
WireConnection;59;5;111;0
|
|
WireConnection;76;0;58;0
|
|
WireConnection;76;1;51;0
|
|
WireConnection;77;0;65;0
|
|
WireConnection;77;1;63;0
|
|
WireConnection;43;0;44;0
|
|
WireConnection;48;0;42;0
|
|
WireConnection;42;0;43;0
|
|
WireConnection;42;1;46;0
|
|
WireConnection;107;0;78;0
|
|
WireConnection;107;1;98;0
|
|
WireConnection;78;0;30;14
|
|
WireConnection;78;1;49;0
|
|
WireConnection;66;1;77;0
|
|
WireConnection;66;5;111;0
|
|
WireConnection;60;0;59;0
|
|
WireConnection;60;1;66;0
|
|
WireConnection;80;0;96;0
|
|
WireConnection;81;0;82;0
|
|
WireConnection;82;0;80;0
|
|
WireConnection;82;1;95;0
|
|
WireConnection;84;0;81;0
|
|
WireConnection;84;1;85;0
|
|
WireConnection;86;0;84;0
|
|
WireConnection;86;1;87;0
|
|
WireConnection;90;0;89;0
|
|
WireConnection;90;1;92;0
|
|
WireConnection;88;1;86;0
|
|
WireConnection;49;0;60;0
|
|
WireConnection;49;1;48;0
|
|
WireConnection;0;0;30;0
|
|
WireConnection;0;1;107;0
|
|
WireConnection;0;4;12;0
|
|
WireConnection;0;7;88;0
|
|
WireConnection;117;0;118;0
|
|
WireConnection;98;1;97;0
|
|
WireConnection;98;5;119;0
|
|
WireConnection;97;13;117;0
|
|
WireConnection;97;130;99;0
|
|
WireConnection;99;0;102;0
|
|
ASEEND*/
|
|
//CHKSM=298B386D162F1FCBE23A9B1E092824C64F12C8F9 |