3539 lines
133 KiB
GLSL
3539 lines
133 KiB
GLSL
Shader /*ase_name*/ "Hidden/HD/Unlit" /*end*/
|
|
{
|
|
Properties
|
|
{
|
|
/*ase_props*/
|
|
[HideInInspector]_RenderQueueType("Render Queue Type", Float) = 1
|
|
[HideInInspector][ToggleUI]_AddPrecomputedVelocity("Add Precomputed Velocity", Float) = 1
|
|
[HideInInspector]_ShadowMatteFilter("Shadow Matte Filter", Float) = 2.006836
|
|
[HideInInspector]_StencilRef("Stencil Ref", Int) = 0
|
|
[HideInInspector]_StencilWriteMask("StencilWrite Mask", Int) = 6
|
|
[HideInInspector]_StencilRefDepth("StencilRefDepth", Int) = 0
|
|
[HideInInspector]_StencilWriteMaskDepth("_StencilWriteMaskDepth", Int) = 8
|
|
[HideInInspector]_StencilRefMV("_StencilRefMV", Int) = 32
|
|
[HideInInspector]_StencilWriteMaskMV("_StencilWriteMaskMV", Int) = 40
|
|
[HideInInspector]_StencilRefDistortionVec("_StencilRefDistortionVec", Int) = 4
|
|
[HideInInspector]_StencilWriteMaskDistortionVec("_StencilWriteMaskDistortionVec", Int) = 4
|
|
[HideInInspector]_StencilWriteMaskGBuffer("_StencilWriteMaskGBuffer", Int) = 14
|
|
[HideInInspector]_StencilRefGBuffer("_StencilRefGBuffer", Int) = 2
|
|
[HideInInspector]_ZTestGBuffer("_ZTestGBuffer", Int) = 4
|
|
[HideInInspector][ToggleUI]_RequireSplitLighting("_RequireSplitLighting", Float) = 0
|
|
[HideInInspector][ToggleUI]_ReceivesSSR("_ReceivesSSR", Float) = 0
|
|
[HideInInspector]_SurfaceType("_SurfaceType", Float) = 0
|
|
[HideInInspector]_BlendMode("_BlendMode", Float) = 0
|
|
[HideInInspector]_SrcBlend("_SrcBlend", Float) = 1
|
|
[HideInInspector]_DstBlend("_DstBlend", Float) = 0
|
|
[HideInInspector]_AlphaSrcBlend("Vec_AlphaSrcBlendtor1", Float) = 1
|
|
[HideInInspector]_AlphaDstBlend("_AlphaDstBlend", Float) = 0
|
|
[HideInInspector][ToggleUI]_ZWrite("_ZWrite", Float) = 1
|
|
[HideInInspector][ToggleUI]_TransparentZWrite("_TransparentZWrite", Float) = 1
|
|
[HideInInspector]_CullMode("Cull Mode", Float) = 2
|
|
[HideInInspector]_TransparentSortPriority("_TransparentSortPriority", Int) = 0
|
|
[HideInInspector][ToggleUI]_EnableFogOnTransparent("_EnableFogOnTransparent", Float) = 1
|
|
[HideInInspector]_CullModeForward("_CullModeForward", Float) = 2
|
|
[HideInInspector][Enum(Front, 1, Back, 2)]_TransparentCullMode("_TransparentCullMode", Float) = 2
|
|
[HideInInspector]_ZTestDepthEqualForOpaque("_ZTestDepthEqualForOpaque", Int) = 4
|
|
[HideInInspector][Enum(UnityEngine.Rendering.CompareFunction)]_ZTestTransparent("_ZTestTransparent", Float) = 4
|
|
[HideInInspector][ToggleUI]_TransparentBackfaceEnable("_TransparentBackfaceEnable", Float) = 0
|
|
[HideInInspector][ToggleUI]_AlphaCutoffEnable("_AlphaCutoffEnable", Float) = 0
|
|
[HideInInspector][ToggleUI]_UseShadowThreshold("_UseShadowThreshold", Float) = 0
|
|
[HideInInspector][ToggleUI]_DoubleSidedEnable("_DoubleSidedEnable", Float) = 0
|
|
[HideInInspector][Enum(Flip, 0, Mirror, 1, None, 2)]_DoubleSidedNormalMode("_DoubleSidedNormalMode", Float) = 2
|
|
[HideInInspector]_DoubleSidedConstants("_DoubleSidedConstants", Vector) = (1, 1, -1, 0)
|
|
[HideInInspector]_DistortionEnable("_DistortionEnable",Float) = 0
|
|
[HideInInspector]_DistortionOnly("_DistortionOnly",Float) = 0
|
|
//_TessPhongStrength( "Tess Phong Strength", Range( 0, 1 ) ) = 0.5
|
|
//_TessValue( "Tess Max Tessellation", Range( 1, 32 ) ) = 16
|
|
//_TessMin( "Tess Min Distance", Float ) = 10
|
|
//_TessMax( "Tess Max Distance", Float ) = 25
|
|
//_TessEdgeLength ( "Tess Edge length", Range( 2, 50 ) ) = 16
|
|
//_TessMaxDisp( "Tess Max Displacement", Float ) = 25
|
|
}
|
|
|
|
SubShader
|
|
{
|
|
/*ase_subshader_options:Name=Additional Options
|
|
Port:Forward Unlit:Vertex Offset
|
|
On:SetDefine:HAVE_MESH_MODIFICATION 1
|
|
Option:Surface Type:Opaque,Transparent:Opaque
|
|
Opaque:SetShaderProperty:_SurfaceType,0
|
|
Opaque:SetPropertyOnSubShader:RenderQueue,Geometry
|
|
Opaque:ShowOption: Rendering Pass
|
|
Opaque:HideOption: Rendering Pass
|
|
Opaque:HideOption: Blending Mode
|
|
Opaque:HideOption: Receive Fog
|
|
Opaque:HideOption: Distortion
|
|
Opaque:HideOption: Depth Write
|
|
Opaque:HideOption: Cull Mode
|
|
Opaque:HideOption: Depth Test
|
|
Transparent:SetShaderProperty:_SurfaceType,1
|
|
Transparent:SetPropertyOnSubShader:RenderQueue,Transparent
|
|
Transparent:HideOption: Rendering Pass
|
|
Transparent:ShowOption: Rendering Pass
|
|
Transparent:ShowOption: Blending Mode
|
|
Transparent:ShowOption: Receive Fog
|
|
Transparent:ShowOption: Distortion
|
|
Transparent:ShowOption: Depth Write
|
|
Transparent:ShowOption: Cull Mode
|
|
Transparent:ShowOption: Depth Test
|
|
Option: Rendering Pass :Default,After Post-Process:Default
|
|
Default:SetPropertyOnSubShader:RenderQueue,Geometry,+0
|
|
Default:SetShaderProperty:_RenderQueueType,1
|
|
After Post-Process:SetPropertyOnSubShader:RenderQueue,AlphaTest,+51
|
|
After Post-Process:SetShaderProperty:_RenderQueueType,2
|
|
Option: Rendering Pass:Before Refraction,Default,Low Resolution,After Post-Process:Default
|
|
Before Refraction:SetPropertyOnSubShader:RenderQueue,Transparent,-250
|
|
Before Refraction:SetShaderProperty:_RenderQueueType,4
|
|
Default:SetPropertyOnSubShader:RenderQueue,Transparent,+0
|
|
Default:SetShaderProperty:_RenderQueueType,5
|
|
Low Resolution:SetPropertyOnSubShader:RenderQueue,Transparent,+400
|
|
Low Resolution:SetShaderProperty:_RenderQueueType,6
|
|
After Post-Process:SetPropertyOnSubShader:RenderQueue,Transparent,+700
|
|
After Post-Process:SetShaderProperty:_RenderQueueType,7
|
|
Option: Blending Mode:Alpha,Premultiply,Additive:Alpha
|
|
Alpha:SetShaderProperty:_BlendMode,0
|
|
Additive:SetShaderProperty:_BlendMode,1
|
|
Premultiply:SetShaderProperty:_BlendMode,4
|
|
Option: Receive Fog:false,true:true
|
|
true:SetShaderProperty:_EnableFogOnTransparent,1
|
|
false,disable:SetShaderProperty:_EnableFogOnTransparent,0
|
|
Option: Distortion:false,true:false
|
|
true:ExcludeAllPassesBut:DistortionVectors
|
|
true:IncludePass:DistortionVectors
|
|
true:SetShaderProperty:_DistortionEnable,1
|
|
true:ShowOption: Distortion Mode
|
|
true:ShowOption: Distortion Only
|
|
true:ShowPort:Forward Unlit:Distortion
|
|
true:ShowPort:Forward Unlit:Distortion Blur
|
|
false,disable:ExcludePass:DistortionVectors
|
|
false:SetShaderProperty:_DistortionEnable,0
|
|
false,disable:HideOption: Distortion Mode
|
|
false,disable:HideOption: Distortion Only
|
|
false,disable:HidePort:Forward Unlit:Distortion
|
|
false,disable:HidePort:Forward Unlit:Distortion Blur
|
|
Option: Distortion Mode:Add,Multiply,Replace:Add
|
|
Add:SetPropertyOnPass:DistortionVectors:BlendRGB,One,One
|
|
Add:SetPropertyOnPass:DistortionVectors:BlendAlpha,One,One
|
|
Multiply:SetPropertyOnPass:DistortionVectors:BlendRGB,DstColor,Zero
|
|
Multiply:SetPropertyOnPass:DistortionVectors:BlendAlpha,DstAlpha,Zero
|
|
Replace:SetPropertyOnPass:DistortionVectors:BlendRGB,One,Zero
|
|
Replace:SetPropertyOnPass:DistortionVectors:BlendAlpha,One,Zero
|
|
Option: Distortion Only:false,true:true
|
|
true:SetPropertyOnPass:DistortionVectors:ZTest,LEqual
|
|
true:SetShaderProperty:_DistortionOnly,1
|
|
false:SetPropertyOnPass:DistortionVectors:ZTest,Always
|
|
false:SetShaderProperty:_DistortionOnly,0
|
|
Option: Depth Write:false,true:true
|
|
true:SetShaderProperty:_ZWrite,1
|
|
false:SetShaderProperty:_ZWrite,0
|
|
Option: Cull Mode:Back,Front:Back
|
|
Back:SetShaderProperty:_TransparentCullMode,2
|
|
Front:SetShaderProperty:_TransparentCullMode,1
|
|
Option: Depth Test:Disabled,Never,Less,Equal,Less Equal,Greater,Not Equal,Greater Equal,Always:Less Equal
|
|
Never:SetShaderProperty:_ZTestTransparent,1
|
|
Less:SetShaderProperty:_ZTestTransparent,2
|
|
Equal:SetShaderProperty:_ZTestTransparent,3
|
|
Less Equal:SetShaderProperty:_ZTestTransparent,4
|
|
Greater:SetShaderProperty:_ZTestTransparent,5
|
|
Not Equal:SetShaderProperty:_ZTestTransparent,6
|
|
Greater Equal:SetShaderProperty:_ZTestTransparent,7
|
|
Always:SetShaderProperty:_ZTestTransparent,8
|
|
Option:Double-Sided:true,false:false
|
|
false:SetShaderProperty:_DoubleSidedEnable,0
|
|
true:SetShaderProperty:_DoubleSidedEnable,1
|
|
Option:Alpha Clipping:false,true:false
|
|
true:SetShaderProperty:_AlphaCutoffEnable,1
|
|
true:ShowPort:Forward Unlit:Alpha Clip Threshold
|
|
false:HidePort:Forward Unlit:Alpha Clip Threshold
|
|
Option:Motion Vectors:false,true:true
|
|
true:SetShaderProperty:_AddPrecomputedVelocity,[HideInInspector][ToggleUI]_AddPrecomputedVelocity("Add Precomputed Velocity", Float) = 1
|
|
false:SetShaderProperty:_AddPrecomputedVelocity,//[HideInInspector][ToggleUI]_AddPrecomputedVelocity("Add Precomputed Velocity", Float) = 1
|
|
true:ShowOption: Add Precomputed Velocity
|
|
false:HideOption: Add Precomputed Velocity
|
|
true:IncludePass:Motion Vectors
|
|
false:ExcludePass:Motion Vectors
|
|
Option: Add Precomputed Velocity:false,true:false
|
|
false,disable:RemoveDefine:_ADD_PRECOMPUTED_VELOCITY 1
|
|
true:SetDefine:_ADD_PRECOMPUTED_VELOCITY 1
|
|
true:SetShaderProperty:_AddPrecomputedVelocity,1
|
|
Option:Shadow Matte:false,true:false
|
|
false,disable:SetShaderProperty:_ShadowMatteFilter,//[HideInInspector]_ShadowMatteFilter("Shadow Matte Filter", Float) = 2
|
|
false,disable:HidePort:Forward Unlit:Shadow Tint
|
|
false,disable:RemoveDefine:_ENABLE_SHADOW_MATTE 1
|
|
false,disable:RemoveDefine:Forward Unlit:pragma multi_compile_fragment SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH SHADOW_VERY_HIGH
|
|
false,disable:RemoveDefine:Forward Unlit:pragma multi_compile_fragment SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON
|
|
false,disable:RemoveDefine:MotionVectors:WRITE_NORMAL_BUFFER
|
|
false,disable:RemoveDefine:DepthForwardOnly:WRITE_NORMAL_BUFFER
|
|
true:SetDefine:_ENABLE_SHADOW_MATTE 1
|
|
true:ShowPort:Forward Unlit:Shadow Tint
|
|
true:SetDefine:Forward Unlit:pragma multi_compile_fragment SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH SHADOW_VERY_HIGH
|
|
true:SetDefine:Forward Unlit:pragma multi_compile_fragment SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON
|
|
true:SetDefine:MotionVectors:WRITE_NORMAL_BUFFER
|
|
true:SetDefine:DepthForwardOnly:WRITE_NORMAL_BUFFER
|
|
Option:Cast Shadows:false,true:true
|
|
true:IncludePass:ShadowCaster
|
|
false,disable:ExcludePass:ShadowCaster
|
|
Option:DOTS Instancing:false,true:false
|
|
true:SetDefine:pragma multi_compile _ DOTS_INSTANCING_ON
|
|
false:RemoveDefine:pragma multi_compile _ DOTS_INSTANCING_ON
|
|
Option:GPU Instancing:false,true:true
|
|
true:SetDefine:pragma multi_compile_instancing
|
|
false:RemoveDefine:pragma multi_compile_instancing
|
|
Option:Tessellation:false,true:false
|
|
true:SetDefine:TESSELLATION_ON 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:TESSELLATION_ON 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
|
|
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:Vertex Position,InvertActionOnDeselection:Absolute,Relative:Relative
|
|
Absolute:SetDefine:ASE_ABSOLUTE_VERTEX_POS 1
|
|
Absolute:SetPortName:Forward Unlit:6,Vertex Position
|
|
Relative:SetPortName:Forward Unlit:6,Vertex Offset
|
|
Option:LOD CrossFade:false,true:false
|
|
true:SetDefine:pragma multi_compile _ LOD_FADE_CROSSFADE
|
|
false:RemoveDefine:pragma multi_compile _ LOD_FADE_CROSSFADE
|
|
*/
|
|
|
|
Tags
|
|
{
|
|
"RenderPipeline"="HDRenderPipeline"
|
|
"RenderType"="Opaque"
|
|
"Queue"="Geometry+0"
|
|
}
|
|
|
|
HLSLINCLUDE
|
|
#pragma target 4.5
|
|
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
|
|
#pragma instancing_options renderinglayer
|
|
|
|
#ifndef ASE_TESS_FUNCS
|
|
#define ASE_TESS_FUNCS
|
|
float4 FixedTess( float tessValue )
|
|
{
|
|
return tessValue;
|
|
}
|
|
|
|
float CalcDistanceTessFactor (float4 vertex, float minDist, float maxDist, float tess, float4x4 o2w, float3 cameraPos )
|
|
{
|
|
float3 wpos = mul(o2w,vertex).xyz;
|
|
float dist = distance (wpos, cameraPos);
|
|
float f = clamp(1.0 - (dist - minDist) / (maxDist - minDist), 0.01, 1.0) * tess;
|
|
return f;
|
|
}
|
|
|
|
float4 CalcTriEdgeTessFactors (float3 triVertexFactors)
|
|
{
|
|
float4 tess;
|
|
tess.x = 0.5 * (triVertexFactors.y + triVertexFactors.z);
|
|
tess.y = 0.5 * (triVertexFactors.x + triVertexFactors.z);
|
|
tess.z = 0.5 * (triVertexFactors.x + triVertexFactors.y);
|
|
tess.w = (triVertexFactors.x + triVertexFactors.y + triVertexFactors.z) / 3.0f;
|
|
return tess;
|
|
}
|
|
|
|
float CalcEdgeTessFactor (float3 wpos0, float3 wpos1, float edgeLen, float3 cameraPos, float4 scParams )
|
|
{
|
|
float dist = distance (0.5 * (wpos0+wpos1), cameraPos);
|
|
float len = distance(wpos0, wpos1);
|
|
float f = max(len * scParams.y / (edgeLen * dist), 1.0);
|
|
return f;
|
|
}
|
|
|
|
float DistanceFromPlaneASE (float3 pos, float4 plane)
|
|
{
|
|
return dot (float4(pos,1.0f), plane);
|
|
}
|
|
|
|
bool WorldViewFrustumCull (float3 wpos0, float3 wpos1, float3 wpos2, float cullEps, float4 planes[6] )
|
|
{
|
|
float4 planeTest;
|
|
planeTest.x = (( DistanceFromPlaneASE(wpos0, planes[0]) > -cullEps) ? 1.0f : 0.0f ) +
|
|
(( DistanceFromPlaneASE(wpos1, planes[0]) > -cullEps) ? 1.0f : 0.0f ) +
|
|
(( DistanceFromPlaneASE(wpos2, planes[0]) > -cullEps) ? 1.0f : 0.0f );
|
|
planeTest.y = (( DistanceFromPlaneASE(wpos0, planes[1]) > -cullEps) ? 1.0f : 0.0f ) +
|
|
(( DistanceFromPlaneASE(wpos1, planes[1]) > -cullEps) ? 1.0f : 0.0f ) +
|
|
(( DistanceFromPlaneASE(wpos2, planes[1]) > -cullEps) ? 1.0f : 0.0f );
|
|
planeTest.z = (( DistanceFromPlaneASE(wpos0, planes[2]) > -cullEps) ? 1.0f : 0.0f ) +
|
|
(( DistanceFromPlaneASE(wpos1, planes[2]) > -cullEps) ? 1.0f : 0.0f ) +
|
|
(( DistanceFromPlaneASE(wpos2, planes[2]) > -cullEps) ? 1.0f : 0.0f );
|
|
planeTest.w = (( DistanceFromPlaneASE(wpos0, planes[3]) > -cullEps) ? 1.0f : 0.0f ) +
|
|
(( DistanceFromPlaneASE(wpos1, planes[3]) > -cullEps) ? 1.0f : 0.0f ) +
|
|
(( DistanceFromPlaneASE(wpos2, planes[3]) > -cullEps) ? 1.0f : 0.0f );
|
|
return !all (planeTest);
|
|
}
|
|
|
|
float4 DistanceBasedTess( float4 v0, float4 v1, float4 v2, float tess, float minDist, float maxDist, float4x4 o2w, float3 cameraPos )
|
|
{
|
|
float3 f;
|
|
f.x = CalcDistanceTessFactor (v0,minDist,maxDist,tess,o2w,cameraPos);
|
|
f.y = CalcDistanceTessFactor (v1,minDist,maxDist,tess,o2w,cameraPos);
|
|
f.z = CalcDistanceTessFactor (v2,minDist,maxDist,tess,o2w,cameraPos);
|
|
|
|
return CalcTriEdgeTessFactors (f);
|
|
}
|
|
|
|
float4 EdgeLengthBasedTess( float4 v0, float4 v1, float4 v2, float edgeLength, float4x4 o2w, float3 cameraPos, float4 scParams )
|
|
{
|
|
float3 pos0 = mul(o2w,v0).xyz;
|
|
float3 pos1 = mul(o2w,v1).xyz;
|
|
float3 pos2 = mul(o2w,v2).xyz;
|
|
float4 tess;
|
|
tess.x = CalcEdgeTessFactor (pos1, pos2, edgeLength, cameraPos, scParams);
|
|
tess.y = CalcEdgeTessFactor (pos2, pos0, edgeLength, cameraPos, scParams);
|
|
tess.z = CalcEdgeTessFactor (pos0, pos1, edgeLength, cameraPos, scParams);
|
|
tess.w = (tess.x + tess.y + tess.z) / 3.0f;
|
|
return tess;
|
|
}
|
|
|
|
float4 EdgeLengthBasedTessCull( float4 v0, float4 v1, float4 v2, float edgeLength, float maxDisplacement, float4x4 o2w, float3 cameraPos, float4 scParams, float4 planes[6] )
|
|
{
|
|
float3 pos0 = mul(o2w,v0).xyz;
|
|
float3 pos1 = mul(o2w,v1).xyz;
|
|
float3 pos2 = mul(o2w,v2).xyz;
|
|
float4 tess;
|
|
|
|
if (WorldViewFrustumCull(pos0, pos1, pos2, maxDisplacement, planes))
|
|
{
|
|
tess = 0.0f;
|
|
}
|
|
else
|
|
{
|
|
tess.x = CalcEdgeTessFactor (pos1, pos2, edgeLength, cameraPos, scParams);
|
|
tess.y = CalcEdgeTessFactor (pos2, pos0, edgeLength, cameraPos, scParams);
|
|
tess.z = CalcEdgeTessFactor (pos0, pos1, edgeLength, cameraPos, scParams);
|
|
tess.w = (tess.x + tess.y + tess.z) / 3.0f;
|
|
}
|
|
return tess;
|
|
}
|
|
#endif //ASE_TESS_FUNCS
|
|
|
|
ENDHLSL
|
|
|
|
/*ase_pass*/
|
|
Pass
|
|
{
|
|
/*ase_main_pass*/
|
|
Name "Forward Unlit"
|
|
Tags { "LightMode" = "ForwardOnly" }
|
|
|
|
Blend [_SrcBlend] [_DstBlend], [_AlphaSrcBlend] [_AlphaDstBlend]
|
|
Cull [_CullModeForward]
|
|
ZTest [_ZTestDepthEqualForOpaque]
|
|
ZWrite [_ZWrite]
|
|
ColorMask [_ColorMaskTransparentVel] 1
|
|
|
|
Stencil
|
|
{
|
|
WriteMask [_StencilWriteMask]
|
|
Ref [_StencilRef]
|
|
Comp Always
|
|
Pass Replace
|
|
}
|
|
HLSLPROGRAM
|
|
#define SHADERPASS SHADERPASS_FORWARD_UNLIT
|
|
|
|
#pragma shader_feature _SURFACE_TYPE_TRANSPARENT
|
|
#pragma shader_feature_local _BLENDMODE_OFF _BLENDMODE_ALPHA _BLENDMODE_ADD _BLENDMODE_PRE_MULTIPLY
|
|
#pragma shader_feature_local _ALPHATEST_ON
|
|
#pragma shader_feature_local _ENABLE_FOG_ON_TRANSPARENT
|
|
#pragma shader_feature_local _ _ADD_PRECOMPUTED_VELOCITY
|
|
#pragma shader_feature_local _ _TRANSPARENT_WRITES_MOTION_VEC
|
|
#pragma multi_compile _ DEBUG_DISPLAY
|
|
|
|
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/GeometricTools.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Tessellation.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphHeader.hlsl"
|
|
|
|
#if defined(_ENABLE_SHADOW_MATTE) && SHADERPASS == SHADERPASS_FORWARD_UNLIT
|
|
#define LIGHTLOOP_DISABLE_TILE_AND_CLUSTER
|
|
#define HAS_LIGHTLOOP
|
|
#define SHADOW_OPTIMIZE_REGISTER_USAGE 1
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonLighting.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowContext.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/HDShadow.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/PunctualLightCommon.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/HDShadowLoop.hlsl"
|
|
#endif
|
|
|
|
#if defined(_TRANSPARENT_WRITES_MOTION_VEC) && defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define _WRITE_TRANSPARENT_MOTION_VECTOR
|
|
#endif
|
|
|
|
/*ase_pragma*/
|
|
|
|
struct VertexInput
|
|
{
|
|
float3 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
/*ase_vdata:p=p;n=n*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct VertexOutput
|
|
{
|
|
float4 positionCS : SV_Position;
|
|
float3 positionRWS : TEXCOORD0;
|
|
/*ase_interp(1,):sp=sp.xyzw;rwp=tc0*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
|
|
|
|
CBUFFER_START( UnityPerMaterial )
|
|
float4 _EmissionColor;
|
|
float _RenderQueueType;
|
|
#ifdef _ADD_PRECOMPUTED_VELOCITY
|
|
float _AddPrecomputedVelocity;
|
|
#endif
|
|
#ifdef _ENABLE_SHADOW_MATTE
|
|
float _ShadowMatteFilter;
|
|
#endif
|
|
float _StencilRef;
|
|
float _StencilWriteMask;
|
|
float _StencilRefDepth;
|
|
float _StencilWriteMaskDepth;
|
|
float _StencilRefMV;
|
|
float _StencilWriteMaskMV;
|
|
float _StencilRefDistortionVec;
|
|
float _StencilWriteMaskDistortionVec;
|
|
float _StencilWriteMaskGBuffer;
|
|
float _StencilRefGBuffer;
|
|
float _ZTestGBuffer;
|
|
float _RequireSplitLighting;
|
|
float _ReceivesSSR;
|
|
float _SurfaceType;
|
|
float _BlendMode;
|
|
float _SrcBlend;
|
|
float _DstBlend;
|
|
float _AlphaSrcBlend;
|
|
float _AlphaDstBlend;
|
|
float _ZWrite;
|
|
float _TransparentZWrite;
|
|
float _CullMode;
|
|
float _TransparentSortPriority;
|
|
float _EnableFogOnTransparent;
|
|
float _CullModeForward;
|
|
float _TransparentCullMode;
|
|
float _ZTestDepthEqualForOpaque;
|
|
float _ZTestTransparent;
|
|
float _TransparentBackfaceEnable;
|
|
float _AlphaCutoffEnable;
|
|
float _AlphaCutoff;
|
|
float _UseShadowThreshold;
|
|
float _DoubleSidedEnable;
|
|
float _DoubleSidedNormalMode;
|
|
float4 _DoubleSidedConstants;
|
|
float _EnableBlendModePreserveSpecularLighting;
|
|
#ifdef TESSELLATION_ON
|
|
float _TessPhongStrength;
|
|
float _TessValue;
|
|
float _TessMin;
|
|
float _TessMax;
|
|
float _TessEdgeLength;
|
|
float _TessMaxDisp;
|
|
#endif
|
|
CBUFFER_END
|
|
/*ase_globals*/
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/Unlit.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
|
|
/*ase_funcs*/
|
|
|
|
struct SurfaceDescription
|
|
{
|
|
float3 Color;
|
|
float3 Emission;
|
|
float4 ShadowTint;
|
|
float Alpha;
|
|
float AlphaClipThreshold;
|
|
float4 VTPackedFeedback;
|
|
};
|
|
|
|
void BuildSurfaceData(FragInputs fragInputs, SurfaceDescription surfaceDescription, float3 V, out SurfaceData surfaceData)
|
|
{
|
|
ZERO_INITIALIZE(SurfaceData, surfaceData);
|
|
surfaceData.color = surfaceDescription.Color;
|
|
}
|
|
|
|
void GetSurfaceAndBuiltinData(SurfaceDescription surfaceDescription , FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
|
|
{
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
LODDitheringTransition(ComputeFadeMaskSeed(V, posInput.positionSS), unity_LODFade.x);
|
|
#endif
|
|
|
|
#if _ALPHATEST_ON
|
|
DoAlphaTest ( surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold );
|
|
#endif
|
|
|
|
#if _DEPTHOFFSET_ON
|
|
ApplyDepthOffsetPositionInput(V, surfaceDescription.DepthOffset, GetViewForwardDir(), GetWorldToHClipMatrix(), posInput);
|
|
#endif
|
|
|
|
BuildSurfaceData(fragInputs, surfaceDescription, V, surfaceData);
|
|
|
|
#ifdef WRITE_NORMAL_BUFFER
|
|
surfaceData.normalWS = fragInputs.tangentToWorld[2];
|
|
#endif
|
|
|
|
#if defined(_ENABLE_SHADOW_MATTE) && SHADERPASS == SHADERPASS_FORWARD_UNLIT
|
|
HDShadowContext shadowContext = InitShadowContext();
|
|
float shadow;
|
|
float3 shadow3;
|
|
posInput = GetPositionInput(fragInputs.positionSS.xy, _ScreenSize.zw, fragInputs.positionSS.z, UNITY_MATRIX_I_VP, UNITY_MATRIX_V);
|
|
float3 normalWS = normalize(fragInputs.tangentToWorld[1]);
|
|
uint renderingLayers = _EnableLightLayers ? asuint(unity_RenderingLayer.x) : DEFAULT_LIGHT_LAYERS;
|
|
ShadowLoopMin(shadowContext, posInput, normalWS, asuint(_ShadowMatteFilter), renderingLayers, shadow3);
|
|
shadow = dot(shadow3, float3(1.0f/3.0f, 1.0f/3.0f, 1.0f/3.0f));
|
|
|
|
float4 shadowColor = (1 - shadow)*surfaceDescription.ShadowTint.rgba;
|
|
float localAlpha = saturate(shadowColor.a + surfaceDescription.Alpha);
|
|
|
|
#ifdef _SURFACE_TYPE_TRANSPARENT
|
|
surfaceData.color = lerp(shadowColor.rgb*surfaceData.color, lerp(lerp(shadowColor.rgb, surfaceData.color, 1 - surfaceDescription.ShadowTint.a), surfaceData.color, shadow), surfaceDescription.Alpha);
|
|
#else
|
|
surfaceData.color = lerp(lerp(shadowColor.rgb, surfaceData.color, 1 - surfaceDescription.ShadowTint.a), surfaceData.color, shadow);
|
|
#endif
|
|
localAlpha = ApplyBlendMode(surfaceData.color, localAlpha).a;
|
|
surfaceDescription.Alpha = localAlpha;
|
|
#endif
|
|
|
|
ZERO_INITIALIZE(BuiltinData, builtinData);
|
|
builtinData.opacity = surfaceDescription.Alpha;
|
|
|
|
#if defined(DEBUG_DISPLAY)
|
|
builtinData.renderingLayers = GetMeshRenderingLightLayer();
|
|
#endif
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
builtinData.alphaClipTreshold = surfaceDescription.AlphaClipThreshold;
|
|
#endif
|
|
|
|
builtinData.emissiveColor = surfaceDescription.Emission;
|
|
|
|
#ifdef UNITY_VIRTUAL_TEXTURING
|
|
builtinData.vtPackedFeedback = surfaceDescription.VTPackedFeedback;
|
|
#endif
|
|
|
|
#if _DEPTHOFFSET_ON
|
|
builtinData.depthOffset = surfaceDescription.DepthOffset;
|
|
#endif
|
|
|
|
ApplyDebugToBuiltinData(builtinData);
|
|
}
|
|
|
|
float GetDeExposureMultiplier()
|
|
{
|
|
#if defined(DISABLE_UNLIT_DEEXPOSURE)
|
|
return 1.0;
|
|
#else
|
|
return _DeExposureMultiplier;
|
|
#endif
|
|
}
|
|
|
|
VertexOutput VertexFunction( VertexInput inputMesh /*ase_vert_input*/ )
|
|
{
|
|
VertexOutput o;
|
|
UNITY_SETUP_INSTANCE_ID(inputMesh);
|
|
UNITY_TRANSFER_INSTANCE_ID(inputMesh, o);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o );
|
|
|
|
/*ase_vert_code:inputMesh=VertexInput;o=VertexOutput*/
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = inputMesh.positionOS.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3( 0, 0, 0 );
|
|
#endif
|
|
float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;6;-1;_VertexOffset*/defaultVertexValue/*end*/;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
inputMesh.positionOS.xyz = vertexValue;
|
|
#else
|
|
inputMesh.positionOS.xyz += vertexValue;
|
|
#endif
|
|
|
|
inputMesh.normalOS = /*ase_vert_out:Vertex Normal;Float3;7;-1;_VertexNormal*/inputMesh.normalOS/*end*/;
|
|
|
|
float3 positionRWS = TransformObjectToWorld(inputMesh.positionOS);
|
|
o.positionCS = TransformWorldToHClip(positionRWS);
|
|
o.positionRWS = positionRWS;
|
|
return o;
|
|
}
|
|
|
|
#if defined(TESSELLATION_ON)
|
|
struct VertexControl
|
|
{
|
|
float3 positionOS : INTERNALTESSPOS;
|
|
float3 normalOS : NORMAL;
|
|
/*ase_vcontrol*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct TessellationFactors
|
|
{
|
|
float edge[3] : SV_TessFactor;
|
|
float inside : SV_InsideTessFactor;
|
|
};
|
|
|
|
VertexControl Vert ( VertexInput v )
|
|
{
|
|
VertexControl o;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
o.positionOS = v.positionOS;
|
|
o.normalOS = v.normalOS;
|
|
/*ase_control_code:v=VertexInput;o=VertexControl*/
|
|
return o;
|
|
}
|
|
|
|
TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
|
|
{
|
|
TessellationFactors o;
|
|
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 (SHADEROPTIONS_CAMERA_RELATIVE_RENDERING != 0)
|
|
float3 cameraPos = 0;
|
|
#else
|
|
float3 cameraPos = _WorldSpaceCameraPos;
|
|
#endif
|
|
#if defined(ASE_FIXED_TESSELLATION)
|
|
tf = FixedTess( tessValue );
|
|
#elif defined(ASE_DISTANCE_TESSELLATION)
|
|
tf = DistanceBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), cameraPos );
|
|
#elif defined(ASE_LENGTH_TESSELLATION)
|
|
tf = EdgeLengthBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, GetObjectToWorldMatrix(), cameraPos, _ScreenParams );
|
|
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
|
tf = EdgeLengthBasedTessCull(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), cameraPos, _ScreenParams, _FrustumPlanes );
|
|
#endif
|
|
o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
|
|
return o;
|
|
}
|
|
|
|
[domain("tri")]
|
|
[partitioning("fractional_odd")]
|
|
[outputtopology("triangle_cw")]
|
|
[patchconstantfunc("TessellationFunction")]
|
|
[outputcontrolpoints(3)]
|
|
VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
|
|
{
|
|
return patch[id];
|
|
}
|
|
|
|
[domain("tri")]
|
|
VertexOutput DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
|
{
|
|
VertexInput o = (VertexInput) 0;
|
|
o.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
|
|
o.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
|
|
/*ase_domain_code:patch=VertexControl;o=VertexInput;bary=SV_DomainLocation*/
|
|
#if defined(ASE_PHONG_TESSELLATION)
|
|
float3 pp[3];
|
|
for (int i = 0; i < 3; ++i)
|
|
pp[i] = o.positionOS.xyz - patch[i].normalOS * (dot(o.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
|
|
float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/;
|
|
o.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.positionOS.xyz;
|
|
#endif
|
|
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
|
return VertexFunction(o);
|
|
}
|
|
#else
|
|
VertexOutput Vert ( VertexInput v )
|
|
{
|
|
return VertexFunction( v );
|
|
}
|
|
#endif
|
|
|
|
#ifdef UNITY_VIRTUAL_TEXTURING
|
|
#define VT_BUFFER_TARGET SV_Target1
|
|
#define EXTRA_BUFFER_TARGET SV_Target2
|
|
#else
|
|
#define EXTRA_BUFFER_TARGET SV_Target1
|
|
#endif
|
|
|
|
void Frag( VertexOutput packedInput,
|
|
out float4 outColor : SV_Target0
|
|
#ifdef UNITY_VIRTUAL_TEXTURING
|
|
,out float4 outVTFeedback : VT_BUFFER_TARGET
|
|
#endif
|
|
#ifdef _DEPTHOFFSET_ON
|
|
, out float outputDepth : DEPTH_OFFSET_SEMANTIC
|
|
#endif
|
|
/*ase_frag_input*/
|
|
)
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID( packedInput );
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( packedInput );
|
|
FragInputs input;
|
|
ZERO_INITIALIZE(FragInputs, input);
|
|
input.tangentToWorld = k_identity3x3;
|
|
/*ase_local_var:rwp*/float3 positionRWS = packedInput.positionRWS;
|
|
|
|
input.positionSS = packedInput.positionCS;
|
|
input.positionRWS = positionRWS;
|
|
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS);
|
|
|
|
/*ase_local_var:wvd*/float3 V = GetWorldSpaceNormalizeViewDir( input.positionRWS );
|
|
|
|
SurfaceDescription surfaceDescription = (SurfaceDescription)0;
|
|
/*ase_frag_code:packedInput=VertexOutput*/
|
|
surfaceDescription.Color = /*ase_frag_out:Color;Float3;0;-1;_Color*/float3( 0.5, 0.5, 0.5 )/*end*/;
|
|
surfaceDescription.Emission = /*ase_frag_out:Emission;Float3;1;-1;_Emission*/0/*end*/;
|
|
surfaceDescription.Alpha = /*ase_frag_out:Alpha;Float;2;-1;_Alpha*/1/*end*/;
|
|
surfaceDescription.AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;3;-1;_AlphaClip*/_AlphaCutoff/*end*/;
|
|
surfaceDescription.ShadowTint = /*ase_frag_out:Shadow Tint;Float4;8;-1;_ShadowTint*/float4( 0, 0 ,0 ,1 )/*end*/;
|
|
float2 Distortion = /*ase_frag_out:Distortion;Float2;4;-1;_Distortion*/float2 ( 0, 0 )/*end*/;
|
|
float DistortionBlur = /*ase_frag_out:Distortion Blur;Float;5;-1;_DistortionBlur*/0/*end*/;
|
|
|
|
surfaceDescription.VTPackedFeedback = float4(1.0f,1.0f,1.0f,1.0f);
|
|
SurfaceData surfaceData;
|
|
BuiltinData builtinData;
|
|
GetSurfaceAndBuiltinData(surfaceDescription, input, V, posInput, surfaceData, builtinData);
|
|
|
|
BSDFData bsdfData = ConvertSurfaceDataToBSDFData( input.positionSS.xy, surfaceData );
|
|
|
|
#if defined(_ENABLE_SHADOW_MATTE)
|
|
bsdfData.color *= GetScreenSpaceAmbientOcclusion(input.positionSS.xy);
|
|
#endif
|
|
|
|
|
|
#ifdef DEBUG_DISPLAY
|
|
if (_DebugLightingMode >= DEBUGLIGHTINGMODE_DIFFUSE_LIGHTING && _DebugLightingMode <= DEBUGLIGHTINGMODE_EMISSIVE_LIGHTING)
|
|
{
|
|
if (_DebugLightingMode != DEBUGLIGHTINGMODE_EMISSIVE_LIGHTING)
|
|
{
|
|
builtinData.emissiveColor = 0.0;
|
|
}
|
|
else
|
|
{
|
|
bsdfData.color = 0.0;
|
|
}
|
|
}
|
|
#endif
|
|
|
|
float4 outResult = ApplyBlendMode(bsdfData.color * GetDeExposureMultiplier() + builtinData.emissiveColor * GetCurrentExposureMultiplier(), builtinData.opacity);
|
|
outResult = EvaluateAtmosphericScattering(posInput, V, outResult);
|
|
|
|
#ifdef DEBUG_DISPLAY
|
|
int bufferSize = int(_DebugViewMaterialArray[0].x);
|
|
for (int index = 1; index <= bufferSize; index++)
|
|
{
|
|
int indexMaterialProperty = int(_DebugViewMaterialArray[index].x);
|
|
if (indexMaterialProperty != 0)
|
|
{
|
|
float3 result = float3(1.0, 0.0, 1.0);
|
|
bool needLinearToSRGB = false;
|
|
|
|
GetPropertiesDataDebug(indexMaterialProperty, result, needLinearToSRGB);
|
|
GetVaryingsDataDebug(indexMaterialProperty, input, result, needLinearToSRGB);
|
|
GetBuiltinDataDebug(indexMaterialProperty, builtinData, posInput, result, needLinearToSRGB);
|
|
GetSurfaceDataDebug(indexMaterialProperty, surfaceData, result, needLinearToSRGB);
|
|
GetBSDFDataDebug(indexMaterialProperty, bsdfData, result, needLinearToSRGB);
|
|
|
|
if (!needLinearToSRGB)
|
|
result = SRGBToLinear(max(0, result));
|
|
|
|
outResult = float4(result, 1.0);
|
|
}
|
|
}
|
|
|
|
if (_DebugFullScreenMode == FULLSCREENDEBUGMODE_TRANSPARENCY_OVERDRAW)
|
|
{
|
|
float4 result = _DebugTransparencyOverdrawWeight * float4(TRANSPARENCY_OVERDRAW_COST, TRANSPARENCY_OVERDRAW_COST, TRANSPARENCY_OVERDRAW_COST, TRANSPARENCY_OVERDRAW_A);
|
|
outResult = result;
|
|
}
|
|
#endif
|
|
|
|
outColor = outResult;
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
outputDepth = posInput.deviceDepth;
|
|
#endif
|
|
|
|
#ifdef UNITY_VIRTUAL_TEXTURING
|
|
outVTFeedback = builtinData.vtPackedFeedback;
|
|
#endif
|
|
}
|
|
|
|
ENDHLSL
|
|
}
|
|
|
|
/*ase_pass*/
|
|
Pass
|
|
{
|
|
/*ase_hide_pass*/
|
|
Name "ShadowCaster"
|
|
Tags { "LightMode" = "ShadowCaster" }
|
|
|
|
Cull [_CullMode]
|
|
ZWrite On
|
|
ZClip [_ZClip]
|
|
ColorMask 0
|
|
|
|
HLSLPROGRAM
|
|
#define SHADERPASS SHADERPASS_SHADOWS
|
|
|
|
|
|
#pragma shader_feature _SURFACE_TYPE_TRANSPARENT
|
|
#pragma shader_feature_local _BLENDMODE_OFF _BLENDMODE_ALPHA _BLENDMODE_ADD _BLENDMODE_PRE_MULTIPLY
|
|
#pragma shader_feature_local _ALPHATEST_ON
|
|
#pragma shader_feature_local _ _ADD_PRECOMPUTED_VELOCITY
|
|
#pragma shader_feature_local _ _TRANSPARENT_WRITES_MOTION_VEC
|
|
#pragma shader_feature_local _ENABLE_FOG_ON_TRANSPARENT
|
|
|
|
#if defined(_TRANSPARENT_WRITES_MOTION_VEC) && defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define _WRITE_TRANSPARENT_MOTION_VECTOR
|
|
#endif
|
|
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/GeometricTools.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Tessellation.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphHeader.hlsl"
|
|
|
|
/*ase_pragma*/
|
|
|
|
struct VertexInput
|
|
{
|
|
float3 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
/*ase_vdata:p=p;n=n*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct VertexOutput
|
|
{
|
|
float4 positionCS : SV_Position;
|
|
/*ase_interp(0,):sp=sp.xyzw*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
CBUFFER_START( UnityPerMaterial )
|
|
float4 _EmissionColor;
|
|
float _RenderQueueType;
|
|
#ifdef _ADD_PRECOMPUTED_VELOCITY
|
|
float _AddPrecomputedVelocity;
|
|
#endif
|
|
#ifdef _ENABLE_SHADOW_MATTE
|
|
float _ShadowMatteFilter;
|
|
#endif
|
|
float _StencilRef;
|
|
float _StencilWriteMask;
|
|
float _StencilRefDepth;
|
|
float _StencilWriteMaskDepth;
|
|
float _StencilRefMV;
|
|
float _StencilWriteMaskMV;
|
|
float _StencilRefDistortionVec;
|
|
float _StencilWriteMaskDistortionVec;
|
|
float _StencilWriteMaskGBuffer;
|
|
float _StencilRefGBuffer;
|
|
float _ZTestGBuffer;
|
|
float _RequireSplitLighting;
|
|
float _ReceivesSSR;
|
|
float _SurfaceType;
|
|
float _BlendMode;
|
|
float _SrcBlend;
|
|
float _DstBlend;
|
|
float _AlphaSrcBlend;
|
|
float _AlphaDstBlend;
|
|
float _ZWrite;
|
|
float _TransparentZWrite;
|
|
float _CullMode;
|
|
float _TransparentSortPriority;
|
|
float _EnableFogOnTransparent;
|
|
float _CullModeForward;
|
|
float _TransparentCullMode;
|
|
float _ZTestDepthEqualForOpaque;
|
|
float _ZTestTransparent;
|
|
float _TransparentBackfaceEnable;
|
|
float _AlphaCutoffEnable;
|
|
float _AlphaCutoff;
|
|
float _UseShadowThreshold;
|
|
float _DoubleSidedEnable;
|
|
float _DoubleSidedNormalMode;
|
|
float4 _DoubleSidedConstants;
|
|
float _EnableBlendModePreserveSpecularLighting;
|
|
#ifdef TESSELLATION_ON
|
|
float _TessPhongStrength;
|
|
float _TessValue;
|
|
float _TessMin;
|
|
float _TessMax;
|
|
float _TessEdgeLength;
|
|
float _TessMaxDisp;
|
|
#endif
|
|
CBUFFER_END
|
|
/*ase_globals*/
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/Unlit.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
|
|
/*ase_funcs*/
|
|
|
|
struct SurfaceDescription
|
|
{
|
|
float Alpha;
|
|
float AlphaClipThreshold;
|
|
};
|
|
|
|
void BuildSurfaceData(FragInputs fragInputs, SurfaceDescription surfaceDescription, float3 V, out SurfaceData surfaceData)
|
|
{
|
|
ZERO_INITIALIZE(SurfaceData, surfaceData);
|
|
#ifdef WRITE_NORMAL_BUFFER
|
|
surfaceData.normalWS = fragInputs.tangentToWorld[2];
|
|
#endif
|
|
}
|
|
|
|
void GetSurfaceAndBuiltinData(SurfaceDescription surfaceDescription, FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
|
|
{
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
LODDitheringTransition(ComputeFadeMaskSeed(V, posInput.positionSS), unity_LODFade.x);
|
|
#endif
|
|
|
|
#if _ALPHATEST_ON
|
|
DoAlphaTest(surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold);
|
|
#endif
|
|
|
|
#if _DEPTHOFFSET_ON
|
|
ApplyDepthOffsetPositionInput(V, surfaceDescription.DepthOffset, GetViewForwardDir(), GetWorldToHClipMatrix(), posInput);
|
|
#endif
|
|
|
|
BuildSurfaceData(fragInputs, surfaceDescription, V, surfaceData);
|
|
|
|
ZERO_INITIALIZE (BuiltinData, builtinData);
|
|
builtinData.opacity = surfaceDescription.Alpha;
|
|
|
|
#if defined(DEBUG_DISPLAY)
|
|
builtinData.renderingLayers = GetMeshRenderingLightLayer();
|
|
#endif
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
builtinData.alphaClipTreshold = surfaceDescription.AlphaClipThreshold;
|
|
#endif
|
|
|
|
#if _DEPTHOFFSET_ON
|
|
builtinData.depthOffset = surfaceDescription.DepthOffset;
|
|
#endif
|
|
|
|
ApplyDebugToBuiltinData(builtinData);
|
|
}
|
|
|
|
VertexOutput VertexFunction( VertexInput inputMesh /*ase_vert_input*/ )
|
|
{
|
|
VertexOutput o;
|
|
UNITY_SETUP_INSTANCE_ID(inputMesh);
|
|
UNITY_TRANSFER_INSTANCE_ID(inputMesh, o);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o );
|
|
|
|
/*ase_vert_code:inputMesh=VertexInput;o=VertexOutput*/
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = inputMesh.positionOS.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3( 0, 0, 0 );
|
|
#endif
|
|
float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;2;-1;_VertexOffset*/ defaultVertexValue /*end*/;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
inputMesh.positionOS.xyz = vertexValue;
|
|
#else
|
|
inputMesh.positionOS.xyz += vertexValue;
|
|
#endif
|
|
|
|
inputMesh.normalOS = /*ase_vert_out:Vertex Normal;Float3;3;-1;_VertexNormal*/ inputMesh.normalOS /*end*/;
|
|
|
|
float3 positionRWS = TransformObjectToWorld(inputMesh.positionOS);
|
|
o.positionCS = TransformWorldToHClip(positionRWS);
|
|
return o;
|
|
}
|
|
|
|
#if defined(TESSELLATION_ON)
|
|
struct VertexControl
|
|
{
|
|
float3 positionOS : INTERNALTESSPOS;
|
|
float3 normalOS : NORMAL;
|
|
/*ase_vcontrol*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct TessellationFactors
|
|
{
|
|
float edge[3] : SV_TessFactor;
|
|
float inside : SV_InsideTessFactor;
|
|
};
|
|
|
|
VertexControl Vert ( VertexInput v )
|
|
{
|
|
VertexControl o;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
o.positionOS = v.positionOS;
|
|
o.normalOS = v.normalOS;
|
|
/*ase_control_code:v=VertexInput;o=VertexControl*/
|
|
return o;
|
|
}
|
|
|
|
TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
|
|
{
|
|
TessellationFactors o;
|
|
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 (SHADEROPTIONS_CAMERA_RELATIVE_RENDERING != 0)
|
|
float3 cameraPos = 0;
|
|
#else
|
|
float3 cameraPos = _WorldSpaceCameraPos;
|
|
#endif
|
|
#if defined(ASE_FIXED_TESSELLATION)
|
|
tf = FixedTess( tessValue );
|
|
#elif defined(ASE_DISTANCE_TESSELLATION)
|
|
tf = DistanceBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), cameraPos );
|
|
#elif defined(ASE_LENGTH_TESSELLATION)
|
|
tf = EdgeLengthBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, GetObjectToWorldMatrix(), cameraPos, _ScreenParams );
|
|
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
|
tf = EdgeLengthBasedTessCull(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), cameraPos, _ScreenParams, _FrustumPlanes );
|
|
#endif
|
|
o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
|
|
return o;
|
|
}
|
|
|
|
[domain("tri")]
|
|
[partitioning("fractional_odd")]
|
|
[outputtopology("triangle_cw")]
|
|
[patchconstantfunc("TessellationFunction")]
|
|
[outputcontrolpoints(3)]
|
|
VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
|
|
{
|
|
return patch[id];
|
|
}
|
|
|
|
[domain("tri")]
|
|
VertexOutput DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
|
{
|
|
VertexInput o = (VertexInput) 0;
|
|
o.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
|
|
o.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
|
|
/*ase_domain_code:patch=VertexControl;o=VertexInput;bary=SV_DomainLocation*/
|
|
#if defined(ASE_PHONG_TESSELLATION)
|
|
float3 pp[3];
|
|
for (int i = 0; i < 3; ++i)
|
|
pp[i] = o.positionOS.xyz - patch[i].normalOS * (dot(o.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
|
|
float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/;
|
|
o.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.positionOS.xyz;
|
|
#endif
|
|
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
|
return VertexFunction(o);
|
|
}
|
|
#else
|
|
VertexOutput Vert ( VertexInput v )
|
|
{
|
|
return VertexFunction( v );
|
|
}
|
|
#endif
|
|
|
|
|
|
void Frag( VertexOutput packedInput
|
|
#ifdef WRITE_MSAA_DEPTH
|
|
, out float4 depthColor : SV_Target0
|
|
#ifdef WRITE_NORMAL_BUFFER
|
|
, out float4 outNormalBuffer : SV_Target1
|
|
#endif
|
|
#else
|
|
#ifdef WRITE_NORMAL_BUFFER
|
|
, out float4 outNormalBuffer : SV_Target0
|
|
#endif
|
|
#endif
|
|
#if defined(_DEPTHOFFSET_ON)
|
|
, out float outputDepth : DEPTH_OFFSET_SEMANTIC
|
|
#endif
|
|
/*ase_frag_input*/
|
|
)
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID( packedInput );
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( packedInput );
|
|
|
|
FragInputs input;
|
|
ZERO_INITIALIZE(FragInputs, input);
|
|
|
|
input.tangentToWorld = k_identity3x3;
|
|
input.positionSS = packedInput.positionCS;
|
|
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS);
|
|
|
|
float3 V = float3( 1.0, 1.0, 1.0 );
|
|
|
|
SurfaceDescription surfaceDescription = (SurfaceDescription)0;
|
|
/*ase_frag_code:packedInput=VertexOutput*/
|
|
surfaceDescription.Alpha = /*ase_frag_out:Alpha;Float;0;-1;_Alpha*/1/*end*/;
|
|
surfaceDescription.AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;1;-1;_AlphaClip*/_AlphaCutoff/*end*/;
|
|
|
|
SurfaceData surfaceData;
|
|
BuiltinData builtinData;
|
|
GetSurfaceAndBuiltinData(surfaceDescription,input, V, posInput, surfaceData, builtinData);
|
|
|
|
#if defined(_DEPTHOFFSET_ON)
|
|
outputDepth = posInput.deviceDepth;
|
|
float bias = max(abs(ddx(posInput.deviceDepth)), abs(ddy(posInput.deviceDepth))) * _SlopeScaleDepthBias;
|
|
outputDepth += bias;
|
|
#endif
|
|
|
|
#ifdef WRITE_MSAA_DEPTH
|
|
depthColor = packedInput.vmesh.positionCS.z;
|
|
|
|
#ifdef _ALPHATOMASK_ON
|
|
depthColor.a = SharpenAlpha(builtinData.opacity, builtinData.alphaClipTreshold);
|
|
#endif
|
|
#endif
|
|
|
|
#if defined(WRITE_NORMAL_BUFFER)
|
|
EncodeIntoNormalBuffer(ConvertSurfaceDataToNormalData(surfaceData), outNormalBuffer);
|
|
#endif
|
|
|
|
#if defined(WRITE_DECAL_BUFFER) && !defined(_DISABLE_DECALS)
|
|
DecalPrepassData decalPrepassData;
|
|
decalPrepassData.geomNormalWS = surfaceData.geomNormalWS;
|
|
decalPrepassData.decalLayerMask = GetMeshRenderingDecalLayer();
|
|
EncodeIntoDecalPrepassBuffer(decalPrepassData, outDecalBuffer);
|
|
#endif
|
|
}
|
|
ENDHLSL
|
|
}
|
|
|
|
/*ase_pass*/
|
|
Pass
|
|
{
|
|
/*ase_hide_pass*/
|
|
Name "META"
|
|
Tags { "LightMode" = "Meta" }
|
|
|
|
Cull Off
|
|
|
|
HLSLPROGRAM
|
|
#define SHADERPASS SHADERPASS_LIGHT_TRANSPORT
|
|
|
|
#pragma shader_feature _SURFACE_TYPE_TRANSPARENT
|
|
#pragma shader_feature _ EDITOR_VISUALIZATION
|
|
#pragma shader_feature_local _BLENDMODE_OFF _BLENDMODE_ALPHA _BLENDMODE_ADD _BLENDMODE_PRE_MULTIPLY
|
|
#pragma shader_feature_local _ALPHATEST_ON
|
|
#pragma shader_feature_local _ _ADD_PRECOMPUTED_VELOCITY
|
|
#pragma shader_feature_local _ _TRANSPARENT_WRITES_MOTION_VEC
|
|
#pragma shader_feature_local _ENABLE_FOG_ON_TRANSPARENT
|
|
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/GeometricTools.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Tessellation.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphHeader.hlsl"
|
|
|
|
#if defined(_TRANSPARENT_WRITES_MOTION_VEC) && defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define _WRITE_TRANSPARENT_MOTION_VECTOR
|
|
#endif
|
|
|
|
CBUFFER_START( UnityPerMaterial )
|
|
float4 _EmissionColor;
|
|
float _RenderQueueType;
|
|
#ifdef _ADD_PRECOMPUTED_VELOCITY
|
|
float _AddPrecomputedVelocity;
|
|
#endif
|
|
#ifdef _ENABLE_SHADOW_MATTE
|
|
float _ShadowMatteFilter;
|
|
#endif
|
|
float _StencilRef;
|
|
float _StencilWriteMask;
|
|
float _StencilRefDepth;
|
|
float _StencilWriteMaskDepth;
|
|
float _StencilRefMV;
|
|
float _StencilWriteMaskMV;
|
|
float _StencilRefDistortionVec;
|
|
float _StencilWriteMaskDistortionVec;
|
|
float _StencilWriteMaskGBuffer;
|
|
float _StencilRefGBuffer;
|
|
float _ZTestGBuffer;
|
|
float _RequireSplitLighting;
|
|
float _ReceivesSSR;
|
|
float _SurfaceType;
|
|
float _BlendMode;
|
|
float _SrcBlend;
|
|
float _DstBlend;
|
|
float _AlphaSrcBlend;
|
|
float _AlphaDstBlend;
|
|
float _ZWrite;
|
|
float _TransparentZWrite;
|
|
float _CullMode;
|
|
float _TransparentSortPriority;
|
|
float _EnableFogOnTransparent;
|
|
float _CullModeForward;
|
|
float _TransparentCullMode;
|
|
float _ZTestDepthEqualForOpaque;
|
|
float _ZTestTransparent;
|
|
float _TransparentBackfaceEnable;
|
|
float _AlphaCutoffEnable;
|
|
float _AlphaCutoff;
|
|
float _UseShadowThreshold;
|
|
float _DoubleSidedEnable;
|
|
float _DoubleSidedNormalMode;
|
|
float4 _DoubleSidedConstants;
|
|
float _EnableBlendModePreserveSpecularLighting;
|
|
#ifdef TESSELLATION_ON
|
|
float _TessPhongStrength;
|
|
float _TessValue;
|
|
float _TessMin;
|
|
float _TessMax;
|
|
float _TessEdgeLength;
|
|
float _TessMaxDisp;
|
|
#endif
|
|
CBUFFER_END
|
|
|
|
|
|
/*ase_globals*/
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/Unlit.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
|
|
/*ase_pragma*/
|
|
|
|
struct VertexInput
|
|
{
|
|
float3 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
float4 uv0 : TEXCOORD0;
|
|
float4 uv1 : TEXCOORD1;
|
|
float4 uv2 : TEXCOORD2;
|
|
float4 uv3 : TEXCOORD3;
|
|
/*ase_vdata:p=p;n=n;uv0=tc0;uv1=tc1;uv2=tc2;uv3=tc3*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct VertexOutput
|
|
{
|
|
float4 positionCS : SV_Position;
|
|
#ifdef EDITOR_VISUALIZATION
|
|
float2 VizUV : TEXCOORD0;
|
|
float4 LightCoord : TEXCOORD1;
|
|
#endif
|
|
/*ase_interp(2,):sp=sp.xyzw*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
|
|
/*ase_funcs*/
|
|
|
|
struct SurfaceDescription
|
|
{
|
|
float3 Color;
|
|
float3 Emission;
|
|
float Alpha;
|
|
float AlphaClipThreshold;
|
|
};
|
|
|
|
void BuildSurfaceData( FragInputs fragInputs, SurfaceDescription surfaceDescription, float3 V, out SurfaceData surfaceData )
|
|
{
|
|
ZERO_INITIALIZE( SurfaceData, surfaceData );
|
|
surfaceData.color = surfaceDescription.Color;
|
|
|
|
#ifdef WRITE_NORMAL_BUFFER
|
|
surfaceData.normalWS = fragInputs.tangentToWorld[2];
|
|
#endif
|
|
}
|
|
|
|
void GetSurfaceAndBuiltinData( SurfaceDescription surfaceDescription, FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData )
|
|
{
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
LODDitheringTransition(ComputeFadeMaskSeed(V, posInput.positionSS), unity_LODFade.x);
|
|
#endif
|
|
|
|
#if _ALPHATEST_ON
|
|
DoAlphaTest( surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold );
|
|
#endif
|
|
|
|
#if _DEPTHOFFSET_ON
|
|
ApplyDepthOffsetPositionInput(V, surfaceDescription.DepthOffset, GetViewForwardDir(), GetWorldToHClipMatrix(), posInput);
|
|
#endif
|
|
|
|
BuildSurfaceData( fragInputs, surfaceDescription, V, surfaceData );
|
|
ZERO_INITIALIZE( BuiltinData, builtinData );
|
|
builtinData.opacity = surfaceDescription.Alpha;
|
|
#if defined(DEBUG_DISPLAY)
|
|
builtinData.renderingLayers = GetMeshRenderingLightLayer();
|
|
#endif
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
builtinData.alphaClipTreshold = surfaceDescription.AlphaClipThreshold;
|
|
#endif
|
|
|
|
builtinData.emissiveColor = surfaceDescription.Emission;
|
|
|
|
#if _DEPTHOFFSET_ON
|
|
builtinData.depthOffset = surfaceDescription.DepthOffset;
|
|
#endif
|
|
|
|
|
|
ApplyDebugToBuiltinData(builtinData);
|
|
}
|
|
|
|
#define SCENEPICKINGPASS
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/PickingSpaceTransforms.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/MetaPass.hlsl"
|
|
|
|
VertexOutput VertexFunction( VertexInput inputMesh /*ase_vert_input*/ )
|
|
{
|
|
VertexOutput o;
|
|
UNITY_SETUP_INSTANCE_ID( inputMesh );
|
|
UNITY_TRANSFER_INSTANCE_ID( inputMesh, o );
|
|
|
|
/*ase_vert_code:inputMesh=VertexInput;o=VertexOutput*/
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = inputMesh.positionOS.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3( 0, 0, 0 );
|
|
#endif
|
|
float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;4;-1;_VertexOffset*/ defaultVertexValue /*end*/;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
inputMesh.positionOS.xyz = vertexValue;
|
|
#else
|
|
inputMesh.positionOS.xyz += vertexValue;
|
|
#endif
|
|
|
|
inputMesh.normalOS = /*ase_vert_out:Vertex Normal;Float3;5;-1;_VertexNormal*/ inputMesh.normalOS /*end*/;
|
|
|
|
#ifdef EDITOR_VISUALIZATION
|
|
float2 vizUV = 0;
|
|
float4 lightCoord = 0;
|
|
UnityEditorVizData(inputMesh.positionOS.xyz, inputMesh.uv0.xy, inputMesh.uv1.xy, inputMesh.uv2.xy, vizUV, lightCoord);
|
|
#endif
|
|
|
|
float2 uv = float2( 0.0, 0.0 );
|
|
if( unity_MetaVertexControl.x )
|
|
{
|
|
uv = inputMesh.uv1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
|
|
}
|
|
else if( unity_MetaVertexControl.y )
|
|
{
|
|
uv = inputMesh.uv2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
|
|
}
|
|
|
|
#ifdef EDITOR_VISUALIZATION
|
|
o.VizUV.xy = vizUV;
|
|
o.LightCoord = lightCoord;
|
|
#endif
|
|
|
|
o.positionCS = float4( uv * 2.0 - 1.0, inputMesh.positionOS.z > 0 ? 1.0e-4 : 0.0, 1.0 );
|
|
return o;
|
|
}
|
|
|
|
#if defined(TESSELLATION_ON)
|
|
struct VertexControl
|
|
{
|
|
float3 positionOS : INTERNALTESSPOS;
|
|
float3 normalOS : NORMAL;
|
|
float4 uv0 : TEXCOORD0;
|
|
float4 uv1 : TEXCOORD1;
|
|
float4 uv2 : TEXCOORD2;
|
|
float4 uv3 : TEXCOORD3;
|
|
/*ase_vcontrol*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct TessellationFactors
|
|
{
|
|
float edge[3] : SV_TessFactor;
|
|
float inside : SV_InsideTessFactor;
|
|
};
|
|
|
|
VertexControl Vert ( VertexInput v )
|
|
{
|
|
VertexControl o;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
o.positionOS = v.positionOS;
|
|
o.normalOS = v.normalOS;
|
|
o.uv0 = v.uv0;
|
|
o.uv1 = v.uv1;
|
|
o.uv2 = v.uv2;
|
|
o.uv3 = v.uv3;
|
|
/*ase_control_code:v=VertexInput;o=VertexControl*/
|
|
return o;
|
|
}
|
|
|
|
TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
|
|
{
|
|
TessellationFactors o;
|
|
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 (SHADEROPTIONS_CAMERA_RELATIVE_RENDERING != 0)
|
|
float3 cameraPos = 0;
|
|
#else
|
|
float3 cameraPos = _WorldSpaceCameraPos;
|
|
#endif
|
|
#if defined(ASE_FIXED_TESSELLATION)
|
|
tf = FixedTess( tessValue );
|
|
#elif defined(ASE_DISTANCE_TESSELLATION)
|
|
tf = DistanceBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), cameraPos );
|
|
#elif defined(ASE_LENGTH_TESSELLATION)
|
|
tf = EdgeLengthBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, GetObjectToWorldMatrix(), cameraPos, _ScreenParams );
|
|
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
|
tf = EdgeLengthBasedTessCull(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), cameraPos, _ScreenParams, _FrustumPlanes );
|
|
#endif
|
|
o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
|
|
return o;
|
|
}
|
|
|
|
[domain("tri")]
|
|
[partitioning("fractional_odd")]
|
|
[outputtopology("triangle_cw")]
|
|
[patchconstantfunc("TessellationFunction")]
|
|
[outputcontrolpoints(3)]
|
|
VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
|
|
{
|
|
return patch[id];
|
|
}
|
|
|
|
[domain("tri")]
|
|
VertexOutput DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
|
{
|
|
VertexInput o = (VertexInput) 0;
|
|
o.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
|
|
o.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
|
|
o.uv0 = patch[0].uv0 * bary.x + patch[1].uv0 * bary.y + patch[2].uv0 * bary.z;
|
|
o.uv1 = patch[0].uv1 * bary.x + patch[1].uv1 * bary.y + patch[2].uv1 * bary.z;
|
|
o.uv2 = patch[0].uv2 * bary.x + patch[1].uv2 * bary.y + patch[2].uv2 * bary.z;
|
|
o.uv3 = patch[0].uv3 * bary.x + patch[1].uv3 * bary.y + patch[2].uv3 * bary.z;
|
|
/*ase_domain_code:patch=VertexControl;o=VertexInput;bary=SV_DomainLocation*/
|
|
#if defined(ASE_PHONG_TESSELLATION)
|
|
float3 pp[3];
|
|
for (int i = 0; i < 3; ++i)
|
|
pp[i] = o.positionOS.xyz - patch[i].normalOS * (dot(o.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
|
|
float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/;
|
|
o.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.positionOS.xyz;
|
|
#endif
|
|
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
|
return VertexFunction(o);
|
|
}
|
|
#else
|
|
VertexOutput Vert ( VertexInput v )
|
|
{
|
|
return VertexFunction( v );
|
|
}
|
|
#endif
|
|
|
|
float4 Frag( VertexOutput packedInput /*ase_frag_input*/ ) : SV_Target
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID( packedInput );
|
|
FragInputs input;
|
|
ZERO_INITIALIZE( FragInputs, input );
|
|
input.tangentToWorld = k_identity3x3;
|
|
input.positionSS = packedInput.positionCS;
|
|
|
|
PositionInputs posInput = GetPositionInput( input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS );
|
|
|
|
float3 V = float3( 1.0, 1.0, 1.0 );
|
|
|
|
SurfaceDescription surfaceDescription = (SurfaceDescription)0;
|
|
/*ase_frag_code:packedInput=VertexOutput*/
|
|
surfaceDescription.Color = /*ase_frag_out:Color;Float3;0;-1;_Color*/float3( 0.5, 0.5, 0.5 )/*end*/;
|
|
surfaceDescription.Emission = /*ase_frag_out:Emission;Float3;1;-1;_Emission*/0/*end*/;
|
|
surfaceDescription.Alpha = /*ase_frag_out:Alpha;Float;2;-1;_Alpha*/1/*end*/;
|
|
surfaceDescription.AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;3;-1;_AlphaClip*/_AlphaCutoff/*end*/;
|
|
|
|
SurfaceData surfaceData;
|
|
BuiltinData builtinData;
|
|
GetSurfaceAndBuiltinData( surfaceDescription,input, V, posInput, surfaceData, builtinData );
|
|
|
|
BSDFData bsdfData = ConvertSurfaceDataToBSDFData( input.positionSS.xy, surfaceData );
|
|
LightTransportData lightTransportData = GetLightTransportData( surfaceData, builtinData, bsdfData );
|
|
|
|
float4 res = float4( 0.0, 0.0, 0.0, 1.0 );
|
|
UnityMetaInput metaInput;
|
|
metaInput.Albedo = lightTransportData.diffuseColor.rgb;
|
|
metaInput.Emission = lightTransportData.emissiveColor;
|
|
#ifdef EDITOR_VISUALIZATION
|
|
metaInput.VizUV = packedInput.VizUV;
|
|
metaInput.LightCoord = packedInput.LightCoord;
|
|
#endif
|
|
res = UnityMetaFragment(metaInput);
|
|
|
|
return res;
|
|
}
|
|
|
|
ENDHLSL
|
|
}
|
|
|
|
/*ase_pass*/
|
|
Pass
|
|
{
|
|
/*ase_hide_pass*/
|
|
Name "SceneSelectionPass"
|
|
Tags { "LightMode" = "SceneSelectionPass" }
|
|
|
|
Cull Off
|
|
|
|
HLSLPROGRAM
|
|
#define SHADERPASS SHADERPASS_DEPTH_ONLY
|
|
#define SCENESELECTIONPASS 1
|
|
#pragma editor_sync_compilation
|
|
|
|
#pragma shader_feature _SURFACE_TYPE_TRANSPARENT
|
|
#pragma shader_feature_local _BLENDMODE_OFF _BLENDMODE_ALPHA _BLENDMODE_ADD _BLENDMODE_PRE_MULTIPLY
|
|
#pragma shader_feature_local _ALPHATEST_ON
|
|
#pragma shader_feature_local _ _ADD_PRECOMPUTED_VELOCITY
|
|
#pragma shader_feature_local _ _TRANSPARENT_WRITES_MOTION_VEC
|
|
#pragma shader_feature_local _ENABLE_FOG_ON_TRANSPARENT
|
|
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/GeometricTools.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Tessellation.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphHeader.hlsl"
|
|
|
|
int _ObjectId;
|
|
int _PassValue;
|
|
|
|
CBUFFER_START( UnityPerMaterial )
|
|
float4 _EmissionColor;
|
|
float _RenderQueueType;
|
|
#ifdef _ADD_PRECOMPUTED_VELOCITY
|
|
float _AddPrecomputedVelocity;
|
|
#endif
|
|
#ifdef _ENABLE_SHADOW_MATTE
|
|
float _ShadowMatteFilter;
|
|
#endif
|
|
float _StencilRef;
|
|
float _StencilWriteMask;
|
|
float _StencilRefDepth;
|
|
float _StencilWriteMaskDepth;
|
|
float _StencilRefMV;
|
|
float _StencilWriteMaskMV;
|
|
float _StencilRefDistortionVec;
|
|
float _StencilWriteMaskDistortionVec;
|
|
float _StencilWriteMaskGBuffer;
|
|
float _StencilRefGBuffer;
|
|
float _ZTestGBuffer;
|
|
float _RequireSplitLighting;
|
|
float _ReceivesSSR;
|
|
float _SurfaceType;
|
|
float _BlendMode;
|
|
float _SrcBlend;
|
|
float _DstBlend;
|
|
float _AlphaSrcBlend;
|
|
float _AlphaDstBlend;
|
|
float _ZWrite;
|
|
float _TransparentZWrite;
|
|
float _CullMode;
|
|
float _TransparentSortPriority;
|
|
float _EnableFogOnTransparent;
|
|
float _CullModeForward;
|
|
float _TransparentCullMode;
|
|
float _ZTestDepthEqualForOpaque;
|
|
float _ZTestTransparent;
|
|
float _TransparentBackfaceEnable;
|
|
float _AlphaCutoffEnable;
|
|
float _AlphaCutoff;
|
|
float _UseShadowThreshold;
|
|
float _DoubleSidedEnable;
|
|
float _DoubleSidedNormalMode;
|
|
float4 _DoubleSidedConstants;
|
|
float _EnableBlendModePreserveSpecularLighting;
|
|
#ifdef TESSELLATION_ON
|
|
float _TessPhongStrength;
|
|
float _TessValue;
|
|
float _TessMin;
|
|
float _TessMax;
|
|
float _TessEdgeLength;
|
|
float _TessMaxDisp;
|
|
#endif
|
|
CBUFFER_END
|
|
/*ase_globals*/
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/PickingSpaceTransforms.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/Unlit.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
|
|
/*ase_pragma*/
|
|
|
|
struct VertexInput
|
|
{
|
|
float3 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
/*ase_vdata:p=p;n=n*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct VertexOutput
|
|
{
|
|
float4 positionCS : SV_Position;
|
|
/*ase_interp(0,):sp=sp.xyzw*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
|
|
/*ase_funcs*/
|
|
|
|
struct SurfaceDescription
|
|
{
|
|
float Alpha;
|
|
float AlphaClipThreshold;
|
|
};
|
|
|
|
void BuildSurfaceData(FragInputs fragInputs, SurfaceDescription surfaceDescription, float3 V, out SurfaceData surfaceData)
|
|
{
|
|
ZERO_INITIALIZE(SurfaceData, surfaceData);
|
|
|
|
#ifdef WRITE_NORMAL_BUFFER
|
|
surfaceData.normalWS = fragInputs.tangentToWorld[2];
|
|
#endif
|
|
}
|
|
|
|
void GetSurfaceAndBuiltinData(SurfaceDescription surfaceDescription, FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
|
|
{
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
LODDitheringTransition(ComputeFadeMaskSeed(V, posInput.positionSS), unity_LODFade.x);
|
|
#endif
|
|
|
|
#if _ALPHATEST_ON
|
|
DoAlphaTest ( surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold );
|
|
#endif
|
|
|
|
BuildSurfaceData(fragInputs, surfaceDescription, V, surfaceData);
|
|
ZERO_INITIALIZE(BuiltinData, builtinData);
|
|
builtinData.opacity = surfaceDescription.Alpha;
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
builtinData.alphaClipTreshold = surfaceDescription.AlphaClipThreshold;
|
|
#endif
|
|
|
|
#if _DEPTHOFFSET_ON
|
|
builtinData.depthOffset = surfaceDescription.DepthOffset;
|
|
#endif
|
|
|
|
|
|
ApplyDebugToBuiltinData(builtinData);
|
|
}
|
|
|
|
VertexOutput VertexFunction( VertexInput inputMesh /*ase_vert_input*/ )
|
|
{
|
|
VertexOutput o;
|
|
UNITY_SETUP_INSTANCE_ID(inputMesh);
|
|
UNITY_TRANSFER_INSTANCE_ID(inputMesh, o);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o );
|
|
|
|
/*ase_vert_code:inputMesh=VertexInput;o=VertexOutput*/
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = inputMesh.positionOS.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3( 0, 0, 0 );
|
|
#endif
|
|
float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;2;-1;_VertexOffset*/ defaultVertexValue /*end*/;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
inputMesh.positionOS.xyz = vertexValue;
|
|
#else
|
|
inputMesh.positionOS.xyz += vertexValue;
|
|
#endif
|
|
|
|
inputMesh.normalOS = /*ase_vert_out:Vertex Normal;Float3;3;-1;_VertexNormal*/ inputMesh.normalOS /*end*/;
|
|
|
|
float3 positionRWS = TransformObjectToWorld(inputMesh.positionOS);
|
|
o.positionCS = TransformWorldToHClip(positionRWS);
|
|
return o;
|
|
}
|
|
|
|
#if defined(TESSELLATION_ON)
|
|
struct VertexControl
|
|
{
|
|
float3 positionOS : INTERNALTESSPOS;
|
|
float3 normalOS : NORMAL;
|
|
/*ase_vcontrol*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct TessellationFactors
|
|
{
|
|
float edge[3] : SV_TessFactor;
|
|
float inside : SV_InsideTessFactor;
|
|
};
|
|
|
|
VertexControl Vert ( VertexInput v )
|
|
{
|
|
VertexControl o;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
o.positionOS = v.positionOS;
|
|
o.normalOS = v.normalOS;
|
|
/*ase_control_code:v=VertexInput;o=VertexControl*/
|
|
return o;
|
|
}
|
|
|
|
TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
|
|
{
|
|
TessellationFactors o;
|
|
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 (SHADEROPTIONS_CAMERA_RELATIVE_RENDERING != 0)
|
|
float3 cameraPos = 0;
|
|
#else
|
|
float3 cameraPos = _WorldSpaceCameraPos;
|
|
#endif
|
|
#if defined(ASE_FIXED_TESSELLATION)
|
|
tf = FixedTess( tessValue );
|
|
#elif defined(ASE_DISTANCE_TESSELLATION)
|
|
tf = DistanceBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), cameraPos );
|
|
#elif defined(ASE_LENGTH_TESSELLATION)
|
|
tf = EdgeLengthBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, GetObjectToWorldMatrix(), cameraPos, _ScreenParams );
|
|
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
|
tf = EdgeLengthBasedTessCull(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), cameraPos, _ScreenParams, _FrustumPlanes );
|
|
#endif
|
|
o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
|
|
return o;
|
|
}
|
|
|
|
[domain("tri")]
|
|
[partitioning("fractional_odd")]
|
|
[outputtopology("triangle_cw")]
|
|
[patchconstantfunc("TessellationFunction")]
|
|
[outputcontrolpoints(3)]
|
|
VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
|
|
{
|
|
return patch[id];
|
|
}
|
|
|
|
[domain("tri")]
|
|
VertexOutput DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
|
{
|
|
VertexInput o = (VertexInput) 0;
|
|
o.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
|
|
o.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
|
|
/*ase_domain_code:patch=VertexControl;o=VertexInput;bary=SV_DomainLocation*/
|
|
#if defined(ASE_PHONG_TESSELLATION)
|
|
float3 pp[3];
|
|
for (int i = 0; i < 3; ++i)
|
|
pp[i] = o.positionOS.xyz - patch[i].normalOS * (dot(o.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
|
|
float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/;
|
|
o.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.positionOS.xyz;
|
|
#endif
|
|
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
|
return VertexFunction(o);
|
|
}
|
|
#else
|
|
VertexOutput Vert ( VertexInput v )
|
|
{
|
|
return VertexFunction( v );
|
|
}
|
|
#endif
|
|
|
|
void Frag( VertexOutput packedInput
|
|
, out float4 outColor : SV_Target0
|
|
#ifdef _DEPTHOFFSET_ON
|
|
, out float outputDepth : SV_Depth
|
|
#endif
|
|
/*ase_frag_input*/
|
|
)
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID( packedInput );
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( packedInput );
|
|
FragInputs input;
|
|
ZERO_INITIALIZE(FragInputs, input);
|
|
input.tangentToWorld = k_identity3x3;
|
|
input.positionSS = packedInput.positionCS;
|
|
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS);
|
|
|
|
float3 V = float3( 1.0, 1.0, 1.0 );
|
|
|
|
SurfaceData surfaceData;
|
|
BuiltinData builtinData;
|
|
SurfaceDescription surfaceDescription = (SurfaceDescription)0;
|
|
/*ase_frag_code:packedInput=VertexOutput*/
|
|
surfaceDescription.Alpha = /*ase_frag_out:Alpha;Float;0;-1;_Alpha*/1/*end*/;
|
|
surfaceDescription.AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;1;-1;_AlphaClip*/_AlphaCutoff/*end*/;
|
|
|
|
GetSurfaceAndBuiltinData(surfaceDescription, input, V, posInput, surfaceData, builtinData);
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
outputDepth = posInput.deviceDepth;
|
|
#endif
|
|
|
|
outColor = float4( _ObjectId, _PassValue, 1.0, 1.0 );
|
|
}
|
|
|
|
ENDHLSL
|
|
}
|
|
|
|
/*ase_pass*/
|
|
Pass
|
|
{
|
|
/*ase_hide_pass*/
|
|
Name "DepthForwardOnly"
|
|
Tags { "LightMode" = "DepthForwardOnly" }
|
|
|
|
Cull [_CullMode]
|
|
ZWrite On
|
|
Stencil
|
|
{
|
|
WriteMask [_StencilWriteMaskDepth]
|
|
Ref [_StencilRefDepth]
|
|
Comp Always
|
|
Pass Replace
|
|
}
|
|
|
|
ColorMask 0 0
|
|
|
|
HLSLPROGRAM
|
|
#define SHADERPASS SHADERPASS_DEPTH_ONLY
|
|
#pragma multi_compile _ WRITE_MSAA_DEPTH
|
|
|
|
#pragma shader_feature _SURFACE_TYPE_TRANSPARENT
|
|
#pragma shader_feature_local _BLENDMODE_OFF _BLENDMODE_ALPHA _BLENDMODE_ADD _BLENDMODE_PRE_MULTIPLY
|
|
#pragma shader_feature_local _ALPHATEST_ON
|
|
#pragma shader_feature_local _ _ADD_PRECOMPUTED_VELOCITY
|
|
#pragma shader_feature_local _ _TRANSPARENT_WRITES_MOTION_VEC
|
|
#pragma shader_feature_local _ENABLE_FOG_ON_TRANSPARENT
|
|
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/GeometricTools.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Tessellation.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphHeader.hlsl"
|
|
|
|
CBUFFER_START( UnityPerMaterial )
|
|
float4 _EmissionColor;
|
|
float _RenderQueueType;
|
|
#ifdef _ADD_PRECOMPUTED_VELOCITY
|
|
float _AddPrecomputedVelocity;
|
|
#endif
|
|
#ifdef _ENABLE_SHADOW_MATTE
|
|
float _ShadowMatteFilter;
|
|
#endif
|
|
float _StencilRef;
|
|
float _StencilWriteMask;
|
|
float _StencilRefDepth;
|
|
float _StencilWriteMaskDepth;
|
|
float _StencilRefMV;
|
|
float _StencilWriteMaskMV;
|
|
float _StencilRefDistortionVec;
|
|
float _StencilWriteMaskDistortionVec;
|
|
float _StencilWriteMaskGBuffer;
|
|
float _StencilRefGBuffer;
|
|
float _ZTestGBuffer;
|
|
float _RequireSplitLighting;
|
|
float _ReceivesSSR;
|
|
float _SurfaceType;
|
|
float _BlendMode;
|
|
float _SrcBlend;
|
|
float _DstBlend;
|
|
float _AlphaSrcBlend;
|
|
float _AlphaDstBlend;
|
|
float _ZWrite;
|
|
float _TransparentZWrite;
|
|
float _CullMode;
|
|
float _TransparentSortPriority;
|
|
float _EnableFogOnTransparent;
|
|
float _CullModeForward;
|
|
float _TransparentCullMode;
|
|
float _ZTestDepthEqualForOpaque;
|
|
float _ZTestTransparent;
|
|
float _TransparentBackfaceEnable;
|
|
float _AlphaCutoffEnable;
|
|
float _AlphaCutoff;
|
|
float _UseShadowThreshold;
|
|
float _DoubleSidedEnable;
|
|
float _DoubleSidedNormalMode;
|
|
float4 _DoubleSidedConstants;
|
|
float _EnableBlendModePreserveSpecularLighting;
|
|
#ifdef TESSELLATION_ON
|
|
float _TessPhongStrength;
|
|
float _TessValue;
|
|
float _TessMin;
|
|
float _TessMax;
|
|
float _TessEdgeLength;
|
|
float _TessMaxDisp;
|
|
#endif
|
|
CBUFFER_END
|
|
/*ase_globals*/
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/Unlit.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
|
|
/*ase_pragma*/
|
|
|
|
struct VertexInput
|
|
{
|
|
float3 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
/*ase_vdata:p=p;n=n*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct VertexOutput
|
|
{
|
|
float4 positionCS : SV_Position;
|
|
/*ase_interp(0,):sp=sp.xyzw*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
/*ase_funcs*/
|
|
|
|
struct SurfaceDescription
|
|
{
|
|
float Alpha;
|
|
float AlphaClipThreshold;
|
|
};
|
|
|
|
void BuildSurfaceData(FragInputs fragInputs, SurfaceDescription surfaceDescription, float3 V, out SurfaceData surfaceData)
|
|
{
|
|
ZERO_INITIALIZE(SurfaceData, surfaceData);
|
|
#ifdef WRITE_NORMAL_BUFFER
|
|
surfaceData.normalWS = fragInputs.tangentToWorld[2];
|
|
#endif
|
|
}
|
|
|
|
void GetSurfaceAndBuiltinData(SurfaceDescription surfaceDescription, FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
|
|
{
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
LODDitheringTransition(ComputeFadeMaskSeed(V, posInput.positionSS), unity_LODFade.x);
|
|
#endif
|
|
|
|
#if _ALPHATEST_ON
|
|
DoAlphaTest ( surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold );
|
|
#endif
|
|
|
|
#if _DEPTHOFFSET_ON
|
|
ApplyDepthOffsetPositionInput(V, surfaceDescription.DepthOffset, GetViewForwardDir(), GetWorldToHClipMatrix(), posInput);
|
|
#endif
|
|
|
|
BuildSurfaceData(fragInputs, surfaceDescription, V, surfaceData);
|
|
ZERO_INITIALIZE(BuiltinData, builtinData);
|
|
builtinData.opacity = surfaceDescription.Alpha;
|
|
|
|
#if defined(DEBUG_DISPLAY)
|
|
builtinData.renderingLayers = GetMeshRenderingLightLayer();
|
|
#endif
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
builtinData.alphaClipTreshold = surfaceDescription.AlphaClipThreshold;
|
|
#endif
|
|
|
|
#if _DEPTHOFFSET_ON
|
|
builtinData.depthOffset = surfaceDescription.DepthOffset;
|
|
#endif
|
|
|
|
ApplyDebugToBuiltinData(builtinData);
|
|
}
|
|
|
|
VertexOutput VertexFunction( VertexInput inputMesh /*ase_vert_input*/ )
|
|
{
|
|
VertexOutput o;
|
|
UNITY_SETUP_INSTANCE_ID(inputMesh);
|
|
UNITY_TRANSFER_INSTANCE_ID(inputMesh, o);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o );
|
|
|
|
/*ase_vert_code:inputMesh=VertexInput;o=VertexOutput*/
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = inputMesh.positionOS.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3( 0, 0, 0 );
|
|
#endif
|
|
float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;2;-1;_VertexOffset*/ defaultVertexValue /*end*/;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
inputMesh.positionOS.xyz = vertexValue;
|
|
#else
|
|
inputMesh.positionOS.xyz += vertexValue;
|
|
#endif
|
|
|
|
inputMesh.normalOS = /*ase_vert_out:Vertex Normal;Float3;3;-1;_VertexNormal*/ inputMesh.normalOS /*end*/;
|
|
|
|
float3 positionRWS = TransformObjectToWorld(inputMesh.positionOS);
|
|
o.positionCS = TransformWorldToHClip(positionRWS);
|
|
return o;
|
|
}
|
|
|
|
#if defined(TESSELLATION_ON)
|
|
struct VertexControl
|
|
{
|
|
float3 positionOS : INTERNALTESSPOS;
|
|
float3 normalOS : NORMAL;
|
|
/*ase_vcontrol*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct TessellationFactors
|
|
{
|
|
float edge[3] : SV_TessFactor;
|
|
float inside : SV_InsideTessFactor;
|
|
};
|
|
|
|
VertexControl Vert ( VertexInput v )
|
|
{
|
|
VertexControl o;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
o.positionOS = v.positionOS;
|
|
o.normalOS = v.normalOS;
|
|
/*ase_control_code:v=VertexInput;o=VertexControl*/
|
|
return o;
|
|
}
|
|
|
|
TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
|
|
{
|
|
TessellationFactors o;
|
|
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 (SHADEROPTIONS_CAMERA_RELATIVE_RENDERING != 0)
|
|
float3 cameraPos = 0;
|
|
#else
|
|
float3 cameraPos = _WorldSpaceCameraPos;
|
|
#endif
|
|
#if defined(ASE_FIXED_TESSELLATION)
|
|
tf = FixedTess( tessValue );
|
|
#elif defined(ASE_DISTANCE_TESSELLATION)
|
|
tf = DistanceBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), cameraPos );
|
|
#elif defined(ASE_LENGTH_TESSELLATION)
|
|
tf = EdgeLengthBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, GetObjectToWorldMatrix(), cameraPos, _ScreenParams );
|
|
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
|
tf = EdgeLengthBasedTessCull(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), cameraPos, _ScreenParams, _FrustumPlanes );
|
|
#endif
|
|
o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
|
|
return o;
|
|
}
|
|
|
|
[domain("tri")]
|
|
[partitioning("fractional_odd")]
|
|
[outputtopology("triangle_cw")]
|
|
[patchconstantfunc("TessellationFunction")]
|
|
[outputcontrolpoints(3)]
|
|
VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
|
|
{
|
|
return patch[id];
|
|
}
|
|
|
|
[domain("tri")]
|
|
VertexOutput DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
|
{
|
|
VertexInput o = (VertexInput) 0;
|
|
o.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
|
|
o.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
|
|
/*ase_domain_code:patch=VertexControl;o=VertexInput;bary=SV_DomainLocation*/
|
|
#if defined(ASE_PHONG_TESSELLATION)
|
|
float3 pp[3];
|
|
for (int i = 0; i < 3; ++i)
|
|
pp[i] = o.positionOS.xyz - patch[i].normalOS * (dot(o.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
|
|
float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/;
|
|
o.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.positionOS.xyz;
|
|
#endif
|
|
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
|
return VertexFunction(o);
|
|
}
|
|
#else
|
|
VertexOutput Vert ( VertexInput v )
|
|
{
|
|
return VertexFunction( v );
|
|
}
|
|
#endif
|
|
|
|
void Frag( VertexOutput packedInput
|
|
#ifdef WRITE_MSAA_DEPTH
|
|
, out float4 depthColor : SV_Target0
|
|
#ifdef WRITE_NORMAL_BUFFER
|
|
, out float4 outNormalBuffer : SV_Target1
|
|
#endif
|
|
#else
|
|
#ifdef WRITE_NORMAL_BUFFER
|
|
, out float4 outNormalBuffer : SV_Target0
|
|
#endif
|
|
#endif
|
|
#if defined(_DEPTHOFFSET_ON) && !defined(SCENEPICKINGPASS)
|
|
, out float outputDepth : DEPTH_OFFSET_SEMANTIC
|
|
#endif
|
|
/*ase_frag_input*/
|
|
)
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID( packedInput );
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( packedInput );
|
|
FragInputs input;
|
|
ZERO_INITIALIZE(FragInputs, input);
|
|
|
|
input.tangentToWorld = k_identity3x3;
|
|
input.positionSS = packedInput.positionCS;
|
|
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS);
|
|
|
|
float3 V = float3( 1.0, 1.0, 1.0 );
|
|
|
|
SurfaceDescription surfaceDescription = (SurfaceDescription)0;
|
|
/*ase_frag_code:packedInput=VertexOutput*/
|
|
surfaceDescription.Alpha = /*ase_frag_out:Alpha;Float;0;-1;_Alpha*/1/*end*/;
|
|
surfaceDescription.AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;1;-1;_AlphaClip*/_AlphaCutoff/*end*/;
|
|
|
|
SurfaceData surfaceData;
|
|
BuiltinData builtinData;
|
|
GetSurfaceAndBuiltinData(surfaceDescription, input, V, posInput, surfaceData, builtinData);
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
outputDepth = posInput.deviceDepth;
|
|
#endif
|
|
|
|
#ifdef WRITE_MSAA_DEPTH
|
|
depthColor = packedInput.positionCS.z;
|
|
#ifdef _ALPHATOMASK_ON
|
|
depthColor.a = SharpenAlpha(builtinData.opacity, builtinData.alphaClipTreshold);
|
|
#endif
|
|
#endif
|
|
|
|
#if defined(WRITE_NORMAL_BUFFER)
|
|
EncodeIntoNormalBuffer(ConvertSurfaceDataToNormalData(surfaceData), outNormalBuffer);
|
|
#endif
|
|
}
|
|
|
|
ENDHLSL
|
|
}
|
|
|
|
/*ase_pass*/
|
|
Pass
|
|
{
|
|
/*ase_hide_pass*/
|
|
Name "Motion Vectors"
|
|
Tags { "LightMode" = "MotionVectors" }
|
|
|
|
Cull [_CullMode]
|
|
|
|
ZWrite On
|
|
|
|
Stencil
|
|
{
|
|
WriteMask [_StencilWriteMaskMV]
|
|
Ref [_StencilRefMV]
|
|
Comp Always
|
|
Pass Replace
|
|
}
|
|
|
|
HLSLPROGRAM
|
|
#define SHADERPASS SHADERPASS_MOTION_VECTORS
|
|
#pragma multi_compile _ WRITE_MSAA_DEPTH
|
|
|
|
#pragma shader_feature _SURFACE_TYPE_TRANSPARENT
|
|
#pragma shader_feature_local _BLENDMODE_OFF _BLENDMODE_ALPHA _BLENDMODE_ADD _BLENDMODE_PRE_MULTIPLY
|
|
#pragma shader_feature_local _ _ADD_PRECOMPUTED_VELOCITY
|
|
#pragma shader_feature_local _ _TRANSPARENT_WRITES_MOTION_VEC
|
|
#pragma shader_feature_local _ALPHATEST_ON
|
|
#pragma shader_feature_local _ENABLE_FOG_ON_TRANSPARENT
|
|
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/GeometricTools.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Tessellation.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphHeader.hlsl"
|
|
|
|
#if defined(_TRANSPARENT_WRITES_MOTION_VEC) && defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define _WRITE_TRANSPARENT_MOTION_VECTOR
|
|
#endif
|
|
|
|
CBUFFER_START( UnityPerMaterial )
|
|
float4 _EmissionColor;
|
|
float _RenderQueueType;
|
|
#ifdef _ADD_PRECOMPUTED_VELOCITY
|
|
float _AddPrecomputedVelocity;
|
|
#endif
|
|
#ifdef _ENABLE_SHADOW_MATTE
|
|
float _ShadowMatteFilter;
|
|
#endif
|
|
float _StencilRef;
|
|
float _StencilWriteMask;
|
|
float _StencilRefDepth;
|
|
float _StencilWriteMaskDepth;
|
|
float _StencilRefMV;
|
|
float _StencilWriteMaskMV;
|
|
float _StencilRefDistortionVec;
|
|
float _StencilWriteMaskDistortionVec;
|
|
float _StencilWriteMaskGBuffer;
|
|
float _StencilRefGBuffer;
|
|
float _ZTestGBuffer;
|
|
float _RequireSplitLighting;
|
|
float _ReceivesSSR;
|
|
float _SurfaceType;
|
|
float _BlendMode;
|
|
float _SrcBlend;
|
|
float _DstBlend;
|
|
float _AlphaSrcBlend;
|
|
float _AlphaDstBlend;
|
|
float _ZWrite;
|
|
float _TransparentZWrite;
|
|
float _CullMode;
|
|
float _TransparentSortPriority;
|
|
float _EnableFogOnTransparent;
|
|
float _CullModeForward;
|
|
float _TransparentCullMode;
|
|
float _ZTestDepthEqualForOpaque;
|
|
float _ZTestTransparent;
|
|
float _TransparentBackfaceEnable;
|
|
float _AlphaCutoffEnable;
|
|
float _AlphaCutoff;
|
|
float _UseShadowThreshold;
|
|
float _DoubleSidedEnable;
|
|
float _DoubleSidedNormalMode;
|
|
float4 _DoubleSidedConstants;
|
|
float _EnableBlendModePreserveSpecularLighting;
|
|
#ifdef TESSELLATION_ON
|
|
float _TessPhongStrength;
|
|
float _TessValue;
|
|
float _TessMin;
|
|
float _TessMax;
|
|
float _TessEdgeLength;
|
|
float _TessMaxDisp;
|
|
#endif
|
|
CBUFFER_END
|
|
/*ase_globals*/
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/Unlit.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
|
|
/*ase_pragma*/
|
|
|
|
struct VertexInput
|
|
{
|
|
float3 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
float3 previousPositionOS : TEXCOORD4;
|
|
#if defined (_ADD_PRECOMPUTED_VELOCITY)
|
|
float3 precomputedVelocity : TEXCOORD5;
|
|
#endif
|
|
/*ase_vdata:p=p;n=n;uv4=tc4;uv5=tc5*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct VertexOutput
|
|
{
|
|
float4 vmeshPositionCS : SV_Position;
|
|
float3 vmeshInterp00 : TEXCOORD0;
|
|
float3 vpassInterpolators0 : TEXCOORD1; //interpolators0
|
|
float3 vpassInterpolators1 : TEXCOORD2; //interpolators1
|
|
/*ase_interp(3,):sp=sp.xyzw*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
/*ase_funcs*/
|
|
|
|
struct SurfaceDescription
|
|
{
|
|
float Alpha;
|
|
float AlphaClipThreshold;
|
|
};
|
|
|
|
void BuildSurfaceData(FragInputs fragInputs, SurfaceDescription surfaceDescription, float3 V, out SurfaceData surfaceData)
|
|
{
|
|
ZERO_INITIALIZE(SurfaceData, surfaceData);
|
|
#ifdef WRITE_NORMAL_BUFFER
|
|
surfaceData.normalWS = fragInputs.tangentToWorld[2];
|
|
#endif
|
|
}
|
|
|
|
void GetSurfaceAndBuiltinData(SurfaceDescription surfaceDescription, FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
|
|
{
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
LODDitheringTransition(ComputeFadeMaskSeed(V, posInput.positionSS), unity_LODFade.x);
|
|
#endif
|
|
|
|
#if _ALPHATEST_ON
|
|
DoAlphaTest ( surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold );
|
|
#endif
|
|
|
|
#if _DEPTHOFFSET_ON
|
|
ApplyDepthOffsetPositionInput(V, surfaceDescription.DepthOffset, GetViewForwardDir(), GetWorldToHClipMatrix(), posInput);
|
|
#endif
|
|
|
|
BuildSurfaceData(fragInputs, surfaceDescription, V, surfaceData);
|
|
ZERO_INITIALIZE(BuiltinData, builtinData);
|
|
builtinData.opacity = surfaceDescription.Alpha;
|
|
|
|
#if defined(DEBUG_DISPLAY)
|
|
builtinData.renderingLayers = GetMeshRenderingLightLayer();
|
|
#endif
|
|
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
builtinData.alphaClipTreshold = surfaceDescription.AlphaClipThreshold;
|
|
#endif
|
|
|
|
|
|
#if _DEPTHOFFSET_ON
|
|
builtinData.depthOffset = surfaceDescription.DepthOffset;
|
|
#endif
|
|
|
|
ApplyDebugToBuiltinData(builtinData);
|
|
}
|
|
|
|
VertexInput ApplyMeshModification(VertexInput inputMesh, float3 timeParameters, inout VertexOutput o/*ase_vert_input*/ )
|
|
{
|
|
_TimeParameters.xyz = timeParameters;
|
|
/*ase_vert_code:inputMesh=VertexInput;o=VertexOutput*/
|
|
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = inputMesh.positionOS.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3( 0, 0, 0 );
|
|
#endif
|
|
float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;2;-1;_VertexOffset*/ defaultVertexValue /*end*/;
|
|
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
inputMesh.positionOS.xyz = vertexValue;
|
|
#else
|
|
inputMesh.positionOS.xyz += vertexValue;
|
|
#endif
|
|
inputMesh.normalOS = /*ase_vert_out:Vertex Normal;Float3;3;-1;_VertexNormal*/ inputMesh.normalOS /*end*/;
|
|
return inputMesh;
|
|
}
|
|
|
|
VertexOutput VertexFunction(VertexInput inputMesh)
|
|
{
|
|
VertexOutput o = (VertexOutput)0;
|
|
VertexInput defaultMesh = inputMesh;
|
|
|
|
UNITY_SETUP_INSTANCE_ID(inputMesh);
|
|
UNITY_TRANSFER_INSTANCE_ID(inputMesh, o);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o );
|
|
|
|
inputMesh = ApplyMeshModification( inputMesh, _TimeParameters.xyz, o);
|
|
|
|
float3 positionRWS = TransformObjectToWorld(inputMesh.positionOS);
|
|
float3 normalWS = TransformObjectToWorldNormal(inputMesh.normalOS);
|
|
|
|
float3 VMESHpositionRWS = positionRWS;
|
|
float4 VMESHpositionCS = TransformWorldToHClip(positionRWS);
|
|
|
|
//#if defined(UNITY_REVERSED_Z)
|
|
// VMESHpositionCS.z -= unity_MotionVectorsParams.z * VMESHpositionCS.w;
|
|
//#else
|
|
// VMESHpositionCS.z += unity_MotionVectorsParams.z * VMESHpositionCS.w;
|
|
//#endif
|
|
|
|
float4 VPASSpreviousPositionCS;
|
|
float4 VPASSpositionCS = mul(UNITY_MATRIX_UNJITTERED_VP, float4(VMESHpositionRWS, 1.0));
|
|
|
|
bool forceNoMotion = unity_MotionVectorsParams.y == 0.0;
|
|
if (forceNoMotion)
|
|
{
|
|
VPASSpreviousPositionCS = float4(0.0, 0.0, 0.0, 1.0);
|
|
}
|
|
else
|
|
{
|
|
bool hasDeformation = unity_MotionVectorsParams.x > 0.0;
|
|
float3 effectivePositionOS = (hasDeformation ? inputMesh.previousPositionOS : defaultMesh.positionOS);
|
|
#if defined(_ADD_PRECOMPUTED_VELOCITY)
|
|
effectivePositionOS -= inputMesh.precomputedVelocity;
|
|
#endif
|
|
|
|
#if defined(HAVE_MESH_MODIFICATION)
|
|
VertexInput previousMesh = defaultMesh;
|
|
previousMesh.positionOS = effectivePositionOS ;
|
|
VertexOutput test = (VertexOutput)0;
|
|
float3 curTime = _TimeParameters.xyz;
|
|
previousMesh = ApplyMeshModification(previousMesh, _LastTimeParameters.xyz, test);
|
|
_TimeParameters.xyz = curTime;
|
|
float3 previousPositionRWS = TransformPreviousObjectToWorld(previousMesh.positionOS);
|
|
#else
|
|
float3 previousPositionRWS = TransformPreviousObjectToWorld(effectivePositionOS);
|
|
#endif
|
|
|
|
#ifdef ATTRIBUTES_NEED_NORMAL
|
|
float3 normalWS = TransformPreviousObjectToWorldNormal(defaultMesh.normalOS);
|
|
#else
|
|
float3 normalWS = float3(0.0, 0.0, 0.0);
|
|
#endif
|
|
|
|
#if defined(HAVE_VERTEX_MODIFICATION)
|
|
//ApplyVertexModification(inputMesh, normalWS, previousPositionRWS, _LastTimeParameters.xyz);
|
|
#endif
|
|
|
|
VPASSpreviousPositionCS = mul(UNITY_MATRIX_PREV_VP, float4(previousPositionRWS, 1.0));
|
|
}
|
|
|
|
o.vmeshPositionCS = VMESHpositionCS;
|
|
o.vmeshInterp00.xyz = VMESHpositionRWS;
|
|
|
|
o.vpassInterpolators0 = float3(VPASSpositionCS.xyw);
|
|
o.vpassInterpolators1 = float3(VPASSpreviousPositionCS.xyw);
|
|
return o;
|
|
}
|
|
|
|
#if defined(TESSELLATION_ON)
|
|
struct VertexControl
|
|
{
|
|
float3 positionOS : INTERNALTESSPOS;
|
|
float3 normalOS : NORMAL;
|
|
float3 previousPositionOS : TEXCOORD4;
|
|
#if defined (_ADD_PRECOMPUTED_VELOCITY)
|
|
float3 precomputedVelocity : TEXCOORD5;
|
|
#endif
|
|
/*ase_vcontrol*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct TessellationFactors
|
|
{
|
|
float edge[3] : SV_TessFactor;
|
|
float inside : SV_InsideTessFactor;
|
|
};
|
|
|
|
VertexControl Vert ( VertexInput v )
|
|
{
|
|
VertexControl o;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
o.positionOS = v.positionOS;
|
|
o.normalOS = v.normalOS;
|
|
o.previousPositionOS = v.previousPositionOS;
|
|
#if defined (_ADD_PRECOMPUTED_VELOCITY)
|
|
o.precomputedVelocity = v.precomputedVelocity;
|
|
#endif
|
|
/*ase_control_code:v=VertexInput;o=VertexControl*/
|
|
return o;
|
|
}
|
|
|
|
TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
|
|
{
|
|
TessellationFactors o;
|
|
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 (SHADEROPTIONS_CAMERA_RELATIVE_RENDERING != 0)
|
|
float3 cameraPos = 0;
|
|
#else
|
|
float3 cameraPos = _WorldSpaceCameraPos;
|
|
#endif
|
|
#if defined(ASE_FIXED_TESSELLATION)
|
|
tf = FixedTess( tessValue );
|
|
#elif defined(ASE_DISTANCE_TESSELLATION)
|
|
tf = DistanceBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), cameraPos );
|
|
#elif defined(ASE_LENGTH_TESSELLATION)
|
|
tf = EdgeLengthBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, GetObjectToWorldMatrix(), cameraPos, _ScreenParams );
|
|
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
|
tf = EdgeLengthBasedTessCull(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), cameraPos, _ScreenParams, _FrustumPlanes );
|
|
#endif
|
|
o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
|
|
return o;
|
|
}
|
|
|
|
[domain("tri")]
|
|
[partitioning("fractional_odd")]
|
|
[outputtopology("triangle_cw")]
|
|
[patchconstantfunc("TessellationFunction")]
|
|
[outputcontrolpoints(3)]
|
|
VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
|
|
{
|
|
return patch[id];
|
|
}
|
|
|
|
[domain("tri")]
|
|
VertexOutput DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
|
{
|
|
VertexInput o = (VertexInput) 0;
|
|
o.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
|
|
o.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
|
|
o.previousPositionOS = patch[0].previousPositionOS * bary.x + patch[1].previousPositionOS * bary.y + patch[2].previousPositionOS * bary.z;
|
|
#if defined (_ADD_PRECOMPUTED_VELOCITY)
|
|
o.precomputedVelocity = patch[0].precomputedVelocity * bary.x + patch[1].precomputedVelocity * bary.y + patch[2].precomputedVelocity * bary.z;
|
|
#endif
|
|
/*ase_domain_code:patch=VertexControl;o=VertexInput;bary=SV_DomainLocation*/
|
|
#if defined(ASE_PHONG_TESSELLATION)
|
|
float3 pp[3];
|
|
for (int i = 0; i < 3; ++i)
|
|
pp[i] = o.positionOS.xyz - patch[i].normalOS * (dot(o.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
|
|
float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/;
|
|
o.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.positionOS.xyz;
|
|
#endif
|
|
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
|
return VertexFunction(o);
|
|
}
|
|
#else
|
|
VertexOutput Vert ( VertexInput v )
|
|
{
|
|
return VertexFunction( v );
|
|
}
|
|
#endif
|
|
|
|
void Frag( VertexOutput packedInput
|
|
#ifdef WRITE_MSAA_DEPTH
|
|
, out float4 depthColor : SV_Target0
|
|
, out float4 outMotionVector : SV_Target1
|
|
#ifdef WRITE_DECAL_BUFFER
|
|
, out float4 outDecalBuffer : SV_Target2
|
|
#endif
|
|
#else
|
|
, out float4 outMotionVector : SV_Target0
|
|
#ifdef WRITE_DECAL_BUFFER
|
|
, out float4 outDecalBuffer : SV_Target1
|
|
#endif
|
|
#endif
|
|
|
|
#ifdef WRITE_NORMAL_BUFFER
|
|
, out float4 outNormalBuffer : SV_TARGET_NORMAL
|
|
#endif
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
, out float outputDepth : DEPTH_OFFSET_SEMANTIC
|
|
#endif
|
|
/*ase_frag_input*/
|
|
)
|
|
{
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( packedInput );
|
|
UNITY_SETUP_INSTANCE_ID( packedInput );
|
|
FragInputs input;
|
|
ZERO_INITIALIZE(FragInputs, input);
|
|
input.tangentToWorld = k_identity3x3;
|
|
input.positionSS = packedInput.vmeshPositionCS;
|
|
input.positionRWS = packedInput.vmeshInterp00.xyz;
|
|
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS);
|
|
|
|
/*ase_local_var:wvd*/float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS);
|
|
|
|
SurfaceDescription surfaceDescription = (SurfaceDescription)0;
|
|
/*ase_frag_code:packedInput=VertexOutput*/
|
|
surfaceDescription.Alpha = /*ase_frag_out:Alpha;Float;0;-1;_Alpha*/1/*end*/;
|
|
surfaceDescription.AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;1;-1;_AlphaClip*/_AlphaCutoff/*end*/;
|
|
|
|
SurfaceData surfaceData;
|
|
BuiltinData builtinData;
|
|
GetSurfaceAndBuiltinData(surfaceDescription, input, V, posInput, surfaceData, builtinData);
|
|
|
|
float4 VPASSpositionCS = float4(packedInput.vpassInterpolators0.xy, 0.0, packedInput.vpassInterpolators0.z);
|
|
float4 VPASSpreviousPositionCS = float4(packedInput.vpassInterpolators1.xy, 0.0, packedInput.vpassInterpolators1.z);
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
VPASSpositionCS.w += builtinData.depthOffset;
|
|
VPASSpreviousPositionCS.w += builtinData.depthOffset;
|
|
#endif
|
|
|
|
float2 motionVector = CalculateMotionVector( VPASSpositionCS, VPASSpreviousPositionCS );
|
|
EncodeMotionVector( motionVector * 0.5, outMotionVector );
|
|
|
|
bool forceNoMotion = unity_MotionVectorsParams.y == 0.0;
|
|
if( forceNoMotion )
|
|
outMotionVector = float4( 2.0, 0.0, 0.0, 0.0 );
|
|
|
|
#ifdef WRITE_MSAA_DEPTH
|
|
depthColor = packedInput.vmeshPositionCS.z;
|
|
#ifdef _ALPHATOMASK_ON
|
|
depthColor.a = SharpenAlpha(builtinData.opacity, builtinData.alphaClipTreshold);
|
|
#endif
|
|
#endif
|
|
|
|
#ifdef WRITE_NORMAL_BUFFER
|
|
EncodeIntoNormalBuffer(ConvertSurfaceDataToNormalData(surfaceData), outNormalBuffer);
|
|
#endif
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
outputDepth = posInput.deviceDepth;
|
|
#endif
|
|
}
|
|
|
|
ENDHLSL
|
|
}
|
|
|
|
/*ase_pass*/
|
|
Pass
|
|
{
|
|
/*ase_hide_pass*/
|
|
Name "DistortionVectors"
|
|
Tags { "LightMode" = "DistortionVectors" }
|
|
|
|
Blend One One, One One
|
|
BlendOp Add, Add
|
|
|
|
Cull [_CullMode]
|
|
ZTest LEqual
|
|
ZWrite Off
|
|
|
|
Stencil
|
|
{
|
|
WriteMask [_StencilWriteMaskDistortionVec]
|
|
Ref [_StencilRefDistortionVec]
|
|
Comp Always
|
|
Pass Replace
|
|
}
|
|
|
|
HLSLPROGRAM
|
|
#define SHADERPASS SHADERPASS_DISTORTION
|
|
|
|
#pragma shader_feature _ _SURFACE_TYPE_TRANSPARENT
|
|
#pragma shader_feature_local _BLENDMODE_OFF _BLENDMODE_ALPHA _BLENDMODE_ADD _BLENDMODE_PRE_MULTIPLY
|
|
#pragma shader_feature_local _ _ADD_PRECOMPUTED_VELOCITY
|
|
#pragma shader_feature_local _ _TRANSPARENT_WRITES_MOTION_VEC
|
|
#pragma shader_feature_local_fragment _ _ENABLE_FOG_ON_TRANSPARENT
|
|
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/GeometricTools.hlsl" // Required by Tessellation.hlsl
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Tessellation.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl" // Required to be include before we include properties as it define DECLARE_STACK_CB
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphHeader.hlsl" // Need to be here for Gradient struct definition
|
|
|
|
#define SHADER_UNLIT
|
|
|
|
CBUFFER_START( UnityPerMaterial )
|
|
float4 _EmissionColor;
|
|
float _RenderQueueType;
|
|
#ifdef _ADD_PRECOMPUTED_VELOCITY
|
|
float _AddPrecomputedVelocity;
|
|
#endif
|
|
#ifdef _ENABLE_SHADOW_MATTE
|
|
float _ShadowMatteFilter;
|
|
#endif
|
|
float _StencilRef;
|
|
float _StencilWriteMask;
|
|
float _StencilRefDepth;
|
|
float _StencilWriteMaskDepth;
|
|
float _StencilRefMV;
|
|
float _StencilWriteMaskMV;
|
|
float _StencilRefDistortionVec;
|
|
float _StencilWriteMaskDistortionVec;
|
|
float _StencilWriteMaskGBuffer;
|
|
float _StencilRefGBuffer;
|
|
float _ZTestGBuffer;
|
|
float _RequireSplitLighting;
|
|
float _ReceivesSSR;
|
|
float _SurfaceType;
|
|
float _BlendMode;
|
|
float _SrcBlend;
|
|
float _DstBlend;
|
|
float _AlphaSrcBlend;
|
|
float _AlphaDstBlend;
|
|
float _ZWrite;
|
|
float _TransparentZWrite;
|
|
float _CullMode;
|
|
float _TransparentSortPriority;
|
|
float _EnableFogOnTransparent;
|
|
float _CullModeForward;
|
|
float _TransparentCullMode;
|
|
float _ZTestDepthEqualForOpaque;
|
|
float _ZTestTransparent;
|
|
float _TransparentBackfaceEnable;
|
|
float _AlphaCutoffEnable;
|
|
float _AlphaCutoff;
|
|
float _UseShadowThreshold;
|
|
float _DoubleSidedEnable;
|
|
float _DoubleSidedNormalMode;
|
|
float4 _DoubleSidedConstants;
|
|
#ifdef TESSELLATION_ON
|
|
float _TessPhongStrength;
|
|
float _TessValue;
|
|
float _TessMin;
|
|
float _TessMax;
|
|
float _TessEdgeLength;
|
|
float _TessMaxDisp;
|
|
#endif
|
|
CBUFFER_END
|
|
/*ase_globals*/
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/Unlit.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
|
|
/*ase_pragma*/
|
|
|
|
struct VertexInput
|
|
{
|
|
float3 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
/*ase_vdata:p=p;n=n*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct VertexOutput
|
|
{
|
|
float4 positionCS : SV_Position;
|
|
/*ase_interp(0,):sp=sp.xyzw*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
/*ase_funcs*/
|
|
|
|
struct SurfaceDescription
|
|
{
|
|
float Alpha;
|
|
float AlphaClipThreshold;
|
|
float2 Distortion;
|
|
float DistortionBlur;
|
|
};
|
|
|
|
void BuildSurfaceData(FragInputs fragInputs, inout SurfaceDescription surfaceDescription, float3 V, out SurfaceData surfaceData)
|
|
{
|
|
ZERO_INITIALIZE(SurfaceData, surfaceData);
|
|
}
|
|
|
|
void GetSurfaceAndBuiltinData(SurfaceDescription surfaceDescription, FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
|
|
{
|
|
#ifdef _ALPHATEST_ON
|
|
DoAlphaTest( surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold );
|
|
#endif
|
|
|
|
BuildSurfaceData( fragInputs, surfaceDescription, V, surfaceData );
|
|
|
|
ZERO_INITIALIZE( BuiltinData, builtinData );
|
|
builtinData.opacity = surfaceDescription.Alpha;
|
|
|
|
builtinData.distortion = surfaceDescription.Distortion;
|
|
builtinData.distortionBlur = surfaceDescription.DistortionBlur;
|
|
}
|
|
|
|
VertexOutput VertexFunction( VertexInput inputMesh /*ase_vert_input*/ )
|
|
{
|
|
VertexOutput o;
|
|
UNITY_SETUP_INSTANCE_ID(inputMesh);
|
|
UNITY_TRANSFER_INSTANCE_ID(inputMesh, o);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o );
|
|
|
|
/*ase_vert_code:inputMesh=VertexInput;o=VertexOutput*/
|
|
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = inputMesh.positionOS.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3( 0, 0, 0 );
|
|
#endif
|
|
float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;4;-1;_VertexOffset*/ defaultVertexValue /*end*/;
|
|
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
inputMesh.positionOS.xyz = vertexValue;
|
|
#else
|
|
inputMesh.positionOS.xyz += vertexValue;
|
|
#endif
|
|
|
|
inputMesh.normalOS = /*ase_vert_out:Vertex Normal;Float3;5;-1;_VertexNormal*/ inputMesh.normalOS /*end*/;
|
|
float3 positionRWS = TransformObjectToWorld(inputMesh.positionOS);
|
|
|
|
o.positionCS = TransformWorldToHClip(positionRWS);
|
|
return o;
|
|
}
|
|
|
|
#if defined(TESSELLATION_ON)
|
|
struct VertexControl
|
|
{
|
|
float3 positionOS : INTERNALTESSPOS;
|
|
float3 normalOS : NORMAL;
|
|
/*ase_vcontrol*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct TessellationFactors
|
|
{
|
|
float edge[3] : SV_TessFactor;
|
|
float inside : SV_InsideTessFactor;
|
|
};
|
|
|
|
VertexControl Vert ( VertexInput v )
|
|
{
|
|
VertexControl o;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
o.positionOS = v.positionOS;
|
|
o.normalOS = v.normalOS;
|
|
/*ase_control_code:v=VertexInput;o=VertexControl*/
|
|
return o;
|
|
}
|
|
|
|
TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
|
|
{
|
|
TessellationFactors o;
|
|
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 (SHADEROPTIONS_CAMERA_RELATIVE_RENDERING != 0)
|
|
float3 cameraPos = 0;
|
|
#else
|
|
float3 cameraPos = _WorldSpaceCameraPos;
|
|
#endif
|
|
#if defined(ASE_FIXED_TESSELLATION)
|
|
tf = FixedTess( tessValue );
|
|
#elif defined(ASE_DISTANCE_TESSELLATION)
|
|
tf = DistanceBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), cameraPos );
|
|
#elif defined(ASE_LENGTH_TESSELLATION)
|
|
tf = EdgeLengthBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, GetObjectToWorldMatrix(), cameraPos, _ScreenParams );
|
|
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
|
tf = EdgeLengthBasedTessCull(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), cameraPos, _ScreenParams, _FrustumPlanes );
|
|
#endif
|
|
o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
|
|
return o;
|
|
}
|
|
|
|
[domain("tri")]
|
|
[partitioning("fractional_odd")]
|
|
[outputtopology("triangle_cw")]
|
|
[patchconstantfunc("TessellationFunction")]
|
|
[outputcontrolpoints(3)]
|
|
VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
|
|
{
|
|
return patch[id];
|
|
}
|
|
|
|
[domain("tri")]
|
|
VertexOutput DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
|
{
|
|
VertexInput o = (VertexInput) 0;
|
|
o.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
|
|
o.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
|
|
/*ase_domain_code:patch=VertexControl;o=VertexInput;bary=SV_DomainLocation*/
|
|
#if defined(ASE_PHONG_TESSELLATION)
|
|
float3 pp[3];
|
|
for (int i = 0; i < 3; ++i)
|
|
pp[i] = o.positionOS.xyz - patch[i].normalOS * (dot(o.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
|
|
float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/;
|
|
o.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.positionOS.xyz;
|
|
#endif
|
|
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
|
return VertexFunction(o);
|
|
}
|
|
#else
|
|
VertexOutput Vert ( VertexInput v )
|
|
{
|
|
return VertexFunction( v );
|
|
}
|
|
#endif
|
|
|
|
float4 Frag( VertexOutput packedInput /*ase_frag_input*/ ) : SV_Target
|
|
{
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( packedInput );
|
|
UNITY_SETUP_INSTANCE_ID( packedInput );
|
|
FragInputs input;
|
|
ZERO_INITIALIZE(FragInputs, input);
|
|
input.tangentToWorld = k_identity3x3;
|
|
input.positionSS = packedInput.positionCS;
|
|
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS);
|
|
float3 V = float3( 1.0, 1.0, 1.0 );
|
|
SurfaceData surfaceData;
|
|
BuiltinData builtinData;
|
|
|
|
SurfaceDescription surfaceDescription = (SurfaceDescription)0;
|
|
/*ase_frag_code:packedInput=VertexOutput*/
|
|
surfaceDescription.Alpha = /*ase_frag_out:Alpha;Float;0;-1;_Alpha*/1/*end*/;
|
|
surfaceDescription.AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;1;-1;_AlphaClip*/_AlphaCutoff/*end*/;
|
|
|
|
surfaceDescription.Distortion = /*ase_frag_out:Distortion;Float2;2;-1;_Distortion*/float2 (0,0)/*end*/;
|
|
surfaceDescription.DistortionBlur = /*ase_frag_out:Distortion Blur;Float;3;-1;_DistortionBlur*/0/*end*/;
|
|
|
|
GetSurfaceAndBuiltinData(surfaceDescription, input, V, posInput, surfaceData, builtinData);
|
|
|
|
float4 outBuffer;
|
|
EncodeDistortion( builtinData.distortion, builtinData.distortionBlur, true, outBuffer );
|
|
return outBuffer;
|
|
}
|
|
ENDHLSL
|
|
}
|
|
|
|
/*ase_pass*/
|
|
Pass
|
|
{
|
|
/*ase_hide_pass*/
|
|
Name "ScenePickingPass"
|
|
Tags
|
|
{
|
|
"LightMode" = "Picking"
|
|
}
|
|
|
|
Cull [_CullMode]
|
|
|
|
HLSLPROGRAM
|
|
|
|
#pragma editor_sync_compilation
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
|
|
#pragma shader_feature _ _SURFACE_TYPE_TRANSPARENT
|
|
#pragma shader_feature_local _BLENDMODE_OFF _BLENDMODE_ALPHA _BLENDMODE_ADD _BLENDMODE_PRE_MULTIPLY
|
|
#pragma shader_feature_local _ _ADD_PRECOMPUTED_VELOCITY
|
|
#pragma shader_feature_local _ _TRANSPARENT_WRITES_MOTION_VEC
|
|
#pragma shader_feature_local_fragment _ _ENABLE_FOG_ON_TRANSPARENT
|
|
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/GeometricTools.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Tessellation.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphHeader.hlsl"
|
|
|
|
#define ATTRIBUTES_NEED_NORMAL
|
|
#define ATTRIBUTES_NEED_TANGENT
|
|
#define VARYINGS_NEED_TANGENT_TO_WORLD
|
|
|
|
|
|
#define SHADERPASS SHADERPASS_DEPTH_ONLY
|
|
#define SCENEPICKINGPASS 1
|
|
|
|
|
|
#define SHADER_UNLIT
|
|
|
|
|
|
#if defined(_TRANSPARENT_WRITES_MOTION_VEC) && defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define _WRITE_TRANSPARENT_MOTION_VECTOR
|
|
#endif
|
|
|
|
float4 _SelectionID;
|
|
|
|
CBUFFER_START( UnityPerMaterial )
|
|
float4 _EmissionColor;
|
|
float _RenderQueueType;
|
|
#ifdef _ADD_PRECOMPUTED_VELOCITY
|
|
float _AddPrecomputedVelocity;
|
|
#endif
|
|
#ifdef _ENABLE_SHADOW_MATTE
|
|
float _ShadowMatteFilter;
|
|
#endif
|
|
float _StencilRef;
|
|
float _StencilWriteMask;
|
|
float _StencilRefDepth;
|
|
float _StencilWriteMaskDepth;
|
|
float _StencilRefMV;
|
|
float _StencilWriteMaskMV;
|
|
float _StencilRefDistortionVec;
|
|
float _StencilWriteMaskDistortionVec;
|
|
float _StencilWriteMaskGBuffer;
|
|
float _StencilRefGBuffer;
|
|
float _ZTestGBuffer;
|
|
float _RequireSplitLighting;
|
|
float _ReceivesSSR;
|
|
float _SurfaceType;
|
|
float _BlendMode;
|
|
float _SrcBlend;
|
|
float _DstBlend;
|
|
float _AlphaSrcBlend;
|
|
float _AlphaDstBlend;
|
|
float _ZWrite;
|
|
float _TransparentZWrite;
|
|
float _CullMode;
|
|
float _TransparentSortPriority;
|
|
float _EnableFogOnTransparent;
|
|
float _CullModeForward;
|
|
float _TransparentCullMode;
|
|
float _ZTestDepthEqualForOpaque;
|
|
float _ZTestTransparent;
|
|
float _TransparentBackfaceEnable;
|
|
float _AlphaCutoffEnable;
|
|
float _AlphaCutoff;
|
|
float _UseShadowThreshold;
|
|
float _DoubleSidedEnable;
|
|
float _DoubleSidedNormalMode;
|
|
float4 _DoubleSidedConstants;
|
|
float _EnableBlendModePreserveSpecularLighting;
|
|
#ifdef TESSELLATION_ON
|
|
float _TessPhongStrength;
|
|
float _TessValue;
|
|
float _TessMin;
|
|
float _TessMax;
|
|
float _TessEdgeLength;
|
|
float _TessMaxDisp;
|
|
#endif
|
|
CBUFFER_END
|
|
/*ase_globals*/
|
|
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/PickingSpaceTransforms.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/Unlit.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
|
|
|
|
/*ase_pragma*/
|
|
|
|
struct VertexInput
|
|
{
|
|
float3 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
float4 tangentOS : TANGENT;
|
|
/*ase_vdata:p=p;n=n;t=t*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct VertexOutput
|
|
{
|
|
float4 positionCS : SV_POSITION;
|
|
float3 normalWS : TEXCOORD0;
|
|
float4 tangentWS : TEXCOORD1;
|
|
/*ase_interp(2,):sp=sp.xyzw;wn=tc0;wt=tc1*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
/*ase_funcs*/
|
|
|
|
struct SurfaceDescription
|
|
{
|
|
float Alpha;
|
|
float AlphaClipThreshold;
|
|
};
|
|
|
|
|
|
void GetSurfaceAndBuiltinData(SurfaceDescription surfaceDescription, FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData RAY_TRACING_OPTIONAL_PARAMETERS)
|
|
{
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
LODDitheringTransition(ComputeFadeMaskSeed(V, posInput.positionSS), unity_LODFade.x);
|
|
#endif
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
float alphaCutoff = surfaceDescription.AlphaClipThreshold;
|
|
GENERIC_ALPHA_TEST(surfaceDescription.Alpha, alphaCutoff);
|
|
#endif
|
|
|
|
#if !defined(SHADER_STAGE_RAY_TRACING) && _DEPTHOFFSET_ON
|
|
ApplyDepthOffsetPositionInput(V, surfaceDescription.DepthOffset, GetViewForwardDir(), GetWorldToHClipMatrix(), posInput);
|
|
#endif
|
|
|
|
|
|
ZERO_INITIALIZE(SurfaceData, surfaceData);
|
|
|
|
ZERO_BUILTIN_INITIALIZE(builtinData);
|
|
builtinData.opacity = surfaceDescription.Alpha;
|
|
|
|
#if defined(DEBUG_DISPLAY)
|
|
builtinData.renderingLayers = GetMeshRenderingLightLayer();
|
|
#endif
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
builtinData.alphaClipTreshold = alphaCutoff;
|
|
#endif
|
|
|
|
#if _DEPTHOFFSET_ON
|
|
builtinData.depthOffset = surfaceDescription.DepthOffset;
|
|
#endif
|
|
|
|
|
|
ApplyDebugToBuiltinData(builtinData);
|
|
|
|
}
|
|
|
|
|
|
VertexOutput VertexFunction(VertexInput inputMesh /*ase_vert_input*/ )
|
|
{
|
|
|
|
VertexOutput o;
|
|
ZERO_INITIALIZE(VertexOutput, o);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
|
|
|
UNITY_SETUP_INSTANCE_ID(inputMesh);
|
|
UNITY_TRANSFER_INSTANCE_ID(inputMesh, o );
|
|
|
|
/*ase_vert_code:inputMesh=VertexInput;o=VertexOutput*/
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = inputMesh.positionOS.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3( 0, 0, 0 );
|
|
#endif
|
|
float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;2;-1;_VertexOffset*/ defaultVertexValue /*end*/;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
inputMesh.positionOS.xyz = vertexValue;
|
|
#else
|
|
inputMesh.positionOS.xyz += vertexValue;
|
|
#endif
|
|
|
|
inputMesh.normalOS = /*ase_vert_out:Vertex Normal;Float3;3;-1;_VertexNormal*/ inputMesh.normalOS /*end*/;
|
|
|
|
float3 positionRWS = TransformObjectToWorld(inputMesh.positionOS);
|
|
float3 normalWS = TransformObjectToWorldNormal(inputMesh.normalOS);
|
|
float4 tangentWS = float4(TransformObjectToWorldDir(inputMesh.tangentOS.xyz), inputMesh.tangentOS.w);
|
|
|
|
o.positionCS = TransformWorldToHClip(positionRWS);
|
|
o.normalWS.xyz = normalWS;
|
|
o.tangentWS.xyzw = tangentWS;
|
|
|
|
return o;
|
|
}
|
|
|
|
#if defined(TESSELLATION_ON)
|
|
struct VertexControl
|
|
{
|
|
float3 positionOS : INTERNALTESSPOS;
|
|
float3 normalOS : NORMAL;
|
|
float4 tangentOS : TANGENT;
|
|
/*ase_vcontrol*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct TessellationFactors
|
|
{
|
|
float edge[3] : SV_TessFactor;
|
|
float inside : SV_InsideTessFactor;
|
|
};
|
|
|
|
VertexControl Vert ( VertexInput v )
|
|
{
|
|
VertexControl o;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
o.positionOS = v.positionOS;
|
|
o.normalOS = v.normalOS;
|
|
o.tangentOS = v.tangentOS;
|
|
/*ase_control_code:v=VertexInput;o=VertexControl*/
|
|
return o;
|
|
}
|
|
|
|
TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
|
|
{
|
|
TessellationFactors o;
|
|
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 (SHADEROPTIONS_CAMERA_RELATIVE_RENDERING != 0)
|
|
float3 cameraPos = 0;
|
|
#else
|
|
float3 cameraPos = _WorldSpaceCameraPos;
|
|
#endif
|
|
#if defined(ASE_FIXED_TESSELLATION)
|
|
tf = FixedTess( tessValue );
|
|
#elif defined(ASE_DISTANCE_TESSELLATION)
|
|
tf = DistanceBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), cameraPos );
|
|
#elif defined(ASE_LENGTH_TESSELLATION)
|
|
tf = EdgeLengthBasedTess(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, GetObjectToWorldMatrix(), cameraPos, _ScreenParams );
|
|
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
|
tf = EdgeLengthBasedTessCull(float4(v[0].positionOS,1), float4(v[1].positionOS,1), float4(v[2].positionOS,1), edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), cameraPos, _ScreenParams, _FrustumPlanes );
|
|
#endif
|
|
o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
|
|
return o;
|
|
}
|
|
|
|
[domain("tri")]
|
|
[partitioning("fractional_odd")]
|
|
[outputtopology("triangle_cw")]
|
|
[patchconstantfunc("TessellationFunction")]
|
|
[outputcontrolpoints(3)]
|
|
VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
|
|
{
|
|
return patch[id];
|
|
}
|
|
|
|
[domain("tri")]
|
|
VertexOutput DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
|
{
|
|
VertexInput o = (VertexInput) 0;
|
|
o.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
|
|
o.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
|
|
o.tangentOS = patch[0].tangentOS * bary.x + patch[1].tangentOS * bary.y + patch[2].tangentOS * bary.z;
|
|
/*ase_domain_code:patch=VertexControl;o=VertexInput;bary=SV_DomainLocation*/
|
|
#if defined(ASE_PHONG_TESSELLATION)
|
|
float3 pp[3];
|
|
for (int i = 0; i < 3; ++i)
|
|
pp[i] = o.positionOS.xyz - patch[i].normalOS * (dot(o.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
|
|
float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/;
|
|
o.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.positionOS.xyz;
|
|
#endif
|
|
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
|
return VertexFunction(o);
|
|
}
|
|
#else
|
|
VertexOutput Vert ( VertexInput v )
|
|
{
|
|
return VertexFunction( v );
|
|
}
|
|
#endif
|
|
|
|
void Frag( VertexOutput packedInput
|
|
, out float4 outColor : SV_Target0
|
|
/*ase_frag_input*/
|
|
)
|
|
{
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(packedInput);
|
|
UNITY_SETUP_INSTANCE_ID(packedInput);
|
|
|
|
FragInputs input;
|
|
ZERO_INITIALIZE(FragInputs, input);
|
|
input.tangentToWorld = k_identity3x3;
|
|
input.positionSS = packedInput.positionCS;
|
|
|
|
input.tangentToWorld = BuildTangentToWorld(packedInput.tangentWS.xyzw, packedInput.normalWS.xyz);
|
|
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS);
|
|
|
|
SurfaceDescription surfaceDescription = (SurfaceDescription)0;
|
|
/*ase_frag_code:packedInput=VertexOutput*/
|
|
surfaceDescription.Alpha = /*ase_frag_out:Alpha;Float;0;-1;_Alpha*/1/*end*/;
|
|
surfaceDescription.AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;1;-1;_AlphaClip*/_AlphaCutoff/*end*/;
|
|
|
|
|
|
float3 V = float3(1.0, 1.0, 1.0);
|
|
|
|
SurfaceData surfaceData;
|
|
BuiltinData builtinData;
|
|
GetSurfaceAndBuiltinData(surfaceDescription, input, V, posInput, surfaceData, builtinData);
|
|
outColor = _SelectionID;
|
|
}
|
|
|
|
ENDHLSL
|
|
}
|
|
|
|
Pass
|
|
{
|
|
Name "FullScreenDebug"
|
|
Tags
|
|
{
|
|
"LightMode" = "FullScreenDebug"
|
|
}
|
|
|
|
Cull [_CullMode]
|
|
ZTest LEqual
|
|
ZWrite Off
|
|
|
|
HLSLPROGRAM
|
|
|
|
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
|
|
#pragma shader_feature _ _SURFACE_TYPE_TRANSPARENT
|
|
#pragma shader_feature_local _BLENDMODE_OFF _BLENDMODE_ALPHA _BLENDMODE_ADD _BLENDMODE_PRE_MULTIPLY
|
|
#pragma shader_feature_local _ _ADD_PRECOMPUTED_VELOCITY
|
|
#pragma shader_feature_local _ _TRANSPARENT_WRITES_MOTION_VEC
|
|
#pragma shader_feature_local_fragment _ _ENABLE_FOG_ON_TRANSPARENT
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/GeometricTools.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Tessellation.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphHeader.hlsl"
|
|
|
|
#define ATTRIBUTES_NEED_NORMAL
|
|
#define ATTRIBUTES_NEED_TANGENT
|
|
|
|
#define SHADERPASS SHADERPASS_FULL_SCREEN_DEBUG
|
|
#define SHADER_UNLIT
|
|
|
|
|
|
#if defined(_TRANSPARENT_WRITES_MOTION_VEC) && defined(_SURFACE_TYPE_TRANSPARENT)
|
|
#define _WRITE_TRANSPARENT_MOTION_VECTOR
|
|
#endif
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/NormalSurfaceGradient.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/Unlit.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
|
|
struct AttributesMesh
|
|
{
|
|
float3 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
float4 tangentOS : TANGENT;
|
|
#if UNITY_ANY_INSTANCING_ENABLED
|
|
uint instanceID : INSTANCEID_SEMANTIC;
|
|
#endif
|
|
};
|
|
|
|
struct VaryingsMeshToPS
|
|
{
|
|
SV_POSITION_QUALIFIERS float4 positionCS : SV_POSITION;
|
|
#if UNITY_ANY_INSTANCING_ENABLED
|
|
uint instanceID : CUSTOM_INSTANCE_ID;
|
|
#endif
|
|
};
|
|
|
|
struct VertexDescriptionInputs
|
|
{
|
|
float3 ObjectSpaceNormal;
|
|
float3 ObjectSpaceTangent;
|
|
float3 ObjectSpacePosition;
|
|
};
|
|
|
|
struct SurfaceDescriptionInputs
|
|
{
|
|
};
|
|
|
|
struct PackedVaryingsMeshToPS
|
|
{
|
|
SV_POSITION_QUALIFIERS float4 positionCS : SV_POSITION;
|
|
#if UNITY_ANY_INSTANCING_ENABLED
|
|
uint instanceID : CUSTOM_INSTANCE_ID;
|
|
#endif
|
|
};
|
|
|
|
PackedVaryingsMeshToPS PackVaryingsMeshToPS (VaryingsMeshToPS input)
|
|
{
|
|
PackedVaryingsMeshToPS output;
|
|
ZERO_INITIALIZE(PackedVaryingsMeshToPS, output);
|
|
output.positionCS = input.positionCS;
|
|
#if UNITY_ANY_INSTANCING_ENABLED
|
|
output.instanceID = input.instanceID;
|
|
#endif
|
|
return output;
|
|
}
|
|
|
|
VaryingsMeshToPS UnpackVaryingsMeshToPS (PackedVaryingsMeshToPS input)
|
|
{
|
|
VaryingsMeshToPS output;
|
|
output.positionCS = input.positionCS;
|
|
#if UNITY_ANY_INSTANCING_ENABLED
|
|
output.instanceID = input.instanceID;
|
|
#endif
|
|
return output;
|
|
}
|
|
|
|
struct VertexDescription
|
|
{
|
|
float3 Position;
|
|
float3 Normal;
|
|
float3 Tangent;
|
|
};
|
|
|
|
VertexDescription VertexDescriptionFunction(VertexDescriptionInputs IN)
|
|
{
|
|
VertexDescription description = (VertexDescription)0;
|
|
description.Position = IN.ObjectSpacePosition;
|
|
description.Normal = IN.ObjectSpaceNormal;
|
|
description.Tangent = IN.ObjectSpaceTangent;
|
|
return description;
|
|
}
|
|
|
|
|
|
struct SurfaceDescription
|
|
{
|
|
float3 BaseColor;
|
|
float3 Emission;
|
|
float Alpha;
|
|
};
|
|
|
|
SurfaceDescription SurfaceDescriptionFunction(SurfaceDescriptionInputs IN)
|
|
{
|
|
SurfaceDescription surface = (SurfaceDescription)0;
|
|
surface.BaseColor = IsGammaSpace() ? float3(0.5, 0.5, 0.5) : SRGBToLinear(float3(0.5, 0.5, 0.5));
|
|
surface.Emission = float3(0, 0, 0);
|
|
surface.Alpha = 1;
|
|
return surface;
|
|
}
|
|
|
|
|
|
|
|
VertexDescriptionInputs AttributesMeshToVertexDescriptionInputs(AttributesMesh input)
|
|
{
|
|
VertexDescriptionInputs output;
|
|
ZERO_INITIALIZE(VertexDescriptionInputs, output);
|
|
output.ObjectSpaceNormal = input.normalOS;
|
|
output.ObjectSpaceTangent = input.tangentOS.xyz;
|
|
output.ObjectSpacePosition = input.positionOS;
|
|
return output;
|
|
}
|
|
|
|
AttributesMesh ApplyMeshModification(AttributesMesh input, float3 timeParameters )
|
|
{
|
|
VertexDescriptionInputs vertexDescriptionInputs = AttributesMeshToVertexDescriptionInputs(input);
|
|
VertexDescription vertexDescription = VertexDescriptionFunction(vertexDescriptionInputs);
|
|
input.positionOS = vertexDescription.Position;
|
|
input.normalOS = vertexDescription.Normal;
|
|
input.tangentOS.xyz = vertexDescription.Tangent;
|
|
return input;
|
|
}
|
|
|
|
FragInputs BuildFragInputs(VaryingsMeshToPS input)
|
|
{
|
|
FragInputs output;
|
|
ZERO_INITIALIZE(FragInputs, output);
|
|
|
|
output.tangentToWorld = k_identity3x3;
|
|
output.positionSS = input.positionCS;
|
|
|
|
return output;
|
|
}
|
|
|
|
|
|
FragInputs UnpackVaryingsMeshToFragInputs(PackedVaryingsMeshToPS input)
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID(input);
|
|
VaryingsMeshToPS unpacked = UnpackVaryingsMeshToPS(input);
|
|
return BuildFragInputs(unpacked);
|
|
}
|
|
SurfaceDescriptionInputs FragInputsToSurfaceDescriptionInputs(FragInputs input, float3 viewWS)
|
|
{
|
|
SurfaceDescriptionInputs output;
|
|
ZERO_INITIALIZE(SurfaceDescriptionInputs, output);
|
|
|
|
|
|
return output;
|
|
}
|
|
|
|
#define DEBUG_DISPLAY
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/FullScreenDebug.hlsl"
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl"
|
|
|
|
PackedVaryingsType Vert(AttributesMesh inputMesh)
|
|
{
|
|
VaryingsType varyingsType;
|
|
varyingsType.vmesh = VertMesh(inputMesh);
|
|
return PackVaryingsType(varyingsType);
|
|
}
|
|
|
|
#if !defined(_DEPTHOFFSET_ON)
|
|
[earlydepthstencil]
|
|
#endif
|
|
void Frag(PackedVaryingsToPS packedInput)
|
|
{
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(packedInput);
|
|
FragInputs input = UnpackVaryingsToFragInputs(packedInput);
|
|
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS.xyz);
|
|
|
|
#ifdef PLATFORM_SUPPORTS_PRIMITIVE_ID_IN_PIXEL_SHADER
|
|
if (_DebugFullScreenMode == FULLSCREENDEBUGMODE_QUAD_OVERDRAW)
|
|
{
|
|
IncrementQuadOverdrawCounter(posInput.positionSS.xy, input.primitiveID);
|
|
}
|
|
#endif
|
|
}
|
|
|
|
ENDHLSL
|
|
}
|
|
/*ase_pass_end*/
|
|
}
|
|
/*ase_lod*/
|
|
CustomEditor "Rendering.HighDefinition.HDUnlitGUI"
|
|
FallBack "Hidden/InternalErrorShader"
|
|
}
|