2303 lines
83 KiB
GLSL
2303 lines
83 KiB
GLSL
Shader /*ase_name*/ "Hidden/Legacy/Lit" /*end*/
|
|
{
|
|
Properties
|
|
{
|
|
/*ase_props*/
|
|
//_TransmissionShadow( "Transmission Shadow", Range( 0, 1 ) ) = 0.5
|
|
//_TransStrength( "Trans Strength", Range( 0, 50 ) ) = 1
|
|
//_TransNormal( "Trans Normal Distortion", Range( 0, 1 ) ) = 0.5
|
|
//_TransScattering( "Trans Scattering", Range( 1, 50 ) ) = 2
|
|
//_TransDirect( "Trans Direct", Range( 0, 1 ) ) = 0.9
|
|
//_TransAmbient( "Trans Ambient", Range( 0, 1 ) ) = 0.1
|
|
//_TransShadow( "Trans Shadow", Range( 0, 1 ) ) = 0.5
|
|
//_TessPhongStrength( "Tess Phong Strength", Range( 0, 1 ) ) = 0.5
|
|
//_TessValue( "Tess Max Tessellation", Range( 1, 32 ) ) = 16
|
|
//_TessMin( "Tess Min Distance", Float ) = 10
|
|
//_TessMax( "Tess Max Distance", Float ) = 25
|
|
//_TessEdgeLength ( "Tess Edge length", Range( 2, 50 ) ) = 16
|
|
//_TessMaxDisp( "Tess Max Displacement", Float ) = 25
|
|
//_SpecularHighlights("Specular Highlights", Float) = 1.0
|
|
//_GlossyReflections("Reflections", Float) = 1.0
|
|
}
|
|
|
|
SubShader
|
|
{
|
|
/*ase_subshader_options:Name=Additional Options
|
|
Option:Workflow,InvertActionOnDeselection:Specular,Metallic:Metallic
|
|
Metallic:ShowPort:Metallic
|
|
Specular:ShowPort:Specular
|
|
Specular:SetDefine:_SPECULAR_SETUP 1
|
|
Option:Surface:Opaque,Transparent:Opaque
|
|
Opaque:SetPropertyOnSubShader:RenderType,Opaque
|
|
Opaque:SetPropertyOnSubShader:RenderQueue,Geometry
|
|
Opaque:SetPropertyOnSubShader:ZWrite,On
|
|
Opaque:HideOption: Blend
|
|
Opaque:HideOption: Dither Shadows
|
|
Opaque:HideOption: Refraction Model
|
|
Transparent:SetPropertyOnSubShader:RenderType,Transparent
|
|
Transparent:SetPropertyOnSubShader:RenderQueue,Transparent
|
|
Transparent:SetPropertyOnSubShader:ZWrite,Off
|
|
Transparent:ShowOption: Blend
|
|
Transparent:ShowOption: Dither Shadows
|
|
Transparent:ShowOption: Refraction Model
|
|
Option: Blend:Alpha,Premultiply,Additive,Multiply,Translucent,Custom:Alpha
|
|
Alpha:SetPropertyOnPass:ForwardBase:BlendRGB,SrcAlpha,OneMinusSrcAlpha
|
|
Alpha:SetPropertyOnPass:ForwardAdd:BlendRGB,SrcAlpha,One
|
|
Alpha:SetDefine:_ALPHABLEND_ON 1
|
|
Premultiply:SetPropertyOnPass:ForwardBase:BlendRGB,One,OneMinusSrcAlpha
|
|
disable,Premultiply,Additive,Multiply,Translucent,Custom:SetPropertyOnPass:ForwardAdd:BlendRGB,One,One
|
|
Premultiply:SetDefine:_ALPHAPREMULTIPLY_ON 1
|
|
Additive:SetPropertyOnPass:ForwardBase:BlendRGB,One,One
|
|
Multiply:SetPropertyOnPass:ForwardBase:BlendRGB,DstColor,Zero
|
|
disable,Premultiply,Additive,Multiply,Translucent,Custom:RemoveDefine:_ALPHABLEND_ON 1
|
|
disable,Alpha,Additive,Multiply,Translucent,Custom:RemoveDefine:_ALPHAPREMULTIPLY_ON 1
|
|
disable,Translucent:SetPropertyOnPass:ForwardBase:BlendRGB,One,Zero
|
|
Option: Refraction Model:None:None
|
|
None,disable:HidePort:ForwardBase:Refraction Index
|
|
None,disable:HidePort:ForwardBase:Refraction Color
|
|
None,disable:RemoveDefine:_REFRACTION_ASE 1
|
|
None,disable:RemoveDefine:ASE_NEEDS_FRAG_SCREEN_POSITION
|
|
Legacy:ShowPort:ForwardBase:Refraction Index
|
|
Legacy:ShowPort:ForwardBase:Refraction Color
|
|
Legacy:SetDefine:_REFRACTION_ASE 1
|
|
Legacy:SetDefine:ASE_NEEDS_FRAG_SCREEN_POSITION
|
|
Option: Dither Shadows:false,true:true
|
|
true:SetDefine:UNITY_STANDARD_USE_DITHER_MASK 1
|
|
false,disable:RemoveDefine:UNITY_STANDARD_USE_DITHER_MASK 1
|
|
Option:Two Sided:On,Cull Back,Cull Front:Cull Back
|
|
On:SetPropertyOnSubShader:CullMode,Off
|
|
Cull Back:SetPropertyOnSubShader:CullMode,Back
|
|
Cull Front:SetPropertyOnSubShader:CullMode,Front
|
|
Option:Deferred Pass:false,true:true
|
|
true:IncludePass:Deferred
|
|
false:ExcludePass:Deferred
|
|
Option:Transmission:false,true:false
|
|
false:RemoveDefine:_TRANSMISSION_ASE 1
|
|
false:HidePort:ForwardBase:Transmission
|
|
false:HideOption: Transmission Shadow
|
|
true:SetDefine:_TRANSMISSION_ASE 1
|
|
true:ShowPort:ForwardBase:Transmission
|
|
true:ShowOption: Transmission Shadow
|
|
true:SetOption:Deferred Pass,0
|
|
Field: Transmission Shadow:Float:0.5:0:1:_TransmissionShadow
|
|
Change:SetMaterialProperty:_TransmissionShadow
|
|
Change:SetShaderProperty:_TransmissionShadow,_TransmissionShadow( "Transmission Shadow", Range( 0, 1 ) ) = 0.5
|
|
Inline,disable:SetShaderProperty:_TransmissionShadow,//_TransmissionShadow( "Transmission Shadow", Range( 0, 1 ) ) = 0.5
|
|
Option:Translucency:false,true:false
|
|
false:RemoveDefine:_TRANSLUCENCY_ASE 1
|
|
false:HidePort:ForwardBase:Translucency
|
|
false:HideOption: Translucency Strength
|
|
false:HideOption: Normal Distortion
|
|
false:HideOption: Scattering
|
|
false:HideOption: Direct
|
|
false:HideOption: Ambient
|
|
false:HideOption: Shadow
|
|
true:SetDefine:_TRANSLUCENCY_ASE 1
|
|
true:ShowPort:ForwardBase:Translucency
|
|
true:ShowOption: Translucency Strength
|
|
true:ShowOption: Normal Distortion
|
|
true:ShowOption: Scattering
|
|
true:ShowOption: Direct
|
|
true:ShowOption: Ambient
|
|
true:ShowOption: Shadow
|
|
true:SetOption:Deferred Pass,0
|
|
Field: Translucency Strength:Float:1:0:50:_TransStrength
|
|
Change:SetMaterialProperty:_TransStrength
|
|
Change:SetShaderProperty:_TransStrength,_TransStrength( "Strength", Range( 0, 50 ) ) = 1
|
|
Inline,disable:SetShaderProperty:_TransStrength,//_TransStrength( "Strength", Range( 0, 50 ) ) = 1
|
|
Field: Normal Distortion:Float:0.5:0:1:_TransNormal
|
|
Change:SetMaterialProperty:_TransNormal
|
|
Change:SetShaderProperty:_TransNormal,_TransNormal( "Normal Distortion", Range( 0, 1 ) ) = 0.5
|
|
Inline,disable:SetShaderProperty:_TransNormal,//_TransNormal( "Normal Distortion", Range( 0, 1 ) ) = 0.5
|
|
Field: Scattering:Float:2:1:50:_TransScattering
|
|
Change:SetMaterialProperty:_TransScattering
|
|
Change:SetShaderProperty:_TransScattering,_TransScattering( "Scattering", Range( 1, 50 ) ) = 2
|
|
Inline,disable:SetShaderProperty:_TransScattering,//_TransScattering( "Scattering", Range( 1, 50 ) ) = 2
|
|
Field: Direct:Float:0.9:0:1:_TransDirect
|
|
Change:SetMaterialProperty:_TransDirect
|
|
Change:SetShaderProperty:_TransDirect,_TransDirect( "Direct", Range( 0, 1 ) ) = 0.9
|
|
Inline,disable:SetShaderProperty:_TransDirect,//_TransDirect( "Direct", Range( 0, 1 ) ) = 0.9
|
|
Field: Ambient:Float:0.1:0:1:_TransAmbient
|
|
Change:SetMaterialProperty:_TransAmbient
|
|
Change:SetShaderProperty:_TransAmbient,_TransAmbient( "Ambient", Range( 0, 1 ) ) = 0.1
|
|
Inline,disable:SetShaderProperty:_TransAmbient,//_TransAmbient( "Ambient", Range( 0, 1 ) ) = 0.1
|
|
Field: Shadow:Float:0.5:0:1:_TransShadow
|
|
Change:SetMaterialProperty:_TransShadow
|
|
Change:SetShaderProperty:_TransShadow,_TransShadow( "Shadow", Range( 0, 1 ) ) = 0.5
|
|
Inline,disable:SetShaderProperty:_TransShadow,//_TransShadow( "Shadow", Range( 0, 1 ) ) = 0.5
|
|
Option:Cast Shadows:false,true:true
|
|
true:IncludePass:ShadowCaster
|
|
false,disable:ExcludePass:ShadowCaster
|
|
true:ShowOption: Use Shadow Threshold
|
|
false:HideOption: Use Shadow Threshold
|
|
Option: Use Shadow Threshold:false,true:false
|
|
true:ShowPort:ForwardBase:Alpha Clip Threshold Shadow
|
|
false,disable:HidePort:ForwardBase:Alpha Clip Threshold Shadow
|
|
Option:Receive Shadows:false,true:true
|
|
true:SetDefine:ASE_NEEDS_FRAG_SHADOWCOORDS
|
|
false:RemoveDefine:ASE_NEEDS_FRAG_SHADOWCOORDS
|
|
Option:GPU Instancing:false,true:true
|
|
true:SetDefine:pragma multi_compile_instancing
|
|
false:RemoveDefine:pragma multi_compile_instancing
|
|
Option:LOD CrossFade:false,true:true
|
|
true:SetDefine:pragma multi_compile __ LOD_FADE_CROSSFADE
|
|
false:RemoveDefine:pragma multi_compile __ LOD_FADE_CROSSFADE
|
|
Option:Built-in Fog:false,true:true
|
|
true:SetDefine:pragma multi_compile_fog
|
|
false:RemoveDefine:pragma multi_compile_fog
|
|
true:SetDefine:ASE_FOG 1
|
|
false:RemoveDefine:ASE_FOG 1
|
|
Option:Ambient Light:false,true:true
|
|
true:RemoveDefine:ASE_NO_AMBIENT 1
|
|
false:SetDefine:ASE_NO_AMBIENT 1
|
|
Option:Meta Pass:false,true:true
|
|
true:IncludePass:Meta
|
|
false,disable:ExcludePass:Meta
|
|
Option:Add Pass:false,true:true
|
|
true:IncludePass:ForwardAdd
|
|
false,disable:ExcludePass:ForwardAdd
|
|
Option:Override Baked GI:false,true:false
|
|
true:ShowPort:ForwardBase:Baked GI
|
|
false:HidePort:ForwardBase:Baked GI
|
|
true:SetDefine:ASE_BAKEDGI 1
|
|
false:RemoveDefine:ASE_BAKEDGI 1
|
|
Option:Extra Pre Pass:false,true:false
|
|
true:IncludePass:ExtraPrePass
|
|
false,disable:ExcludePass:ExtraPrePass
|
|
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:Fwd Specular Highlights Toggle:false,true:false
|
|
true:SetShaderProperty:_SpecularHighlights,[ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0
|
|
false:SetShaderProperty:_SpecularHighlights,//[ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0
|
|
true:SetDefine:pragma shader_feature _SPECULARHIGHLIGHTS_OFF
|
|
false:RemoveDefine:pragma shader_feature _SPECULARHIGHLIGHTS_OFF
|
|
Option:Fwd Reflections Toggle:false,true:false
|
|
true:SetShaderProperty:_GlossyReflections,[ToggleOff] _GlossyReflections("Reflections", Float) = 1.0
|
|
false:SetShaderProperty:_GlossyReflections,//[ToggleOff] _GlossyReflections("Reflections", Float) = 1.0
|
|
true:SetDefine:pragma shader_feature _GLOSSYREFLECTIONS_OFF
|
|
false:RemoveDefine:pragma shader_feature _GLOSSYREFLECTIONS_OFF
|
|
Option:Disable Batching:False,True,LOD Fading:False
|
|
False:SetPropertyOnSubShader:DisableBatching,False
|
|
True:SetPropertyOnSubShader:DisableBatching,True
|
|
LOD Fading:SetPropertyOnSubShader:DisableBatching,LODFading
|
|
Option:Vertex Position,InvertActionOnDeselection:Absolute,Relative:Relative
|
|
Absolute:SetDefine:ASE_ABSOLUTE_VERTEX_POS 1
|
|
Absolute:SetPortName:ForwardBase:15,Vertex Position
|
|
Relative:SetPortName:ForwardBase:15,Vertex Offset
|
|
Absolute:SetPortName:ExtraPrePass:3,Vertex Position
|
|
Relative:SetPortName:ExtraPrePass:3,Vertex Offset
|
|
Port:ForwardBase:Alpha Clip Threshold
|
|
On:SetDefine:_ALPHATEST_ON 1
|
|
Port:ForwardBase:Alpha Clip Threshold Shadow
|
|
On:SetDefine:_ALPHATEST_SHADOW_ON 1
|
|
*/
|
|
Tags{ "RenderType" = "Opaque" "Queue" = "Geometry+0" "DisableBatching" = "False" }
|
|
LOD 0
|
|
|
|
Cull Back
|
|
AlphaToMask Off
|
|
ZWrite On
|
|
ZTest LEqual
|
|
ColorMask RGBA
|
|
/*ase_stencil*/
|
|
/*ase_all_modules*/
|
|
|
|
CGINCLUDE
|
|
#pragma target 3.0
|
|
|
|
float4 FixedTess( float tessValue )
|
|
{
|
|
return tessValue;
|
|
}
|
|
|
|
float CalcDistanceTessFactor (float4 vertex, float minDist, float maxDist, float tess, float4x4 o2w, float3 cameraPos )
|
|
{
|
|
float3 wpos = mul(o2w,vertex).xyz;
|
|
float dist = distance (wpos, cameraPos);
|
|
float f = clamp(1.0 - (dist - minDist) / (maxDist - minDist), 0.01, 1.0) * tess;
|
|
return f;
|
|
}
|
|
|
|
float4 CalcTriEdgeTessFactors (float3 triVertexFactors)
|
|
{
|
|
float4 tess;
|
|
tess.x = 0.5 * (triVertexFactors.y + triVertexFactors.z);
|
|
tess.y = 0.5 * (triVertexFactors.x + triVertexFactors.z);
|
|
tess.z = 0.5 * (triVertexFactors.x + triVertexFactors.y);
|
|
tess.w = (triVertexFactors.x + triVertexFactors.y + triVertexFactors.z) / 3.0f;
|
|
return tess;
|
|
}
|
|
|
|
float CalcEdgeTessFactor (float3 wpos0, float3 wpos1, float edgeLen, float3 cameraPos, float4 scParams )
|
|
{
|
|
float dist = distance (0.5 * (wpos0+wpos1), cameraPos);
|
|
float len = distance(wpos0, wpos1);
|
|
float f = max(len * scParams.y / (edgeLen * dist), 1.0);
|
|
return f;
|
|
}
|
|
|
|
float DistanceFromPlane (float3 pos, float4 plane)
|
|
{
|
|
float d = dot (float4(pos,1.0f), plane);
|
|
return d;
|
|
}
|
|
|
|
bool WorldViewFrustumCull (float3 wpos0, float3 wpos1, float3 wpos2, float cullEps, float4 planes[6] )
|
|
{
|
|
float4 planeTest;
|
|
planeTest.x = (( DistanceFromPlane(wpos0, planes[0]) > -cullEps) ? 1.0f : 0.0f ) +
|
|
(( DistanceFromPlane(wpos1, planes[0]) > -cullEps) ? 1.0f : 0.0f ) +
|
|
(( DistanceFromPlane(wpos2, planes[0]) > -cullEps) ? 1.0f : 0.0f );
|
|
planeTest.y = (( DistanceFromPlane(wpos0, planes[1]) > -cullEps) ? 1.0f : 0.0f ) +
|
|
(( DistanceFromPlane(wpos1, planes[1]) > -cullEps) ? 1.0f : 0.0f ) +
|
|
(( DistanceFromPlane(wpos2, planes[1]) > -cullEps) ? 1.0f : 0.0f );
|
|
planeTest.z = (( DistanceFromPlane(wpos0, planes[2]) > -cullEps) ? 1.0f : 0.0f ) +
|
|
(( DistanceFromPlane(wpos1, planes[2]) > -cullEps) ? 1.0f : 0.0f ) +
|
|
(( DistanceFromPlane(wpos2, planes[2]) > -cullEps) ? 1.0f : 0.0f );
|
|
planeTest.w = (( DistanceFromPlane(wpos0, planes[3]) > -cullEps) ? 1.0f : 0.0f ) +
|
|
(( DistanceFromPlane(wpos1, planes[3]) > -cullEps) ? 1.0f : 0.0f ) +
|
|
(( DistanceFromPlane(wpos2, planes[3]) > -cullEps) ? 1.0f : 0.0f );
|
|
return !all (planeTest);
|
|
}
|
|
|
|
float4 DistanceBasedTess( float4 v0, float4 v1, float4 v2, float tess, float minDist, float maxDist, float4x4 o2w, float3 cameraPos )
|
|
{
|
|
float3 f;
|
|
f.x = CalcDistanceTessFactor (v0,minDist,maxDist,tess,o2w,cameraPos);
|
|
f.y = CalcDistanceTessFactor (v1,minDist,maxDist,tess,o2w,cameraPos);
|
|
f.z = CalcDistanceTessFactor (v2,minDist,maxDist,tess,o2w,cameraPos);
|
|
|
|
return CalcTriEdgeTessFactors (f);
|
|
}
|
|
|
|
float4 EdgeLengthBasedTess( float4 v0, float4 v1, float4 v2, float edgeLength, float4x4 o2w, float3 cameraPos, float4 scParams )
|
|
{
|
|
float3 pos0 = mul(o2w,v0).xyz;
|
|
float3 pos1 = mul(o2w,v1).xyz;
|
|
float3 pos2 = mul(o2w,v2).xyz;
|
|
float4 tess;
|
|
tess.x = CalcEdgeTessFactor (pos1, pos2, edgeLength, cameraPos, scParams);
|
|
tess.y = CalcEdgeTessFactor (pos2, pos0, edgeLength, cameraPos, scParams);
|
|
tess.z = CalcEdgeTessFactor (pos0, pos1, edgeLength, cameraPos, scParams);
|
|
tess.w = (tess.x + tess.y + tess.z) / 3.0f;
|
|
return tess;
|
|
}
|
|
|
|
float4 EdgeLengthBasedTessCull( float4 v0, float4 v1, float4 v2, float edgeLength, float maxDisplacement, float4x4 o2w, float3 cameraPos, float4 scParams, float4 planes[6] )
|
|
{
|
|
float3 pos0 = mul(o2w,v0).xyz;
|
|
float3 pos1 = mul(o2w,v1).xyz;
|
|
float3 pos2 = mul(o2w,v2).xyz;
|
|
float4 tess;
|
|
|
|
if (WorldViewFrustumCull(pos0, pos1, pos2, maxDisplacement, planes))
|
|
{
|
|
tess = 0.0f;
|
|
}
|
|
else
|
|
{
|
|
tess.x = CalcEdgeTessFactor (pos1, pos2, edgeLength, cameraPos, scParams);
|
|
tess.y = CalcEdgeTessFactor (pos2, pos0, edgeLength, cameraPos, scParams);
|
|
tess.z = CalcEdgeTessFactor (pos0, pos1, edgeLength, cameraPos, scParams);
|
|
tess.w = (tess.x + tess.y + tess.z) / 3.0f;
|
|
}
|
|
return tess;
|
|
}
|
|
ENDCG
|
|
|
|
/*ase_pass*/
|
|
Pass
|
|
{
|
|
Name "ExtraPrePass"
|
|
Tags { "LightMode" = "ForwardBase" }
|
|
|
|
Blend One Zero
|
|
Cull Back
|
|
ZWrite On
|
|
ZTest LEqual
|
|
Offset 0,0
|
|
ColorMask RGBA
|
|
/*ase_stencil*/
|
|
|
|
CGPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#pragma multi_compile_fwdbase
|
|
#ifndef UNITY_PASS_FORWARDBASE
|
|
#define UNITY_PASS_FORWARDBASE
|
|
#endif
|
|
#include "HLSLSupport.cginc"
|
|
#ifndef UNITY_INSTANCED_LOD_FADE
|
|
#define UNITY_INSTANCED_LOD_FADE
|
|
#endif
|
|
#ifndef UNITY_INSTANCED_SH
|
|
#define UNITY_INSTANCED_SH
|
|
#endif
|
|
#ifndef UNITY_INSTANCED_LIGHTMAPSTS
|
|
#define UNITY_INSTANCED_LIGHTMAPSTS
|
|
#endif
|
|
#include "UnityShaderVariables.cginc"
|
|
#include "UnityCG.cginc"
|
|
#include "Lighting.cginc"
|
|
#include "UnityPBSLighting.cginc"
|
|
#include "AutoLight.cginc"
|
|
|
|
/*ase_pragma*/
|
|
struct appdata {
|
|
float4 vertex : POSITION;
|
|
float4 tangent : TANGENT;
|
|
float3 normal : NORMAL;
|
|
float4 texcoord1 : TEXCOORD1;
|
|
float4 texcoord2 : TEXCOORD2;
|
|
/*ase_vdata:p=p;t=t;n=n;uv1=tc1.xyzw;uv2=tc2.xyzw*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct v2f {
|
|
#if UNITY_VERSION >= 201810
|
|
UNITY_POSITION(pos);
|
|
#else
|
|
float4 pos : SV_POSITION;
|
|
#endif
|
|
#if defined(UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS) && UNITY_VERSION >= 201810 && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
|
|
UNITY_LIGHTING_COORDS(2,3)
|
|
#elif defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
|
|
#if UNITY_VERSION >= 201710
|
|
UNITY_SHADOW_COORDS(2)
|
|
#else
|
|
SHADOW_COORDS(2)
|
|
#endif
|
|
#endif
|
|
#ifdef ASE_FOG
|
|
UNITY_FOG_COORDS(4)
|
|
#endif
|
|
float4 tSpace0 : TEXCOORD5;
|
|
float4 tSpace1 : TEXCOORD6;
|
|
float4 tSpace2 : TEXCOORD7;
|
|
/*ase_interp(8,):sp=sp.xyzw;sc=tc2;wn.xyz=tc5.xyz;wt.xyz=tc6.xyz;wbt.xyz=tc7.xyz;wp.x=tc5.w;wp.y=tc6.w;wp.z=tc7.w*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
#ifdef TESSELLATION_ON
|
|
float _TessPhongStrength;
|
|
float _TessValue;
|
|
float _TessMin;
|
|
float _TessMax;
|
|
float _TessEdgeLength;
|
|
float _TessMaxDisp;
|
|
#endif
|
|
/*ase_globals*/
|
|
|
|
/*ase_funcs*/
|
|
|
|
v2f VertexFunction (appdata v /*ase_vert_input*/ ) {
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
v2f o;
|
|
UNITY_INITIALIZE_OUTPUT(v2f,o);
|
|
UNITY_TRANSFER_INSTANCE_ID(v,o);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
|
|
|
/*ase_vert_code:v=appdata;o=v2f*/
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = v.vertex.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3(0, 0, 0);
|
|
#endif
|
|
float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;3;-1;_VertexP*/defaultVertexValue/*end*/;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
v.vertex.xyz = vertexValue;
|
|
#else
|
|
v.vertex.xyz += vertexValue;
|
|
#endif
|
|
v.vertex.w = 1;
|
|
v.normal = /*ase_vert_out:Vertex Normal;Float3;4;-1;_VertexNormalP*/v.normal/*end*/;
|
|
v.tangent = /*ase_vert_out:Vertex Tangent;Float4;5;-1;_VertexTangentP*/v.tangent/*end*/;
|
|
|
|
o.pos = UnityObjectToClipPos(v.vertex);
|
|
float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
|
|
fixed3 worldNormal = UnityObjectToWorldNormal(v.normal);
|
|
fixed3 worldTangent = UnityObjectToWorldDir(v.tangent.xyz);
|
|
fixed tangentSign = v.tangent.w * unity_WorldTransformParams.w;
|
|
fixed3 worldBinormal = cross(worldNormal, worldTangent) * tangentSign;
|
|
o.tSpace0 = float4(worldTangent.x, worldBinormal.x, worldNormal.x, worldPos.x);
|
|
o.tSpace1 = float4(worldTangent.y, worldBinormal.y, worldNormal.y, worldPos.y);
|
|
o.tSpace2 = float4(worldTangent.z, worldBinormal.z, worldNormal.z, worldPos.z);
|
|
|
|
#if UNITY_VERSION >= 201810 && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
|
|
UNITY_TRANSFER_LIGHTING(o, v.texcoord1.xy);
|
|
#elif defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
|
|
#if UNITY_VERSION >= 201710
|
|
UNITY_TRANSFER_SHADOW(o, v.texcoord1.xy);
|
|
#else
|
|
TRANSFER_SHADOW(o);
|
|
#endif
|
|
#endif
|
|
|
|
#ifdef ASE_FOG
|
|
UNITY_TRANSFER_FOG(o,o.pos);
|
|
#endif
|
|
return o;
|
|
}
|
|
|
|
#if defined(TESSELLATION_ON)
|
|
struct VertexControl
|
|
{
|
|
float4 vertex : INTERNALTESSPOS;
|
|
float4 tangent : TANGENT;
|
|
float3 normal : NORMAL;
|
|
float4 texcoord1 : TEXCOORD1;
|
|
float4 texcoord2 : TEXCOORD2;
|
|
/*ase_vcontrol*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct TessellationFactors
|
|
{
|
|
float edge[3] : SV_TessFactor;
|
|
float inside : SV_InsideTessFactor;
|
|
};
|
|
|
|
VertexControl vert ( appdata v )
|
|
{
|
|
VertexControl o;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
o.vertex = v.vertex;
|
|
o.tangent = v.tangent;
|
|
o.normal = v.normal;
|
|
o.texcoord1 = v.texcoord1;
|
|
o.texcoord2 = v.texcoord2;
|
|
/*ase_control_code:v=appdata;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 defined(ASE_FIXED_TESSELLATION)
|
|
tf = FixedTess( tessValue );
|
|
#elif defined(ASE_DISTANCE_TESSELLATION)
|
|
tf = DistanceBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, tessValue, tessMin, tessMax, UNITY_MATRIX_M, _WorldSpaceCameraPos );
|
|
#elif defined(ASE_LENGTH_TESSELLATION)
|
|
tf = EdgeLengthBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, UNITY_MATRIX_M, _WorldSpaceCameraPos, _ScreenParams );
|
|
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
|
tf = EdgeLengthBasedTessCull(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, tessMaxDisp, UNITY_MATRIX_M, _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
|
|
#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")]
|
|
v2f DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
|
{
|
|
appdata o = (appdata) 0;
|
|
o.vertex = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
|
|
o.tangent = patch[0].tangent * bary.x + patch[1].tangent * bary.y + patch[2].tangent * bary.z;
|
|
o.normal = patch[0].normal * bary.x + patch[1].normal * bary.y + patch[2].normal * bary.z;
|
|
o.texcoord1 = patch[0].texcoord1 * bary.x + patch[1].texcoord1 * bary.y + patch[2].texcoord1 * bary.z;
|
|
o.texcoord2 = patch[0].texcoord2 * bary.x + patch[1].texcoord2 * bary.y + patch[2].texcoord2 * bary.z;
|
|
/*ase_domain_code:patch=VertexControl;o=appdata;bary=SV_DomainLocation*/
|
|
#if defined(ASE_PHONG_TESSELLATION)
|
|
float3 pp[3];
|
|
for (int i = 0; i < 3; ++i)
|
|
pp[i] = o.vertex.xyz - patch[i].normal * (dot(o.vertex.xyz, patch[i].normal) - dot(patch[i].vertex.xyz, patch[i].normal));
|
|
float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/;
|
|
o.vertex.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.vertex.xyz;
|
|
#endif
|
|
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
|
return VertexFunction(o);
|
|
}
|
|
#else
|
|
v2f vert ( appdata v )
|
|
{
|
|
return VertexFunction( v );
|
|
}
|
|
#endif
|
|
|
|
fixed4 frag (v2f IN /*ase_frag_input*/
|
|
#ifdef _DEPTHOFFSET_ON
|
|
, out float outputDepth : SV_Depth
|
|
#endif
|
|
) : SV_Target
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID(IN);
|
|
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
UNITY_APPLY_DITHER_CROSSFADE(IN.pos.xy);
|
|
#endif
|
|
|
|
#if defined(_SPECULAR_SETUP)
|
|
SurfaceOutputStandardSpecular o = (SurfaceOutputStandardSpecular)0;
|
|
#else
|
|
SurfaceOutputStandard o = (SurfaceOutputStandard)0;
|
|
#endif
|
|
/*ase_local_var:wt*/float3 WorldTangent = float3(IN.tSpace0.x,IN.tSpace1.x,IN.tSpace2.x);
|
|
/*ase_local_var:wbt*/float3 WorldBiTangent = float3(IN.tSpace0.y,IN.tSpace1.y,IN.tSpace2.y);
|
|
/*ase_local_var:wn*/float3 WorldNormal = float3(IN.tSpace0.z,IN.tSpace1.z,IN.tSpace2.z);
|
|
/*ase_local_var:wp*/float3 worldPos = float3(IN.tSpace0.w,IN.tSpace1.w,IN.tSpace2.w);
|
|
/*ase_local_var:wvd*/float3 worldViewDir = normalize(UnityWorldSpaceViewDir(worldPos));
|
|
#if defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
|
|
UNITY_LIGHT_ATTENUATION(atten, IN, worldPos)
|
|
#else
|
|
/*ase_local_var:sc*/half atten = 1;
|
|
#endif
|
|
|
|
/*ase_frag_code:IN=v2f*/
|
|
float3 Color = /*ase_frag_out:Color;Float3;0;-1;_ColorP*/fixed3( 0, 0, 0 )/*end*/;
|
|
float Alpha = /*ase_frag_out:Alpha;Float;1;-1;_AlphaP*/1/*end*/;
|
|
float AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;2;-1;_AlphaClipP*/0.5/*end*/;
|
|
|
|
float4 c = float4( Color, Alpha );
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
clip( Alpha - AlphaClipThreshold );
|
|
#endif
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
outputDepth = IN.pos.z;
|
|
#endif
|
|
|
|
#ifdef ASE_FOG
|
|
UNITY_APPLY_FOG(IN.fogCoord, c);
|
|
#endif
|
|
return c;
|
|
}
|
|
ENDCG
|
|
}
|
|
|
|
/*ase_pass*/
|
|
Pass
|
|
{
|
|
/*ase_main_pass*/
|
|
Name "ForwardBase"
|
|
Tags { "LightMode" = "ForwardBase" }
|
|
|
|
Blend One Zero
|
|
|
|
CGPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#pragma multi_compile_fwdbase
|
|
#ifndef UNITY_PASS_FORWARDBASE
|
|
#define UNITY_PASS_FORWARDBASE
|
|
#endif
|
|
#include "HLSLSupport.cginc"
|
|
#ifndef UNITY_INSTANCED_LOD_FADE
|
|
#define UNITY_INSTANCED_LOD_FADE
|
|
#endif
|
|
#ifndef UNITY_INSTANCED_SH
|
|
#define UNITY_INSTANCED_SH
|
|
#endif
|
|
#ifndef UNITY_INSTANCED_LIGHTMAPSTS
|
|
#define UNITY_INSTANCED_LIGHTMAPSTS
|
|
#endif
|
|
#include "UnityShaderVariables.cginc"
|
|
#include "UnityCG.cginc"
|
|
#include "Lighting.cginc"
|
|
#include "UnityPBSLighting.cginc"
|
|
#include "AutoLight.cginc"
|
|
|
|
/*ase_pragma*/
|
|
struct appdata {
|
|
float4 vertex : POSITION;
|
|
float4 tangent : TANGENT;
|
|
float3 normal : NORMAL;
|
|
float4 texcoord1 : TEXCOORD1;
|
|
float4 texcoord2 : TEXCOORD2;
|
|
/*ase_vdata:p=p;t=t;n=n;uv1=tc1.xyzw;uv2=tc2.xyzw*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct v2f {
|
|
#if UNITY_VERSION >= 201810
|
|
UNITY_POSITION(pos);
|
|
#else
|
|
float4 pos : SV_POSITION;
|
|
#endif
|
|
#if defined(LIGHTMAP_ON) || (!defined(LIGHTMAP_ON) && SHADER_TARGET >= 30)
|
|
float4 lmap : TEXCOORD0;
|
|
#endif
|
|
#if !defined(LIGHTMAP_ON) && UNITY_SHOULD_SAMPLE_SH
|
|
half3 sh : TEXCOORD1;
|
|
#endif
|
|
#if defined(UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS) && UNITY_VERSION >= 201810 && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
|
|
UNITY_LIGHTING_COORDS(2,3)
|
|
#elif defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
|
|
#if UNITY_VERSION >= 201710
|
|
UNITY_SHADOW_COORDS(2)
|
|
#else
|
|
SHADOW_COORDS(2)
|
|
#endif
|
|
#endif
|
|
#ifdef ASE_FOG
|
|
UNITY_FOG_COORDS(4)
|
|
#endif
|
|
float4 tSpace0 : TEXCOORD5;
|
|
float4 tSpace1 : TEXCOORD6;
|
|
float4 tSpace2 : TEXCOORD7;
|
|
#if defined(ASE_NEEDS_FRAG_SCREEN_POSITION)
|
|
float4 screenPos : TEXCOORD8;
|
|
#endif
|
|
/*ase_interp(9,):sp=sp.xyzw;sc=tc2;wn.xyz=tc5.xyz;wt.xyz=tc6.xyz;wbt.xyz=tc7.xyz;wp.x=tc5.w;wp.y=tc6.w;wp.z=tc7.w;spu=tc8*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
#ifdef _TRANSMISSION_ASE
|
|
float _TransmissionShadow;
|
|
#endif
|
|
#ifdef _TRANSLUCENCY_ASE
|
|
float _TransStrength;
|
|
float _TransNormal;
|
|
float _TransScattering;
|
|
float _TransDirect;
|
|
float _TransAmbient;
|
|
float _TransShadow;
|
|
#endif
|
|
#ifdef TESSELLATION_ON
|
|
float _TessPhongStrength;
|
|
float _TessValue;
|
|
float _TessMin;
|
|
float _TessMax;
|
|
float _TessEdgeLength;
|
|
float _TessMaxDisp;
|
|
#endif
|
|
/*ase_globals*/
|
|
|
|
/*ase_funcs*/
|
|
|
|
v2f VertexFunction (appdata v /*ase_vert_input*/ ) {
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
v2f o;
|
|
UNITY_INITIALIZE_OUTPUT(v2f,o);
|
|
UNITY_TRANSFER_INSTANCE_ID(v,o);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
|
|
|
/*ase_vert_code:v=appdata;o=v2f*/
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = v.vertex.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3(0, 0, 0);
|
|
#endif
|
|
float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;15;-1;_Vertex*/defaultVertexValue/*end*/;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
v.vertex.xyz = vertexValue;
|
|
#else
|
|
v.vertex.xyz += vertexValue;
|
|
#endif
|
|
v.vertex.w = 1;
|
|
v.normal = /*ase_vert_out:Vertex Normal;Float3;16;-1;_VertexNormal*/v.normal/*end*/;
|
|
v.tangent = /*ase_vert_out:Vertex Tangent;Float4;17;-1;_VertexTangent*/v.tangent/*end*/;
|
|
|
|
o.pos = UnityObjectToClipPos(v.vertex);
|
|
float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
|
|
fixed3 worldNormal = UnityObjectToWorldNormal(v.normal);
|
|
fixed3 worldTangent = UnityObjectToWorldDir(v.tangent.xyz);
|
|
fixed tangentSign = v.tangent.w * unity_WorldTransformParams.w;
|
|
fixed3 worldBinormal = cross(worldNormal, worldTangent) * tangentSign;
|
|
o.tSpace0 = float4(worldTangent.x, worldBinormal.x, worldNormal.x, worldPos.x);
|
|
o.tSpace1 = float4(worldTangent.y, worldBinormal.y, worldNormal.y, worldPos.y);
|
|
o.tSpace2 = float4(worldTangent.z, worldBinormal.z, worldNormal.z, worldPos.z);
|
|
|
|
#ifdef DYNAMICLIGHTMAP_ON
|
|
o.lmap.zw = v.texcoord2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
|
|
#endif
|
|
#ifdef LIGHTMAP_ON
|
|
o.lmap.xy = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
|
|
#endif
|
|
|
|
#ifndef LIGHTMAP_ON
|
|
#if UNITY_SHOULD_SAMPLE_SH && !UNITY_SAMPLE_FULL_SH_PER_PIXEL
|
|
o.sh = 0;
|
|
#ifdef VERTEXLIGHT_ON
|
|
o.sh += Shade4PointLights (
|
|
unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0,
|
|
unity_LightColor[0].rgb, unity_LightColor[1].rgb, unity_LightColor[2].rgb, unity_LightColor[3].rgb,
|
|
unity_4LightAtten0, worldPos, worldNormal);
|
|
#endif
|
|
o.sh = ShadeSHPerVertex (worldNormal, o.sh);
|
|
#endif
|
|
#endif
|
|
|
|
#if UNITY_VERSION >= 201810 && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
|
|
UNITY_TRANSFER_LIGHTING(o, v.texcoord1.xy);
|
|
#elif defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
|
|
#if UNITY_VERSION >= 201710
|
|
UNITY_TRANSFER_SHADOW(o, v.texcoord1.xy);
|
|
#else
|
|
TRANSFER_SHADOW(o);
|
|
#endif
|
|
#endif
|
|
|
|
#ifdef ASE_FOG
|
|
UNITY_TRANSFER_FOG(o,o.pos);
|
|
#endif
|
|
#if defined(ASE_NEEDS_FRAG_SCREEN_POSITION)
|
|
o.screenPos = ComputeScreenPos(o.pos);
|
|
#endif
|
|
return o;
|
|
}
|
|
|
|
#if defined(TESSELLATION_ON)
|
|
struct VertexControl
|
|
{
|
|
float4 vertex : INTERNALTESSPOS;
|
|
float4 tangent : TANGENT;
|
|
float3 normal : NORMAL;
|
|
float4 texcoord1 : TEXCOORD1;
|
|
float4 texcoord2 : TEXCOORD2;
|
|
/*ase_vcontrol*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct TessellationFactors
|
|
{
|
|
float edge[3] : SV_TessFactor;
|
|
float inside : SV_InsideTessFactor;
|
|
};
|
|
|
|
VertexControl vert ( appdata v )
|
|
{
|
|
VertexControl o;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
o.vertex = v.vertex;
|
|
o.tangent = v.tangent;
|
|
o.normal = v.normal;
|
|
o.texcoord1 = v.texcoord1;
|
|
o.texcoord2 = v.texcoord2;
|
|
/*ase_control_code:v=appdata;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 defined(ASE_FIXED_TESSELLATION)
|
|
tf = FixedTess( tessValue );
|
|
#elif defined(ASE_DISTANCE_TESSELLATION)
|
|
tf = DistanceBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, tessValue, tessMin, tessMax, UNITY_MATRIX_M, _WorldSpaceCameraPos );
|
|
#elif defined(ASE_LENGTH_TESSELLATION)
|
|
tf = EdgeLengthBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, UNITY_MATRIX_M, _WorldSpaceCameraPos, _ScreenParams );
|
|
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
|
tf = EdgeLengthBasedTessCull(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, tessMaxDisp, UNITY_MATRIX_M, _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
|
|
#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")]
|
|
v2f DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
|
{
|
|
appdata o = (appdata) 0;
|
|
o.vertex = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
|
|
o.tangent = patch[0].tangent * bary.x + patch[1].tangent * bary.y + patch[2].tangent * bary.z;
|
|
o.normal = patch[0].normal * bary.x + patch[1].normal * bary.y + patch[2].normal * bary.z;
|
|
o.texcoord1 = patch[0].texcoord1 * bary.x + patch[1].texcoord1 * bary.y + patch[2].texcoord1 * bary.z;
|
|
o.texcoord2 = patch[0].texcoord2 * bary.x + patch[1].texcoord2 * bary.y + patch[2].texcoord2 * bary.z;
|
|
/*ase_domain_code:patch=VertexControl;o=appdata;bary=SV_DomainLocation*/
|
|
#if defined(ASE_PHONG_TESSELLATION)
|
|
float3 pp[3];
|
|
for (int i = 0; i < 3; ++i)
|
|
pp[i] = o.vertex.xyz - patch[i].normal * (dot(o.vertex.xyz, patch[i].normal) - dot(patch[i].vertex.xyz, patch[i].normal));
|
|
float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/;
|
|
o.vertex.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.vertex.xyz;
|
|
#endif
|
|
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
|
return VertexFunction(o);
|
|
}
|
|
#else
|
|
v2f vert ( appdata v )
|
|
{
|
|
return VertexFunction( v );
|
|
}
|
|
#endif
|
|
|
|
fixed4 frag (v2f IN /*ase_frag_input*/
|
|
#ifdef _DEPTHOFFSET_ON
|
|
, out float outputDepth : SV_Depth
|
|
#endif
|
|
) : SV_Target
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID(IN);
|
|
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
UNITY_APPLY_DITHER_CROSSFADE(IN.pos.xy);
|
|
#endif
|
|
|
|
#if defined(_SPECULAR_SETUP)
|
|
SurfaceOutputStandardSpecular o = (SurfaceOutputStandardSpecular)0;
|
|
#else
|
|
SurfaceOutputStandard o = (SurfaceOutputStandard)0;
|
|
#endif
|
|
/*ase_local_var:wt*/float3 WorldTangent = float3(IN.tSpace0.x,IN.tSpace1.x,IN.tSpace2.x);
|
|
/*ase_local_var:wbt*/float3 WorldBiTangent = float3(IN.tSpace0.y,IN.tSpace1.y,IN.tSpace2.y);
|
|
/*ase_local_var:wn*/float3 WorldNormal = float3(IN.tSpace0.z,IN.tSpace1.z,IN.tSpace2.z);
|
|
/*ase_local_var:wp*/float3 worldPos = float3(IN.tSpace0.w,IN.tSpace1.w,IN.tSpace2.w);
|
|
/*ase_local_var:wvd*/float3 worldViewDir = normalize(UnityWorldSpaceViewDir(worldPos));
|
|
#if defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
|
|
UNITY_LIGHT_ATTENUATION(atten, IN, worldPos)
|
|
#else
|
|
/*ase_local_var:sc*/half atten = 1;
|
|
#endif
|
|
#if defined(ASE_NEEDS_FRAG_SCREEN_POSITION)
|
|
/*ase_local_var:spu*/float4 ScreenPos = IN.screenPos;
|
|
#endif
|
|
|
|
/*ase_frag_code:IN=v2f*/
|
|
o.Albedo = /*ase_frag_out:Albedo;Float3;0;-1;_Albedo*/fixed3( 0.5, 0.5, 0.5 )/*end*/;
|
|
o.Normal = /*ase_frag_out:Normal;Float3;1;-1;_Normal*/fixed3( 0, 0, 1 )/*end*/;
|
|
o.Emission = /*ase_frag_out:Emission;Float3;2;-1;_Emission*/half3( 0, 0, 0 )/*end*/;
|
|
#if defined(_SPECULAR_SETUP)
|
|
o.Specular = /*ase_frag_out:Specular;Float3;3;-1;_Specular*/fixed3( 0, 0, 0 )/*end*/;
|
|
#else
|
|
o.Metallic = /*ase_frag_out:Metallic;Float;4;-1;_Metallic*/0/*end*/;
|
|
#endif
|
|
o.Smoothness = /*ase_frag_out:Smoothness;Float;5;-1;_Smoothness*/0/*end*/;
|
|
o.Occlusion = /*ase_frag_out:Occlusion;Float;6;-1;_Occlusion*/1/*end*/;
|
|
o.Alpha = /*ase_frag_out:Alpha;Float;7;-1;_Alpha*/1/*end*/;
|
|
float AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;8;-1;_AlphaClip*/0.5/*end*/;
|
|
float AlphaClipThresholdShadow = /*ase_frag_out:Alpha Clip Threshold Shadow;Float;9;-1;_AlphaClipShadow*/0.5/*end*/;
|
|
float3 BakedGI = /*ase_frag_out:Baked GI;Float3;10;-1;_BakedGI*/0/*end*/;
|
|
float3 RefractionColor = /*ase_frag_out:Refraction Color;Float3;11;-1;_RefractionColor*/1/*end*/;
|
|
float RefractionIndex = /*ase_frag_out:Refraction Index;Float;12;-1;_RefractionIndex*/1/*end*/;
|
|
float3 Transmission = /*ase_frag_out:Transmission;Float3;13;-1;_Transmission*/1/*end*/;
|
|
float3 Translucency = /*ase_frag_out:Translucency;Float3;14;-1;_Translucency*/1/*end*/;
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
clip( o.Alpha - AlphaClipThreshold );
|
|
#endif
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
outputDepth = IN.pos.z;
|
|
#endif
|
|
|
|
#ifndef USING_DIRECTIONAL_LIGHT
|
|
fixed3 lightDir = normalize(UnityWorldSpaceLightDir(worldPos));
|
|
#else
|
|
fixed3 lightDir = _WorldSpaceLightPos0.xyz;
|
|
#endif
|
|
|
|
fixed4 c = 0;
|
|
float3 worldN;
|
|
worldN.x = dot(IN.tSpace0.xyz, o.Normal);
|
|
worldN.y = dot(IN.tSpace1.xyz, o.Normal);
|
|
worldN.z = dot(IN.tSpace2.xyz, o.Normal);
|
|
worldN = normalize(worldN);
|
|
o.Normal = worldN;
|
|
|
|
UnityGI gi;
|
|
UNITY_INITIALIZE_OUTPUT(UnityGI, gi);
|
|
gi.indirect.diffuse = 0;
|
|
gi.indirect.specular = 0;
|
|
gi.light.color = _LightColor0.rgb;
|
|
gi.light.dir = lightDir;
|
|
|
|
UnityGIInput giInput;
|
|
UNITY_INITIALIZE_OUTPUT(UnityGIInput, giInput);
|
|
giInput.light = gi.light;
|
|
giInput.worldPos = worldPos;
|
|
giInput.worldViewDir = worldViewDir;
|
|
giInput.atten = atten;
|
|
#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
|
|
giInput.lightmapUV = IN.lmap;
|
|
#else
|
|
giInput.lightmapUV = 0.0;
|
|
#endif
|
|
#if UNITY_SHOULD_SAMPLE_SH && !UNITY_SAMPLE_FULL_SH_PER_PIXEL
|
|
giInput.ambient = IN.sh;
|
|
#else
|
|
giInput.ambient.rgb = 0.0;
|
|
#endif
|
|
giInput.probeHDR[0] = unity_SpecCube0_HDR;
|
|
giInput.probeHDR[1] = unity_SpecCube1_HDR;
|
|
#if defined(UNITY_SPECCUBE_BLENDING) || defined(UNITY_SPECCUBE_BOX_PROJECTION)
|
|
giInput.boxMin[0] = unity_SpecCube0_BoxMin;
|
|
#endif
|
|
#ifdef UNITY_SPECCUBE_BOX_PROJECTION
|
|
giInput.boxMax[0] = unity_SpecCube0_BoxMax;
|
|
giInput.probePosition[0] = unity_SpecCube0_ProbePosition;
|
|
giInput.boxMax[1] = unity_SpecCube1_BoxMax;
|
|
giInput.boxMin[1] = unity_SpecCube1_BoxMin;
|
|
giInput.probePosition[1] = unity_SpecCube1_ProbePosition;
|
|
#endif
|
|
|
|
#if defined(_SPECULAR_SETUP)
|
|
LightingStandardSpecular_GI(o, giInput, gi);
|
|
#else
|
|
LightingStandard_GI( o, giInput, gi );
|
|
#endif
|
|
|
|
#ifdef ASE_BAKEDGI
|
|
gi.indirect.diffuse = BakedGI;
|
|
#endif
|
|
|
|
#if UNITY_SHOULD_SAMPLE_SH && !defined(LIGHTMAP_ON) && defined(ASE_NO_AMBIENT)
|
|
gi.indirect.diffuse = 0;
|
|
#endif
|
|
|
|
#if defined(_SPECULAR_SETUP)
|
|
c += LightingStandardSpecular (o, worldViewDir, gi);
|
|
#else
|
|
c += LightingStandard( o, worldViewDir, gi );
|
|
#endif
|
|
|
|
#ifdef _TRANSMISSION_ASE
|
|
{
|
|
float shadow = /*ase_inline_begin*/_TransmissionShadow/*ase_inline_end*/;
|
|
#ifdef DIRECTIONAL
|
|
float3 lightAtten = lerp( _LightColor0.rgb, gi.light.color, shadow );
|
|
#else
|
|
float3 lightAtten = gi.light.color;
|
|
#endif
|
|
half3 transmission = max(0 , -dot(o.Normal, gi.light.dir)) * lightAtten * Transmission;
|
|
c.rgb += o.Albedo * transmission;
|
|
}
|
|
#endif
|
|
|
|
#ifdef _TRANSLUCENCY_ASE
|
|
{
|
|
float shadow = /*ase_inline_begin*/_TransShadow/*ase_inline_end*/;
|
|
float normal = /*ase_inline_begin*/_TransNormal/*ase_inline_end*/;
|
|
float scattering = /*ase_inline_begin*/_TransScattering/*ase_inline_end*/;
|
|
float direct = /*ase_inline_begin*/_TransDirect/*ase_inline_end*/;
|
|
float ambient = /*ase_inline_begin*/_TransAmbient/*ase_inline_end*/;
|
|
float strength = /*ase_inline_begin*/_TransStrength/*ase_inline_end*/;
|
|
|
|
#ifdef DIRECTIONAL
|
|
float3 lightAtten = lerp( _LightColor0.rgb, gi.light.color, shadow );
|
|
#else
|
|
float3 lightAtten = gi.light.color;
|
|
#endif
|
|
half3 lightDir = gi.light.dir + o.Normal * normal;
|
|
half transVdotL = pow( saturate( dot( worldViewDir, -lightDir ) ), scattering );
|
|
half3 translucency = lightAtten * (transVdotL * direct + gi.indirect.diffuse * ambient) * Translucency;
|
|
c.rgb += o.Albedo * translucency * strength;
|
|
}
|
|
#endif
|
|
|
|
//#ifdef _REFRACTION_ASE
|
|
// float4 projScreenPos = ScreenPos / ScreenPos.w;
|
|
// float3 refractionOffset = ( RefractionIndex - 1.0 ) * mul( UNITY_MATRIX_V, WorldNormal ).xyz * ( 1.0 - dot( WorldNormal, WorldViewDirection ) );
|
|
// projScreenPos.xy += refractionOffset.xy;
|
|
// float3 refraction = UNITY_SAMPLE_SCREENSPACE_TEXTURE( _GrabTexture, projScreenPos ) * RefractionColor;
|
|
// color.rgb = lerp( refraction, color.rgb, color.a );
|
|
// color.a = 1;
|
|
//#endif
|
|
|
|
c.rgb += o.Emission;
|
|
|
|
#ifdef ASE_FOG
|
|
UNITY_APPLY_FOG(IN.fogCoord, c);
|
|
#endif
|
|
return c;
|
|
}
|
|
ENDCG
|
|
}
|
|
|
|
/*ase_pass*/
|
|
Pass
|
|
{
|
|
/*ase_hide_pass*/
|
|
Name "ForwardAdd"
|
|
Tags { "LightMode"="ForwardAdd" }
|
|
ZWrite Off
|
|
Blend One One
|
|
|
|
CGPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#pragma skip_variants INSTANCING_ON
|
|
#pragma multi_compile_fwdadd_fullshadows
|
|
#ifndef UNITY_PASS_FORWARDADD
|
|
#define UNITY_PASS_FORWARDADD
|
|
#endif
|
|
#include "HLSLSupport.cginc"
|
|
#if !defined( UNITY_INSTANCED_LOD_FADE )
|
|
#define UNITY_INSTANCED_LOD_FADE
|
|
#endif
|
|
#if !defined( UNITY_INSTANCED_SH )
|
|
#define UNITY_INSTANCED_SH
|
|
#endif
|
|
#if !defined( UNITY_INSTANCED_LIGHTMAPSTS )
|
|
#define UNITY_INSTANCED_LIGHTMAPSTS
|
|
#endif
|
|
#include "UnityShaderVariables.cginc"
|
|
#include "UnityCG.cginc"
|
|
#include "Lighting.cginc"
|
|
#include "UnityPBSLighting.cginc"
|
|
#include "AutoLight.cginc"
|
|
|
|
/*ase_pragma*/
|
|
struct appdata {
|
|
float4 vertex : POSITION;
|
|
float4 tangent : TANGENT;
|
|
float3 normal : NORMAL;
|
|
float4 texcoord1 : TEXCOORD1;
|
|
float4 texcoord2 : TEXCOORD2;
|
|
/*ase_vdata:p=p;t=t;n=n;uv1=tc1.xyzw;uv2=tc2.xyzw*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
struct v2f {
|
|
#if UNITY_VERSION >= 201810
|
|
UNITY_POSITION(pos);
|
|
#else
|
|
float4 pos : SV_POSITION;
|
|
#endif
|
|
#if UNITY_VERSION >= 201810 && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
|
|
UNITY_LIGHTING_COORDS(1,2)
|
|
#elif defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
|
|
#if UNITY_VERSION >= 201710
|
|
UNITY_SHADOW_COORDS(1)
|
|
#else
|
|
SHADOW_COORDS(1)
|
|
#endif
|
|
#endif
|
|
#ifdef ASE_FOG
|
|
UNITY_FOG_COORDS(3)
|
|
#endif
|
|
float4 tSpace0 : TEXCOORD5;
|
|
float4 tSpace1 : TEXCOORD6;
|
|
float4 tSpace2 : TEXCOORD7;
|
|
#if defined(ASE_NEEDS_FRAG_SCREEN_POSITION)
|
|
float4 screenPos : TEXCOORD8;
|
|
#endif
|
|
/*ase_interp(9,):sp=sp.xyzw;sc=tc1;wn.xyz=tc5.xyz;wt.xyz=tc6.xyz;wbt.xyz=tc7.xyz;wp.x=tc5.w;wp.y=tc6.w;wp.z=tc7.w;spu=tc8*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
#ifdef _TRANSMISSION_ASE
|
|
float _TransmissionShadow;
|
|
#endif
|
|
#ifdef _TRANSLUCENCY_ASE
|
|
float _TransStrength;
|
|
float _TransNormal;
|
|
float _TransScattering;
|
|
float _TransDirect;
|
|
float _TransAmbient;
|
|
float _TransShadow;
|
|
#endif
|
|
#ifdef TESSELLATION_ON
|
|
float _TessPhongStrength;
|
|
float _TessValue;
|
|
float _TessMin;
|
|
float _TessMax;
|
|
float _TessEdgeLength;
|
|
float _TessMaxDisp;
|
|
#endif
|
|
/*ase_globals*/
|
|
|
|
/*ase_funcs*/
|
|
|
|
v2f VertexFunction (appdata v /*ase_vert_input*/ ) {
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
v2f o;
|
|
UNITY_INITIALIZE_OUTPUT(v2f,o);
|
|
UNITY_TRANSFER_INSTANCE_ID(v,o);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
|
|
|
/*ase_vert_code:v=appdata;o=v2f*/
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = v.vertex.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3(0, 0, 0);
|
|
#endif
|
|
float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;11;-1;_Vertex*/defaultVertexValue/*end*/;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
v.vertex.xyz = vertexValue;
|
|
#else
|
|
v.vertex.xyz += vertexValue;
|
|
#endif
|
|
v.vertex.w = 1;
|
|
v.normal = /*ase_vert_out:Vertex Normal;Float3;12;-1;_VertexNormal*/v.normal/*end*/;
|
|
v.tangent = /*ase_vert_out:Vertex Tangent;Float4;13;-1;_VertexTangent*/v.tangent/*end*/;
|
|
|
|
o.pos = UnityObjectToClipPos(v.vertex);
|
|
float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
|
|
fixed3 worldNormal = UnityObjectToWorldNormal(v.normal);
|
|
fixed3 worldTangent = UnityObjectToWorldDir(v.tangent.xyz);
|
|
fixed tangentSign = v.tangent.w * unity_WorldTransformParams.w;
|
|
fixed3 worldBinormal = cross(worldNormal, worldTangent) * tangentSign;
|
|
o.tSpace0 = float4(worldTangent.x, worldBinormal.x, worldNormal.x, worldPos.x);
|
|
o.tSpace1 = float4(worldTangent.y, worldBinormal.y, worldNormal.y, worldPos.y);
|
|
o.tSpace2 = float4(worldTangent.z, worldBinormal.z, worldNormal.z, worldPos.z);
|
|
|
|
#if UNITY_VERSION >= 201810 && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
|
|
UNITY_TRANSFER_LIGHTING(o, v.texcoord1.xy);
|
|
#elif defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
|
|
#if UNITY_VERSION >= 201710
|
|
UNITY_TRANSFER_SHADOW(o, v.texcoord1.xy);
|
|
#else
|
|
TRANSFER_SHADOW(o);
|
|
#endif
|
|
#endif
|
|
|
|
#ifdef ASE_FOG
|
|
UNITY_TRANSFER_FOG(o,o.pos);
|
|
#endif
|
|
#if defined(ASE_NEEDS_FRAG_SCREEN_POSITION)
|
|
o.screenPos = ComputeScreenPos(o.pos);
|
|
#endif
|
|
return o;
|
|
}
|
|
|
|
#if defined(TESSELLATION_ON)
|
|
struct VertexControl
|
|
{
|
|
float4 vertex : INTERNALTESSPOS;
|
|
float4 tangent : TANGENT;
|
|
float3 normal : NORMAL;
|
|
float4 texcoord1 : TEXCOORD1;
|
|
float4 texcoord2 : TEXCOORD2;
|
|
/*ase_vcontrol*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct TessellationFactors
|
|
{
|
|
float edge[3] : SV_TessFactor;
|
|
float inside : SV_InsideTessFactor;
|
|
};
|
|
|
|
VertexControl vert ( appdata v )
|
|
{
|
|
VertexControl o;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
o.vertex = v.vertex;
|
|
o.tangent = v.tangent;
|
|
o.normal = v.normal;
|
|
o.texcoord1 = v.texcoord1;
|
|
o.texcoord2 = v.texcoord2;
|
|
/*ase_control_code:v=appdata;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 defined(ASE_FIXED_TESSELLATION)
|
|
tf = FixedTess( tessValue );
|
|
#elif defined(ASE_DISTANCE_TESSELLATION)
|
|
tf = DistanceBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, tessValue, tessMin, tessMax, UNITY_MATRIX_M, _WorldSpaceCameraPos );
|
|
#elif defined(ASE_LENGTH_TESSELLATION)
|
|
tf = EdgeLengthBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, UNITY_MATRIX_M, _WorldSpaceCameraPos, _ScreenParams );
|
|
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
|
tf = EdgeLengthBasedTessCull(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, tessMaxDisp, UNITY_MATRIX_M, _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
|
|
#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")]
|
|
v2f DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
|
{
|
|
appdata o = (appdata) 0;
|
|
o.vertex = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
|
|
o.tangent = patch[0].tangent * bary.x + patch[1].tangent * bary.y + patch[2].tangent * bary.z;
|
|
o.normal = patch[0].normal * bary.x + patch[1].normal * bary.y + patch[2].normal * bary.z;
|
|
o.texcoord1 = patch[0].texcoord1 * bary.x + patch[1].texcoord1 * bary.y + patch[2].texcoord1 * bary.z;
|
|
o.texcoord2 = patch[0].texcoord2 * bary.x + patch[1].texcoord2 * bary.y + patch[2].texcoord2 * bary.z;
|
|
/*ase_domain_code:patch=VertexControl;o=appdata;bary=SV_DomainLocation*/
|
|
#if defined(ASE_PHONG_TESSELLATION)
|
|
float3 pp[3];
|
|
for (int i = 0; i < 3; ++i)
|
|
pp[i] = o.vertex.xyz - patch[i].normal * (dot(o.vertex.xyz, patch[i].normal) - dot(patch[i].vertex.xyz, patch[i].normal));
|
|
float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/;
|
|
o.vertex.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.vertex.xyz;
|
|
#endif
|
|
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
|
return VertexFunction(o);
|
|
}
|
|
#else
|
|
v2f vert ( appdata v )
|
|
{
|
|
return VertexFunction( v );
|
|
}
|
|
#endif
|
|
|
|
fixed4 frag ( v2f IN /*ase_frag_input*/
|
|
#ifdef _DEPTHOFFSET_ON
|
|
, out float outputDepth : SV_Depth
|
|
#endif
|
|
) : SV_Target
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID(IN);
|
|
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
UNITY_APPLY_DITHER_CROSSFADE(IN.pos.xy);
|
|
#endif
|
|
|
|
#if defined(_SPECULAR_SETUP)
|
|
SurfaceOutputStandardSpecular o = (SurfaceOutputStandardSpecular)0;
|
|
#else
|
|
SurfaceOutputStandard o = (SurfaceOutputStandard)0;
|
|
#endif
|
|
/*ase_local_var:wt*/float3 WorldTangent = float3(IN.tSpace0.x,IN.tSpace1.x,IN.tSpace2.x);
|
|
/*ase_local_var:wbt*/float3 WorldBiTangent = float3(IN.tSpace0.y,IN.tSpace1.y,IN.tSpace2.y);
|
|
/*ase_local_var:wn*/float3 WorldNormal = float3(IN.tSpace0.z,IN.tSpace1.z,IN.tSpace2.z);
|
|
/*ase_local_var:wp*/float3 worldPos = float3(IN.tSpace0.w,IN.tSpace1.w,IN.tSpace2.w);
|
|
/*ase_local_var:wvd*/float3 worldViewDir = normalize(UnityWorldSpaceViewDir(worldPos));
|
|
#if defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
|
|
UNITY_LIGHT_ATTENUATION(atten, IN, worldPos)
|
|
#else
|
|
/*ase_local_var:sc*/half atten = 1;
|
|
#endif
|
|
#if defined(ASE_NEEDS_FRAG_SCREEN_POSITION)
|
|
/*ase_local_var:spu*/float4 ScreenPos = IN.screenPos;
|
|
#endif
|
|
|
|
|
|
/*ase_frag_code:IN=v2f*/
|
|
o.Albedo = /*ase_frag_out:Albedo;Float3;0;-1;_Albedo*/fixed3( 0.5, 0.5, 0.5 )/*end*/;
|
|
o.Normal = /*ase_frag_out:Normal;Float3;1;-1;_Normal*/fixed3( 0, 0, 1 )/*end*/;
|
|
o.Emission = /*ase_frag_out:Emission;Float3;2;-1;_Emission*/half3( 0, 0, 0 )/*end*/;
|
|
#if defined(_SPECULAR_SETUP)
|
|
o.Specular = /*ase_frag_out:Specular;Float3;3;-1;_Specular*/fixed3( 0, 0, 0 )/*end*/;
|
|
#else
|
|
o.Metallic = /*ase_frag_out:Metallic;Float;4;-1;_Metallic*/0/*end*/;
|
|
#endif
|
|
o.Smoothness = /*ase_frag_out:Smoothness;Float;5;-1;_Smoothness*/0/*end*/;
|
|
o.Occlusion = /*ase_frag_out:Occlusion;Float;6;-1;_Occlusion*/1/*end*/;
|
|
o.Alpha = /*ase_frag_out:Alpha;Float;7;-1;_Alpha*/1/*end*/;
|
|
float AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;8;-1;_AlphaClip*/0.5/*end*/;
|
|
float3 Transmission = /*ase_frag_out:Transmission;Float3;9;-1;_Transmission*/1/*end*/;
|
|
float3 Translucency = /*ase_frag_out:Translucency;Float3;10;-1;_Translucency*/1/*end*/;
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
clip( o.Alpha - AlphaClipThreshold );
|
|
#endif
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
outputDepth = IN.pos.z;
|
|
#endif
|
|
|
|
#ifndef USING_DIRECTIONAL_LIGHT
|
|
fixed3 lightDir = normalize(UnityWorldSpaceLightDir(worldPos));
|
|
#else
|
|
fixed3 lightDir = _WorldSpaceLightPos0.xyz;
|
|
#endif
|
|
|
|
fixed4 c = 0;
|
|
float3 worldN;
|
|
worldN.x = dot(IN.tSpace0.xyz, o.Normal);
|
|
worldN.y = dot(IN.tSpace1.xyz, o.Normal);
|
|
worldN.z = dot(IN.tSpace2.xyz, o.Normal);
|
|
worldN = normalize(worldN);
|
|
o.Normal = worldN;
|
|
|
|
UnityGI gi;
|
|
UNITY_INITIALIZE_OUTPUT(UnityGI, gi);
|
|
gi.indirect.diffuse = 0;
|
|
gi.indirect.specular = 0;
|
|
gi.light.color = _LightColor0.rgb;
|
|
gi.light.dir = lightDir;
|
|
gi.light.color *= atten;
|
|
|
|
#if defined(_SPECULAR_SETUP)
|
|
c += LightingStandardSpecular( o, worldViewDir, gi );
|
|
#else
|
|
c += LightingStandard( o, worldViewDir, gi );
|
|
#endif
|
|
|
|
#ifdef _TRANSMISSION_ASE
|
|
{
|
|
float shadow = /*ase_inline_begin*/_TransmissionShadow/*ase_inline_end*/;
|
|
#ifdef DIRECTIONAL
|
|
float3 lightAtten = lerp( _LightColor0.rgb, gi.light.color, shadow );
|
|
#else
|
|
float3 lightAtten = gi.light.color;
|
|
#endif
|
|
half3 transmission = max(0 , -dot(o.Normal, gi.light.dir)) * lightAtten * Transmission;
|
|
c.rgb += o.Albedo * transmission;
|
|
}
|
|
#endif
|
|
|
|
#ifdef _TRANSLUCENCY_ASE
|
|
{
|
|
float shadow = /*ase_inline_begin*/_TransShadow/*ase_inline_end*/;
|
|
float normal = /*ase_inline_begin*/_TransNormal/*ase_inline_end*/;
|
|
float scattering = /*ase_inline_begin*/_TransScattering/*ase_inline_end*/;
|
|
float direct = /*ase_inline_begin*/_TransDirect/*ase_inline_end*/;
|
|
float ambient = /*ase_inline_begin*/_TransAmbient/*ase_inline_end*/;
|
|
float strength = /*ase_inline_begin*/_TransStrength/*ase_inline_end*/;
|
|
|
|
#ifdef DIRECTIONAL
|
|
float3 lightAtten = lerp( _LightColor0.rgb, gi.light.color, shadow );
|
|
#else
|
|
float3 lightAtten = gi.light.color;
|
|
#endif
|
|
half3 lightDir = gi.light.dir + o.Normal * normal;
|
|
half transVdotL = pow( saturate( dot( worldViewDir, -lightDir ) ), scattering );
|
|
half3 translucency = lightAtten * (transVdotL * direct + gi.indirect.diffuse * ambient) * Translucency;
|
|
c.rgb += o.Albedo * translucency * strength;
|
|
}
|
|
#endif
|
|
|
|
//#ifdef _REFRACTION_ASE
|
|
// float4 projScreenPos = ScreenPos / ScreenPos.w;
|
|
// float3 refractionOffset = ( RefractionIndex - 1.0 ) * mul( UNITY_MATRIX_V, WorldNormal ).xyz * ( 1.0 - dot( WorldNormal, WorldViewDirection ) );
|
|
// projScreenPos.xy += refractionOffset.xy;
|
|
// float3 refraction = UNITY_SAMPLE_SCREENSPACE_TEXTURE( _GrabTexture, projScreenPos ) * RefractionColor;
|
|
// color.rgb = lerp( refraction, color.rgb, color.a );
|
|
// color.a = 1;
|
|
//#endif
|
|
|
|
#ifdef ASE_FOG
|
|
UNITY_APPLY_FOG(IN.fogCoord, c);
|
|
#endif
|
|
return c;
|
|
}
|
|
ENDCG
|
|
}
|
|
|
|
/*ase_pass*/
|
|
Pass
|
|
{
|
|
/*ase_hide_pass*/
|
|
Name "Deferred"
|
|
Tags { "LightMode"="Deferred" }
|
|
|
|
AlphaToMask Off
|
|
|
|
CGPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#pragma target 3.0
|
|
#pragma exclude_renderers nomrt
|
|
#pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
|
|
#pragma multi_compile_prepassfinal
|
|
#ifndef UNITY_PASS_DEFERRED
|
|
#define UNITY_PASS_DEFERRED
|
|
#endif
|
|
#include "HLSLSupport.cginc"
|
|
#if !defined( UNITY_INSTANCED_LOD_FADE )
|
|
#define UNITY_INSTANCED_LOD_FADE
|
|
#endif
|
|
#if !defined( UNITY_INSTANCED_SH )
|
|
#define UNITY_INSTANCED_SH
|
|
#endif
|
|
#if !defined( UNITY_INSTANCED_LIGHTMAPSTS )
|
|
#define UNITY_INSTANCED_LIGHTMAPSTS
|
|
#endif
|
|
#include "UnityShaderVariables.cginc"
|
|
#include "UnityCG.cginc"
|
|
#include "Lighting.cginc"
|
|
#include "UnityPBSLighting.cginc"
|
|
|
|
/*ase_pragma*/
|
|
struct appdata {
|
|
float4 vertex : POSITION;
|
|
float4 tangent : TANGENT;
|
|
float3 normal : NORMAL;
|
|
float4 texcoord1 : TEXCOORD1;
|
|
float4 texcoord2 : TEXCOORD2;
|
|
/*ase_vdata:p=p;t=t;n=n;uv1=tc1.xyzw;uv2=tc2.xyzw*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct v2f {
|
|
#if UNITY_VERSION >= 201810
|
|
UNITY_POSITION(pos);
|
|
#else
|
|
float4 pos : SV_POSITION;
|
|
#endif
|
|
float4 lmap : TEXCOORD2;
|
|
#ifndef LIGHTMAP_ON
|
|
#if UNITY_SHOULD_SAMPLE_SH && !UNITY_SAMPLE_FULL_SH_PER_PIXEL
|
|
half3 sh : TEXCOORD3;
|
|
#endif
|
|
#else
|
|
#ifdef DIRLIGHTMAP_OFF
|
|
float4 lmapFadePos : TEXCOORD4;
|
|
#endif
|
|
#endif
|
|
float4 tSpace0 : TEXCOORD5;
|
|
float4 tSpace1 : TEXCOORD6;
|
|
float4 tSpace2 : TEXCOORD7;
|
|
/*ase_interp(8,):sp=sp.xyzw;wn.xyz=tc5.xyz;wt.xyz=tc6.xyz;wbt.xyz=tc7.xyz;wp.x=tc5.w;wp.y=tc6.w;wp.z=tc7.w*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
#ifdef LIGHTMAP_ON
|
|
float4 unity_LightmapFade;
|
|
#endif
|
|
fixed4 unity_Ambient;
|
|
#ifdef TESSELLATION_ON
|
|
float _TessPhongStrength;
|
|
float _TessValue;
|
|
float _TessMin;
|
|
float _TessMax;
|
|
float _TessEdgeLength;
|
|
float _TessMaxDisp;
|
|
#endif
|
|
/*ase_globals*/
|
|
|
|
/*ase_funcs*/
|
|
|
|
v2f VertexFunction (appdata v /*ase_vert_input*/ ) {
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
v2f o;
|
|
UNITY_INITIALIZE_OUTPUT(v2f,o);
|
|
UNITY_TRANSFER_INSTANCE_ID(v,o);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
|
|
|
/*ase_vert_code:v=appdata;o=v2f*/
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = v.vertex.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3(0, 0, 0);
|
|
#endif
|
|
float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;10;-1;_Vertex*/defaultVertexValue/*end*/;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
v.vertex.xyz = vertexValue;
|
|
#else
|
|
v.vertex.xyz += vertexValue;
|
|
#endif
|
|
v.vertex.w = 1;
|
|
v.normal = /*ase_vert_out:Vertex Normal;Float3;11;-1;_VertexNormal*/v.normal/*end*/;
|
|
v.tangent = /*ase_vert_out:Vertex Tangent;Float4;12;-1;_VertexTangent*/v.tangent/*end*/;
|
|
|
|
o.pos = UnityObjectToClipPos(v.vertex);
|
|
float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
|
|
fixed3 worldNormal = UnityObjectToWorldNormal(v.normal);
|
|
fixed3 worldTangent = UnityObjectToWorldDir(v.tangent.xyz);
|
|
fixed tangentSign = v.tangent.w * unity_WorldTransformParams.w;
|
|
fixed3 worldBinormal = cross(worldNormal, worldTangent) * tangentSign;
|
|
o.tSpace0 = float4(worldTangent.x, worldBinormal.x, worldNormal.x, worldPos.x);
|
|
o.tSpace1 = float4(worldTangent.y, worldBinormal.y, worldNormal.y, worldPos.y);
|
|
o.tSpace2 = float4(worldTangent.z, worldBinormal.z, worldNormal.z, worldPos.z);
|
|
|
|
#ifdef DYNAMICLIGHTMAP_ON
|
|
o.lmap.zw = v.texcoord2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
|
|
#else
|
|
o.lmap.zw = 0;
|
|
#endif
|
|
#ifdef LIGHTMAP_ON
|
|
o.lmap.xy = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
|
|
#ifdef DIRLIGHTMAP_OFF
|
|
o.lmapFadePos.xyz = (mul(unity_ObjectToWorld, v.vertex).xyz - unity_ShadowFadeCenterAndType.xyz) * unity_ShadowFadeCenterAndType.w;
|
|
o.lmapFadePos.w = (-UnityObjectToViewPos(v.vertex).z) * (1.0 - unity_ShadowFadeCenterAndType.w);
|
|
#endif
|
|
#else
|
|
o.lmap.xy = 0;
|
|
#if UNITY_SHOULD_SAMPLE_SH && !UNITY_SAMPLE_FULL_SH_PER_PIXEL
|
|
o.sh = 0;
|
|
o.sh = ShadeSHPerVertex (worldNormal, o.sh);
|
|
#endif
|
|
#endif
|
|
return o;
|
|
}
|
|
|
|
#if defined(TESSELLATION_ON)
|
|
struct VertexControl
|
|
{
|
|
float4 vertex : INTERNALTESSPOS;
|
|
float4 tangent : TANGENT;
|
|
float3 normal : NORMAL;
|
|
float4 texcoord1 : TEXCOORD1;
|
|
float4 texcoord2 : TEXCOORD2;
|
|
/*ase_vcontrol*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct TessellationFactors
|
|
{
|
|
float edge[3] : SV_TessFactor;
|
|
float inside : SV_InsideTessFactor;
|
|
};
|
|
|
|
VertexControl vert ( appdata v )
|
|
{
|
|
VertexControl o;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
o.vertex = v.vertex;
|
|
o.tangent = v.tangent;
|
|
o.normal = v.normal;
|
|
o.texcoord1 = v.texcoord1;
|
|
o.texcoord2 = v.texcoord2;
|
|
/*ase_control_code:v=appdata;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 defined(ASE_FIXED_TESSELLATION)
|
|
tf = FixedTess( tessValue );
|
|
#elif defined(ASE_DISTANCE_TESSELLATION)
|
|
tf = DistanceBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, tessValue, tessMin, tessMax, UNITY_MATRIX_M, _WorldSpaceCameraPos );
|
|
#elif defined(ASE_LENGTH_TESSELLATION)
|
|
tf = EdgeLengthBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, UNITY_MATRIX_M, _WorldSpaceCameraPos, _ScreenParams );
|
|
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
|
tf = EdgeLengthBasedTessCull(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, tessMaxDisp, UNITY_MATRIX_M, _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
|
|
#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")]
|
|
v2f DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
|
{
|
|
appdata o = (appdata) 0;
|
|
o.vertex = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
|
|
o.tangent = patch[0].tangent * bary.x + patch[1].tangent * bary.y + patch[2].tangent * bary.z;
|
|
o.normal = patch[0].normal * bary.x + patch[1].normal * bary.y + patch[2].normal * bary.z;
|
|
o.texcoord1 = patch[0].texcoord1 * bary.x + patch[1].texcoord1 * bary.y + patch[2].texcoord1 * bary.z;
|
|
o.texcoord2 = patch[0].texcoord2 * bary.x + patch[1].texcoord2 * bary.y + patch[2].texcoord2 * bary.z;
|
|
/*ase_domain_code:patch=VertexControl;o=appdata;bary=SV_DomainLocation*/
|
|
#if defined(ASE_PHONG_TESSELLATION)
|
|
float3 pp[3];
|
|
for (int i = 0; i < 3; ++i)
|
|
pp[i] = o.vertex.xyz - patch[i].normal * (dot(o.vertex.xyz, patch[i].normal) - dot(patch[i].vertex.xyz, patch[i].normal));
|
|
float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/;
|
|
o.vertex.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.vertex.xyz;
|
|
#endif
|
|
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
|
return VertexFunction(o);
|
|
}
|
|
#else
|
|
v2f vert ( appdata v )
|
|
{
|
|
return VertexFunction( v );
|
|
}
|
|
#endif
|
|
|
|
void frag (v2f IN /*ase_frag_input*/
|
|
, out half4 outGBuffer0 : SV_Target0
|
|
, out half4 outGBuffer1 : SV_Target1
|
|
, out half4 outGBuffer2 : SV_Target2
|
|
, out half4 outEmission : SV_Target3
|
|
#if defined(SHADOWS_SHADOWMASK) && (UNITY_ALLOWED_MRT_COUNT > 4)
|
|
, out half4 outShadowMask : SV_Target4
|
|
#endif
|
|
#ifdef _DEPTHOFFSET_ON
|
|
, out float outputDepth : SV_Depth
|
|
#endif
|
|
)
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID(IN);
|
|
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
UNITY_APPLY_DITHER_CROSSFADE(IN.pos.xy);
|
|
#endif
|
|
|
|
#if defined(_SPECULAR_SETUP)
|
|
SurfaceOutputStandardSpecular o = (SurfaceOutputStandardSpecular)0;
|
|
#else
|
|
SurfaceOutputStandard o = (SurfaceOutputStandard)0;
|
|
#endif
|
|
/*ase_local_var:wt*/float3 WorldTangent = float3(IN.tSpace0.x,IN.tSpace1.x,IN.tSpace2.x);
|
|
/*ase_local_var:wbt*/float3 WorldBiTangent = float3(IN.tSpace0.y,IN.tSpace1.y,IN.tSpace2.y);
|
|
/*ase_local_var:wn*/float3 WorldNormal = float3(IN.tSpace0.z,IN.tSpace1.z,IN.tSpace2.z);
|
|
/*ase_local_var:wp*/float3 worldPos = float3(IN.tSpace0.w,IN.tSpace1.w,IN.tSpace2.w);
|
|
/*ase_local_var:wvd*/float3 worldViewDir = normalize(UnityWorldSpaceViewDir(worldPos));
|
|
/*ase_local_var:sc*/half atten = 1;
|
|
|
|
/*ase_frag_code:IN=v2f*/
|
|
o.Albedo = /*ase_frag_out:Albedo;Float3;0;-1;_Albedo*/fixed3( 0.5, 0.5, 0.5 )/*end*/;
|
|
o.Normal = /*ase_frag_out:Normal;Float3;1;-1;_Normal*/fixed3( 0, 0, 1 )/*end*/;
|
|
o.Emission = /*ase_frag_out:Emission;Float3;2;-1;_Emission*/half3( 0, 0, 0 )/*end*/;
|
|
#if defined(_SPECULAR_SETUP)
|
|
o.Specular = /*ase_frag_out:Specular;Float3;3;-1;_Specular*/fixed3( 0, 0, 0 )/*end*/;
|
|
#else
|
|
o.Metallic = /*ase_frag_out:Metallic;Float;4;-1;_Metallic*/0/*end*/;
|
|
#endif
|
|
o.Smoothness = /*ase_frag_out:Smoothness;Float;5;-1;_Smoothness*/0/*end*/;
|
|
o.Occlusion = /*ase_frag_out:Occlusion;Float;6;-1;_Occlusion*/1/*end*/;
|
|
o.Alpha = /*ase_frag_out:Alpha;Float;7;-1;_Alpha*/1/*end*/;
|
|
float AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;8;-1;_AlphaClip*/0.5/*end*/;
|
|
float3 BakedGI = /*ase_frag_out:Baked GI;Float3;9;-1;_BakedGI*/0/*end*/;
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
clip( o.Alpha - AlphaClipThreshold );
|
|
#endif
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
outputDepth = IN.pos.z;
|
|
#endif
|
|
|
|
#ifndef USING_DIRECTIONAL_LIGHT
|
|
fixed3 lightDir = normalize(UnityWorldSpaceLightDir(worldPos));
|
|
#else
|
|
fixed3 lightDir = _WorldSpaceLightPos0.xyz;
|
|
#endif
|
|
|
|
float3 worldN;
|
|
worldN.x = dot(IN.tSpace0.xyz, o.Normal);
|
|
worldN.y = dot(IN.tSpace1.xyz, o.Normal);
|
|
worldN.z = dot(IN.tSpace2.xyz, o.Normal);
|
|
worldN = normalize(worldN);
|
|
o.Normal = worldN;
|
|
|
|
UnityGI gi;
|
|
UNITY_INITIALIZE_OUTPUT(UnityGI, gi);
|
|
gi.indirect.diffuse = 0;
|
|
gi.indirect.specular = 0;
|
|
gi.light.color = 0;
|
|
gi.light.dir = half3(0,1,0);
|
|
|
|
UnityGIInput giInput;
|
|
UNITY_INITIALIZE_OUTPUT(UnityGIInput, giInput);
|
|
giInput.light = gi.light;
|
|
giInput.worldPos = worldPos;
|
|
giInput.worldViewDir = worldViewDir;
|
|
giInput.atten = atten;
|
|
#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
|
|
giInput.lightmapUV = IN.lmap;
|
|
#else
|
|
giInput.lightmapUV = 0.0;
|
|
#endif
|
|
#if UNITY_SHOULD_SAMPLE_SH && !UNITY_SAMPLE_FULL_SH_PER_PIXEL
|
|
giInput.ambient = IN.sh;
|
|
#else
|
|
giInput.ambient.rgb = 0.0;
|
|
#endif
|
|
giInput.probeHDR[0] = unity_SpecCube0_HDR;
|
|
giInput.probeHDR[1] = unity_SpecCube1_HDR;
|
|
#if defined(UNITY_SPECCUBE_BLENDING) || defined(UNITY_SPECCUBE_BOX_PROJECTION)
|
|
giInput.boxMin[0] = unity_SpecCube0_BoxMin;
|
|
#endif
|
|
#ifdef UNITY_SPECCUBE_BOX_PROJECTION
|
|
giInput.boxMax[0] = unity_SpecCube0_BoxMax;
|
|
giInput.probePosition[0] = unity_SpecCube0_ProbePosition;
|
|
giInput.boxMax[1] = unity_SpecCube1_BoxMax;
|
|
giInput.boxMin[1] = unity_SpecCube1_BoxMin;
|
|
giInput.probePosition[1] = unity_SpecCube1_ProbePosition;
|
|
#endif
|
|
|
|
#if defined(_SPECULAR_SETUP)
|
|
LightingStandardSpecular_GI( o, giInput, gi );
|
|
#else
|
|
LightingStandard_GI( o, giInput, gi );
|
|
#endif
|
|
|
|
#ifdef ASE_BAKEDGI
|
|
gi.indirect.diffuse = BakedGI;
|
|
#endif
|
|
|
|
#if UNITY_SHOULD_SAMPLE_SH && !defined(LIGHTMAP_ON) && defined(ASE_NO_AMBIENT)
|
|
gi.indirect.diffuse = 0;
|
|
#endif
|
|
|
|
#if defined(_SPECULAR_SETUP)
|
|
outEmission = LightingStandardSpecular_Deferred( o, worldViewDir, gi, outGBuffer0, outGBuffer1, outGBuffer2 );
|
|
#else
|
|
outEmission = LightingStandard_Deferred( o, worldViewDir, gi, outGBuffer0, outGBuffer1, outGBuffer2 );
|
|
#endif
|
|
|
|
#if defined(SHADOWS_SHADOWMASK) && (UNITY_ALLOWED_MRT_COUNT > 4)
|
|
outShadowMask = UnityGetRawBakedOcclusions (IN.lmap.xy, float3(0, 0, 0));
|
|
#endif
|
|
#ifndef UNITY_HDR_ON
|
|
outEmission.rgb = exp2(-outEmission.rgb);
|
|
#endif
|
|
}
|
|
ENDCG
|
|
}
|
|
|
|
/*ase_pass*/
|
|
Pass
|
|
{
|
|
/*ase_hide_pass*/
|
|
Name "Meta"
|
|
Tags { "LightMode"="Meta" }
|
|
Cull Off
|
|
|
|
CGPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
|
|
#pragma shader_feature EDITOR_VISUALIZATION
|
|
#ifndef UNITY_PASS_META
|
|
#define UNITY_PASS_META
|
|
#endif
|
|
#include "HLSLSupport.cginc"
|
|
#if !defined( UNITY_INSTANCED_LOD_FADE )
|
|
#define UNITY_INSTANCED_LOD_FADE
|
|
#endif
|
|
#if !defined( UNITY_INSTANCED_SH )
|
|
#define UNITY_INSTANCED_SH
|
|
#endif
|
|
#if !defined( UNITY_INSTANCED_LIGHTMAPSTS )
|
|
#define UNITY_INSTANCED_LIGHTMAPSTS
|
|
#endif
|
|
#include "UnityShaderVariables.cginc"
|
|
#include "UnityCG.cginc"
|
|
#include "Lighting.cginc"
|
|
#include "UnityPBSLighting.cginc"
|
|
#include "UnityMetaPass.cginc"
|
|
|
|
/*ase_pragma*/
|
|
struct appdata {
|
|
float4 vertex : POSITION;
|
|
float4 tangent : TANGENT;
|
|
float3 normal : NORMAL;
|
|
float4 texcoord1 : TEXCOORD1;
|
|
float4 texcoord2 : TEXCOORD2;
|
|
/*ase_vdata:p=p;t=t;n=n;uv1=tc1.xyzw;uv2=tc2.xyzw*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
struct v2f {
|
|
#if UNITY_VERSION >= 201810
|
|
UNITY_POSITION(pos);
|
|
#else
|
|
float4 pos : SV_POSITION;
|
|
#endif
|
|
#ifdef EDITOR_VISUALIZATION
|
|
float2 vizUV : TEXCOORD1;
|
|
float4 lightCoord : TEXCOORD2;
|
|
#endif
|
|
/*ase_interp(3,):sp=sp.xyzw*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
#ifdef TESSELLATION_ON
|
|
float _TessPhongStrength;
|
|
float _TessValue;
|
|
float _TessMin;
|
|
float _TessMax;
|
|
float _TessEdgeLength;
|
|
float _TessMaxDisp;
|
|
#endif
|
|
/*ase_globals*/
|
|
|
|
/*ase_funcs*/
|
|
|
|
v2f VertexFunction (appdata v /*ase_vert_input*/ ) {
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
v2f o;
|
|
UNITY_INITIALIZE_OUTPUT(v2f,o);
|
|
UNITY_TRANSFER_INSTANCE_ID(v,o);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
|
|
|
/*ase_vert_code:v=appdata;o=v2f*/
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = v.vertex.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3(0, 0, 0);
|
|
#endif
|
|
float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;4;-1;_Vertex*/defaultVertexValue/*end*/;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
v.vertex.xyz = vertexValue;
|
|
#else
|
|
v.vertex.xyz += vertexValue;
|
|
#endif
|
|
v.vertex.w = 1;
|
|
v.normal = /*ase_vert_out:Vertex Normal;Float3;5;-1;_VertexNormal*/v.normal/*end*/;
|
|
v.tangent = /*ase_vert_out:Vertex Tangent;Float4;6;-1;_VertexTangent*/v.tangent/*end*/;
|
|
|
|
#ifdef EDITOR_VISUALIZATION
|
|
o.vizUV = 0;
|
|
o.lightCoord = 0;
|
|
if (unity_VisualizationMode == EDITORVIZ_TEXTURE)
|
|
o.vizUV = UnityMetaVizUV(unity_EditorViz_UVIndex, v.texcoord.xy, v.texcoord1.xy, v.texcoord2.xy, unity_EditorViz_Texture_ST);
|
|
else if (unity_VisualizationMode == EDITORVIZ_SHOWLIGHTMASK)
|
|
{
|
|
o.vizUV = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
|
|
o.lightCoord = mul(unity_EditorViz_WorldToLight, mul(unity_ObjectToWorld, float4(v.vertex.xyz, 1)));
|
|
}
|
|
#endif
|
|
|
|
o.pos = UnityMetaVertexPosition(v.vertex, v.texcoord1.xy, v.texcoord2.xy, unity_LightmapST, unity_DynamicLightmapST);
|
|
|
|
return o;
|
|
}
|
|
|
|
#if defined(TESSELLATION_ON)
|
|
struct VertexControl
|
|
{
|
|
float4 vertex : INTERNALTESSPOS;
|
|
float4 tangent : TANGENT;
|
|
float3 normal : NORMAL;
|
|
float4 texcoord1 : TEXCOORD1;
|
|
float4 texcoord2 : TEXCOORD2;
|
|
/*ase_vcontrol*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct TessellationFactors
|
|
{
|
|
float edge[3] : SV_TessFactor;
|
|
float inside : SV_InsideTessFactor;
|
|
};
|
|
|
|
VertexControl vert ( appdata v )
|
|
{
|
|
VertexControl o;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
o.vertex = v.vertex;
|
|
o.tangent = v.tangent;
|
|
o.normal = v.normal;
|
|
o.texcoord1 = v.texcoord1;
|
|
o.texcoord2 = v.texcoord2;
|
|
/*ase_control_code:v=appdata;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 defined(ASE_FIXED_TESSELLATION)
|
|
tf = FixedTess( tessValue );
|
|
#elif defined(ASE_DISTANCE_TESSELLATION)
|
|
tf = DistanceBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, tessValue, tessMin, tessMax, UNITY_MATRIX_M, _WorldSpaceCameraPos );
|
|
#elif defined(ASE_LENGTH_TESSELLATION)
|
|
tf = EdgeLengthBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, UNITY_MATRIX_M, _WorldSpaceCameraPos, _ScreenParams );
|
|
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
|
tf = EdgeLengthBasedTessCull(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, tessMaxDisp, UNITY_MATRIX_M, _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
|
|
#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")]
|
|
v2f DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
|
{
|
|
appdata o = (appdata) 0;
|
|
o.vertex = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
|
|
o.tangent = patch[0].tangent * bary.x + patch[1].tangent * bary.y + patch[2].tangent * bary.z;
|
|
o.normal = patch[0].normal * bary.x + patch[1].normal * bary.y + patch[2].normal * bary.z;
|
|
o.texcoord1 = patch[0].texcoord1 * bary.x + patch[1].texcoord1 * bary.y + patch[2].texcoord1 * bary.z;
|
|
o.texcoord2 = patch[0].texcoord2 * bary.x + patch[1].texcoord2 * bary.y + patch[2].texcoord2 * bary.z;
|
|
/*ase_domain_code:patch=VertexControl;o=appdata;bary=SV_DomainLocation*/
|
|
#if defined(ASE_PHONG_TESSELLATION)
|
|
float3 pp[3];
|
|
for (int i = 0; i < 3; ++i)
|
|
pp[i] = o.vertex.xyz - patch[i].normal * (dot(o.vertex.xyz, patch[i].normal) - dot(patch[i].vertex.xyz, patch[i].normal));
|
|
float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/;
|
|
o.vertex.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.vertex.xyz;
|
|
#endif
|
|
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
|
return VertexFunction(o);
|
|
}
|
|
#else
|
|
v2f vert ( appdata v )
|
|
{
|
|
return VertexFunction( v );
|
|
}
|
|
#endif
|
|
|
|
fixed4 frag (v2f IN /*ase_frag_input*/
|
|
#ifdef _DEPTHOFFSET_ON
|
|
, out float outputDepth : SV_Depth
|
|
#endif
|
|
) : SV_Target
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID(IN);
|
|
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
UNITY_APPLY_DITHER_CROSSFADE(IN.pos.xy);
|
|
#endif
|
|
|
|
#if defined(_SPECULAR_SETUP)
|
|
SurfaceOutputStandardSpecular o = (SurfaceOutputStandardSpecular)0;
|
|
#else
|
|
SurfaceOutputStandard o = (SurfaceOutputStandard)0;
|
|
#endif
|
|
|
|
/*ase_frag_code:IN=v2f*/
|
|
o.Albedo = /*ase_frag_out:Albedo;Float3;0;-1;_Albedo*/fixed3( 0.5, 0.5, 0.5 )/*end*/;
|
|
o.Normal = fixed3( 0, 0, 1 );
|
|
o.Emission = /*ase_frag_out:Emission;Float3;1;-1;_Emission*/half3( 0, 0, 0 )/*end*/;
|
|
o.Alpha = /*ase_frag_out:Alpha;Float;2;-1;_Alpha*/1/*end*/;
|
|
float AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;3;-1;_AlphaClip*/0.5/*end*/;
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
clip( o.Alpha - AlphaClipThreshold );
|
|
#endif
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
outputDepth = IN.pos.z;
|
|
#endif
|
|
|
|
UnityMetaInput metaIN;
|
|
UNITY_INITIALIZE_OUTPUT(UnityMetaInput, metaIN);
|
|
metaIN.Albedo = o.Albedo;
|
|
metaIN.Emission = o.Emission;
|
|
#ifdef EDITOR_VISUALIZATION
|
|
metaIN.VizUV = IN.vizUV;
|
|
metaIN.LightCoord = IN.lightCoord;
|
|
#endif
|
|
return UnityMetaFragment(metaIN);
|
|
}
|
|
ENDCG
|
|
}
|
|
|
|
/*ase_pass*/
|
|
Pass
|
|
{
|
|
/*ase_hide_pass*/
|
|
Name "ShadowCaster"
|
|
Tags { "LightMode"="ShadowCaster" }
|
|
ZWrite On
|
|
ZTest LEqual
|
|
AlphaToMask Off
|
|
|
|
CGPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
|
|
#pragma multi_compile_shadowcaster
|
|
#ifndef UNITY_PASS_SHADOWCASTER
|
|
#define UNITY_PASS_SHADOWCASTER
|
|
#endif
|
|
#include "HLSLSupport.cginc"
|
|
#ifndef UNITY_INSTANCED_LOD_FADE
|
|
#define UNITY_INSTANCED_LOD_FADE
|
|
#endif
|
|
#ifndef UNITY_INSTANCED_SH
|
|
#define UNITY_INSTANCED_SH
|
|
#endif
|
|
#ifndef UNITY_INSTANCED_LIGHTMAPSTS
|
|
#define UNITY_INSTANCED_LIGHTMAPSTS
|
|
#endif
|
|
#if ( SHADER_API_D3D11 || SHADER_API_GLCORE || SHADER_API_GLES || SHADER_API_GLES3 || SHADER_API_METAL || SHADER_API_VULKAN )
|
|
#define CAN_SKIP_VPOS
|
|
#endif
|
|
#include "UnityShaderVariables.cginc"
|
|
#include "UnityCG.cginc"
|
|
#include "Lighting.cginc"
|
|
#include "UnityPBSLighting.cginc"
|
|
|
|
/*ase_pragma*/
|
|
struct appdata {
|
|
float4 vertex : POSITION;
|
|
float4 tangent : TANGENT;
|
|
float3 normal : NORMAL;
|
|
float4 texcoord1 : TEXCOORD1;
|
|
float4 texcoord2 : TEXCOORD2;
|
|
/*ase_vdata:p=p;t=t;n=n;uv1=tc1.xyzw;uv2=tc2.xyzw*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct v2f {
|
|
V2F_SHADOW_CASTER;
|
|
/*ase_interp(2,):sp=sp.xyzw*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
#ifdef UNITY_STANDARD_USE_DITHER_MASK
|
|
sampler3D _DitherMaskLOD;
|
|
#endif
|
|
#ifdef TESSELLATION_ON
|
|
float _TessPhongStrength;
|
|
float _TessValue;
|
|
float _TessMin;
|
|
float _TessMax;
|
|
float _TessEdgeLength;
|
|
float _TessMaxDisp;
|
|
#endif
|
|
/*ase_globals*/
|
|
|
|
/*ase_funcs*/
|
|
|
|
v2f VertexFunction (appdata v /*ase_vert_input*/ ) {
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
v2f o;
|
|
UNITY_INITIALIZE_OUTPUT(v2f,o);
|
|
UNITY_TRANSFER_INSTANCE_ID(v,o);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
|
|
|
/*ase_vert_code:v=appdata;o=v2f*/
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = v.vertex.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3(0, 0, 0);
|
|
#endif
|
|
float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;3;-1;_Vertex*/defaultVertexValue/*end*/;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
v.vertex.xyz = vertexValue;
|
|
#else
|
|
v.vertex.xyz += vertexValue;
|
|
#endif
|
|
v.vertex.w = 1;
|
|
v.normal = /*ase_vert_out:Vertex Normal;Float3;4;-1;_VertexNormal*/v.normal/*end*/;
|
|
v.tangent = /*ase_vert_out:Vertex Tangent;Float4;5;-1;_VertexTangent*/v.tangent/*end*/;
|
|
|
|
TRANSFER_SHADOW_CASTER_NORMALOFFSET(o)
|
|
return o;
|
|
}
|
|
|
|
#if defined(TESSELLATION_ON)
|
|
struct VertexControl
|
|
{
|
|
float4 vertex : INTERNALTESSPOS;
|
|
float4 tangent : TANGENT;
|
|
float3 normal : NORMAL;
|
|
float4 texcoord1 : TEXCOORD1;
|
|
float4 texcoord2 : TEXCOORD2;
|
|
/*ase_vcontrol*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct TessellationFactors
|
|
{
|
|
float edge[3] : SV_TessFactor;
|
|
float inside : SV_InsideTessFactor;
|
|
};
|
|
|
|
VertexControl vert ( appdata v )
|
|
{
|
|
VertexControl o;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
o.vertex = v.vertex;
|
|
o.tangent = v.tangent;
|
|
o.normal = v.normal;
|
|
o.texcoord1 = v.texcoord1;
|
|
o.texcoord2 = v.texcoord2;
|
|
/*ase_control_code:v=appdata;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 defined(ASE_FIXED_TESSELLATION)
|
|
tf = FixedTess( tessValue );
|
|
#elif defined(ASE_DISTANCE_TESSELLATION)
|
|
tf = DistanceBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, tessValue, tessMin, tessMax, UNITY_MATRIX_M, _WorldSpaceCameraPos );
|
|
#elif defined(ASE_LENGTH_TESSELLATION)
|
|
tf = EdgeLengthBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, UNITY_MATRIX_M, _WorldSpaceCameraPos, _ScreenParams );
|
|
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
|
tf = EdgeLengthBasedTessCull(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, tessMaxDisp, UNITY_MATRIX_M, _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
|
|
#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")]
|
|
v2f DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
|
{
|
|
appdata o = (appdata) 0;
|
|
o.vertex = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
|
|
o.tangent = patch[0].tangent * bary.x + patch[1].tangent * bary.y + patch[2].tangent * bary.z;
|
|
o.normal = patch[0].normal * bary.x + patch[1].normal * bary.y + patch[2].normal * bary.z;
|
|
o.texcoord1 = patch[0].texcoord1 * bary.x + patch[1].texcoord1 * bary.y + patch[2].texcoord1 * bary.z;
|
|
o.texcoord2 = patch[0].texcoord2 * bary.x + patch[1].texcoord2 * bary.y + patch[2].texcoord2 * bary.z;
|
|
/*ase_domain_code:patch=VertexControl;o=appdata;bary=SV_DomainLocation*/
|
|
#if defined(ASE_PHONG_TESSELLATION)
|
|
float3 pp[3];
|
|
for (int i = 0; i < 3; ++i)
|
|
pp[i] = o.vertex.xyz - patch[i].normal * (dot(o.vertex.xyz, patch[i].normal) - dot(patch[i].vertex.xyz, patch[i].normal));
|
|
float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/;
|
|
o.vertex.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.vertex.xyz;
|
|
#endif
|
|
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
|
return VertexFunction(o);
|
|
}
|
|
#else
|
|
v2f vert ( appdata v )
|
|
{
|
|
return VertexFunction( v );
|
|
}
|
|
#endif
|
|
|
|
fixed4 frag (v2f IN /*ase_frag_input*/
|
|
#ifdef _DEPTHOFFSET_ON
|
|
, out float outputDepth : SV_Depth
|
|
#endif
|
|
#if !defined( CAN_SKIP_VPOS )
|
|
, UNITY_VPOS_TYPE vpos : VPOS
|
|
#endif
|
|
) : SV_Target
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID(IN);
|
|
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
UNITY_APPLY_DITHER_CROSSFADE(IN.pos.xy);
|
|
#endif
|
|
|
|
#if defined(_SPECULAR_SETUP)
|
|
SurfaceOutputStandardSpecular o = (SurfaceOutputStandardSpecular)0;
|
|
#else
|
|
SurfaceOutputStandard o = (SurfaceOutputStandard)0;
|
|
#endif
|
|
|
|
/*ase_frag_code:IN=v2f*/
|
|
o.Normal = fixed3( 0, 0, 1 );
|
|
o.Occlusion = 1;
|
|
o.Alpha = /*ase_frag_out:Alpha;Float;0;-1;_Alpha*/1/*end*/;
|
|
float AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;1;-1;_AlphaClip*/0.5/*end*/;
|
|
float AlphaClipThresholdShadow = /*ase_frag_out:Alpha Clip Threshold Shadow;Float;2;-1;_AlphaClipShadow*/0.5/*end*/;
|
|
|
|
#ifdef _ALPHATEST_SHADOW_ON
|
|
if (unity_LightShadowBias.z != 0.0)
|
|
clip(o.Alpha - AlphaClipThresholdShadow);
|
|
#ifdef _ALPHATEST_ON
|
|
else
|
|
clip(o.Alpha - AlphaClipThreshold);
|
|
#endif
|
|
#else
|
|
#ifdef _ALPHATEST_ON
|
|
clip(o.Alpha - AlphaClipThreshold);
|
|
#endif
|
|
#endif
|
|
|
|
#if defined( CAN_SKIP_VPOS )
|
|
float2 vpos = IN.pos;
|
|
#endif
|
|
|
|
#ifdef UNITY_STANDARD_USE_DITHER_MASK
|
|
half alphaRef = tex3D(_DitherMaskLOD, float3(vpos.xy*0.25,o.Alpha*0.9375)).a;
|
|
clip(alphaRef - 0.01);
|
|
#endif
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
outputDepth = IN.pos.z;
|
|
#endif
|
|
|
|
SHADOW_CASTER_FRAGMENT(IN)
|
|
}
|
|
ENDCG
|
|
}
|
|
/*ase_pass_end*/
|
|
}
|
|
CustomEditor "ASEMaterialInspector"
|
|
}
|