Shader /*ase_name*/ "Hidden/Universal/Lit" /*end*/ { Properties { /*ase_props*/ //_TransmissionShadow( "Transmission Shadow", Range( 0, 1 ) ) = 0.5 //_TransStrength( "Trans Strength", Range( 0, 50 ) ) = 1 //_TransNormal( "Trans Normal Distortion", Range( 0, 1 ) ) = 0.5 //_TransScattering( "Trans Scattering", Range( 1, 50 ) ) = 2 //_TransDirect( "Trans Direct", Range( 0, 1 ) ) = 0.9 //_TransAmbient( "Trans Ambient", Range( 0, 1 ) ) = 0.1 //_TransShadow( "Trans Shadow", Range( 0, 1 ) ) = 0.5 //_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 //_InstancedTerrainNormals("Instanced Terrain Normals", Float) = 1.0 [ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0 [ToggleOff] _EnvironmentReflections("Environment Reflections", Float) = 1.0 [ToggleUI] _ReceiveShadows("Receive Shadows", Float) = 1.0 [HideInInspector] _QueueOffset("_QueueOffset", Float) = 0 [HideInInspector] _QueueControl("_QueueControl", Float) = -1 [HideInInspector][NoScaleOffset] unity_Lightmaps("unity_Lightmaps", 2DArray) = "" {} [HideInInspector][NoScaleOffset] unity_LightmapsInd("unity_LightmapsInd", 2DArray) = "" {} [HideInInspector][NoScaleOffset] unity_ShadowMasks("unity_ShadowMasks", 2DArray) = "" {} [HideInInspector][ToggleUI] _AddPrecomputedVelocity("Add Precomputed Velocity", Float) = 1 [HideInInspector] _XRMotionVectorsPass("_XRMotionVectorsPass", Float) = 1 } SubShader { /*ase_subshader_options:Name=Additional Options Option:Category,InvertActionOnDeselection:Geometry,Terrain,Impostor:Geometry Geometry:SetDefine:ASE_GEOMETRY Terrain:SetDefine:ASE_TERRAIN Terrain:ShowOption: Instanced Terrain Normals Impostor:SetDefine:ASE_IMPOSTOR Option: Instanced Terrain Normals:Force Vertex,Force Pixel,Material Option:Force Pixel Force Vertex?Category=Terrain:SetShaderProperty:_InstancedTerrainNormals,//[KeywordEnum(Vertex, Pixel)] _InstancedTerrainNormals("Instanced Terrain Normals", Float) = 1.0 Force Pixel?Category=Terrain:SetDefine:Forward:_INSTANCEDTERRAINNORMALS_PIXEL Force Pixel?Category=Terrain:SetDefine:GBuffer:_INSTANCEDTERRAINNORMALS_PIXEL Force Pixel?Category=Terrain:SetDefine:DepthNormals:_INSTANCEDTERRAINNORMALS_PIXEL Force Pixel?Category=Terrain:SetShaderProperty:_InstancedTerrainNormals,//[KeywordEnum(Vertex, Pixel)] _InstancedTerrainNormals("Instanced Terrain Normals", Float) = 1.0 Material Option?Category=Terrain:SetDefine:Forward:pragma shader_feature _INSTANCEDTERRAINNORMALS_PIXEL Material Option?Category=Terrain:SetDefine:GBuffer:pragma shader_feature _INSTANCEDTERRAINNORMALS_PIXEL Material Option?Category=Terrain:SetDefine:DepthNormals:pragma shader_feature _INSTANCEDTERRAINNORMALS_PIXEL Material Option?Category=Terrain:SetShaderProperty:_InstancedTerrainNormals,[KeywordEnum(Vertex, Pixel)] _InstancedTerrainNormals("Instanced Terrain Normals", Float) = 1.0 Option:Lighting Model:PBR,Simple:PBR PBR:SetPropertyOnSubShader:ChangeTagValue,UniversalMaterialType,Lit PBR:SetShaderProperty:_SpecularHighlights,1 PBR:SetShaderProperty:_EnvironmentReflections,1 PBR:RemoveDefine:ASE_LIGHTING_SIMPLE Simple:SetOption:Workflow,0 Simple:SetDefine:ASE_LIGHTING_SIMPLE Simple:SetPropertyOnSubShader:ChangeTagValue,UniversalMaterialType,SimpleLit Simple:SetShaderProperty:_SpecularHighlights,0 Simple:SetShaderProperty:_EnvironmentReflections,0 Option:Workflow:Specular,Metallic:Metallic Specular:SetDefine:_SPECULAR_SETUP 1 Specular:ShowPort:Forward:Specular Specular:HidePort:Forward:Metallic Metallic:SetOption:Lighting Model,0 Metallic:RemoveDefine:_SPECULAR_SETUP 1 Metallic:ShowPort:Forward:Metallic Metallic:HidePort:Forward:Specular Option:Surface:Opaque,Transparent:Opaque Opaque:SetPropertyOnSubShader:RenderType,Opaque Opaque:SetPropertyOnSubShader:RenderQueue,Geometry Opaque:SetPropertyOnSubShader:ZWrite,On Opaque:ShowOption: Keep Alpha Opaque:HideOption: Refraction Model Opaque:HideOption: Blend Opaque:RemoveDefine:_SURFACE_TYPE_TRANSPARENT 1 Opaque:RefreshOption:Alpha Clipping Transparent:SetPropertyOnSubShader:RenderType,Transparent Transparent:SetPropertyOnSubShader:RenderQueue,Transparent Transparent:SetPropertyOnSubShader:ZWrite,Off Transparent:HideOption: Keep Alpha Transparent:ShowOption: Refraction Model Transparent:ShowOption: Blend Transparent:SetDefine:_SURFACE_TYPE_TRANSPARENT 1 Option: Keep Alpha:false,true:false true:SetDefine:ASE_OPAQUE_KEEP_ALPHA false:RemoveDefine:ASE_OPAQUE_KEEP_ALPHA Option: Refraction Model:None,Legacy:None None,disable:HidePort:Forward:Refraction Index None,disable:HidePort:Forward:Refraction Color None,disable:RemoveDefine:ASE_REFRACTION 1 None,disable:RemoveDefine:REQUIRE_OPAQUE_TEXTURE 1 Legacy:ShowPort:Forward:Refraction Index Legacy:ShowPort:Forward:Refraction Color Legacy:SetDefine:ASE_REFRACTION 1 Legacy:SetDefine:REQUIRE_OPAQUE_TEXTURE 1 Option: Blend:Alpha,Premultiply,Additive,Multiply:Alpha Alpha:SetPropertyOnPass:Forward:BlendRGB,SrcAlpha,OneMinusSrcAlpha Premultiply:SetPropertyOnPass:Forward:BlendRGB,One,OneMinusSrcAlpha Additive:SetPropertyOnPass:Forward:BlendRGB,One,One Multiply:SetPropertyOnPass:Forward:BlendRGB,DstColor,Zero Alpha,Premultiply,Additive:SetPropertyOnPass:Forward:BlendAlpha,One,OneMinusSrcAlpha Multiply:SetPropertyOnPass:Forward:BlendAlpha,One,Zero disable:SetPropertyOnPass:Forward:BlendRGB,One,Zero disable:SetPropertyOnPass:Forward:BlendAlpha,One,Zero Option:Two Sided:On,Cull Back,Cull Front:Cull Back On:SetPropertyOnSubShader:CullMode,Off Cull Back:SetPropertyOnSubShader:CullMode,Back Cull Front:SetPropertyOnSubShader:CullMode,Front Option:Alpha Clipping:false,true:true true:ShowPort:Forward:Alpha Clip Threshold true?Cast Shadows=true:ShowOption: Use Shadow Threshold true?Surface=Opaque:SetPropertyOnSubShader:RenderType,TransparentCutout true?Surface=Opaque:SetPropertyOnSubShader:RenderQueue,AlphaTest true:SetDefine:Forward:pragma multi_compile_local_fragment _ALPHATEST_ON true:SetDefine:GBuffer:pragma multi_compile_local_fragment _ALPHATEST_ON true:SetDefine:Meta:pragma multi_compile_local_fragment _ALPHATEST_ON true:SetDefine:Universal2D:pragma multi_compile_local_fragment _ALPHATEST_ON true:SetDefine:ShadowCaster:pragma multi_compile_local _ALPHATEST_ON true:SetDefine:DepthOnly:pragma multi_compile_local _ALPHATEST_ON true:SetDefine:DepthNormals:pragma multi_compile_local _ALPHATEST_ON true:SetDefine:MotionVectors:pragma multi_compile_local _ALPHATEST_ON true:SetDefine:XRMotionVectors:pragma multi_compile_local _ALPHATEST_ON false:HidePort:Forward:Alpha Clip Threshold false:SetOption: Use Shadow Threshold,0 false:HideOption: Use Shadow Threshold false:RefreshOption:Surface false:RemoveDefine:Forward:pragma multi_compile_local_fragment _ALPHATEST_ON false:RemoveDefine:GBuffer:pragma multi_compile_local_fragment _ALPHATEST_ON false:RemoveDefine:Meta:pragma multi_compile_local_fragment _ALPHATEST_ON false:RemoveDefine:Universal2D:pragma multi_compile_local_fragment _ALPHATEST_ON false:RemoveDefine:ShadowCaster:pragma multi_compile_local _ALPHATEST_ON false:RemoveDefine:DepthOnly:pragma multi_compile_local _ALPHATEST_ON false:RemoveDefine:DepthNormals:pragma multi_compile_local _ALPHATEST_ON false:RemoveDefine:MotionVectors:pragma multi_compile_local _ALPHATEST_ON false:RemoveDefine:XRMotionVectors:pragma multi_compile_local _ALPHATEST_ON Option: Use Shadow Threshold:false,true:false true:ShowPort:Forward:Alpha Clip Threshold Shadow true:SetDefine:_ALPHATEST_SHADOW_ON 1 false,disable:RemoveDefine:_ALPHATEST_SHADOW_ON 1 false,disable:HidePort:Forward:Alpha Clip Threshold Shadow Option:Fragment Normal Space,InvertActionOnDeselection:Tangent,Object,World:Tangent Tangent:SetDefine:_NORMAL_DROPOFF_TS 1 Tangent:SetPortName:Forward:1,Normal Object:SetDefine:_NORMAL_DROPOFF_OS 1 Object:SetPortName:Forward:1,Object Normal World:SetDefine:_NORMAL_DROPOFF_WS 1 World:SetPortName:Forward:1,World Normal Option:Forward Only:false,true:false false,disable:SetPropertyOnPass:Forward:ChangeTagValue,LightMode,UniversalForward false,disable:SetPropertyOnPass:DepthNormals:ChangeTagValue,LightMode,DepthNormals false,disable:IncludePass:GBuffer true:SetPropertyOnPass:Forward:ChangeTagValue,LightMode,UniversalForwardOnly true:SetPropertyOnPass:DepthNormals:ChangeTagValue,LightMode,DepthNormalsOnly true:ExcludePass:GBuffer Option:Transmission:false,true:false true:SetOption:Forward Only,1 true:ExcludePass:GBuffer false,disable:IncludePass:GBuffer false:RemoveDefine:ASE_TRANSMISSION 1 false:HidePort:Forward:Transmission false:HideOption: Transmission Shadow true:SetDefine:ASE_TRANSMISSION 1 true:ShowPort:Forward:Transmission true:ShowOption: Transmission Shadow Field: Transmission Shadow:Float:0.5:0:1:_TransmissionShadow Change:SetMaterialProperty:_TransmissionShadow Change:SetShaderProperty:_TransmissionShadow,_TransmissionShadow( "Transmission Shadow", Range( 0, 1 ) ) = 0.5 Inline,disable:SetShaderProperty:_TransmissionShadow,//_TransmissionShadow( "Transmission Shadow", Range( 0, 1 ) ) = 0.5 Option:Translucency:false,true:false true:SetOption:Forward Only,1 true:ExcludePass:GBuffer false,disable:IncludePass:GBuffer false:RemoveDefine:ASE_TRANSLUCENCY 1 false:HidePort:Forward:Translucency false:HideOption: Translucency Strength false:HideOption: Normal Distortion false:HideOption: Scattering false:HideOption: Direct false:HideOption: Ambient false:HideOption: Shadow true:SetDefine:ASE_TRANSLUCENCY 1 true:ShowPort:Forward:Translucency true:ShowOption: Translucency Strength true:ShowOption: Normal Distortion true:ShowOption: Scattering true:ShowOption: Direct true:ShowOption: Ambient true:ShowOption: Shadow Field: Translucency Strength:Float:1:0:50:_TransStrength Change:SetMaterialProperty:_TransStrength Change:SetShaderProperty:_TransStrength,_TransStrength( "Strength", Range( 0, 50 ) ) = 1 Inline,disable:SetShaderProperty:_TransStrength,//_TransStrength( "Strength", Range( 0, 50 ) ) = 1 Field: Normal Distortion:Float:0.5:0:1:_TransNormal Change:SetMaterialProperty:_TransNormal Change:SetShaderProperty:_TransNormal,_TransNormal( "Normal Distortion", Range( 0, 1 ) ) = 0.5 Inline,disable:SetShaderProperty:_TransNormal,//_TransNormal( "Normal Distortion", Range( 0, 1 ) ) = 0.5 Field: Scattering:Float:2:1:50:_TransScattering Change:SetMaterialProperty:_TransScattering Change:SetShaderProperty:_TransScattering,_TransScattering( "Scattering", Range( 1, 50 ) ) = 2 Inline,disable:SetShaderProperty:_TransScattering,//_TransScattering( "Scattering", Range( 1, 50 ) ) = 2 Field: Direct:Float:0.9:0:1:_TransDirect Change:SetMaterialProperty:_TransDirect Change:SetShaderProperty:_TransDirect,_TransDirect( "Direct", Range( 0, 1 ) ) = 0.9 Inline,disable:SetShaderProperty:_TransDirect,//_TransDirect( "Direct", Range( 0, 1 ) ) = 0.9 Field: Ambient:Float:0.1:0:1:_TransAmbient Change:SetMaterialProperty:_TransAmbient Change:SetShaderProperty:_TransAmbient,_TransAmbient( "Ambient", Range( 0, 1 ) ) = 0.1 Inline,disable:SetShaderProperty:_TransAmbient,//_TransAmbient( "Ambient", Range( 0, 1 ) ) = 0.1 Field: Shadow:Float:0.5:0:1:_TransShadow Change:SetMaterialProperty:_TransShadow Change:SetShaderProperty:_TransShadow,_TransShadow( "Shadow", Range( 0, 1 ) ) = 0.5 Inline,disable:SetShaderProperty:_TransShadow,//_TransShadow( "Shadow", Range( 0, 1 ) ) = 0.5 Option:Cast Shadows:false,true:true true:IncludePass:ShadowCaster false,disable:ExcludePass:ShadowCaster true?Alpha Clipping=true:ShowOption: Use Shadow Threshold false:HideOption: Use Shadow Threshold Option:Receive Shadows:Force Off,Force On,Material Toggle:Material Toggle Force On:RemoveDefine:Forward:pragma multi_compile_local_fragment _RECEIVE_SHADOWS_OFF Force On:RemoveDefine:GBuffer:pragma multi_compile_local_fragment _RECEIVE_SHADOWS_OFF Force On:RemoveDefine:Forward:pragma shader_feature_local_fragment _RECEIVE_SHADOWS_OFF Force On:RemoveDefine:GBuffer:pragma shader_feature_local_fragment _RECEIVE_SHADOWS_OFF Force On:SetShaderProperty:_ReceiveShadows,//[ToggleUI] _ReceiveShadows("Receive Shadows", Float) = 1.0 Force Off:RemoveDefine:Forward:pragma shader_feature_local_fragment _RECEIVE_SHADOWS_OFF Force Off:RemoveDefine:GBuffer:pragma shader_feature_local_fragment _RECEIVE_SHADOWS_OFF Force Off:SetDefine:Forward:pragma multi_compile_local_fragment _RECEIVE_SHADOWS_OFF Force Off:SetDefine:GBuffer:pragma multi_compile_local_fragment _RECEIVE_SHADOWS_OFF Force Off:SetShaderProperty:_ReceiveShadows,//[ToggleUI] _ReceiveShadows("Receive Shadows", Float) = 1.0 Material Toggle:SetDefine:Forward:pragma shader_feature_local_fragment _RECEIVE_SHADOWS_OFF Material Toggle:SetDefine:GBuffer:pragma shader_feature_local_fragment _RECEIVE_SHADOWS_OFF Material Toggle:RemoveDefine:Forward:pragma multi_compile_local_fragment _RECEIVE_SHADOWS_OFF Material Toggle:RemoveDefine:GBuffer:pragma multi_compile_local_fragment _RECEIVE_SHADOWS_OFF Material Toggle:SetShaderProperty:_ReceiveShadows,[ToggleUI] _ReceiveShadows("Receive Shadows", Float) = 1.0 Option:Specular Highlights:Force Off,Force On,Material Toggle:Material Toggle Force On:RemoveDefine:Forward:pragma multi_compile_local_fragment _SPECULARHIGHLIGHTS_OFF Force On:RemoveDefine:GBuffer:pragma multi_compile_local_fragment _SPECULARHIGHLIGHTS_OFF Force On:RemoveDefine:Forward:pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF Force On:RemoveDefine:GBuffer:pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF Force On:SetShaderProperty:_SpecularHighlights,//[ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0 Force Off:RemoveDefine:Forward:pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF Force Off:RemoveDefine:GBuffer:pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF Force Off:SetDefine:Forward:pragma multi_compile_local_fragment _SPECULARHIGHLIGHTS_OFF Force Off:SetDefine:GBuffer:pragma multi_compile_local_fragment _SPECULARHIGHLIGHTS_OFF Force Off:SetShaderProperty:_SpecularHighlights,//[ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0 Material Toggle:SetDefine:Forward:pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF Material Toggle:SetDefine:GBuffer:pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF Material Toggle:RemoveDefine:Forward:pragma multi_compile_local_fragment _SPECULARHIGHLIGHTS_OFF Material Toggle:RemoveDefine:GBuffer:pragma multi_compile_local_fragment _SPECULARHIGHLIGHTS_OFF Material Toggle:SetShaderProperty:_SpecularHighlights,[ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0 Option:Environment Reflections:Force Off,Force On,Material Toggle:Material Toggle Force On:RemoveDefine:Forward:pragma multi_compile_local_fragment _ENVIRONMENTREFLECTIONS_OFF Force On:RemoveDefine:GBuffer:pragma multi_compile_local_fragment _ENVIRONMENTREFLECTIONS_OFF Force On:RemoveDefine:Forward:pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF Force On:RemoveDefine:GBuffer:pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF Force On:SetShaderProperty:_EnvironmentReflections,//[ToggleOff] _EnvironmentReflections("Environment Reflections", Float) = 1.0 Force Off:RemoveDefine:Forward:pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF Force Off:RemoveDefine:GBuffer:pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF Force Off:SetDefine:Forward:pragma multi_compile_local_fragment _ENVIRONMENTREFLECTIONS_OFF Force Off:SetDefine:GBuffer:pragma multi_compile_local_fragment _ENVIRONMENTREFLECTIONS_OFF Force Off:SetShaderProperty:_EnvironmentReflections,//[ToggleOff] _EnvironmentReflections("Environment Reflections", Float) = 1.0 Material Toggle:SetDefine:Forward:pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF Material Toggle:SetDefine:GBuffer:pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF Material Toggle:RemoveDefine:Forward:pragma multi_compile_local_fragment _ENVIRONMENTREFLECTIONS_OFF Material Toggle:RemoveDefine:GBuffer:pragma multi_compile_local_fragment _ENVIRONMENTREFLECTIONS_OFF Material Toggle:SetShaderProperty:_EnvironmentReflections,[ToggleOff] _EnvironmentReflections("Environment Reflections", Float) = 1.0 Option:Receive SSAO:false,true:true true:SetDefine:Forward:pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION false:RemoveDefine:Forward:pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION Option:Motion Vectors:false,true:true true:ShowOption: Add Precomputed Velocity true:ShowOption: XR Motion Vectors true:IncludePass:MotionVectors true:SetOption:Tessellation,0 false:HideOption: Add Precomputed Velocity false:HideOption: XR Motion Vectors false:ExcludePass:MotionVectors false:ExcludePass:XRMotionVectors Option: Add Precomputed Velocity:false,true:false true:SetShaderProperty:_AddPrecomputedVelocity,[HideInInspector][ToggleUI] _AddPrecomputedVelocity("Add Precomputed Velocity", Float) = 1 true:SetShaderProperty:_AddPrecomputedVelocity,1 true:SetDefine:MotionVectors:pragma shader_feature_local_vertex _ADD_PRECOMPUTED_VELOCITY true:SetDefine:XRMotionVectors:pragma shader_feature_local_vertex _ADD_PRECOMPUTED_VELOCITY false:SetShaderProperty:_AddPrecomputedVelocity,//[HideInInspector][ToggleUI] _AddPrecomputedVelocity("Add Precomputed Velocity", Float) = 1 false:RemoveDefine:MotionVectors:pragma shader_feature_local_vertex _ADD_PRECOMPUTED_VELOCITY false:RemoveDefine:XRMotionVectors:pragma shader_feature_local_vertex _ADD_PRECOMPUTED_VELOCITY Option: XR Motion Vectors:false,true:false true:IncludePass:XRMotionVectors true:SetShaderProperty:_XRMotionVectorsPass,[HideInInspector] _XRMotionVectorsPass("_XRMotionVectorsPass", Float) = 1 false:ExcludePass:XRMotionVectors false:SetShaderProperty:_XRMotionVectorsPass,//[HideInInspector] _XRMotionVectorsPass("_XRMotionVectorsPass", Float) = 1 Option:GPU Instancing:false,true:true true:SetDefine:Forward:pragma multi_compile_instancing true:SetDefine:GBuffer:pragma multi_compile_instancing true:SetDefine:ShadowCaster:pragma multi_compile_instancing true:SetDefine:DepthOnly:pragma multi_compile_instancing true:SetDefine:DepthNormals:pragma multi_compile_instancing false:RemoveDefine:Forward:pragma multi_compile_instancing false:RemoveDefine:GBuffer:pragma multi_compile_instancing false:RemoveDefine:ShadowCaster:pragma multi_compile_instancing false:RemoveDefine:DepthOnly:pragma multi_compile_instancing false:RemoveDefine:DepthNormals:pragma multi_compile_instancing true:SetDefine:Forward:pragma instancing_options renderinglayer true:SetDefine:GBuffer:pragma instancing_options renderinglayer false:RemoveDefine:Forward:pragma instancing_options renderinglayer false:RemoveDefine:GBuffer:pragma instancing_options renderinglayer Option:LOD CrossFade:false,true:true true:SetDefine:Forward:pragma multi_compile _ LOD_FADE_CROSSFADE true:SetDefine:GBuffer:pragma multi_compile _ LOD_FADE_CROSSFADE true:SetDefine:ShadowCaster:pragma multi_compile _ LOD_FADE_CROSSFADE true:SetDefine:DepthOnly:pragma multi_compile _ LOD_FADE_CROSSFADE true:SetDefine:DepthNormals:pragma multi_compile _ LOD_FADE_CROSSFADE true:SetDefine:MotionVectors:pragma multi_compile _ LOD_FADE_CROSSFADE true:SetDefine:XRMotionVectors:pragma multi_compile _ LOD_FADE_CROSSFADE false:RemoveDefine:Forward:pragma multi_compile _ LOD_FADE_CROSSFADE false:RemoveDefine:GBuffer:pragma multi_compile _ LOD_FADE_CROSSFADE false:RemoveDefine:ShadowCaster:pragma multi_compile _ LOD_FADE_CROSSFADE false:RemoveDefine:DepthOnly:pragma multi_compile _ LOD_FADE_CROSSFADE false:RemoveDefine:DepthNormals:pragma multi_compile _ LOD_FADE_CROSSFADE false:RemoveDefine:MotionVectors:pragma multi_compile _ LOD_FADE_CROSSFADE false:RemoveDefine:XRMotionVectors:pragma multi_compile _ LOD_FADE_CROSSFADE Option:Built-in Fog:false,true:true true:SetDefine:ASE_FOG 1 false:RemoveDefine:ASE_FOG 1 Option,_FinalColorxAlpha:Final Color x Alpha:true,false:false true:SetDefine:ASE_FINAL_COLOR_ALPHA_MULTIPLY 1 false:RemoveDefine:ASE_FINAL_COLOR_ALPHA_MULTIPLY 1 Option:Meta Pass:false,true:true true:IncludePass:Meta false,disable:ExcludePass:Meta Option:Override Baked GI:false,true:false true:ShowPort:Forward:Baked GI false:HidePort:Forward:Baked GI Option:Extra Pre Pass:false,true:false true:IncludePass:ExtraPrePass false,disable:ExcludePass:ExtraPrePass Option:Tessellation:false,true:false true:SetDefine:ASE_TESSELLATION 1 true:SetDefine:pragma require tessellation tessHW true:SetDefine:pragma hull HullFunction true:SetDefine:pragma domain DomainFunction true:ShowOption: Phong true:ShowOption: Type false,disable:RemoveDefine:ASE_TESSELLATION 1 false,disable:RemoveDefine:pragma require tessellation tessHW false,disable:RemoveDefine:pragma hull HullFunction false,disable:RemoveDefine:pragma domain DomainFunction false,disable:HideOption: Phong false,disable:HideOption: Type true:SetOption:Motion Vectors,0 Option: Phong:false,true:false true:SetDefine:ASE_PHONG_TESSELLATION false,disable:RemoveDefine:ASE_PHONG_TESSELLATION true:ShowOption: Strength false,disable:HideOption: Strength Field: Strength:Float:0.5:0:1:_TessPhongStrength Change:SetMaterialProperty:_TessPhongStrength Change:SetShaderProperty:_TessPhongStrength,_TessPhongStrength( "Phong Tess Strength", Range( 0, 1 ) ) = 0.5 Inline,disable:SetShaderProperty:_TessPhongStrength,//_TessPhongStrength( "Phong Tess Strength", Range( 0, 1 ) ) = 0.5 Option: Type:Fixed,Distance Based,Edge Length,Edge Length Cull:Fixed Fixed:SetDefine:ASE_FIXED_TESSELLATION Fixed,Distance Based:ShowOption: Tess Distance Based:SetDefine:ASE_DISTANCE_TESSELLATION Distance Based:ShowOption: Min Distance Based:ShowOption: Max Edge Length:SetDefine:ASE_LENGTH_TESSELLATION Edge Length,Edge Length Cull:ShowOption: Edge Length Edge Length Cull:SetDefine:ASE_LENGTH_CULL_TESSELLATION Edge Length Cull:ShowOption: Max Displacement disable,Distance Based,Edge Length,Edge Length Cull:RemoveDefine:ASE_FIXED_TESSELLATION disable,Fixed,Edge Length,Edge Length Cull:RemoveDefine:ASE_DISTANCE_TESSELLATION disable,Fixed,Distance Based,Edge Length Cull:RemoveDefine:ASE_LENGTH_TESSELLATION disable,Fixed,Distance Based,Edge Length:RemoveDefine:ASE_LENGTH_CULL_TESSELLATION disable,Edge Length,Edge Length Cull:HideOption: Tess disable,Fixed,Edge Length,Edge Length Cull:HideOption: Min disable,Fixed,Edge Length,Edge Length Cull:HideOption: Max disable,Fixed,Distance Based:HideOption: Edge Length disable,Fixed,Distance Based,Edge Length:HideOption: Max Displacement Field: Tess:Float:16:1:32:_TessValue Change:SetMaterialProperty:_TessValue Change:SetShaderProperty:_TessValue,_TessValue( "Max Tessellation", Range( 1, 32 ) ) = 16 Inline,disable:SetShaderProperty:_TessValue,//_TessValue( "Max Tessellation", Range( 1, 32 ) ) = 16 Field: Min:Float:10:_TessMin Change:SetMaterialProperty:_TessMin Change:SetShaderProperty:_TessMin,_TessMin( "Tess Min Distance", Float ) = 10 Inline,disable:SetShaderProperty:_TessMin,//_TessMin( "Tess Min Distance", Float ) = 10 Field: Max:Float:25:_TessMax Change:SetMaterialProperty:_TessMax Change:SetShaderProperty:_TessMax,_TessMax( "Tess Max Distance", Float ) = 25 Inline,disable:SetShaderProperty:_TessMax,//_TessMax( "Tess Max Distance", Float ) = 25 Field: Edge Length:Float:16:2:50:_TessEdgeLength Change:SetMaterialProperty:_TessEdgeLength Change:SetShaderProperty:_TessEdgeLength,_TessEdgeLength ( "Edge length", Range( 2, 50 ) ) = 16 Inline,disable:SetShaderProperty:_TessEdgeLength,//_TessEdgeLength ( "Edge length", Range( 2, 50 ) ) = 16 Field: Max Displacement:Float:25:_TessMaxDisp Change:SetMaterialProperty:_TessMaxDisp Change:SetShaderProperty:_TessMaxDisp,_TessMaxDisp( "Max Displacement", Float ) = 25 Inline,disable:SetShaderProperty:_TessMaxDisp,//_TessMaxDisp( "Max Displacement", Float ) = 25 Option:Write Depth:false,true:false true:SetDefine:ASE_DEPTH_WRITE_ON true:ShowOption: Early Z true:ShowPort:Forward:Depth false,disable:RemoveDefine:ASE_DEPTH_WRITE_ON false,disable:HideOption: Early Z false,disable:HidePort:Forward:Depth Option: Early Z:false,true:false true:SetDefine:ASE_EARLY_Z_DEPTH_OPTIMIZE false,disable:RemoveDefine:ASE_EARLY_Z_DEPTH_OPTIMIZE Option:Vertex Position,InvertActionOnDeselection:Absolute,Relative:Relative Absolute:SetDefine:ASE_ABSOLUTE_VERTEX_POS 1 Absolute:SetPortName:Forward:8,Vertex Position Relative:SetPortName:Forward:8,Vertex Offset Absolute:SetPortName:ExtraPrePass:3,Vertex Position Relative:SetPortName:ExtraPrePass:3,Vertex Offset Option:Debug Display:false,true:true true:SetDefine:pragma multi_compile_fragment _ DEBUG_DISPLAY false,disable:RemoveDefine:pragma multi_compile_fragment _ DEBUG_DISPLAY Option:Clear Coat:false,true:false true:ShowPort:Forward:Coat Mask true:ShowPort:Forward:Coat Smoothness true:SetDefine:Forward:shader_feature_local_fragment _ _CLEARCOAT true:SetDefine:Forward:_CLEARCOAT 1 true:SetOption:Forward Only,1 true:ExcludePass:GBuffer false,disable:HidePort:Forward:Coat Mask false,disable:HidePort:Forward:Coat Smoothness false:RemoveDefine:Forward:shader_feature_local_fragment _ _CLEARCOAT false:RemoveDefine:Forward:_CLEARCOAT 1 false,disable:IncludePass:GBuffer Port:Forward:Emission On:SetDefine:_EMISSION Port:Forward:Baked GI On:SetDefine:ASE_BAKEDGI 1 Port:Forward:Normal On:SetDefine:_NORMALMAP 1 */ /*ase_unity_cond_begin:<=10000000*/ // A list of master node input port IDs; will be excluded from generated shaders. // 0 => Frag: Base Color // 1 => Frag: Normal // 2 => Frag: Emission // 3 => Frag: Metallic // 4 => Frag: Smoothness // 5 => Frag: Occlusion // 6 => Frag: Alpha // 7 => Frag: Alpha Clip Threshold // 8 => Vert: Vertex Offset // 9 => Frag: Specular // 10 => Vert: Vertex Normal // 11 => Frag: Baked GI // 12 => Frag: Refraction Color // 13 => Frag: Refraction Index // 14 => Frag: Transmission // 15 => Frag: Translucency // 16 => Frag: Alpha Clip Threshold Shadow // 17 => Frag: Depth Value // 18 => Frag: Coat Mask // 20 => Frag: Coat Smoothness // 30 => Vert: Vertex Tangent /*ase_unity_cond_end*/ Tags { "RenderPipeline" = "UniversalPipeline" "RenderType"="Opaque" "Queue"="Geometry+0" "UniversalMaterialType"="Lit" } Cull Back ZWrite On ZTest LEqual Offset 0,0 AlphaToMask Off /*ase_stencil*/ HLSLINCLUDE #pragma target 4.5 #pragma prefer_hlslcc gles #pragma exclude_renderers d3d9 // ensure rendering platforms toggle list is visible #if ( SHADER_TARGET > 35 ) && defined( SHADER_API_GLES3 ) #error For WebGL2/GLES3, please set your shader target to 3.5 via SubShader options. URP shaders in ASE use target 4.5 by default. #endif #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Filtering.hlsl" #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 DistanceFromPlane (float3 pos, float4 plane) { float d = dot (float4(pos,1.0f), plane); return d; } bool WorldViewFrustumCull (float3 wpos0, float3 wpos1, float3 wpos2, float cullEps, float4 planes[6] ) { float4 planeTest; planeTest.x = (( DistanceFromPlane(wpos0, planes[0]) > -cullEps) ? 1.0f : 0.0f ) + (( DistanceFromPlane(wpos1, planes[0]) > -cullEps) ? 1.0f : 0.0f ) + (( DistanceFromPlane(wpos2, planes[0]) > -cullEps) ? 1.0f : 0.0f ); planeTest.y = (( DistanceFromPlane(wpos0, planes[1]) > -cullEps) ? 1.0f : 0.0f ) + (( DistanceFromPlane(wpos1, planes[1]) > -cullEps) ? 1.0f : 0.0f ) + (( DistanceFromPlane(wpos2, planes[1]) > -cullEps) ? 1.0f : 0.0f ); planeTest.z = (( DistanceFromPlane(wpos0, planes[2]) > -cullEps) ? 1.0f : 0.0f ) + (( DistanceFromPlane(wpos1, planes[2]) > -cullEps) ? 1.0f : 0.0f ) + (( DistanceFromPlane(wpos2, planes[2]) > -cullEps) ? 1.0f : 0.0f ); planeTest.w = (( DistanceFromPlane(wpos0, planes[3]) > -cullEps) ? 1.0f : 0.0f ) + (( DistanceFromPlane(wpos1, planes[3]) > -cullEps) ? 1.0f : 0.0f ) + (( DistanceFromPlane(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 /*ase_pass*/ Pass { Name "ExtraPrePass" Tags{ } Blend One Zero Cull Back ZWrite On ZTest LEqual Offset 0,0 ColorMask RGBA /*ase_stencil*/ HLSLPROGRAM #pragma vertex vert #pragma fragment frag #if defined(_SPECULAR_SETUP) && defined(ASE_LIGHTING_SIMPLE) #define _SPECULAR_COLOR 1 #endif #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/UnityInstancing.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl" #if defined(LOD_FADE_CROSSFADE) #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl" #endif /*ase_pragma*/ struct Attributes { float4 positionOS : POSITION; half3 normalOS : NORMAL; half4 tangentOS : TANGENT; /*ase_vdata:p=p;n=n;t=t*/ UNITY_VERTEX_INPUT_INSTANCE_ID }; struct PackedVaryings { float4 positionCS : SV_POSITION; float3 positionWS : TEXCOORD0; #if defined(ASE_FOG) || defined(_ADDITIONAL_LIGHTS_VERTEX) half4 fogFactorAndVertexLight : TEXCOORD1; #endif /*ase_interp(2,):sp=sp;wp=tc0.xyz*/ UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_OUTPUT_STEREO }; CBUFFER_START(UnityPerMaterial) #ifdef ASE_TRANSMISSION float _TransmissionShadow; #endif #ifdef ASE_TRANSLUCENCY float _TransStrength; float _TransNormal; float _TransScattering; float _TransDirect; float _TransAmbient; float _TransShadow; #endif #ifdef ASE_TESSELLATION float _TessPhongStrength; float _TessValue; float _TessMin; float _TessMax; float _TessEdgeLength; float _TessMaxDisp; #endif CBUFFER_END #ifdef SCENEPICKINGPASS float4 _SelectionID; #endif #ifdef SCENESELECTIONPASS int _ObjectId; int _PassValue; #endif /*ase_globals*/ /*ase_funcs*/ PackedVaryings VertexFunction( Attributes input /*ase_vert_input*/ ) { PackedVaryings output = (PackedVaryings)0; UNITY_SETUP_INSTANCE_ID(input); UNITY_TRANSFER_INSTANCE_ID(input, output); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); /*ase_vert_code:input=Attributes;output=PackedVaryings*/ #ifdef ASE_ABSOLUTE_VERTEX_POS float3 defaultVertexValue = input.positionOS.xyz; #else float3 defaultVertexValue = float3(0, 0, 0); #endif float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;3;-1;_VertexP*/defaultVertexValue/*end*/; #ifdef ASE_ABSOLUTE_VERTEX_POS input.positionOS.xyz = vertexValue; #else input.positionOS.xyz += vertexValue; #endif input.normalOS = /*ase_vert_out:Vertex Normal;Float3;4;-1;_NormalP*/input.normalOS/*end*/; input.tangentOS = /*ase_vert_out:Vertex Tangent;Float4;30;-1;_TangentP*/input.tangentOS/*end*/; VertexPositionInputs vertexInput = GetVertexPositionInputs( input.positionOS.xyz ); VertexNormalInputs normalInput = GetVertexNormalInputs( input.normalOS, input.tangentOS ); #if defined(ASE_FOG) || defined(_ADDITIONAL_LIGHTS_VERTEX) output.fogFactorAndVertexLight = 0; #if defined(ASE_FOG) && !defined(_FOG_FRAGMENT) output.fogFactorAndVertexLight.x = ComputeFogFactor(vertexInput.positionCS.z); #endif #ifdef _ADDITIONAL_LIGHTS_VERTEX half3 vertexLight = VertexLighting( vertexInput.positionWS, normalInput.normalWS ); output.fogFactorAndVertexLight.yzw = vertexLight; #endif #endif output.positionCS = vertexInput.positionCS; output.positionWS = vertexInput.positionWS; return output; } #if defined(ASE_TESSELLATION) struct VertexControl { float4 positionOS : INTERNALTESSPOS; half3 normalOS : NORMAL; half4 tangentOS : TANGENT; /*ase_vcontrol*/ UNITY_VERTEX_INPUT_INSTANCE_ID }; struct TessellationFactors { float edge[3] : SV_TessFactor; float inside : SV_InsideTessFactor; }; VertexControl vert ( Attributes input ) { VertexControl output; UNITY_SETUP_INSTANCE_ID(input); UNITY_TRANSFER_INSTANCE_ID(input, output); output.positionOS = input.positionOS; output.normalOS = input.normalOS; output.tangentOS = input.tangentOS; /*ase_control_code:input=Attributes;output=VertexControl*/ return output; } TessellationFactors TessellationFunction (InputPatch input) { TessellationFactors output; float4 tf = 1; float tessValue = /*ase_inline_begin*/_TessValue/*ase_inline_end*/; float tessMin = /*ase_inline_begin*/_TessMin/*ase_inline_end*/; float tessMax = /*ase_inline_begin*/_TessMax/*ase_inline_end*/; float edgeLength = /*ase_inline_begin*/_TessEdgeLength/*ase_inline_end*/; float tessMaxDisp = /*ase_inline_begin*/_TessMaxDisp/*ase_inline_end*/; #if defined(ASE_FIXED_TESSELLATION) tf = FixedTess( tessValue ); #elif defined(ASE_DISTANCE_TESSELLATION) tf = DistanceBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos ); #elif defined(ASE_LENGTH_TESSELLATION) tf = EdgeLengthBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams ); #elif defined(ASE_LENGTH_CULL_TESSELLATION) tf = EdgeLengthBasedTessCull(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes ); #endif output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w; return output; } [domain("tri")] [partitioning("fractional_odd")] [outputtopology("triangle_cw")] [patchconstantfunc("TessellationFunction")] [outputcontrolpoints(3)] VertexControl HullFunction(InputPatch patch, uint id : SV_OutputControlPointID) { return patch[id]; } [domain("tri")] PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch patch, float3 bary : SV_DomainLocation) { Attributes output = (Attributes) 0; output.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z; output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z; output.tangentOS = patch[0].tangentOS * bary.x + patch[1].tangentOS * bary.y + patch[2].tangentOS * bary.z; /*ase_domain_code:patch=VertexControl;output=Attributes;bary=SV_DomainLocation*/ #if defined(ASE_PHONG_TESSELLATION) float3 pp[3]; for (int i = 0; i < 3; ++i) pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS)); float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/; output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz; #endif UNITY_TRANSFER_INSTANCE_ID(patch[0], output); return VertexFunction(output); } #else PackedVaryings vert ( Attributes input ) { return VertexFunction( input ); } #endif half4 frag ( PackedVaryings input /*ase_frag_input*/ ) : SV_Target { UNITY_SETUP_INSTANCE_ID( input ); UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( input ); #if defined( _SURFACE_TYPE_TRANSPARENT ) const bool isTransparent = true; #else const bool isTransparent = false; #endif #if defined(MAIN_LIGHT_CALCULATE_SHADOWS) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS) float4 shadowCoord = TransformWorldToShadowCoord(input.positionWS); #else float4 shadowCoord = float4(0, 0, 0, 0); #endif /*ase_local_var:wp*/float3 PositionWS = input.positionWS; /*ase_local_var:rwp*/float3 PositionRWS = GetCameraRelativePositionWS( input.positionWS ); /*ase_local_var:wvd*/float3 ViewDirWS = GetWorldSpaceNormalizeViewDir( PositionWS ); /*ase_local_var:sc*/float4 ShadowCoord = shadowCoord; /*ase_local_var:spn*/float4 ScreenPosNorm = float4( GetNormalizedScreenSpaceUV( input.positionCS ), input.positionCS.zw ); /*ase_local_var:sp*/float4 ClipPos = ComputeClipSpacePosition( ScreenPosNorm.xy, input.positionCS.z ) * input.positionCS.w; /*ase_local_var:spu*/float4 ScreenPos = ComputeScreenPos( ClipPos ); /*ase_frag_code:input=PackedVaryings*/ float3 Color = /*ase_frag_out:Color;Float3;0;-1;_ColorP*/float3( 0, 0, 0 )/*end*/; float Alpha = /*ase_frag_out:Alpha;Float;1;-1;_AlphaP*/1/*end*/; float AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;2;-1;_AlphaClipP*/0.5/*end*/; #if defined( _ALPHATEST_ON ) AlphaDiscard( Alpha, AlphaClipThreshold ); #endif InputData inputData = (InputData)0; inputData.positionWS = PositionWS; inputData.positionCS = float4( input.positionCS.xy, ClipPos.zw / ClipPos.w ); inputData.normalizedScreenSpaceUV = ScreenPosNorm.xy; inputData.viewDirectionWS = ViewDirWS; #ifdef ASE_FOG inputData.fogCoord = InitializeInputDataFog(float4(inputData.positionWS, 1.0), input.fogFactorAndVertexLight.x); #endif #ifdef _ADDITIONAL_LIGHTS_VERTEX inputData.vertexLighting = input.fogFactorAndVertexLight.yzw; #endif #ifdef ASE_FOG #ifdef TERRAIN_SPLAT_ADDPASS Color.rgb = MixFogColor(Color.rgb, half3(0,0,0), inputData.fogCoord); #else Color.rgb = MixFog(Color.rgb, inputData.fogCoord); #endif #endif #if defined(LOD_FADE_CROSSFADE) LODFadeCrossFade( input.positionCS ); #endif #if defined( ASE_OPAQUE_KEEP_ALPHA ) return half4( Color, Alpha ); #else return half4( Color, OutputAlpha( Alpha, isTransparent ) ); #endif } ENDHLSL } /*ase_pass*/ Pass { /*ase_main_pass*/ Name "Forward" Tags { "LightMode" = "UniversalForward" } Blend One Zero ZWrite On ZTest LEqual Offset 0,0 ColorMask RGBA /*ase_stencil*/ HLSLPROGRAM #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS #pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX #pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING #pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION #pragma multi_compile_fragment _ _REFLECTION_PROBE_ATLAS #pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 #pragma multi_compile _ _LIGHT_LAYERS #pragma multi_compile_fragment _ _LIGHT_COOKIES #pragma multi_compile _ _CLUSTER_LIGHT_LOOP #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING #pragma multi_compile _ SHADOWS_SHADOWMASK #pragma multi_compile _ DIRLIGHTMAP_COMBINED #pragma multi_compile _ LIGHTMAP_ON #pragma multi_compile _ LIGHTMAP_BICUBIC_SAMPLING #pragma multi_compile _ DYNAMICLIGHTMAP_ON #pragma multi_compile _ USE_LEGACY_LIGHTMAPS #pragma vertex vert #pragma fragment frag #if defined(_SPECULAR_SETUP) && defined(ASE_LIGHTING_SIMPLE) #define _SPECULAR_COLOR 1 #endif #define SHADERPASS SHADERPASS_FORWARD #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Fog.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DBuffer.hlsl" #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl" #if defined(LOD_FADE_CROSSFADE) #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl" #endif #if defined( UNITY_INSTANCING_ENABLED ) && defined( ASE_INSTANCED_TERRAIN ) && ( defined(_TERRAIN_INSTANCED_PERPIXEL_NORMAL) || defined(_INSTANCEDTERRAINNORMALS_PIXEL) ) #define ENABLE_TERRAIN_PERPIXEL_NORMAL #endif /*ase_pragma*/ #if defined(ASE_EARLY_Z_DEPTH_OPTIMIZE) && (SHADER_TARGET >= 45) #define ASE_SV_DEPTH SV_DepthLessEqual #define ASE_SV_POSITION_QUALIFIERS linear noperspective centroid #else #define ASE_SV_DEPTH SV_Depth #define ASE_SV_POSITION_QUALIFIERS #endif struct Attributes { float4 positionOS : POSITION; half3 normalOS : NORMAL; half4 tangentOS : TANGENT; float4 texcoord : TEXCOORD0; #if defined(LIGHTMAP_ON) || defined(ASE_NEEDS_TEXTURE_COORDINATES1) float4 texcoord1 : TEXCOORD1; #endif #if defined(DYNAMICLIGHTMAP_ON) || defined(ASE_NEEDS_TEXTURE_COORDINATES2) float4 texcoord2 : TEXCOORD2; #endif /*ase_vdata:p=p;n=n;t=t;uv0=tc0;uv1=tc1;uv2=tc2*/ UNITY_VERTEX_INPUT_INSTANCE_ID }; struct PackedVaryings { ASE_SV_POSITION_QUALIFIERS float4 positionCS : SV_POSITION; float3 positionWS : TEXCOORD0; half3 normalWS : TEXCOORD1; float4 tangentWS : TEXCOORD2; // holds terrainUV ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL float4 lightmapUVOrVertexSH : TEXCOORD3; #if defined(ASE_FOG) || defined(_ADDITIONAL_LIGHTS_VERTEX) half4 fogFactorAndVertexLight : TEXCOORD4; #endif #if defined(DYNAMICLIGHTMAP_ON) float2 dynamicLightmapUV : TEXCOORD5; #endif #if defined(USE_APV_PROBE_OCCLUSION) float4 probeOcclusion : TEXCOORD6; #endif /*ase_interp(7,):sp=sp;wp=tc0.xyz;wn.xyz=tc1.xyz;wt=tc2*/ UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_OUTPUT_STEREO }; CBUFFER_START(UnityPerMaterial) #ifdef ASE_TRANSMISSION float _TransmissionShadow; #endif #ifdef ASE_TRANSLUCENCY float _TransStrength; float _TransNormal; float _TransScattering; float _TransDirect; float _TransAmbient; float _TransShadow; #endif #ifdef ASE_TESSELLATION float _TessPhongStrength; float _TessValue; float _TessMin; float _TessMax; float _TessEdgeLength; float _TessMaxDisp; #endif CBUFFER_END #ifdef SCENEPICKINGPASS float4 _SelectionID; #endif #ifdef SCENESELECTIONPASS int _ObjectId; int _PassValue; #endif /*ase_globals*/ /*ase_funcs*/ PackedVaryings VertexFunction( Attributes input /*ase_vert_input*/ ) { PackedVaryings output = (PackedVaryings)0; UNITY_SETUP_INSTANCE_ID(input); UNITY_TRANSFER_INSTANCE_ID(input, output); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); /*ase_vert_code:input=Attributes;output=PackedVaryings*/ #ifdef ASE_ABSOLUTE_VERTEX_POS float3 defaultVertexValue = input.positionOS.xyz; #else float3 defaultVertexValue = float3(0, 0, 0); #endif float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;8;-1;_Vertex*/defaultVertexValue/*end*/; #ifdef ASE_ABSOLUTE_VERTEX_POS input.positionOS.xyz = vertexValue; #else input.positionOS.xyz += vertexValue; #endif input.normalOS = /*ase_vert_out:Vertex Normal;Float3;10;-1;_Normal*/input.normalOS/*end*/; input.tangentOS = /*ase_vert_out:Vertex Tangent;Float4;30;-1;_Tangent*/input.tangentOS/*end*/; VertexPositionInputs vertexInput = GetVertexPositionInputs( input.positionOS.xyz ); VertexNormalInputs normalInput = GetVertexNormalInputs( input.normalOS, input.tangentOS ); OUTPUT_LIGHTMAP_UV(input.texcoord1, unity_LightmapST, output.lightmapUVOrVertexSH.xy); #if defined(DYNAMICLIGHTMAP_ON) output.dynamicLightmapUV.xy = input.texcoord2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw; #endif OUTPUT_SH4(vertexInput.positionWS, normalInput.normalWS.xyz, GetWorldSpaceNormalizeViewDir(vertexInput.positionWS), output.lightmapUVOrVertexSH.xyz, output.probeOcclusion); #if defined(ASE_FOG) || defined(_ADDITIONAL_LIGHTS_VERTEX) output.fogFactorAndVertexLight = 0; #if defined(ASE_FOG) && !defined(_FOG_FRAGMENT) output.fogFactorAndVertexLight.x = ComputeFogFactor(vertexInput.positionCS.z); #endif #ifdef _ADDITIONAL_LIGHTS_VERTEX half3 vertexLight = VertexLighting( vertexInput.positionWS, normalInput.normalWS ); output.fogFactorAndVertexLight.yzw = vertexLight; #endif #endif output.positionCS = vertexInput.positionCS; output.positionWS = vertexInput.positionWS; output.normalWS = normalInput.normalWS; output.tangentWS = float4( normalInput.tangentWS, ( input.tangentOS.w > 0.0 ? 1.0 : -1.0 ) * GetOddNegativeScale() ); #if defined( ENABLE_TERRAIN_PERPIXEL_NORMAL ) output.tangentWS.zw = input.texcoord.xy; output.tangentWS.xy = input.texcoord.xy * unity_LightmapST.xy + unity_LightmapST.zw; #endif return output; } #if defined(ASE_TESSELLATION) struct VertexControl { float4 positionOS : INTERNALTESSPOS; half3 normalOS : NORMAL; half4 tangentOS : TANGENT; float4 texcoord : TEXCOORD0; #if defined(LIGHTMAP_ON) || defined(ASE_NEEDS_TEXTURE_COORDINATES1) float4 texcoord1 : TEXCOORD1; #endif #if defined(DYNAMICLIGHTMAP_ON) || defined(ASE_NEEDS_TEXTURE_COORDINATES2) float4 texcoord2 : TEXCOORD2; #endif /*ase_vcontrol*/ UNITY_VERTEX_INPUT_INSTANCE_ID }; struct TessellationFactors { float edge[3] : SV_TessFactor; float inside : SV_InsideTessFactor; }; VertexControl vert ( Attributes input ) { VertexControl output; UNITY_SETUP_INSTANCE_ID(input); UNITY_TRANSFER_INSTANCE_ID(input, output); output.positionOS = input.positionOS; output.normalOS = input.normalOS; output.tangentOS = input.tangentOS; output.texcoord = input.texcoord; #if defined(LIGHTMAP_ON) || defined(ASE_NEEDS_TEXTURE_COORDINATES1) output.texcoord1 = input.texcoord1; #endif #if defined(DYNAMICLIGHTMAP_ON) || defined(ASE_NEEDS_TEXTURE_COORDINATES2) output.texcoord2 = input.texcoord2; #endif /*ase_control_code:input=Attributes;output=VertexControl*/ return output; } TessellationFactors TessellationFunction (InputPatch input) { TessellationFactors output; float4 tf = 1; float tessValue = /*ase_inline_begin*/_TessValue/*ase_inline_end*/; float tessMin = /*ase_inline_begin*/_TessMin/*ase_inline_end*/; float tessMax = /*ase_inline_begin*/_TessMax/*ase_inline_end*/; float edgeLength = /*ase_inline_begin*/_TessEdgeLength/*ase_inline_end*/; float tessMaxDisp = /*ase_inline_begin*/_TessMaxDisp/*ase_inline_end*/; #if defined(ASE_FIXED_TESSELLATION) tf = FixedTess( tessValue ); #elif defined(ASE_DISTANCE_TESSELLATION) tf = DistanceBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos ); #elif defined(ASE_LENGTH_TESSELLATION) tf = EdgeLengthBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams ); #elif defined(ASE_LENGTH_CULL_TESSELLATION) tf = EdgeLengthBasedTessCull(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes ); #endif output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w; return output; } [domain("tri")] [partitioning("fractional_odd")] [outputtopology("triangle_cw")] [patchconstantfunc("TessellationFunction")] [outputcontrolpoints(3)] VertexControl HullFunction(InputPatch patch, uint id : SV_OutputControlPointID) { return patch[id]; } [domain("tri")] PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch patch, float3 bary : SV_DomainLocation) { Attributes output = (Attributes) 0; output.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z; output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z; output.tangentOS = patch[0].tangentOS * bary.x + patch[1].tangentOS * bary.y + patch[2].tangentOS * bary.z; output.texcoord = patch[0].texcoord * bary.x + patch[1].texcoord * bary.y + patch[2].texcoord * bary.z; #if defined(LIGHTMAP_ON) || defined(ASE_NEEDS_TEXTURE_COORDINATES1) output.texcoord1 = patch[0].texcoord1 * bary.x + patch[1].texcoord1 * bary.y + patch[2].texcoord1 * bary.z; #endif #if defined(DYNAMICLIGHTMAP_ON) || defined(ASE_NEEDS_TEXTURE_COORDINATES2) output.texcoord2 = patch[0].texcoord2 * bary.x + patch[1].texcoord2 * bary.y + patch[2].texcoord2 * bary.z; #endif /*ase_domain_code:patch=VertexControl;output=Attributes;bary=SV_DomainLocation*/ #if defined(ASE_PHONG_TESSELLATION) float3 pp[3]; for (int i = 0; i < 3; ++i) pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS)); float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/; output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz; #endif UNITY_TRANSFER_INSTANCE_ID(patch[0], output); return VertexFunction(output); } #else PackedVaryings vert ( Attributes input ) { return VertexFunction( input ); } #endif half4 frag ( PackedVaryings input #if defined( ASE_DEPTH_WRITE_ON ) ,out float outputDepth : ASE_SV_DEPTH #endif #ifdef _WRITE_RENDERING_LAYERS , out uint outRenderingLayers : SV_Target1 #endif /*ase_frag_input*/ ) : SV_Target { UNITY_SETUP_INSTANCE_ID(input); UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); #if defined( _SURFACE_TYPE_TRANSPARENT ) const bool isTransparent = true; #else const bool isTransparent = false; #endif #if defined(LOD_FADE_CROSSFADE) LODFadeCrossFade( input.positionCS ); #endif #if defined(MAIN_LIGHT_CALCULATE_SHADOWS) float4 shadowCoord = TransformWorldToShadowCoord( input.positionWS ); #else float4 shadowCoord = float4(0, 0, 0, 0); #endif // @diogo: mikktspace compliant float renormFactor = 1.0 / max( FLT_MIN, length( input.normalWS ) ); /*ase_local_var:wp*/float3 PositionWS = input.positionWS; /*ase_local_var:rwp*/float3 PositionRWS = GetCameraRelativePositionWS( PositionWS ); /*ase_local_var:wvd*/float3 ViewDirWS = GetWorldSpaceNormalizeViewDir( PositionWS ); /*ase_local_var:sc*/float4 ShadowCoord = shadowCoord; /*ase_local_var:spn*/float4 ScreenPosNorm = float4( GetNormalizedScreenSpaceUV( input.positionCS ), input.positionCS.zw ); /*ase_local_var:sp*/float4 ClipPos = ComputeClipSpacePosition( ScreenPosNorm.xy, input.positionCS.z ) * input.positionCS.w; /*ase_local_var:spu*/float4 ScreenPos = ComputeScreenPos( ClipPos ); /*ase_local_var:wt*/float3 TangentWS = input.tangentWS.xyz * renormFactor; /*ase_local_var:wbt*/float3 BitangentWS = cross( input.normalWS, input.tangentWS.xyz ) * input.tangentWS.w * renormFactor; /*ase_local_var:wn*/float3 NormalWS = input.normalWS * renormFactor; #if defined( ENABLE_TERRAIN_PERPIXEL_NORMAL ) float2 sampleCoords = (input.tangentWS.zw / _TerrainHeightmapRecipSize.zw + 0.5f) * _TerrainHeightmapRecipSize.xy; NormalWS = TransformObjectToWorldNormal(normalize(SAMPLE_TEXTURE2D(_TerrainNormalmapTexture, sampler_TerrainNormalmapTexture, sampleCoords).rgb * 2 - 1)); TangentWS = -cross(GetObjectToWorldMatrix()._13_23_33, NormalWS); BitangentWS = cross(NormalWS, -TangentWS); #endif /*ase_frag_code:input=PackedVaryings*/ float3 BaseColor = /*ase_frag_out:Base Color;Float3;0;-1;_BaseColor*/float3(0.5, 0.5, 0.5)/*end*/; float3 Normal = /*ase_frag_out:Normal;Float3;1;-1;_FragNormal*/float3(0, 0, 1)/*end*/; float3 Specular = /*ase_frag_out:Specular;Float3;9;-1;_Specular*/0.5/*end*/; float Metallic = /*ase_frag_out:Metallic;Float;3;-1;_Metallic*/0/*end*/; float Smoothness = /*ase_frag_out:Smoothness;Float;4;-1;_Smoothness*/0.5/*end*/; float Occlusion = /*ase_frag_out:Occlusion;Float;5;-1;_Occlusion*/1/*end*/; float3 Emission = /*ase_frag_out:Emission;Float3;2;-1;_Emission*/0/*end*/; float Alpha = /*ase_frag_out:Alpha;Float;6;-1;_Alpha*/1/*end*/; float AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;7;-1;_AlphaClip*/0.5/*end*/; float AlphaClipThresholdShadow = /*ase_frag_out:Alpha Clip Threshold Shadow;Float;16;-1;_AlphaClipShadow*/0.5/*end*/; float3 BakedGI = /*ase_frag_out:Baked GI;Float3;11;-1;_BakedGI*/0/*end*/; float3 RefractionColor = /*ase_frag_out:Refraction Color;Float3;12;-1;_RefractionColor*/1/*end*/; float RefractionIndex = /*ase_frag_out:Refraction Index;Float;13;-1;_RefractionIndex*/1/*end*/; float3 Transmission = /*ase_frag_out:Transmission;Float3;14;-1;_Transmission*/1/*end*/; float3 Translucency = /*ase_frag_out:Translucency;Float3;15;-1;_Translucency*/1/*end*/; #if defined( ASE_DEPTH_WRITE_ON ) float DeviceDepth = /*ase_frag_out:Depth;Float;17;-1;_DepthValue*/ClipPos.z/*end*/; #endif #ifdef _CLEARCOAT float CoatMask = /*ase_frag_out:Coat Mask;Float;18;-1;_CoatMask*/0/*end*/; float CoatSmoothness = /*ase_frag_out:Coat Smoothness;Float;20;-1;_clearCoatSmoothness*/0/*end*/; #endif #if defined( _ALPHATEST_ON ) AlphaDiscard( Alpha, AlphaClipThreshold ); #endif #if defined(MAIN_LIGHT_CALCULATE_SHADOWS) && defined(ASE_CHANGES_WORLD_POS) ShadowCoord = TransformWorldToShadowCoord( PositionWS ); #endif InputData inputData = (InputData)0; inputData.positionWS = PositionWS; inputData.positionCS = float4( input.positionCS.xy, ClipPos.zw / ClipPos.w ); inputData.normalizedScreenSpaceUV = ScreenPosNorm.xy; inputData.viewDirectionWS = ViewDirWS; inputData.shadowCoord = ShadowCoord; #ifdef _NORMALMAP #if _NORMAL_DROPOFF_TS inputData.normalWS = TransformTangentToWorld(Normal, half3x3(TangentWS, BitangentWS, NormalWS)); #elif _NORMAL_DROPOFF_OS inputData.normalWS = TransformObjectToWorldNormal(Normal); #elif _NORMAL_DROPOFF_WS inputData.normalWS = Normal; #endif inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS); #else inputData.normalWS = NormalWS; #endif #ifdef ASE_FOG inputData.fogCoord = InitializeInputDataFog(float4(inputData.positionWS, 1.0), input.fogFactorAndVertexLight.x); #endif #ifdef _ADDITIONAL_LIGHTS_VERTEX inputData.vertexLighting = input.fogFactorAndVertexLight.yzw; #endif #if defined( ENABLE_TERRAIN_PERPIXEL_NORMAL ) float3 SH = SampleSH(inputData.normalWS.xyz); #else float3 SH = input.lightmapUVOrVertexSH.xyz; #endif #if defined(DYNAMICLIGHTMAP_ON) inputData.bakedGI = SAMPLE_GI(input.lightmapUVOrVertexSH.xy, input.dynamicLightmapUV.xy, SH, inputData.normalWS); inputData.shadowMask = SAMPLE_SHADOWMASK(input.lightmapUVOrVertexSH.xy); #elif !defined(LIGHTMAP_ON) && (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2)) inputData.bakedGI = SAMPLE_GI( SH, GetAbsolutePositionWS(inputData.positionWS), inputData.normalWS, inputData.viewDirectionWS, input.positionCS.xy, input.probeOcclusion, inputData.shadowMask ); #else inputData.bakedGI = SAMPLE_GI(input.lightmapUVOrVertexSH.xy, SH, inputData.normalWS); inputData.shadowMask = SAMPLE_SHADOWMASK(input.lightmapUVOrVertexSH.xy); #endif #ifdef ASE_BAKEDGI inputData.bakedGI = BakedGI; #endif #if defined(DEBUG_DISPLAY) #if defined(DYNAMICLIGHTMAP_ON) inputData.dynamicLightmapUV = input.dynamicLightmapUV.xy; #endif #if defined(LIGHTMAP_ON) inputData.staticLightmapUV = input.lightmapUVOrVertexSH.xy; #else inputData.vertexSH = SH; #endif #if defined(USE_APV_PROBE_OCCLUSION) inputData.probeOcclusion = input.probeOcclusion; #endif #endif SurfaceData surfaceData; surfaceData.albedo = BaseColor; surfaceData.metallic = saturate(Metallic); surfaceData.specular = Specular; surfaceData.smoothness = saturate(Smoothness), surfaceData.occlusion = Occlusion, surfaceData.emission = Emission, surfaceData.alpha = saturate(Alpha); surfaceData.normalTS = Normal; surfaceData.clearCoatMask = 0; surfaceData.clearCoatSmoothness = 1; #ifdef _CLEARCOAT surfaceData.clearCoatMask = saturate(CoatMask); surfaceData.clearCoatSmoothness = saturate(CoatSmoothness); #endif #if defined(_DBUFFER) ApplyDecalToSurfaceData(input.positionCS, surfaceData, inputData); #endif #ifdef ASE_LIGHTING_SIMPLE half4 color = UniversalFragmentBlinnPhong( inputData, surfaceData); #else half4 color = UniversalFragmentPBR( inputData, surfaceData); #endif #ifdef ASE_TRANSMISSION { float shadow = /*ase_inline_begin*/_TransmissionShadow/*ase_inline_end*/; #define SUM_LIGHT_TRANSMISSION(Light)\ float3 atten = Light.color * Light.distanceAttenuation;\ atten = lerp( atten, atten * Light.shadowAttenuation, shadow );\ half3 transmission = max( 0, -dot( inputData.normalWS, Light.direction ) ) * atten * Transmission;\ color.rgb += BaseColor * transmission; SUM_LIGHT_TRANSMISSION( GetMainLight( inputData.shadowCoord ) ); #if defined(_ADDITIONAL_LIGHTS) uint meshRenderingLayers = GetMeshRenderingLayer(); uint pixelLightCount = GetAdditionalLightsCount(); #if USE_CLUSTER_LIGHT_LOOP [loop] for (uint lightIndex = 0; lightIndex < min(URP_FP_DIRECTIONAL_LIGHTS_COUNT, MAX_VISIBLE_LIGHTS); lightIndex++) { CLUSTER_LIGHT_LOOP_SUBTRACTIVE_LIGHT_CHECK Light light = GetAdditionalLight(lightIndex, inputData.positionWS, inputData.shadowMask); #ifdef _LIGHT_LAYERS if (IsMatchingLightLayer(light.layerMask, meshRenderingLayers)) #endif { SUM_LIGHT_TRANSMISSION( light ); } } #endif LIGHT_LOOP_BEGIN( pixelLightCount ) Light light = GetAdditionalLight(lightIndex, inputData.positionWS, inputData.shadowMask); #ifdef _LIGHT_LAYERS if (IsMatchingLightLayer(light.layerMask, meshRenderingLayers)) #endif { SUM_LIGHT_TRANSMISSION( light ); } LIGHT_LOOP_END #endif } #endif #ifdef ASE_TRANSLUCENCY { float shadow = /*ase_inline_begin*/_TransShadow/*ase_inline_end*/; float normal = /*ase_inline_begin*/_TransNormal/*ase_inline_end*/; float scattering = /*ase_inline_begin*/_TransScattering/*ase_inline_end*/; float direct = /*ase_inline_begin*/_TransDirect/*ase_inline_end*/; float ambient = /*ase_inline_begin*/_TransAmbient/*ase_inline_end*/; float strength = /*ase_inline_begin*/_TransStrength/*ase_inline_end*/; #define SUM_LIGHT_TRANSLUCENCY(Light)\ float3 atten = Light.color * Light.distanceAttenuation;\ atten = lerp( atten, atten * Light.shadowAttenuation, shadow );\ half3 lightDir = Light.direction + inputData.normalWS * normal;\ half VdotL = pow( saturate( dot( inputData.viewDirectionWS, -lightDir ) ), scattering );\ half3 translucency = atten * ( VdotL * direct + inputData.bakedGI * ambient ) * Translucency;\ color.rgb += BaseColor * translucency * strength; SUM_LIGHT_TRANSLUCENCY( GetMainLight( inputData.shadowCoord ) ); #if defined(_ADDITIONAL_LIGHTS) uint meshRenderingLayers = GetMeshRenderingLayer(); uint pixelLightCount = GetAdditionalLightsCount(); #if USE_CLUSTER_LIGHT_LOOP [loop] for (uint lightIndex = 0; lightIndex < min(URP_FP_DIRECTIONAL_LIGHTS_COUNT, MAX_VISIBLE_LIGHTS); lightIndex++) { CLUSTER_LIGHT_LOOP_SUBTRACTIVE_LIGHT_CHECK Light light = GetAdditionalLight(lightIndex, inputData.positionWS, inputData.shadowMask); #ifdef _LIGHT_LAYERS if (IsMatchingLightLayer(light.layerMask, meshRenderingLayers)) #endif { SUM_LIGHT_TRANSLUCENCY( light ); } } #endif LIGHT_LOOP_BEGIN( pixelLightCount ) Light light = GetAdditionalLight(lightIndex, inputData.positionWS, inputData.shadowMask); #ifdef _LIGHT_LAYERS if (IsMatchingLightLayer(light.layerMask, meshRenderingLayers)) #endif { SUM_LIGHT_TRANSLUCENCY( light ); } LIGHT_LOOP_END #endif } #endif #ifdef ASE_REFRACTION float4 projScreenPos = ScreenPos / ScreenPos.w; float3 refractionOffset = ( RefractionIndex - 1.0 ) * mul( UNITY_MATRIX_V, float4( NormalWS,0 ) ).xyz * ( 1.0 - dot( NormalWS, ViewDirWS ) ); projScreenPos.xy += refractionOffset.xy; float3 refraction = SHADERGRAPH_SAMPLE_SCENE_COLOR( projScreenPos.xy ) * RefractionColor; color.rgb = lerp( refraction, color.rgb, color.a ); color.a = 1; #endif #ifdef ASE_FINAL_COLOR_ALPHA_MULTIPLY color.rgb *= color.a; #endif #ifdef ASE_FOG #ifdef TERRAIN_SPLAT_ADDPASS color.rgb = MixFogColor(color.rgb, half3(0,0,0), inputData.fogCoord); #else color.rgb = MixFog(color.rgb, inputData.fogCoord); #endif #endif #if defined( ASE_DEPTH_WRITE_ON ) outputDepth = DeviceDepth; #endif #ifdef _WRITE_RENDERING_LAYERS outRenderingLayers = EncodeMeshRenderingLayer(); #endif #if defined( ASE_OPAQUE_KEEP_ALPHA ) return half4( color.rgb, color.a ); #else return half4( color.rgb, OutputAlpha( color.a, isTransparent ) ); #endif } ENDHLSL } /*ase_pass*/ Pass { /*ase_hide_pass*/ Name "ShadowCaster" Tags { "LightMode" = "ShadowCaster" } ZWrite On ZTest LEqual AlphaToMask Off ColorMask 0 HLSLPROGRAM #pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW #pragma vertex vert #pragma fragment frag #if defined(_SPECULAR_SETUP) && defined(ASE_LIGHTING_SIMPLE) #define _SPECULAR_COLOR 1 #endif #define SHADERPASS SHADERPASS_SHADOWCASTER #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl" #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl" #if defined(LOD_FADE_CROSSFADE) #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl" #endif /*ase_pragma*/ #if defined(ASE_EARLY_Z_DEPTH_OPTIMIZE) && (SHADER_TARGET >= 45) #define ASE_SV_DEPTH SV_DepthLessEqual #define ASE_SV_POSITION_QUALIFIERS linear noperspective centroid #else #define ASE_SV_DEPTH SV_Depth #define ASE_SV_POSITION_QUALIFIERS #endif struct Attributes { float4 positionOS : POSITION; half3 normalOS : NORMAL; half4 tangentOS : TANGENT; /*ase_vdata:p=p;n=n;t=t*/ UNITY_VERTEX_INPUT_INSTANCE_ID }; struct PackedVaryings { ASE_SV_POSITION_QUALIFIERS float4 positionCS : SV_POSITION; float3 positionWS : TEXCOORD0; /*ase_interp(1,):sp=sp;wp=tc0.xyz*/ UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_OUTPUT_STEREO }; CBUFFER_START(UnityPerMaterial) #ifdef ASE_TRANSMISSION float _TransmissionShadow; #endif #ifdef ASE_TRANSLUCENCY float _TransStrength; float _TransNormal; float _TransScattering; float _TransDirect; float _TransAmbient; float _TransShadow; #endif #ifdef ASE_TESSELLATION float _TessPhongStrength; float _TessValue; float _TessMin; float _TessMax; float _TessEdgeLength; float _TessMaxDisp; #endif CBUFFER_END #ifdef SCENEPICKINGPASS float4 _SelectionID; #endif #ifdef SCENESELECTIONPASS int _ObjectId; int _PassValue; #endif /*ase_globals*/ float3 _LightDirection; float3 _LightPosition; /*ase_funcs*/ PackedVaryings VertexFunction( Attributes input/*ase_vert_input*/ ) { PackedVaryings output; UNITY_SETUP_INSTANCE_ID(input); UNITY_TRANSFER_INSTANCE_ID(input, output); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( output ); /*ase_vert_code:input=Attributes;output=PackedVaryings*/ #ifdef ASE_ABSOLUTE_VERTEX_POS float3 defaultVertexValue = input.positionOS.xyz; #else float3 defaultVertexValue = float3(0, 0, 0); #endif float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;8;-1;_Vertex*/defaultVertexValue/*end*/; #ifdef ASE_ABSOLUTE_VERTEX_POS input.positionOS.xyz = vertexValue; #else input.positionOS.xyz += vertexValue; #endif input.normalOS = /*ase_vert_out:Vertex Normal;Float3;10;-1;_Normal*/input.normalOS/*end*/; input.tangentOS = /*ase_vert_out:Vertex Tangent;Float4;30;-1;_Tangent*/input.tangentOS/*end*/; float3 positionWS = TransformObjectToWorld( input.positionOS.xyz ); float3 normalWS = TransformObjectToWorldDir(input.normalOS); #if _CASTING_PUNCTUAL_LIGHT_SHADOW float3 lightDirectionWS = normalize(_LightPosition - positionWS); #else float3 lightDirectionWS = _LightDirection; #endif float4 positionCS = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, lightDirectionWS)); //code for UNITY_REVERSED_Z is moved into Shadows.hlsl from 6000.0.22 and or higher positionCS = ApplyShadowClamping(positionCS); output.positionCS = positionCS; output.positionWS = positionWS; return output; } #if defined(ASE_TESSELLATION) struct VertexControl { float4 positionOS : INTERNALTESSPOS; half3 normalOS : NORMAL; half4 tangentOS : TANGENT; /*ase_vcontrol*/ UNITY_VERTEX_INPUT_INSTANCE_ID }; struct TessellationFactors { float edge[3] : SV_TessFactor; float inside : SV_InsideTessFactor; }; VertexControl vert ( Attributes input ) { VertexControl output; UNITY_SETUP_INSTANCE_ID(input); UNITY_TRANSFER_INSTANCE_ID(input, output); output.positionOS = input.positionOS; output.normalOS = input.normalOS; output.tangentOS = input.tangentOS; /*ase_control_code:input=Attributes;output=VertexControl*/ return output; } TessellationFactors TessellationFunction (InputPatch input) { TessellationFactors output; float4 tf = 1; float tessValue = /*ase_inline_begin*/_TessValue/*ase_inline_end*/; float tessMin = /*ase_inline_begin*/_TessMin/*ase_inline_end*/; float tessMax = /*ase_inline_begin*/_TessMax/*ase_inline_end*/; float edgeLength = /*ase_inline_begin*/_TessEdgeLength/*ase_inline_end*/; float tessMaxDisp = /*ase_inline_begin*/_TessMaxDisp/*ase_inline_end*/; #if defined(ASE_FIXED_TESSELLATION) tf = FixedTess( tessValue ); #elif defined(ASE_DISTANCE_TESSELLATION) tf = DistanceBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos ); #elif defined(ASE_LENGTH_TESSELLATION) tf = EdgeLengthBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams ); #elif defined(ASE_LENGTH_CULL_TESSELLATION) tf = EdgeLengthBasedTessCull(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes ); #endif output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w; return output; } [domain("tri")] [partitioning("fractional_odd")] [outputtopology("triangle_cw")] [patchconstantfunc("TessellationFunction")] [outputcontrolpoints(3)] VertexControl HullFunction(InputPatch patch, uint id : SV_OutputControlPointID) { return patch[id]; } [domain("tri")] PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch patch, float3 bary : SV_DomainLocation) { Attributes output = (Attributes) 0; output.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z; output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z; output.tangentOS = patch[0].tangentOS * bary.x + patch[1].tangentOS * bary.y + patch[2].tangentOS * bary.z; /*ase_domain_code:patch=VertexControl;output=Attributes;bary=SV_DomainLocation*/ #if defined(ASE_PHONG_TESSELLATION) float3 pp[3]; for (int i = 0; i < 3; ++i) pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS)); float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/; output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz; #endif UNITY_TRANSFER_INSTANCE_ID(patch[0], output); return VertexFunction(output); } #else PackedVaryings vert ( Attributes input ) { return VertexFunction( input ); } #endif half4 frag( PackedVaryings input #if defined( ASE_DEPTH_WRITE_ON ) ,out float outputDepth : ASE_SV_DEPTH #endif /*ase_frag_input*/ ) : SV_Target { UNITY_SETUP_INSTANCE_ID( input ); UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( input ); #if defined(MAIN_LIGHT_CALCULATE_SHADOWS) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS) float4 shadowCoord = TransformWorldToShadowCoord(input.positionWS); #else float4 shadowCoord = float4(0, 0, 0, 0); #endif /*ase_local_var:wp*/float3 PositionWS = input.positionWS; /*ase_local_var:rwp*/float3 PositionRWS = GetCameraRelativePositionWS( input.positionWS ); /*ase_local_var:sc*/float4 ShadowCoord = shadowCoord; /*ase_local_var:spn*/float4 ScreenPosNorm = float4( GetNormalizedScreenSpaceUV( input.positionCS ), input.positionCS.zw ); /*ase_local_var:sp*/float4 ClipPos = ComputeClipSpacePosition( ScreenPosNorm.xy, input.positionCS.z ) * input.positionCS.w; /*ase_local_var:spu*/float4 ScreenPos = ComputeScreenPos( ClipPos ); /*ase_frag_code:input=PackedVaryings*/ float Alpha = /*ase_frag_out:Alpha;Float;6;-1;_Alpha*/1/*end*/; float AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;7;-1;_AlphaClip*/0.5/*end*/; float AlphaClipThresholdShadow = /*ase_frag_out:Alpha Clip Threshold Shadow;Float;16;-1;_AlphaClipShadow*/0.5/*end*/; #if defined( ASE_DEPTH_WRITE_ON ) float DeviceDepth = /*ase_frag_out:Depth;Float;17;-1;_DepthValue*/input.positionCS.z/*end*/; #endif #if defined( _ALPHATEST_ON ) #if defined( _ALPHATEST_SHADOW_ON ) AlphaDiscard( Alpha, AlphaClipThresholdShadow ); #else AlphaDiscard( Alpha, AlphaClipThreshold ); #endif #endif #if defined(LOD_FADE_CROSSFADE) LODFadeCrossFade( input.positionCS ); #endif #if defined( ASE_DEPTH_WRITE_ON ) outputDepth = DeviceDepth; #endif return 0; } ENDHLSL } /*ase_pass*/ Pass { /*ase_hide_pass*/ Name "DepthOnly" Tags { "LightMode" = "DepthOnly" } ZWrite On ColorMask R AlphaToMask Off HLSLPROGRAM #pragma vertex vert #pragma fragment frag #if defined(_SPECULAR_SETUP) && defined(ASE_LIGHTING_SIMPLE) #define _SPECULAR_COLOR 1 #endif #define SHADERPASS SHADERPASS_DEPTHONLY #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl" #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl" #if defined(LOD_FADE_CROSSFADE) #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl" #endif /*ase_pragma*/ #if defined(ASE_EARLY_Z_DEPTH_OPTIMIZE) && (SHADER_TARGET >= 45) #define ASE_SV_DEPTH SV_DepthLessEqual #define ASE_SV_POSITION_QUALIFIERS linear noperspective centroid #else #define ASE_SV_DEPTH SV_Depth #define ASE_SV_POSITION_QUALIFIERS #endif struct Attributes { float4 positionOS : POSITION; half3 normalOS : NORMAL; half4 tangentOS : TANGENT; /*ase_vdata:p=p;n=n;t=t*/ UNITY_VERTEX_INPUT_INSTANCE_ID }; struct PackedVaryings { ASE_SV_POSITION_QUALIFIERS float4 positionCS : SV_POSITION; float3 positionWS : TEXCOORD0; /*ase_interp(1,):sp=sp;wp=tc0.xyz*/ UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_OUTPUT_STEREO }; CBUFFER_START(UnityPerMaterial) #ifdef ASE_TRANSMISSION float _TransmissionShadow; #endif #ifdef ASE_TRANSLUCENCY float _TransStrength; float _TransNormal; float _TransScattering; float _TransDirect; float _TransAmbient; float _TransShadow; #endif #ifdef ASE_TESSELLATION float _TessPhongStrength; float _TessValue; float _TessMin; float _TessMax; float _TessEdgeLength; float _TessMaxDisp; #endif CBUFFER_END #ifdef SCENEPICKINGPASS float4 _SelectionID; #endif #ifdef SCENESELECTIONPASS int _ObjectId; int _PassValue; #endif /*ase_globals*/ /*ase_funcs*/ PackedVaryings VertexFunction( Attributes input /*ase_vert_input*/ ) { PackedVaryings output = (PackedVaryings)0; UNITY_SETUP_INSTANCE_ID(input); UNITY_TRANSFER_INSTANCE_ID(input, output); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); /*ase_vert_code:input=Attributes;output=PackedVaryings*/ #ifdef ASE_ABSOLUTE_VERTEX_POS float3 defaultVertexValue = input.positionOS.xyz; #else float3 defaultVertexValue = float3(0, 0, 0); #endif float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;8;-1;_Vertex*/defaultVertexValue/*end*/; #ifdef ASE_ABSOLUTE_VERTEX_POS input.positionOS.xyz = vertexValue; #else input.positionOS.xyz += vertexValue; #endif input.normalOS = /*ase_vert_out:Vertex Normal;Float3;10;-1;_Normal*/input.normalOS/*end*/; input.tangentOS = /*ase_vert_out:Vertex Tangent;Float4;30;-1;_Tangent*/input.tangentOS/*end*/; VertexPositionInputs vertexInput = GetVertexPositionInputs( input.positionOS.xyz ); output.positionCS = vertexInput.positionCS; output.positionWS = vertexInput.positionWS; return output; } #if defined(ASE_TESSELLATION) struct VertexControl { float4 positionOS : INTERNALTESSPOS; half3 normalOS : NORMAL; half4 tangentOS : TANGENT; /*ase_vcontrol*/ UNITY_VERTEX_INPUT_INSTANCE_ID }; struct TessellationFactors { float edge[3] : SV_TessFactor; float inside : SV_InsideTessFactor; }; VertexControl vert ( Attributes input ) { VertexControl output; UNITY_SETUP_INSTANCE_ID(input); UNITY_TRANSFER_INSTANCE_ID(input, output); output.positionOS = input.positionOS; output.normalOS = input.normalOS; output.tangentOS = input.tangentOS; /*ase_control_code:input=Attributes;output=VertexControl*/ return output; } TessellationFactors TessellationFunction (InputPatch input) { TessellationFactors output; float4 tf = 1; float tessValue = /*ase_inline_begin*/_TessValue/*ase_inline_end*/; float tessMin = /*ase_inline_begin*/_TessMin/*ase_inline_end*/; float tessMax = /*ase_inline_begin*/_TessMax/*ase_inline_end*/; float edgeLength = /*ase_inline_begin*/_TessEdgeLength/*ase_inline_end*/; float tessMaxDisp = /*ase_inline_begin*/_TessMaxDisp/*ase_inline_end*/; #if defined(ASE_FIXED_TESSELLATION) tf = FixedTess( tessValue ); #elif defined(ASE_DISTANCE_TESSELLATION) tf = DistanceBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos ); #elif defined(ASE_LENGTH_TESSELLATION) tf = EdgeLengthBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams ); #elif defined(ASE_LENGTH_CULL_TESSELLATION) tf = EdgeLengthBasedTessCull(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes ); #endif output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w; return output; } [domain("tri")] [partitioning("fractional_odd")] [outputtopology("triangle_cw")] [patchconstantfunc("TessellationFunction")] [outputcontrolpoints(3)] VertexControl HullFunction(InputPatch patch, uint id : SV_OutputControlPointID) { return patch[id]; } [domain("tri")] PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch patch, float3 bary : SV_DomainLocation) { Attributes output = (Attributes) 0; output.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z; output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z; output.tangentOS = patch[0].tangentOS * bary.x + patch[1].tangentOS * bary.y + patch[2].tangentOS * bary.z; /*ase_domain_code:patch=VertexControl;output=Attributes;bary=SV_DomainLocation*/ #if defined(ASE_PHONG_TESSELLATION) float3 pp[3]; for (int i = 0; i < 3; ++i) pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS)); float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/; output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz; #endif UNITY_TRANSFER_INSTANCE_ID(patch[0], output); return VertexFunction(output); } #else PackedVaryings vert ( Attributes input ) { return VertexFunction( input ); } #endif half4 frag( PackedVaryings input #if defined( ASE_DEPTH_WRITE_ON ) ,out float outputDepth : ASE_SV_DEPTH #endif /*ase_frag_input*/ ) : SV_Target { UNITY_SETUP_INSTANCE_ID(input); UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( input ); #if defined(MAIN_LIGHT_CALCULATE_SHADOWS) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS) float4 shadowCoord = TransformWorldToShadowCoord(input.positionWS); #else float4 shadowCoord = float4(0, 0, 0, 0); #endif /*ase_local_var:wp*/float3 PositionWS = input.positionWS; /*ase_local_var:rwp*/float3 PositionRWS = GetCameraRelativePositionWS( input.positionWS ); /*ase_local_var:sc*/float4 ShadowCoord = shadowCoord; /*ase_local_var:spn*/float4 ScreenPosNorm = float4( GetNormalizedScreenSpaceUV( input.positionCS ), input.positionCS.zw ); /*ase_local_var:sp*/float4 ClipPos = ComputeClipSpacePosition( ScreenPosNorm.xy, input.positionCS.z ) * input.positionCS.w; /*ase_local_var:spu*/float4 ScreenPos = ComputeScreenPos( ClipPos ); /*ase_frag_code:input=PackedVaryings*/ float Alpha = /*ase_frag_out:Alpha;Float;6;-1;_Alpha*/1/*end*/; float AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;7;-1;_AlphaClip*/0.5/*end*/; #if defined( ASE_DEPTH_WRITE_ON ) float DeviceDepth = /*ase_frag_out:Depth;Float;17;-1;_DepthValue*/input.positionCS.z/*end*/; #endif #if defined( _ALPHATEST_ON ) AlphaDiscard( Alpha, AlphaClipThreshold ); #endif #if defined(LOD_FADE_CROSSFADE) LODFadeCrossFade( input.positionCS ); #endif #if defined( ASE_DEPTH_WRITE_ON ) outputDepth = DeviceDepth; #endif return 0; } ENDHLSL } /*ase_pass*/ Pass { /*ase_hide_pass*/ Name "Meta" Tags { "LightMode" = "Meta" } Cull Off HLSLPROGRAM #pragma shader_feature EDITOR_VISUALIZATION #pragma vertex vert #pragma fragment frag #if defined(_SPECULAR_SETUP) && defined(ASE_LIGHTING_SIMPLE) #define _SPECULAR_COLOR 1 #endif #define SHADERPASS SHADERPASS_META #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/MetaInput.hlsl" #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl" /*ase_pragma*/ struct Attributes { float4 positionOS : POSITION; half3 normalOS : NORMAL; half4 tangentOS : TANGENT; float4 texcoord0 : TEXCOORD0; float4 texcoord1 : TEXCOORD1; float4 texcoord2 : TEXCOORD2; /*ase_vdata:p=p;n=n;t=t;uv0=tc0;uv1=tc1;uv2=tc2*/ UNITY_VERTEX_INPUT_INSTANCE_ID }; struct PackedVaryings { float4 positionCS : SV_POSITION; float3 positionWS : TEXCOORD0; #ifdef EDITOR_VISUALIZATION float4 VizUV : TEXCOORD1; float4 LightCoord : TEXCOORD2; #endif /*ase_interp(3,):sp=sp;wp=tc0.xyz*/ UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_OUTPUT_STEREO }; CBUFFER_START(UnityPerMaterial) #ifdef ASE_TRANSMISSION float _TransmissionShadow; #endif #ifdef ASE_TRANSLUCENCY float _TransStrength; float _TransNormal; float _TransScattering; float _TransDirect; float _TransAmbient; float _TransShadow; #endif #ifdef ASE_TESSELLATION float _TessPhongStrength; float _TessValue; float _TessMin; float _TessMax; float _TessEdgeLength; float _TessMaxDisp; #endif CBUFFER_END #ifdef SCENEPICKINGPASS float4 _SelectionID; #endif #ifdef SCENESELECTIONPASS int _ObjectId; int _PassValue; #endif /*ase_globals*/ /*ase_funcs*/ PackedVaryings VertexFunction( Attributes input /*ase_vert_input*/ ) { PackedVaryings output = (PackedVaryings)0; UNITY_SETUP_INSTANCE_ID(input); UNITY_TRANSFER_INSTANCE_ID(input, output); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); /*ase_vert_code:input=Attributes;output=PackedVaryings*/ #ifdef ASE_ABSOLUTE_VERTEX_POS float3 defaultVertexValue = input.positionOS.xyz; #else float3 defaultVertexValue = float3(0, 0, 0); #endif float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;8;-1;_Vertex*/defaultVertexValue/*end*/; #ifdef ASE_ABSOLUTE_VERTEX_POS input.positionOS.xyz = vertexValue; #else input.positionOS.xyz += vertexValue; #endif input.normalOS = /*ase_vert_out:Vertex Normal;Float3;10;-1;_Normal*/input.normalOS/*end*/; input.tangentOS = /*ase_vert_out:Vertex Tangent;Float4;30;-1;_Tangent*/input.tangentOS/*end*/; #ifdef EDITOR_VISUALIZATION float2 VizUV = 0; float4 LightCoord = 0; UnityEditorVizData(input.positionOS.xyz, input.texcoord0.xy, input.texcoord1.xy, input.texcoord2.xy, VizUV, LightCoord); output.VizUV = float4(VizUV, 0, 0); output.LightCoord = LightCoord; #endif output.positionCS = MetaVertexPosition( input.positionOS, input.texcoord1.xy, input.texcoord1.xy, unity_LightmapST, unity_DynamicLightmapST ); output.positionWS = TransformObjectToWorld( input.positionOS.xyz ); return output; } #if defined(ASE_TESSELLATION) struct VertexControl { float4 positionOS : INTERNALTESSPOS; half3 normalOS : NORMAL; half4 tangentOS : TANGENT; /*ase_vcontrol*/ UNITY_VERTEX_INPUT_INSTANCE_ID }; struct TessellationFactors { float edge[3] : SV_TessFactor; float inside : SV_InsideTessFactor; }; VertexControl vert ( Attributes input ) { VertexControl output; UNITY_SETUP_INSTANCE_ID(input); UNITY_TRANSFER_INSTANCE_ID(input, output); output.positionOS = input.positionOS; output.normalOS = input.normalOS; output.tangentOS = input.tangentOS; /*ase_control_code:input=Attributes;output=VertexControl*/ return output; } TessellationFactors TessellationFunction (InputPatch input) { TessellationFactors output; float4 tf = 1; float tessValue = /*ase_inline_begin*/_TessValue/*ase_inline_end*/; float tessMin = /*ase_inline_begin*/_TessMin/*ase_inline_end*/; float tessMax = /*ase_inline_begin*/_TessMax/*ase_inline_end*/; float edgeLength = /*ase_inline_begin*/_TessEdgeLength/*ase_inline_end*/; float tessMaxDisp = /*ase_inline_begin*/_TessMaxDisp/*ase_inline_end*/; #if defined(ASE_FIXED_TESSELLATION) tf = FixedTess( tessValue ); #elif defined(ASE_DISTANCE_TESSELLATION) tf = DistanceBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos ); #elif defined(ASE_LENGTH_TESSELLATION) tf = EdgeLengthBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams ); #elif defined(ASE_LENGTH_CULL_TESSELLATION) tf = EdgeLengthBasedTessCull(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes ); #endif output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w; return output; } [domain("tri")] [partitioning("fractional_odd")] [outputtopology("triangle_cw")] [patchconstantfunc("TessellationFunction")] [outputcontrolpoints(3)] VertexControl HullFunction(InputPatch patch, uint id : SV_OutputControlPointID) { return patch[id]; } [domain("tri")] PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch patch, float3 bary : SV_DomainLocation) { Attributes output = (Attributes) 0; output.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z; output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z; output.tangentOS = patch[0].tangentOS * bary.x + patch[1].tangentOS * bary.y + patch[2].tangentOS * bary.z; /*ase_domain_code:patch=VertexControl;output=Attributes;bary=SV_DomainLocation*/ #if defined(ASE_PHONG_TESSELLATION) float3 pp[3]; for (int i = 0; i < 3; ++i) pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS)); float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/; output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz; #endif UNITY_TRANSFER_INSTANCE_ID(patch[0], output); return VertexFunction(output); } #else PackedVaryings vert ( Attributes input ) { return VertexFunction( input ); } #endif half4 frag(PackedVaryings input /*ase_frag_input*/ ) : SV_Target { UNITY_SETUP_INSTANCE_ID(input); UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( input ); #if defined(MAIN_LIGHT_CALCULATE_SHADOWS) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS) float4 shadowCoord = TransformWorldToShadowCoord(input.positionWS); #else float4 shadowCoord = float4(0, 0, 0, 0); #endif /*ase_local_var:wp*/float3 PositionWS = input.positionWS; /*ase_local_var:rwp*/float3 PositionRWS = GetCameraRelativePositionWS( input.positionWS ); /*ase_local_var:sc*/float4 ShadowCoord = shadowCoord; /*ase_frag_code:input=PackedVaryings*/ float3 BaseColor = /*ase_frag_out:Base Color;Float3;0;-1;_BaseColor*/float3(0.5, 0.5, 0.5)/*end*/; float3 Emission = /*ase_frag_out:Emission;Float3;2;-1;_Emission*/0/*end*/; float Alpha = /*ase_frag_out:Alpha;Float;6;-1;_Alpha*/1/*end*/; float AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;7;-1;_AlphaClip*/0.5/*end*/; #if defined( _ALPHATEST_ON ) AlphaDiscard( Alpha, AlphaClipThreshold ); #endif MetaInput metaInput = (MetaInput)0; metaInput.Albedo = BaseColor; metaInput.Emission = Emission; #ifdef EDITOR_VISUALIZATION metaInput.VizUV = input.VizUV.xy; metaInput.LightCoord = input.LightCoord; #endif return UnityMetaFragment(metaInput); } ENDHLSL } /*ase_pass*/ Pass { /*ase_hide_pass:SyncP*/ Name "Universal2D" Tags { "LightMode" = "Universal2D" } Blend One Zero ZWrite On ZTest LEqual Offset 0,0 ColorMask RGBA HLSLPROGRAM #pragma vertex vert #pragma fragment frag #if defined(_SPECULAR_SETUP) && defined(ASE_LIGHTING_SIMPLE) #define _SPECULAR_COLOR 1 #endif #define SHADERPASS SHADERPASS_2D #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl" #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl" /*ase_pragma*/ struct Attributes { float4 positionOS : POSITION; half3 normalOS : NORMAL; half4 tangentOS : TANGENT; /*ase_vdata:p=p;n=n;t=t*/ UNITY_VERTEX_INPUT_INSTANCE_ID }; struct PackedVaryings { float4 positionCS : SV_POSITION; float3 positionWS : TEXCOORD0; /*ase_interp(1,):sp=sp;wp=tc0.xyz*/ UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_OUTPUT_STEREO }; CBUFFER_START(UnityPerMaterial) #ifdef ASE_TRANSMISSION float _TransmissionShadow; #endif #ifdef ASE_TRANSLUCENCY float _TransStrength; float _TransNormal; float _TransScattering; float _TransDirect; float _TransAmbient; float _TransShadow; #endif #ifdef ASE_TESSELLATION float _TessPhongStrength; float _TessValue; float _TessMin; float _TessMax; float _TessEdgeLength; float _TessMaxDisp; #endif CBUFFER_END #ifdef SCENEPICKINGPASS float4 _SelectionID; #endif #ifdef SCENESELECTIONPASS int _ObjectId; int _PassValue; #endif /*ase_globals*/ /*ase_funcs*/ PackedVaryings VertexFunction( Attributes input /*ase_vert_input*/ ) { PackedVaryings output = (PackedVaryings)0; UNITY_SETUP_INSTANCE_ID( input ); UNITY_TRANSFER_INSTANCE_ID( input, output ); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( output ); /*ase_vert_code:input=Attributes;output=PackedVaryings*/ #ifdef ASE_ABSOLUTE_VERTEX_POS float3 defaultVertexValue = input.positionOS.xyz; #else float3 defaultVertexValue = float3(0, 0, 0); #endif float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;8;-1;_Vertex*/defaultVertexValue/*end*/; #ifdef ASE_ABSOLUTE_VERTEX_POS input.positionOS.xyz = vertexValue; #else input.positionOS.xyz += vertexValue; #endif input.normalOS = /*ase_vert_out:Vertex Normal;Float3;10;-1;_Normal*/input.normalOS/*end*/; input.tangentOS = /*ase_vert_out:Vertex Tangent;Float4;30;-1;_Tangent*/input.tangentOS/*end*/; VertexPositionInputs vertexInput = GetVertexPositionInputs( input.positionOS.xyz ); output.positionCS = vertexInput.positionCS; output.positionWS = vertexInput.positionWS; return output; } #if defined(ASE_TESSELLATION) struct VertexControl { float4 positionOS : INTERNALTESSPOS; half3 normalOS : NORMAL; half4 tangentOS : TANGENT; /*ase_vcontrol*/ UNITY_VERTEX_INPUT_INSTANCE_ID }; struct TessellationFactors { float edge[3] : SV_TessFactor; float inside : SV_InsideTessFactor; }; VertexControl vert ( Attributes input ) { VertexControl output; UNITY_SETUP_INSTANCE_ID(input); UNITY_TRANSFER_INSTANCE_ID(input, output); output.positionOS = input.positionOS; output.normalOS = input.normalOS; output.tangentOS = input.tangentOS; /*ase_control_code:input=Attributes;output=VertexControl*/ return output; } TessellationFactors TessellationFunction (InputPatch input) { TessellationFactors output; float4 tf = 1; float tessValue = /*ase_inline_begin*/_TessValue/*ase_inline_end*/; float tessMin = /*ase_inline_begin*/_TessMin/*ase_inline_end*/; float tessMax = /*ase_inline_begin*/_TessMax/*ase_inline_end*/; float edgeLength = /*ase_inline_begin*/_TessEdgeLength/*ase_inline_end*/; float tessMaxDisp = /*ase_inline_begin*/_TessMaxDisp/*ase_inline_end*/; #if defined(ASE_FIXED_TESSELLATION) tf = FixedTess( tessValue ); #elif defined(ASE_DISTANCE_TESSELLATION) tf = DistanceBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos ); #elif defined(ASE_LENGTH_TESSELLATION) tf = EdgeLengthBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams ); #elif defined(ASE_LENGTH_CULL_TESSELLATION) tf = EdgeLengthBasedTessCull(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes ); #endif output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w; return output; } [domain("tri")] [partitioning("fractional_odd")] [outputtopology("triangle_cw")] [patchconstantfunc("TessellationFunction")] [outputcontrolpoints(3)] VertexControl HullFunction(InputPatch patch, uint id : SV_OutputControlPointID) { return patch[id]; } [domain("tri")] PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch patch, float3 bary : SV_DomainLocation) { Attributes output = (Attributes) 0; output.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z; output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z; output.tangentOS = patch[0].tangentOS * bary.x + patch[1].tangentOS * bary.y + patch[2].tangentOS * bary.z; /*ase_domain_code:patch=VertexControl;output=Attributes;bary=SV_DomainLocation*/ #if defined(ASE_PHONG_TESSELLATION) float3 pp[3]; for (int i = 0; i < 3; ++i) pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS)); float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/; output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz; #endif UNITY_TRANSFER_INSTANCE_ID(patch[0], output); return VertexFunction(output); } #else PackedVaryings vert ( Attributes input ) { return VertexFunction( input ); } #endif half4 frag(PackedVaryings input /*ase_frag_input*/ ) : SV_Target { UNITY_SETUP_INSTANCE_ID( input ); UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( input ); #if defined(MAIN_LIGHT_CALCULATE_SHADOWS) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS) float4 shadowCoord = TransformWorldToShadowCoord(input.positionWS); #else float4 shadowCoord = float4(0, 0, 0, 0); #endif /*ase_local_var:wp*/float3 PositionWS = input.positionWS; /*ase_local_var:rwp*/float3 PositionRWS = GetCameraRelativePositionWS( input.positionWS ); /*ase_local_var:sc*/float4 ShadowCoord = shadowCoord; /*ase_frag_code:input=PackedVaryings*/ float3 BaseColor = /*ase_frag_out:Base Color;Float3;0;-1;_BaseColor*/float3(0.5, 0.5, 0.5)/*end*/; float Alpha = /*ase_frag_out:Alpha;Float;6;-1;_Alpha*/1/*end*/; float AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;7;-1;_AlphaClip*/0.5/*end*/; half4 color = half4(BaseColor, Alpha ); #if defined( _ALPHATEST_ON ) AlphaDiscard( Alpha, AlphaClipThreshold ); #endif return color; } ENDHLSL } /*ase_pass*/ Pass { /*ase_hide_pass*/ Name "DepthNormals" Tags { "LightMode" = "DepthNormals" } ZWrite On Blend One Zero ZTest LEqual ZWrite On HLSLPROGRAM #pragma vertex vert #pragma fragment frag #if defined(_SPECULAR_SETUP) && defined(ASE_LIGHTING_SIMPLE) #define _SPECULAR_COLOR 1 #endif #define SHADERPASS SHADERPASS_DEPTHNORMALSONLY //#define SHADERPASS SHADERPASS_DEPTHNORMALS #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl" #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl" #if defined(LOD_FADE_CROSSFADE) #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl" #endif #if defined( UNITY_INSTANCING_ENABLED ) && defined( ASE_INSTANCED_TERRAIN ) && ( defined(_TERRAIN_INSTANCED_PERPIXEL_NORMAL) || defined(_INSTANCEDTERRAINNORMALS_PIXEL) ) #define ENABLE_TERRAIN_PERPIXEL_NORMAL #endif /*ase_pragma*/ #if defined(ASE_EARLY_Z_DEPTH_OPTIMIZE) && (SHADER_TARGET >= 45) #define ASE_SV_DEPTH SV_DepthLessEqual #define ASE_SV_POSITION_QUALIFIERS linear noperspective centroid #else #define ASE_SV_DEPTH SV_Depth #define ASE_SV_POSITION_QUALIFIERS #endif struct Attributes { float4 positionOS : POSITION; half3 normalOS : NORMAL; half4 tangentOS : TANGENT; half4 texcoord : TEXCOORD0; /*ase_vdata:p=p;n=n;t=t;uv0=tc0*/ UNITY_VERTEX_INPUT_INSTANCE_ID }; struct PackedVaryings { ASE_SV_POSITION_QUALIFIERS float4 positionCS : SV_POSITION; float3 positionWS : TEXCOORD0; half3 normalWS : TEXCOORD1; float4 tangentWS : TEXCOORD2; // holds terrainUV ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL /*ase_interp(3,):sp=sp;wp=tc0.xyz;wn=tc1.xyz;wt=tc2*/ UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_OUTPUT_STEREO }; CBUFFER_START(UnityPerMaterial) #ifdef ASE_TRANSMISSION float _TransmissionShadow; #endif #ifdef ASE_TRANSLUCENCY float _TransStrength; float _TransNormal; float _TransScattering; float _TransDirect; float _TransAmbient; float _TransShadow; #endif #ifdef ASE_TESSELLATION float _TessPhongStrength; float _TessValue; float _TessMin; float _TessMax; float _TessEdgeLength; float _TessMaxDisp; #endif CBUFFER_END #ifdef SCENEPICKINGPASS float4 _SelectionID; #endif #ifdef SCENESELECTIONPASS int _ObjectId; int _PassValue; #endif /*ase_globals*/ /*ase_funcs*/ PackedVaryings VertexFunction( Attributes input /*ase_vert_input*/ ) { PackedVaryings output = (PackedVaryings)0; UNITY_SETUP_INSTANCE_ID(input); UNITY_TRANSFER_INSTANCE_ID(input, output); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); /*ase_vert_code:input=Attributes;output=PackedVaryings*/ #ifdef ASE_ABSOLUTE_VERTEX_POS float3 defaultVertexValue = input.positionOS.xyz; #else float3 defaultVertexValue = float3(0, 0, 0); #endif float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;8;-1;_Vertex*/defaultVertexValue/*end*/; #ifdef ASE_ABSOLUTE_VERTEX_POS input.positionOS.xyz = vertexValue; #else input.positionOS.xyz += vertexValue; #endif input.normalOS = /*ase_vert_out:Vertex Normal;Float3;10;-1;_Normal*/input.normalOS/*end*/; input.tangentOS = /*ase_vert_out:Vertex Tangent;Float4;30;-1;_Tangent*/input.tangentOS/*end*/; VertexPositionInputs vertexInput = GetVertexPositionInputs( input.positionOS.xyz ); VertexNormalInputs normalInput = GetVertexNormalInputs( input.normalOS, input.tangentOS ); output.positionCS = vertexInput.positionCS; output.positionWS = vertexInput.positionWS; output.normalWS = normalInput.normalWS; output.tangentWS = float4( normalInput.tangentWS, ( input.tangentOS.w > 0.0 ? 1.0 : -1.0 ) * GetOddNegativeScale() ); #if defined( ENABLE_TERRAIN_PERPIXEL_NORMAL ) output.tangentWS.zw = input.texcoord.xy; output.tangentWS.xy = input.texcoord.xy * unity_LightmapST.xy + unity_LightmapST.zw; #endif return output; } #if defined(ASE_TESSELLATION) struct VertexControl { float4 positionOS : INTERNALTESSPOS; half3 normalOS : NORMAL; half4 tangentOS : TANGENT; float4 texcoord : TEXCOORD0; /*ase_vcontrol*/ UNITY_VERTEX_INPUT_INSTANCE_ID }; struct TessellationFactors { float edge[3] : SV_TessFactor; float inside : SV_InsideTessFactor; }; VertexControl vert ( Attributes input ) { VertexControl output; UNITY_SETUP_INSTANCE_ID(input); UNITY_TRANSFER_INSTANCE_ID(input, output); output.positionOS = input.positionOS; output.normalOS = input.normalOS; output.tangentOS = input.tangentOS; output.texcoord = input.texcoord; /*ase_control_code:input=Attributes;output=VertexControl*/ return output; } TessellationFactors TessellationFunction (InputPatch input) { TessellationFactors output; float4 tf = 1; float tessValue = /*ase_inline_begin*/_TessValue/*ase_inline_end*/; float tessMin = /*ase_inline_begin*/_TessMin/*ase_inline_end*/; float tessMax = /*ase_inline_begin*/_TessMax/*ase_inline_end*/; float edgeLength = /*ase_inline_begin*/_TessEdgeLength/*ase_inline_end*/; float tessMaxDisp = /*ase_inline_begin*/_TessMaxDisp/*ase_inline_end*/; #if defined(ASE_FIXED_TESSELLATION) tf = FixedTess( tessValue ); #elif defined(ASE_DISTANCE_TESSELLATION) tf = DistanceBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos ); #elif defined(ASE_LENGTH_TESSELLATION) tf = EdgeLengthBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams ); #elif defined(ASE_LENGTH_CULL_TESSELLATION) tf = EdgeLengthBasedTessCull(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes ); #endif output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w; return output; } [domain("tri")] [partitioning("fractional_odd")] [outputtopology("triangle_cw")] [patchconstantfunc("TessellationFunction")] [outputcontrolpoints(3)] VertexControl HullFunction(InputPatch patch, uint id : SV_OutputControlPointID) { return patch[id]; } [domain("tri")] PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch patch, float3 bary : SV_DomainLocation) { Attributes output = (Attributes) 0; output.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z; output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z; output.tangentOS = patch[0].tangentOS * bary.x + patch[1].tangentOS * bary.y + patch[2].tangentOS * bary.z; output.texcoord = patch[0].texcoord * bary.x + patch[1].texcoord * bary.y + patch[2].texcoord * bary.z; /*ase_domain_code:patch=VertexControl;output=Attributes;bary=SV_DomainLocation*/ #if defined(ASE_PHONG_TESSELLATION) float3 pp[3]; for (int i = 0; i < 3; ++i) pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS)); float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/; output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz; #endif UNITY_TRANSFER_INSTANCE_ID(patch[0], output); return VertexFunction(output); } #else PackedVaryings vert ( Attributes input ) { return VertexFunction( input ); } #endif void frag( PackedVaryings input , out half4 outNormalWS : SV_Target0 #if defined( ASE_DEPTH_WRITE_ON ) ,out float outputDepth : ASE_SV_DEPTH #endif #ifdef _WRITE_RENDERING_LAYERS , out uint outRenderingLayers : SV_Target1 #endif /*ase_frag_input*/ ) { UNITY_SETUP_INSTANCE_ID(input); UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( input ); #if defined(MAIN_LIGHT_CALCULATE_SHADOWS) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS) float4 shadowCoord = TransformWorldToShadowCoord(input.positionWS); #else float4 shadowCoord = float4(0, 0, 0, 0); #endif // @diogo: mikktspace compliant float renormFactor = 1.0 / max( FLT_MIN, length( input.normalWS ) ); /*ase_local_var:wp*/float3 PositionWS = input.positionWS; /*ase_local_var:rwp*/float3 PositionRWS = GetCameraRelativePositionWS( input.positionWS ); /*ase_local_var:sc*/float4 ShadowCoord = shadowCoord; /*ase_local_var:spn*/float4 ScreenPosNorm = float4( GetNormalizedScreenSpaceUV( input.positionCS ), input.positionCS.zw ); /*ase_local_var:sp*/float4 ClipPos = ComputeClipSpacePosition( ScreenPosNorm.xy, input.positionCS.z ) * input.positionCS.w; /*ase_local_var:spu*/float4 ScreenPos = ComputeScreenPos( ClipPos ); /*ase_local_var:wt*/float3 TangentWS = input.tangentWS.xyz * renormFactor; /*ase_local_var:wbt*/float3 BitangentWS = cross( input.normalWS, input.tangentWS.xyz ) * input.tangentWS.w * renormFactor; /*ase_local_var:wn*/float3 NormalWS = input.normalWS * renormFactor; #if defined( ENABLE_TERRAIN_PERPIXEL_NORMAL ) float2 sampleCoords = (input.tangentWS.zw / _TerrainHeightmapRecipSize.zw + 0.5f) * _TerrainHeightmapRecipSize.xy; NormalWS = TransformObjectToWorldNormal(normalize(SAMPLE_TEXTURE2D(_TerrainNormalmapTexture, sampler_TerrainNormalmapTexture, sampleCoords).rgb * 2 - 1)); TangentWS = -cross(GetObjectToWorldMatrix()._13_23_33, NormalWS); BitangentWS = cross(NormalWS, -TangentWS); #endif /*ase_frag_code:input=PackedVaryings*/ float3 Normal = /*ase_frag_out:Normal;Float3;1;-1;_FragNormal*/float3(0, 0, 1)/*end*/; float Alpha = /*ase_frag_out:Alpha;Float;6;-1;_Alpha*/1/*end*/; float AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;7;-1;_AlphaClip*/0.5/*end*/; #if defined( ASE_DEPTH_WRITE_ON ) float DeviceDepth = /*ase_frag_out:Depth;Float;17;-1;_DepthValue*/input.positionCS.z/*end*/; #endif #if defined( _ALPHATEST_ON ) AlphaDiscard( Alpha, AlphaClipThreshold ); #endif #if defined(LOD_FADE_CROSSFADE) LODFadeCrossFade( input.positionCS ); #endif #if defined( ASE_DEPTH_WRITE_ON ) outputDepth = DeviceDepth; #endif #if defined(_GBUFFER_NORMALS_OCT) float2 octNormalWS = PackNormalOctQuadEncode(NormalWS); float2 remappedOctNormalWS = saturate(octNormalWS * 0.5 + 0.5); half3 packedNormalWS = PackFloat2To888(remappedOctNormalWS); outNormalWS = half4(packedNormalWS, 0.0); #else #if defined(_NORMALMAP) #if _NORMAL_DROPOFF_TS float3 normalWS = TransformTangentToWorld(Normal, half3x3(TangentWS, BitangentWS, NormalWS)); #elif _NORMAL_DROPOFF_OS float3 normalWS = TransformObjectToWorldNormal(Normal); #elif _NORMAL_DROPOFF_WS float3 normalWS = Normal; #endif #else float3 normalWS = NormalWS; #endif outNormalWS = half4(NormalizeNormalPerPixel(normalWS), 0.0); #endif #ifdef _WRITE_RENDERING_LAYERS outRenderingLayers = EncodeMeshRenderingLayer(); #endif } ENDHLSL } /*ase_pass*/ Pass { /*ase_hide_pass:SyncP*/ Name "GBuffer" Tags { "LightMode" = "UniversalGBuffer" } Blend One Zero ZWrite On ZTest LEqual Offset 0,0 ColorMask RGBA /*ase_stencil*/ HLSLPROGRAM #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING #pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION #pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT #pragma multi_compile_fragment _ _RENDER_PASS_ENABLED #pragma multi_compile _ _CLUSTER_LIGHT_LOOP #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING #pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE #pragma multi_compile _ SHADOWS_SHADOWMASK #pragma multi_compile _ DIRLIGHTMAP_COMBINED #pragma multi_compile _ USE_LEGACY_LIGHTMAPS #pragma multi_compile _ LIGHTMAP_ON #pragma multi_compile _ LIGHTMAP_BICUBIC_SAMPLING #pragma multi_compile _ DYNAMICLIGHTMAP_ON #pragma vertex vert #pragma fragment frag #if defined(_SPECULAR_SETUP) && defined(ASE_LIGHTING_SIMPLE) #define _SPECULAR_COLOR 1 #endif #define SHADERPASS SHADERPASS_GBUFFER #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DBuffer.hlsl" #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl" #if defined(LOD_FADE_CROSSFADE) #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl" #endif #if defined( UNITY_INSTANCING_ENABLED ) && defined( ASE_INSTANCED_TERRAIN ) && ( defined(_TERRAIN_INSTANCED_PERPIXEL_NORMAL) || defined(_INSTANCEDTERRAINNORMALS_PIXEL) ) #define ENABLE_TERRAIN_PERPIXEL_NORMAL #endif /*ase_pragma*/ #if defined(ASE_EARLY_Z_DEPTH_OPTIMIZE) && (SHADER_TARGET >= 45) #define ASE_SV_DEPTH SV_DepthLessEqual #define ASE_SV_POSITION_QUALIFIERS linear noperspective centroid #else #define ASE_SV_DEPTH SV_Depth #define ASE_SV_POSITION_QUALIFIERS #endif struct Attributes { float4 positionOS : POSITION; half3 normalOS : NORMAL; half4 tangentOS : TANGENT; float4 texcoord : TEXCOORD0; #if defined(LIGHTMAP_ON) || defined(ASE_NEEDS_TEXTURE_COORDINATES1) float4 texcoord1 : TEXCOORD1; #endif #if defined(DYNAMICLIGHTMAP_ON) || defined(ASE_NEEDS_TEXTURE_COORDINATES2) float4 texcoord2 : TEXCOORD2; #endif /*ase_vdata:p=p;n=n;t=t;uv0=tc0;uv1=tc1;uv2=tc2*/ UNITY_VERTEX_INPUT_INSTANCE_ID }; struct PackedVaryings { ASE_SV_POSITION_QUALIFIERS float4 positionCS : SV_POSITION; float3 positionWS : TEXCOORD0; half3 normalWS : TEXCOORD1; float4 tangentWS : TEXCOORD2; // holds terrainUV ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL float4 lightmapUVOrVertexSH : TEXCOORD3; #if defined(ASE_FOG) || defined(_ADDITIONAL_LIGHTS_VERTEX) half4 fogFactorAndVertexLight : TEXCOORD4; #endif #if defined(DYNAMICLIGHTMAP_ON) float2 dynamicLightmapUV : TEXCOORD5; #endif #if defined(USE_APV_PROBE_OCCLUSION) float4 probeOcclusion : TEXCOORD6; #endif /*ase_interp(7,):sp=sp;wp=tc0.xyz;wn.xyz=tc1.xyz;wt.xyz=tc2.xyz*/ UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_OUTPUT_STEREO }; CBUFFER_START(UnityPerMaterial) #ifdef ASE_TRANSMISSION float _TransmissionShadow; #endif #ifdef ASE_TRANSLUCENCY float _TransStrength; float _TransNormal; float _TransScattering; float _TransDirect; float _TransAmbient; float _TransShadow; #endif #ifdef ASE_TESSELLATION float _TessPhongStrength; float _TessValue; float _TessMin; float _TessMax; float _TessEdgeLength; float _TessMaxDisp; #endif CBUFFER_END #ifdef SCENEPICKINGPASS float4 _SelectionID; #endif #ifdef SCENESELECTIONPASS int _ObjectId; int _PassValue; #endif /*ase_globals*/ #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutput.hlsl" /*ase_funcs*/ PackedVaryings VertexFunction( Attributes input /*ase_vert_input*/ ) { PackedVaryings output = (PackedVaryings)0; UNITY_SETUP_INSTANCE_ID(input); UNITY_TRANSFER_INSTANCE_ID(input, output); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); /*ase_vert_code:input=Attributes;output=PackedVaryings*/ #ifdef ASE_ABSOLUTE_VERTEX_POS float3 defaultVertexValue = input.positionOS.xyz; #else float3 defaultVertexValue = float3(0, 0, 0); #endif float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;8;-1;_Vertex*/defaultVertexValue/*end*/; #ifdef ASE_ABSOLUTE_VERTEX_POS input.positionOS.xyz = vertexValue; #else input.positionOS.xyz += vertexValue; #endif input.normalOS = /*ase_vert_out:Vertex Normal;Float3;10;-1;_Normal*/input.normalOS/*end*/; input.tangentOS = /*ase_vert_out:Vertex Tangent;Float4;30;-1;_Tangent*/input.tangentOS/*end*/; VertexPositionInputs vertexInput = GetVertexPositionInputs( input.positionOS.xyz ); VertexNormalInputs normalInput = GetVertexNormalInputs( input.normalOS, input.tangentOS ); OUTPUT_LIGHTMAP_UV(input.texcoord1, unity_LightmapST, output.lightmapUVOrVertexSH.xy); #if defined(DYNAMICLIGHTMAP_ON) output.dynamicLightmapUV.xy = input.texcoord2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw; #endif OUTPUT_SH4(vertexInput.positionWS, normalInput.normalWS.xyz, GetWorldSpaceNormalizeViewDir(vertexInput.positionWS), output.lightmapUVOrVertexSH.xyz, output.probeOcclusion); #if defined(ASE_FOG) || defined(_ADDITIONAL_LIGHTS_VERTEX) output.fogFactorAndVertexLight = 0; #if defined(ASE_FOG) && !defined(_FOG_FRAGMENT) // @diogo: no fog applied in GBuffer #endif #ifdef _ADDITIONAL_LIGHTS_VERTEX half3 vertexLight = VertexLighting( vertexInput.positionWS, normalInput.normalWS ); output.fogFactorAndVertexLight.yzw = vertexLight; #endif #endif output.positionCS = vertexInput.positionCS; output.positionWS = vertexInput.positionWS; output.normalWS = normalInput.normalWS; output.tangentWS = float4( normalInput.tangentWS, ( input.tangentOS.w > 0.0 ? 1.0 : -1.0 ) * GetOddNegativeScale() ); #if defined( ENABLE_TERRAIN_PERPIXEL_NORMAL ) output.tangentWS.zw = input.texcoord.xy; output.tangentWS.xy = input.texcoord.xy * unity_LightmapST.xy + unity_LightmapST.zw; #endif return output; } #if defined(ASE_TESSELLATION) struct VertexControl { float4 positionOS : INTERNALTESSPOS; half3 normalOS : NORMAL; half4 tangentOS : TANGENT; float4 texcoord : TEXCOORD0; #if defined(LIGHTMAP_ON) || defined(ASE_NEEDS_TEXTURE_COORDINATES1) float4 texcoord1 : TEXCOORD1; #endif #if defined(DYNAMICLIGHTMAP_ON) || defined(ASE_NEEDS_TEXTURE_COORDINATES2) float4 texcoord2 : TEXCOORD2; #endif /*ase_vcontrol*/ UNITY_VERTEX_INPUT_INSTANCE_ID }; struct TessellationFactors { float edge[3] : SV_TessFactor; float inside : SV_InsideTessFactor; }; VertexControl vert ( Attributes input ) { VertexControl output; UNITY_SETUP_INSTANCE_ID(input); UNITY_TRANSFER_INSTANCE_ID(input, output); output.positionOS = input.positionOS; output.normalOS = input.normalOS; output.tangentOS = input.tangentOS; output.texcoord = input.texcoord; #if defined(LIGHTMAP_ON) || defined(ASE_NEEDS_TEXTURE_COORDINATES1) output.texcoord1 = input.texcoord1; #endif #if defined(DYNAMICLIGHTMAP_ON) || defined(ASE_NEEDS_TEXTURE_COORDINATES2) output.texcoord2 = input.texcoord2; #endif /*ase_control_code:input=Attributes;output=VertexControl*/ return output; } TessellationFactors TessellationFunction (InputPatch input) { TessellationFactors output; float4 tf = 1; float tessValue = /*ase_inline_begin*/_TessValue/*ase_inline_end*/; float tessMin = /*ase_inline_begin*/_TessMin/*ase_inline_end*/; float tessMax = /*ase_inline_begin*/_TessMax/*ase_inline_end*/; float edgeLength = /*ase_inline_begin*/_TessEdgeLength/*ase_inline_end*/; float tessMaxDisp = /*ase_inline_begin*/_TessMaxDisp/*ase_inline_end*/; #if defined(ASE_FIXED_TESSELLATION) tf = FixedTess( tessValue ); #elif defined(ASE_DISTANCE_TESSELLATION) tf = DistanceBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos ); #elif defined(ASE_LENGTH_TESSELLATION) tf = EdgeLengthBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams ); #elif defined(ASE_LENGTH_CULL_TESSELLATION) tf = EdgeLengthBasedTessCull(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes ); #endif output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w; return output; } [domain("tri")] [partitioning("fractional_odd")] [outputtopology("triangle_cw")] [patchconstantfunc("TessellationFunction")] [outputcontrolpoints(3)] VertexControl HullFunction(InputPatch patch, uint id : SV_OutputControlPointID) { return patch[id]; } [domain("tri")] PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch patch, float3 bary : SV_DomainLocation) { Attributes output = (Attributes) 0; output.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z; output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z; output.tangentOS = patch[0].tangentOS * bary.x + patch[1].tangentOS * bary.y + patch[2].tangentOS * bary.z; output.texcoord = patch[0].texcoord * bary.x + patch[1].texcoord * bary.y + patch[2].texcoord * bary.z; #if defined(LIGHTMAP_ON) || defined(ASE_NEEDS_TEXTURE_COORDINATES1) output.texcoord1 = patch[0].texcoord1 * bary.x + patch[1].texcoord1 * bary.y + patch[2].texcoord1 * bary.z; #endif #if defined(DYNAMICLIGHTMAP_ON) || defined(ASE_NEEDS_TEXTURE_COORDINATES2) output.texcoord2 = patch[0].texcoord2 * bary.x + patch[1].texcoord2 * bary.y + patch[2].texcoord2 * bary.z; #endif /*ase_domain_code:patch=VertexControl;output=Attributes;bary=SV_DomainLocation*/ #if defined(ASE_PHONG_TESSELLATION) float3 pp[3]; for (int i = 0; i < 3; ++i) pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS)); float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/; output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz; #endif UNITY_TRANSFER_INSTANCE_ID(patch[0], output); return VertexFunction(output); } #else PackedVaryings vert ( Attributes input ) { return VertexFunction( input ); } #endif GBufferFragOutput frag ( PackedVaryings input #if defined( ASE_DEPTH_WRITE_ON ) ,out float outputDepth : ASE_SV_DEPTH #endif /*ase_frag_input*/ ) { UNITY_SETUP_INSTANCE_ID(input); UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); #if defined(LOD_FADE_CROSSFADE) LODFadeCrossFade( input.positionCS ); #endif #if defined(MAIN_LIGHT_CALCULATE_SHADOWS) float4 shadowCoord = TransformWorldToShadowCoord( input.positionWS ); #else float4 shadowCoord = float4(0, 0, 0, 0); #endif // @diogo: mikktspace compliant float renormFactor = 1.0 / max( FLT_MIN, length( input.normalWS ) ); /*ase_local_var:wp*/float3 PositionWS = input.positionWS; /*ase_local_var:rwp*/float3 PositionRWS = GetCameraRelativePositionWS( PositionWS ); /*ase_local_var:wvd*/float3 ViewDirWS = GetWorldSpaceNormalizeViewDir( PositionWS ); /*ase_local_var:sc*/float4 ShadowCoord = shadowCoord; /*ase_local_var:spn*/float4 ScreenPosNorm = float4( GetNormalizedScreenSpaceUV( input.positionCS ), input.positionCS.zw ); /*ase_local_var:sp*/float4 ClipPos = ComputeClipSpacePosition( ScreenPosNorm.xy, input.positionCS.z ) * input.positionCS.w; /*ase_local_var:spu*/float4 ScreenPos = ComputeScreenPos( ClipPos ); /*ase_local_var:wt*/float3 TangentWS = input.tangentWS.xyz * renormFactor; /*ase_local_var:wbt*/float3 BitangentWS = cross( input.normalWS, input.tangentWS.xyz ) * input.tangentWS.w * renormFactor; /*ase_local_var:wn*/float3 NormalWS = input.normalWS * renormFactor; #if defined( ENABLE_TERRAIN_PERPIXEL_NORMAL ) float2 sampleCoords = (input.tangentWS.zw / _TerrainHeightmapRecipSize.zw + 0.5f) * _TerrainHeightmapRecipSize.xy; NormalWS = TransformObjectToWorldNormal(normalize(SAMPLE_TEXTURE2D(_TerrainNormalmapTexture, sampler_TerrainNormalmapTexture, sampleCoords).rgb * 2 - 1)); TangentWS = -cross(GetObjectToWorldMatrix()._13_23_33, NormalWS); BitangentWS = cross(NormalWS, -TangentWS); #endif /*ase_frag_code:input=PackedVaryings*/ float3 BaseColor = /*ase_frag_out:Base Color;Float3;0;-1;_BaseColor*/float3(0.5, 0.5, 0.5)/*end*/; float3 Normal = /*ase_frag_out:Normal;Float3;1;-1;_FragNormal*/float3(0, 0, 1)/*end*/; float3 Specular = /*ase_frag_out:Specular;Float3;9;-1;_Specular*/0.5/*end*/; float Metallic = /*ase_frag_out:Metallic;Float;3;-1;_Metallic*/0/*end*/; float Smoothness = /*ase_frag_out:Smoothness;Float;4;-1;_Smoothness*/0.5/*end*/; float Occlusion = /*ase_frag_out:Occlusion;Float;5;-1;_Occlusion*/1/*end*/; float3 Emission = /*ase_frag_out:Emission;Float3;2;-1;_Emission*/0/*end*/; float Alpha = /*ase_frag_out:Alpha;Float;6;-1;_Alpha*/1/*end*/; float AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;7;-1;_AlphaClip*/0.5/*end*/; float AlphaClipThresholdShadow = /*ase_frag_out:Alpha Clip Threshold Shadow;Float;16;-1;_AlphaClipShadow*/0.5/*end*/; float3 BakedGI = /*ase_frag_out:Baked GI;Float3;11;-1;_BakedGI*/0/*end*/; float3 RefractionColor = /*ase_frag_out:Refraction Color;Float3;12;-1;_RefractionColor*/1/*end*/; float RefractionIndex = /*ase_frag_out:Refraction Index;Float;13;-1;_RefractionIndex*/1/*end*/; float3 Transmission = /*ase_frag_out:Transmission;Float3;14;-1;_Transmission*/1/*end*/; float3 Translucency = /*ase_frag_out:Translucency;Float3;15;-1;_Translucency*/1/*end*/; #if defined( ASE_DEPTH_WRITE_ON ) float DeviceDepth = /*ase_frag_out:Depth;Float;17;-1;_DepthValue*/ClipPos.z/*end*/; #endif #if defined( _ALPHATEST_ON ) AlphaDiscard( Alpha, AlphaClipThreshold ); #endif #if defined(MAIN_LIGHT_CALCULATE_SHADOWS) && defined(ASE_CHANGES_WORLD_POS) ShadowCoord = TransformWorldToShadowCoord( PositionWS ); #endif InputData inputData = (InputData)0; inputData.positionWS = PositionWS; inputData.positionCS = float4( input.positionCS.xy, ClipPos.zw / ClipPos.w ); inputData.normalizedScreenSpaceUV = ScreenPosNorm.xy; inputData.shadowCoord = ShadowCoord; #ifdef _NORMALMAP #if _NORMAL_DROPOFF_TS inputData.normalWS = TransformTangentToWorld(Normal, half3x3( TangentWS, BitangentWS, NormalWS )); #elif _NORMAL_DROPOFF_OS inputData.normalWS = TransformObjectToWorldNormal(Normal); #elif _NORMAL_DROPOFF_WS inputData.normalWS = Normal; #endif #else inputData.normalWS = NormalWS; #endif inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS); inputData.viewDirectionWS = SafeNormalize( ViewDirWS ); #ifdef ASE_FOG // @diogo: no fog applied in GBuffer #endif #ifdef _ADDITIONAL_LIGHTS_VERTEX inputData.vertexLighting = input.fogFactorAndVertexLight.yzw; #endif #if defined( ENABLE_TERRAIN_PERPIXEL_NORMAL ) float3 SH = SampleSH(inputData.normalWS.xyz); #else float3 SH = input.lightmapUVOrVertexSH.xyz; #endif #if defined(DYNAMICLIGHTMAP_ON) inputData.bakedGI = SAMPLE_GI(input.lightmapUVOrVertexSH.xy, input.dynamicLightmapUV.xy, SH, inputData.normalWS); inputData.shadowMask = SAMPLE_SHADOWMASK(input.lightmapUVOrVertexSH.xy); #elif !defined(LIGHTMAP_ON) && (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2)) inputData.bakedGI = SAMPLE_GI(SH, GetAbsolutePositionWS(inputData.positionWS), inputData.normalWS, inputData.viewDirectionWS, input.positionCS.xy, input.probeOcclusion, inputData.shadowMask); #else inputData.bakedGI = SAMPLE_GI(input.lightmapUVOrVertexSH.xy, SH, inputData.normalWS); inputData.shadowMask = SAMPLE_SHADOWMASK(input.lightmapUVOrVertexSH.xy); #endif #ifdef ASE_BAKEDGI inputData.bakedGI = BakedGI; #endif #if defined(DEBUG_DISPLAY) #if defined(DYNAMICLIGHTMAP_ON) inputData.dynamicLightmapUV = input.dynamicLightmapUV.xy; #endif #if defined(LIGHTMAP_ON) inputData.staticLightmapUV = input.lightmapUVOrVertexSH.xy; #else inputData.vertexSH = SH; #endif #if defined(USE_APV_PROBE_OCCLUSION) inputData.probeOcclusion = input.probeOcclusion; #endif #endif #ifdef _DBUFFER ApplyDecal(input.positionCS, BaseColor, Specular, inputData.normalWS, Metallic, Occlusion, Smoothness); #endif BRDFData brdfData; InitializeBRDFData(BaseColor, Metallic, Specular, Smoothness, Alpha, brdfData); Light mainLight = GetMainLight(inputData.shadowCoord, inputData.positionWS, inputData.shadowMask); half4 color; MixRealtimeAndBakedGI(mainLight, inputData.normalWS, inputData.bakedGI, inputData.shadowMask); color.rgb = GlobalIllumination(brdfData, (BRDFData)0, 0, inputData.bakedGI, Occlusion, inputData.positionWS, inputData.normalWS, inputData.viewDirectionWS, inputData.normalizedScreenSpaceUV); color.a = Alpha; #ifdef ASE_FINAL_COLOR_ALPHA_MULTIPLY color.rgb *= color.a; #endif #if defined( ASE_DEPTH_WRITE_ON ) outputDepth = DeviceDepth; #endif return PackGBuffersBRDFData(brdfData, inputData, Smoothness, Emission + color.rgb, Occlusion); } ENDHLSL } /*ase_pass*/ Pass { /*ase_hide_pass*/ Name "SceneSelectionPass" Tags { "LightMode" = "SceneSelectionPass" } Cull Off AlphaToMask Off HLSLPROGRAM #pragma vertex vert #pragma fragment frag #if defined(_SPECULAR_SETUP) && defined(ASE_LIGHTING_SIMPLE) #define _SPECULAR_COLOR 1 #endif #define SCENESELECTIONPASS 1 #define ATTRIBUTES_NEED_NORMAL #define ATTRIBUTES_NEED_TANGENT #define SHADERPASS SHADERPASS_DEPTHONLY #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl" /*ase_pragma*/ #if defined(ASE_EARLY_Z_DEPTH_OPTIMIZE) && (SHADER_TARGET >= 45) #define ASE_SV_DEPTH SV_DepthLessEqual #define ASE_SV_POSITION_QUALIFIERS linear noperspective centroid #else #define ASE_SV_DEPTH SV_Depth #define ASE_SV_POSITION_QUALIFIERS #endif struct Attributes { float4 positionOS : POSITION; half3 normalOS : NORMAL; half4 tangentOS : TANGENT; /*ase_vdata:p=p;n=n;t=t*/ UNITY_VERTEX_INPUT_INSTANCE_ID }; struct PackedVaryings { ASE_SV_POSITION_QUALIFIERS float4 positionCS : SV_POSITION; float3 positionWS : TEXCOORD0; /*ase_interp(1,):sp=sp;wp=tc0.xyz*/ UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_OUTPUT_STEREO }; CBUFFER_START(UnityPerMaterial) #ifdef ASE_TRANSMISSION float _TransmissionShadow; #endif #ifdef ASE_TRANSLUCENCY float _TransStrength; float _TransNormal; float _TransScattering; float _TransDirect; float _TransAmbient; float _TransShadow; #endif #ifdef ASE_TESSELLATION float _TessPhongStrength; float _TessValue; float _TessMin; float _TessMax; float _TessEdgeLength; float _TessMaxDisp; #endif CBUFFER_END #ifdef SCENEPICKINGPASS float4 _SelectionID; #endif #ifdef SCENESELECTIONPASS int _ObjectId; int _PassValue; #endif /*ase_globals*/ /*ase_funcs*/ struct SurfaceDescription { float Alpha; float AlphaClipThreshold; }; PackedVaryings VertexFunction(Attributes input /*ase_vert_input*/ ) { PackedVaryings output; ZERO_INITIALIZE(PackedVaryings, output); UNITY_SETUP_INSTANCE_ID(input); UNITY_TRANSFER_INSTANCE_ID(input, output); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); /*ase_vert_code:input=Attributes;output=PackedVaryings*/ #ifdef ASE_ABSOLUTE_VERTEX_POS float3 defaultVertexValue = input.positionOS.xyz; #else float3 defaultVertexValue = float3(0, 0, 0); #endif float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;8;-1;_Vertex*/defaultVertexValue/*end*/; #ifdef ASE_ABSOLUTE_VERTEX_POS input.positionOS.xyz = vertexValue; #else input.positionOS.xyz += vertexValue; #endif input.normalOS = /*ase_vert_out:Vertex Normal;Float3;10;-1;_Normal*/input.normalOS/*end*/; VertexPositionInputs vertexInput = GetVertexPositionInputs( input.positionOS.xyz ); output.positionCS = vertexInput.positionCS; output.positionWS = vertexInput.positionWS; return output; } #if defined(ASE_TESSELLATION) struct VertexControl { float4 positionOS : INTERNALTESSPOS; half3 normalOS : NORMAL; half4 tangentOS : TANGENT; /*ase_vcontrol*/ UNITY_VERTEX_INPUT_INSTANCE_ID }; struct TessellationFactors { float edge[3] : SV_TessFactor; float inside : SV_InsideTessFactor; }; VertexControl vert ( Attributes input ) { VertexControl output; UNITY_SETUP_INSTANCE_ID(input); UNITY_TRANSFER_INSTANCE_ID(input, output); output.positionOS = input.positionOS; output.normalOS = input.normalOS; output.tangentOS = input.tangentOS; /*ase_control_code:input=Attributes;output=VertexControl*/ return output; } TessellationFactors TessellationFunction (InputPatch input) { TessellationFactors output; float4 tf = 1; float tessValue = /*ase_inline_begin*/_TessValue/*ase_inline_end*/; float tessMin = /*ase_inline_begin*/_TessMin/*ase_inline_end*/; float tessMax = /*ase_inline_begin*/_TessMax/*ase_inline_end*/; float edgeLength = /*ase_inline_begin*/_TessEdgeLength/*ase_inline_end*/; float tessMaxDisp = /*ase_inline_begin*/_TessMaxDisp/*ase_inline_end*/; #if defined(ASE_FIXED_TESSELLATION) tf = FixedTess( tessValue ); #elif defined(ASE_DISTANCE_TESSELLATION) tf = DistanceBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos ); #elif defined(ASE_LENGTH_TESSELLATION) tf = EdgeLengthBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams ); #elif defined(ASE_LENGTH_CULL_TESSELLATION) tf = EdgeLengthBasedTessCull(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes ); #endif output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w; return output; } [domain("tri")] [partitioning("fractional_odd")] [outputtopology("triangle_cw")] [patchconstantfunc("TessellationFunction")] [outputcontrolpoints(3)] VertexControl HullFunction(InputPatch patch, uint id : SV_OutputControlPointID) { return patch[id]; } [domain("tri")] PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch patch, float3 bary : SV_DomainLocation) { Attributes output = (Attributes) 0; output.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z; output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z; output.tangentOS = patch[0].tangentOS * bary.x + patch[1].tangentOS * bary.y + patch[2].tangentOS * bary.z; /*ase_domain_code:patch=VertexControl;output=Attributes;bary=SV_DomainLocation*/ #if defined(ASE_PHONG_TESSELLATION) float3 pp[3]; for (int i = 0; i < 3; ++i) pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS)); float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/; output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz; #endif UNITY_TRANSFER_INSTANCE_ID(patch[0], output); return VertexFunction(output); } #else PackedVaryings vert ( Attributes input ) { return VertexFunction( input ); } #endif half4 frag( PackedVaryings input #if defined( ASE_DEPTH_WRITE_ON ) ,out float outputDepth : ASE_SV_DEPTH #endif /*ase_frag_input*/ ) : SV_Target { SurfaceDescription surfaceDescription = (SurfaceDescription)0; /*ase_local_var:wp*/float3 PositionWS = input.positionWS; /*ase_local_var:rwp*/float3 PositionRWS = GetCameraRelativePositionWS( PositionWS ); /*ase_local_var:spn*/float4 ScreenPosNorm = float4( GetNormalizedScreenSpaceUV( input.positionCS ), input.positionCS.zw ); /*ase_local_var:sp*/float4 ClipPos = ComputeClipSpacePosition( ScreenPosNorm.xy, input.positionCS.z ) * input.positionCS.w; /*ase_frag_code:input=PackedVaryings*/ surfaceDescription.Alpha = /*ase_frag_out:Alpha;Float;0;-1;_Alpha*/1/*end*/; surfaceDescription.AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;7;-1;_AlphaClip*/0.5/*end*/; #if defined( ASE_DEPTH_WRITE_ON ) float DeviceDepth = /*ase_frag_out:Depth;Float;17;-1;_DepthValue*/input.positionCS.z/*end*/; #endif #if _ALPHATEST_ON float alphaClipThreshold = 0.01f; #if ALPHA_CLIP_THRESHOLD alphaClipThreshold = surfaceDescription.AlphaClipThreshold; #endif clip(surfaceDescription.Alpha - alphaClipThreshold); #endif #if defined( ASE_DEPTH_WRITE_ON ) outputDepth = DeviceDepth; #endif return half4( _ObjectId, _PassValue, 1.0, 1.0 ); } ENDHLSL } /*ase_pass*/ Pass { /*ase_hide_pass*/ Name "ScenePickingPass" Tags { "LightMode" = "Picking" } AlphaToMask Off HLSLPROGRAM #pragma vertex vert #pragma fragment frag #if defined(_SPECULAR_SETUP) && defined(ASE_LIGHTING_SIMPLE) #define _SPECULAR_COLOR 1 #endif #define SCENEPICKINGPASS 1 #define ATTRIBUTES_NEED_NORMAL #define ATTRIBUTES_NEED_TANGENT #define SHADERPASS SHADERPASS_DEPTHONLY #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl" /*ase_pragma*/ #if defined(ASE_EARLY_Z_DEPTH_OPTIMIZE) && (SHADER_TARGET >= 45) #define ASE_SV_DEPTH SV_DepthLessEqual #define ASE_SV_POSITION_QUALIFIERS linear noperspective centroid #else #define ASE_SV_DEPTH SV_Depth #define ASE_SV_POSITION_QUALIFIERS #endif struct Attributes { float4 positionOS : POSITION; half3 normalOS : NORMAL; half4 tangentOS : TANGENT; /*ase_vdata:p=p;n=n;t=t*/ UNITY_VERTEX_INPUT_INSTANCE_ID }; struct PackedVaryings { ASE_SV_POSITION_QUALIFIERS float4 positionCS : SV_POSITION; float3 positionWS : TEXCOORD0; /*ase_interp(1,):sp=sp;wp=tc0.xyz*/ UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_OUTPUT_STEREO }; CBUFFER_START(UnityPerMaterial) #ifdef ASE_TRANSMISSION float _TransmissionShadow; #endif #ifdef ASE_TRANSLUCENCY float _TransStrength; float _TransNormal; float _TransScattering; float _TransDirect; float _TransAmbient; float _TransShadow; #endif #ifdef ASE_TESSELLATION float _TessPhongStrength; float _TessValue; float _TessMin; float _TessMax; float _TessEdgeLength; float _TessMaxDisp; #endif CBUFFER_END #ifdef SCENEPICKINGPASS float4 _SelectionID; #endif #ifdef SCENESELECTIONPASS int _ObjectId; int _PassValue; #endif /*ase_globals*/ /*ase_funcs*/ struct SurfaceDescription { float Alpha; float AlphaClipThreshold; }; PackedVaryings VertexFunction( Attributes input /*ase_vert_input*/ ) { PackedVaryings output; ZERO_INITIALIZE(PackedVaryings, output); UNITY_SETUP_INSTANCE_ID(input); UNITY_TRANSFER_INSTANCE_ID(input, output); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); /*ase_vert_code:input=Attributes;output=PackedVaryings*/ #ifdef ASE_ABSOLUTE_VERTEX_POS float3 defaultVertexValue = input.positionOS.xyz; #else float3 defaultVertexValue = float3(0, 0, 0); #endif float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;8;-1;_Vertex*/defaultVertexValue/*end*/; #ifdef ASE_ABSOLUTE_VERTEX_POS input.positionOS.xyz = vertexValue; #else input.positionOS.xyz += vertexValue; #endif input.normalOS = /*ase_vert_out:Vertex Normal;Float3;10;-1;_Normal*/input.normalOS/*end*/; VertexPositionInputs vertexInput = GetVertexPositionInputs( input.positionOS.xyz ); output.positionCS = vertexInput.positionCS; output.positionWS = vertexInput.positionWS; return output; } #if defined(ASE_TESSELLATION) struct VertexControl { float4 positionOS : INTERNALTESSPOS; half3 normalOS : NORMAL; half4 tangentOS : TANGENT; /*ase_vcontrol*/ UNITY_VERTEX_INPUT_INSTANCE_ID }; struct TessellationFactors { float edge[3] : SV_TessFactor; float inside : SV_InsideTessFactor; }; VertexControl vert ( Attributes input ) { VertexControl output; UNITY_SETUP_INSTANCE_ID(input); UNITY_TRANSFER_INSTANCE_ID(input, output); output.positionOS = input.positionOS; output.normalOS = input.normalOS; output.tangentOS = input.tangentOS; /*ase_control_code:input=Attributes;output=VertexControl*/ return output; } TessellationFactors TessellationFunction (InputPatch input) { TessellationFactors output; float4 tf = 1; float tessValue = /*ase_inline_begin*/_TessValue/*ase_inline_end*/; float tessMin = /*ase_inline_begin*/_TessMin/*ase_inline_end*/; float tessMax = /*ase_inline_begin*/_TessMax/*ase_inline_end*/; float edgeLength = /*ase_inline_begin*/_TessEdgeLength/*ase_inline_end*/; float tessMaxDisp = /*ase_inline_begin*/_TessMaxDisp/*ase_inline_end*/; #if defined(ASE_FIXED_TESSELLATION) tf = FixedTess( tessValue ); #elif defined(ASE_DISTANCE_TESSELLATION) tf = DistanceBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos ); #elif defined(ASE_LENGTH_TESSELLATION) tf = EdgeLengthBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams ); #elif defined(ASE_LENGTH_CULL_TESSELLATION) tf = EdgeLengthBasedTessCull(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes ); #endif output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w; return output; } [domain("tri")] [partitioning("fractional_odd")] [outputtopology("triangle_cw")] [patchconstantfunc("TessellationFunction")] [outputcontrolpoints(3)] VertexControl HullFunction(InputPatch patch, uint id : SV_OutputControlPointID) { return patch[id]; } [domain("tri")] PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch patch, float3 bary : SV_DomainLocation) { Attributes output = (Attributes) 0; output.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z; output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z; output.tangentOS = patch[0].tangentOS * bary.x + patch[1].tangentOS * bary.y + patch[2].tangentOS * bary.z; /*ase_domain_code:patch=VertexControl;output=Attributes;bary=SV_DomainLocation*/ #if defined(ASE_PHONG_TESSELLATION) float3 pp[3]; for (int i = 0; i < 3; ++i) pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS)); float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/; output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz; #endif UNITY_TRANSFER_INSTANCE_ID(patch[0], output); return VertexFunction(output); } #else PackedVaryings vert ( Attributes input ) { return VertexFunction( input ); } #endif half4 frag( PackedVaryings input #if defined( ASE_DEPTH_WRITE_ON ) ,out float outputDepth : ASE_SV_DEPTH #endif /*ase_frag_input*/ ) : SV_Target { SurfaceDescription surfaceDescription = (SurfaceDescription)0; /*ase_local_var:wp*/float3 PositionWS = input.positionWS; /*ase_local_var:rwp*/float3 PositionRWS = GetCameraRelativePositionWS( PositionWS ); /*ase_local_var:spn*/float4 ScreenPosNorm = float4( GetNormalizedScreenSpaceUV( input.positionCS ), input.positionCS.zw ); /*ase_local_var:sp*/float4 ClipPos = ComputeClipSpacePosition( ScreenPosNorm.xy, input.positionCS.z ) * input.positionCS.w; /*ase_frag_code:input=PackedVaryings*/ surfaceDescription.Alpha = /*ase_frag_out:Alpha;Float;0;-1;_Alpha*/1/*end*/; surfaceDescription.AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;7;-1;_AlphaClip*/0.5/*end*/; #if defined( ASE_DEPTH_WRITE_ON ) float DeviceDepth = /*ase_frag_out:Depth;Float;17;-1;_DepthValue*/input.positionCS.z/*end*/; #endif #if _ALPHATEST_ON float alphaClipThreshold = 0.01f; #if ALPHA_CLIP_THRESHOLD alphaClipThreshold = surfaceDescription.AlphaClipThreshold; #endif clip(surfaceDescription.Alpha - alphaClipThreshold); #endif #if defined( ASE_DEPTH_WRITE_ON ) outputDepth = DeviceDepth; #endif return unity_SelectionID; } ENDHLSL } /*ase_pass*/ Pass { /*ase_hide_pass*/ Name "MotionVectors" Tags { "LightMode" = "MotionVectors" } ColorMask RG HLSLPROGRAM #pragma vertex vert #pragma fragment frag #if defined(_SPECULAR_SETUP) && defined(ASE_LIGHTING_SIMPLE) #define _SPECULAR_COLOR 1 #endif #define SHADERPASS SHADERPASS_MOTION_VECTORS #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl" #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl" #if defined(LOD_FADE_CROSSFADE) #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl" #endif #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/MotionVectorsCommon.hlsl" /*ase_pragma*/ #if defined(ASE_EARLY_Z_DEPTH_OPTIMIZE) && (SHADER_TARGET >= 45) #define ASE_SV_DEPTH SV_DepthLessEqual #define ASE_SV_POSITION_QUALIFIERS linear noperspective centroid #else #define ASE_SV_DEPTH SV_Depth #define ASE_SV_POSITION_QUALIFIERS #endif struct Attributes { float4 positionOS : POSITION; float3 positionOld : TEXCOORD4; #if _ADD_PRECOMPUTED_VELOCITY float3 alembicMotionVector : TEXCOORD5; #endif half3 normalOS : NORMAL; half4 tangentOS : TANGENT; /*ase_vdata:p=p;n=n;t=t;uv4=tc4;uv5=tc5*/ UNITY_VERTEX_INPUT_INSTANCE_ID }; struct PackedVaryings { float4 positionCS : SV_POSITION; float4 positionCSNoJitter : TEXCOORD0; float4 previousPositionCSNoJitter : TEXCOORD1; float3 positionWS : TEXCOORD2; /*ase_interp(3,):sp=sp.xyzw*/ UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_OUTPUT_STEREO }; CBUFFER_START(UnityPerMaterial) #ifdef ASE_TRANSMISSION float _TransmissionShadow; #endif #ifdef ASE_TRANSLUCENCY float _TransStrength; float _TransNormal; float _TransScattering; float _TransDirect; float _TransAmbient; float _TransShadow; #endif #ifdef ASE_TESSELLATION float _TessPhongStrength; float _TessValue; float _TessMin; float _TessMax; float _TessEdgeLength; float _TessMaxDisp; #endif CBUFFER_END #ifdef SCENEPICKINGPASS float4 _SelectionID; #endif #ifdef SCENESELECTIONPASS int _ObjectId; int _PassValue; #endif /*ase_globals*/ /*ase_funcs*/ PackedVaryings VertexFunction( Attributes input /*ase_vert_input*/ ) { PackedVaryings output = (PackedVaryings)0; UNITY_SETUP_INSTANCE_ID(input); UNITY_TRANSFER_INSTANCE_ID(input, output); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); /*ase_vert_code:input=Attributes;output=PackedVaryings*/ #ifdef ASE_ABSOLUTE_VERTEX_POS float3 defaultVertexValue = input.positionOS.xyz; #else float3 defaultVertexValue = float3(0, 0, 0); #endif float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;8;-1;_Vertex*/defaultVertexValue/*end*/; #ifdef ASE_ABSOLUTE_VERTEX_POS input.positionOS.xyz = vertexValue; #else input.positionOS.xyz += vertexValue; #endif VertexPositionInputs vertexInput = GetVertexPositionInputs( input.positionOS.xyz ); #if defined(APPLICATION_SPACE_WARP_MOTION) output.positionCSNoJitter = mul(_NonJitteredViewProjMatrix, mul(UNITY_MATRIX_M, input.positionOS)); output.positionCS = output.positionCSNoJitter; #else output.positionCS = vertexInput.positionCS; output.positionCSNoJitter = mul(_NonJitteredViewProjMatrix, mul(UNITY_MATRIX_M, input.positionOS)); #endif float4 prevPos = ( unity_MotionVectorsParams.x == 1 ) ? float4( input.positionOld, 1 ) : input.positionOS; #if _ADD_PRECOMPUTED_VELOCITY prevPos = prevPos - float4(input.alembicMotionVector, 0); #endif output.previousPositionCSNoJitter = mul( _PrevViewProjMatrix, mul( UNITY_PREV_MATRIX_M, prevPos ) ); output.positionWS = vertexInput.positionWS; // removed in ObjectMotionVectors.hlsl found in unity 6000.0.23 and higher //ApplyMotionVectorZBias( output.positionCS ); return output; } PackedVaryings vert ( Attributes input ) { return VertexFunction( input ); } half4 frag( PackedVaryings input #if defined( ASE_DEPTH_WRITE_ON ) ,out float outputDepth : ASE_SV_DEPTH #endif /*ase_frag_input*/ ) : SV_Target { UNITY_SETUP_INSTANCE_ID(input); UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( input ); /*ase_local_var:wp*/float3 PositionWS = input.positionWS; /*ase_local_var:rwp*/float3 PositionRWS = GetCameraRelativePositionWS( PositionWS ); /*ase_local_var:spn*/float4 ScreenPosNorm = float4( GetNormalizedScreenSpaceUV( input.positionCS ), input.positionCS.zw ); /*ase_local_var:sp*/float4 ClipPos = ComputeClipSpacePosition( ScreenPosNorm.xy, input.positionCS.z ) * input.positionCS.w; /*ase_frag_code:input=PackedVaryings*/ float Alpha = /*ase_frag_out:Alpha;Float;6;-1;_Alpha*/1/*end*/; float AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;7;-1;_AlphaClip*/0.5/*end*/; #if defined( ASE_DEPTH_WRITE_ON ) float DeviceDepth = /*ase_frag_out:Depth;Float;17;-1;_DepthValue*/input.positionCS.z/*end*/; #endif #ifdef _ALPHATEST_ON clip(Alpha - AlphaClipThreshold); #endif #if defined(ASE_CHANGES_WORLD_POS) float3 positionOS = mul( GetWorldToObjectMatrix(), float4( PositionWS, 1.0 ) ).xyz; float3 previousPositionWS = mul( GetPrevObjectToWorldMatrix(), float4( positionOS, 1.0 ) ).xyz; input.positionCSNoJitter = mul( _NonJitteredViewProjMatrix, float4( PositionWS, 1.0 ) ); input.previousPositionCSNoJitter = mul( _PrevViewProjMatrix, float4( previousPositionWS, 1.0 ) ); #endif #if defined(LOD_FADE_CROSSFADE) LODFadeCrossFade( input.positionCS ); #endif #if defined( ASE_DEPTH_WRITE_ON ) outputDepth = DeviceDepth; #endif #if defined(APPLICATION_SPACE_WARP_MOTION) return float4( CalcAswNdcMotionVectorFromCsPositions( input.positionCSNoJitter, input.previousPositionCSNoJitter ), 1 ); #else return float4( CalcNdcMotionVectorFromCsPositions( input.positionCSNoJitter, input.previousPositionCSNoJitter ), 0, 0 ); #endif } ENDHLSL } /*ase_pass*/ Pass { /*ase_hide_pass*/ Name "XRMotionVectors" Tags { "LightMode" = "XRMotionVectors" } ColorMask RGBA Stencil { WriteMask 1 Ref 1 Comp Always Pass Replace } HLSLPROGRAM #pragma vertex vert #pragma fragment frag #define APPLICATION_SPACE_WARP_MOTION 1 #if defined(_SPECULAR_SETUP) && defined(ASE_LIGHTING_SIMPLE) #define _SPECULAR_COLOR 1 #endif #define SHADERPASS SHADERPASS_MOTION_VECTORS #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl" #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl" #if defined(LOD_FADE_CROSSFADE) #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl" #endif #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/MotionVectorsCommon.hlsl" /*ase_pragma*/ #if defined(ASE_EARLY_Z_DEPTH_OPTIMIZE) && (SHADER_TARGET >= 45) #define ASE_SV_DEPTH SV_DepthLessEqual #define ASE_SV_POSITION_QUALIFIERS linear noperspective centroid #else #define ASE_SV_DEPTH SV_Depth #define ASE_SV_POSITION_QUALIFIERS #endif struct Attributes { float4 positionOS : POSITION; float3 positionOld : TEXCOORD4; #if _ADD_PRECOMPUTED_VELOCITY float3 alembicMotionVector : TEXCOORD5; #endif half3 normalOS : NORMAL; half4 tangentOS : TANGENT; /*ase_vdata:p=p;n=n;t=t;uv4=tc4;uv5=tc5*/ UNITY_VERTEX_INPUT_INSTANCE_ID }; struct PackedVaryings { float4 positionCS : SV_POSITION; float4 positionCSNoJitter : TEXCOORD0; float4 previousPositionCSNoJitter : TEXCOORD1; float3 positionWS : TEXCOORD2; /*ase_interp(3,):sp=sp.xyzw*/ UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_OUTPUT_STEREO }; CBUFFER_START(UnityPerMaterial) #ifdef ASE_TRANSMISSION float _TransmissionShadow; #endif #ifdef ASE_TRANSLUCENCY float _TransStrength; float _TransNormal; float _TransScattering; float _TransDirect; float _TransAmbient; float _TransShadow; #endif #ifdef ASE_TESSELLATION float _TessPhongStrength; float _TessValue; float _TessMin; float _TessMax; float _TessEdgeLength; float _TessMaxDisp; #endif CBUFFER_END #ifdef SCENEPICKINGPASS float4 _SelectionID; #endif #ifdef SCENESELECTIONPASS int _ObjectId; int _PassValue; #endif /*ase_globals*/ /*ase_funcs*/ PackedVaryings VertexFunction( Attributes input /*ase_vert_input*/ ) { PackedVaryings output = (PackedVaryings)0; UNITY_SETUP_INSTANCE_ID(input); UNITY_TRANSFER_INSTANCE_ID(input, output); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); /*ase_vert_code:input=Attributes;output=PackedVaryings*/ #ifdef ASE_ABSOLUTE_VERTEX_POS float3 defaultVertexValue = input.positionOS.xyz; #else float3 defaultVertexValue = float3(0, 0, 0); #endif float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;8;-1;_Vertex*/defaultVertexValue/*end*/; #ifdef ASE_ABSOLUTE_VERTEX_POS input.positionOS.xyz = vertexValue; #else input.positionOS.xyz += vertexValue; #endif VertexPositionInputs vertexInput = GetVertexPositionInputs( input.positionOS.xyz ); #if defined(APPLICATION_SPACE_WARP_MOTION) output.positionCSNoJitter = mul(_NonJitteredViewProjMatrix, mul(UNITY_MATRIX_M, input.positionOS));; output.positionCS = output.positionCSNoJitter; #else output.positionCS = vertexInput.positionCS; output.positionCSNoJitter = mul(_NonJitteredViewProjMatrix, mul(UNITY_MATRIX_M, input.positionOS)); #endif float4 prevPos = ( unity_MotionVectorsParams.x == 1 ) ? float4( input.positionOld, 1 ) : input.positionOS; #if _ADD_PRECOMPUTED_VELOCITY prevPos = prevPos - float4(input.alembicMotionVector, 0); #endif output.previousPositionCSNoJitter = mul( _PrevViewProjMatrix, mul( UNITY_PREV_MATRIX_M, prevPos ) ); output.positionWS = vertexInput.positionWS; // removed in ObjectMotionVectors.hlsl found in unity 6000.0.23 and higher //ApplyMotionVectorZBias( output.positionCS ); return output; } PackedVaryings vert ( Attributes input ) { return VertexFunction( input ); } half4 frag( PackedVaryings input #if defined( ASE_DEPTH_WRITE_ON ) ,out float outputDepth : ASE_SV_DEPTH #endif /*ase_frag_input*/ ) : SV_Target { UNITY_SETUP_INSTANCE_ID(input); UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( input ); /*ase_local_var:wp*/float3 PositionWS = input.positionWS; /*ase_local_var:rwp*/float3 PositionRWS = GetCameraRelativePositionWS( PositionWS ); /*ase_local_var:spn*/float4 ScreenPosNorm = float4( GetNormalizedScreenSpaceUV( input.positionCS ), input.positionCS.zw ); /*ase_local_var:sp*/float4 ClipPos = ComputeClipSpacePosition( ScreenPosNorm.xy, input.positionCS.z ) * input.positionCS.w; /*ase_frag_code:input=PackedVaryings*/ float Alpha = /*ase_frag_out:Alpha;Float;6;-1;_Alpha*/1/*end*/; float AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;7;-1;_AlphaClip*/0.5/*end*/; #if defined( ASE_DEPTH_WRITE_ON ) float DeviceDepth = /*ase_frag_out:Depth;Float;17;-1;_DepthValue*/input.positionCS.z/*end*/; #endif #ifdef _ALPHATEST_ON clip(Alpha - AlphaClipThreshold); #endif #if defined(ASE_CHANGES_WORLD_POS) float3 positionOS = mul( GetWorldToObjectMatrix(), float4( PositionWS, 1.0 ) ).xyz; float3 previousPositionWS = mul( GetPrevObjectToWorldMatrix(), float4( positionOS, 1.0 ) ).xyz; input.positionCSNoJitter = mul( _NonJitteredViewProjMatrix, float4( PositionWS, 1.0 ) ); input.previousPositionCSNoJitter = mul( _PrevViewProjMatrix, float4( previousPositionWS, 1.0 ) ); #endif #if defined(LOD_FADE_CROSSFADE) LODFadeCrossFade( input.positionCS ); #endif #if defined( ASE_DEPTH_WRITE_ON ) outputDepth = DeviceDepth; #endif #if defined(APPLICATION_SPACE_WARP_MOTION) return float4( CalcAswNdcMotionVectorFromCsPositions( input.positionCSNoJitter, input.previousPositionCSNoJitter ), 1 ); #else return float4( CalcNdcMotionVectorFromCsPositions( input.positionCSNoJitter, input.previousPositionCSNoJitter ), 0, 0 ); #endif } ENDHLSL } /*ase_pass_end*/ } /*ase_lod*/ CustomEditor "UnityEditor.ShaderGraphLitGUI" FallBack "Hidden/Shader Graph/FallbackError" }