2993 lines
108 KiB
GLSL
2993 lines
108 KiB
GLSL
Shader /*ase_name*/ "Hidden/Built-In/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
|
|
|
|
//_InstancedTerrainNormals("Specular Highlights", Float) = 1.0
|
|
}
|
|
|
|
SubShader
|
|
{
|
|
/*ase_subshader_options:Name=Additional Options
|
|
Option:Category,InvertActionOnDeselection:Geometry,Terrain,Impostor:Geometry
|
|
Geometry:SetDefine:ASE_GEOMETRY
|
|
Terrain:SetDefine:ASE_TERRAIN
|
|
Terrain:ShowOption: Instanced Terrain Normals
|
|
Impostor:SetDefine:ASE_IMPOSTOR
|
|
Option: Instanced Terrain Normals:Force Vertex,Force Pixel,Material Option:Force Pixel
|
|
Force Vertex?Category=Terrain:SetShaderProperty:_InstancedTerrainNormals,//[KeywordEnum(Vertex, Pixel)] _InstancedTerrainNormals("Instanced Terrain Normals", Float) = 1.0
|
|
Force Pixel?Category=Terrain:SetDefine:ForwardBase:_INSTANCEDTERRAINNORMALS_PIXEL
|
|
Force Pixel?Category=Terrain:SetDefine:ForwardAdd:_INSTANCEDTERRAINNORMALS_PIXEL
|
|
Force Pixel?Category=Terrain:SetDefine:Deferred:_INSTANCEDTERRAINNORMALS_PIXEL
|
|
Force Pixel?Category=Terrain:SetShaderProperty:_InstancedTerrainNormals,//[KeywordEnum(Vertex, Pixel)] _InstancedTerrainNormals("Instanced Terrain Normals", Float) = 1.0
|
|
Material Option?Category=Terrain:SetDefine:ForwardBase:pragma shader_feature _INSTANCEDTERRAINNORMALS_PIXEL
|
|
Material Option?Category=Terrain:SetDefine:ForwardAdd:pragma shader_feature _INSTANCEDTERRAINNORMALS_PIXEL
|
|
Material Option?Category=Terrain:SetDefine:Deferred:pragma shader_feature _INSTANCEDTERRAINNORMALS_PIXEL
|
|
Material Option?Category=Terrain:SetShaderProperty:_InstancedTerrainNormals,[KeywordEnum(Vertex, Pixel)] _InstancedTerrainNormals("Instanced Terrain Normals", Float) = 1.0
|
|
Option:Workflow:Specular,Metallic,BlinnPhong,Lambert:Metallic
|
|
Specular:SetDefine:_SPECULAR_SETUP 1
|
|
Specular:RemoveDefine:ASE_LIGHTING_SIMPLE 1
|
|
Specular:ShowPort:Specular
|
|
Specular:HidePort:Metallic
|
|
Specular:ShowPort:Smoothness
|
|
Specular:ShowPort:Occlusion
|
|
Metallic:RemoveDefine:_SPECULAR_SETUP 1
|
|
Metallic:RemoveDefine:ASE_LIGHTING_SIMPLE 1
|
|
Metallic:HidePort:Specular
|
|
Metallic:ShowPort:Metallic
|
|
Metallic:ShowPort:Smoothness
|
|
Metallic:ShowPort:Occlusion
|
|
BlinnPhong:SetDefine:_SPECULAR_SETUP 1
|
|
BlinnPhong:SetDefine:ASE_LIGHTING_SIMPLE 1
|
|
BlinnPhong:ShowPort:Specular
|
|
BlinnPhong:HidePort:Metallic
|
|
BlinnPhong:ShowPort:Smoothness
|
|
BlinnPhong:HidePort:Occlusion
|
|
Lambert:RemoveDefine:_SPECULAR_SETUP 1
|
|
Lambert:SetDefine:ASE_LIGHTING_SIMPLE 1
|
|
Lambert:HidePort:Specular
|
|
Lambert:HidePort:Metallic
|
|
Lambert:HidePort:Smoothness
|
|
Lambert:HidePort:Occlusion
|
|
Option:Surface:Opaque,Transparent:Opaque
|
|
Opaque:SetPropertyOnSubShader:RenderType,Opaque
|
|
Opaque:SetPropertyOnSubShader:RenderQueue,Geometry
|
|
Opaque:SetPropertyOnSubShader:ZWrite,On
|
|
Opaque:HideOption: Blend
|
|
Opaque:HideOption: Dither Shadows
|
|
Transparent:SetPropertyOnSubShader:RenderType,Transparent
|
|
Transparent:SetPropertyOnSubShader:RenderQueue,Transparent
|
|
Transparent:SetPropertyOnSubShader:ZWrite,Off
|
|
Transparent:ShowOption: Blend
|
|
Transparent:ShowOption: Dither Shadows
|
|
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: 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:Alpha Clipping:false,true:false
|
|
true:ShowOption: Use Shadow Threshold
|
|
true:ShowPort:ForwardBase:Alpha Clip Threshold
|
|
true:SetDefine:pragma multi_compile_local _ALPHATEST_ON
|
|
false:HideOption: Use Shadow Threshold
|
|
false:HidePort:ForwardBase:Alpha Clip Threshold
|
|
false:RemoveDefine:pragma multi_compile_local _ALPHATEST_ON
|
|
Option: Use Shadow Threshold:false,true:false
|
|
true:SetDefine:_ALPHATEST_SHADOW_ON 1
|
|
true:ShowPort:ForwardBase:Alpha Clip Threshold Shadow
|
|
true:SetShaderProperty:_UseShadowThreshold,1
|
|
false,disable:RemoveDefine:_ALPHATEST_SHADOW_ON 1
|
|
false,disable:HidePort:ForwardBase:Alpha Clip Threshold Shadow
|
|
Option:Deferred Pass:false,true:true
|
|
true:IncludePass:Deferred
|
|
false:ExcludePass:Deferred
|
|
Option:Normal Space,InvertActionOnDeselection:Tangent,Object,World:Tangent
|
|
Tangent:SetDefine:ASE_FRAGMENT_NORMAL 0
|
|
Tangent:SetPortName:ForwardBase:_Normal,Normal
|
|
Object:SetDefine:ASE_FRAGMENT_NORMAL 1
|
|
Object:SetPortName:ForwardBase:_Normal,Normal OS
|
|
World:SetDefine:ASE_FRAGMENT_NORMAL 2
|
|
World:SetPortName:ForwardBase:_Normal,Normal WS
|
|
Option:Transmission:false,true:false
|
|
false:RemoveDefine:ASE_TRANSMISSION 1
|
|
false:HidePort:ForwardBase:Transmission
|
|
false:HideOption: Transmission Shadow
|
|
true:SetDefine:ASE_TRANSMISSION 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:ASE_TRANSLUCENCY 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:ASE_TRANSLUCENCY 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:Receive Shadows:false,true:true
|
|
true:SetDefine:ASE_RECEIVE_SHADOWS
|
|
false:RemoveDefine:ASE_RECEIVE_SHADOWS
|
|
Option:Receive Specular:Force Off,Force On,Material Toggle:Material Toggle
|
|
Force On:RemoveDefine:ForwardBase:pragma multi_compile_local_fragment _SPECULARHIGHLIGHTS_OFF
|
|
Force On:RemoveDefine:ForwardAdd:pragma multi_compile_local_fragment _SPECULARHIGHLIGHTS_OFF
|
|
Force On:RemoveDefine:Deferred:pragma multi_compile_local_fragment _SPECULARHIGHLIGHTS_OFF
|
|
Force On:RemoveDefine:ForwardBase:pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF
|
|
Force On:RemoveDefine:ForwardAdd:pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF
|
|
Force On:RemoveDefine:Deferred:pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF
|
|
Force On:SetShaderProperty:_SpecularHighlights,//[ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0
|
|
Force Off:RemoveDefine:ForwardBase:pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF
|
|
Force Off:RemoveDefine:ForwardAdd:pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF
|
|
Force Off:RemoveDefine:Deferred:pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF
|
|
Force Off:SetDefine:ForwardBase:pragma multi_compile_local_fragment _SPECULARHIGHLIGHTS_OFF
|
|
Force Off:SetDefine:ForwardAdd:pragma multi_compile_local_fragment _SPECULARHIGHLIGHTS_OFF
|
|
Force Off:SetDefine:Deferred:pragma multi_compile_local_fragment _SPECULARHIGHLIGHTS_OFF
|
|
Force Off:SetShaderProperty:_SpecularHighlights,//[ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0
|
|
Material Toggle:SetDefine:ForwardBase:pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF
|
|
Material Toggle:SetDefine:ForwardAdd:pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF
|
|
Material Toggle:SetDefine:Deferred:pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF
|
|
Material Toggle:RemoveDefine:ForwardBase:pragma multi_compile_local_fragment _SPECULARHIGHLIGHTS_OFF
|
|
Material Toggle:RemoveDefine:ForwardAdd:pragma multi_compile_local_fragment _SPECULARHIGHLIGHTS_OFF
|
|
Material Toggle:RemoveDefine:Deferred:pragma multi_compile_local_fragment _SPECULARHIGHLIGHTS_OFF
|
|
Material Toggle:SetShaderProperty:_SpecularHighlights,[ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0
|
|
Option:Receive Reflections:Force Off,Force On,Material Toggle:Material Toggle
|
|
Force On:RemoveDefine:ForwardBase:pragma multi_compile_local_fragment _GLOSSYREFLECTIONS_OFF
|
|
Force On:RemoveDefine:Deferred:pragma multi_compile_local_fragment _GLOSSYREFLECTIONS_OFF
|
|
Force On:RemoveDefine:ForwardBase:pragma shader_feature_local_fragment _GLOSSYREFLECTIONS_OFF
|
|
Force On:RemoveDefine:Deferred:pragma shader_feature_local_fragment _GLOSSYREFLECTIONS_OFF
|
|
Force On:SetShaderProperty:_GlossyReflections,//[ToggleOff] _GlossyReflections("Reflections", Float) = 1.0
|
|
Force Off:RemoveDefine:ForwardBase:pragma shader_feature_local_fragment _GLOSSYREFLECTIONS_OFF
|
|
Force Off:RemoveDefine:Deferred:pragma shader_feature_local_fragment _GLOSSYREFLECTIONS_OFF
|
|
Force Off:SetDefine:ForwardBase:pragma multi_compile_local_fragment _GLOSSYREFLECTIONS_OFF
|
|
Force Off:SetDefine:Deferred:pragma multi_compile_local_fragment _GLOSSYREFLECTIONS_OFF
|
|
Force Off:SetShaderProperty:_GlossyReflections,//[ToggleOff] _GlossyReflections("Reflections", Float) = 1.0
|
|
Material Toggle:SetDefine:ForwardBase:pragma shader_feature_local_fragment _GLOSSYREFLECTIONS_OFF
|
|
Material Toggle:SetDefine:Deferred:pragma shader_feature_local_fragment _GLOSSYREFLECTIONS_OFF
|
|
Material Toggle:RemoveDefine:ForwardBase:pragma multi_compile_local_fragment _GLOSSYREFLECTIONS_OFF
|
|
Material Toggle:RemoveDefine:Deferred:pragma multi_compile_local_fragment _GLOSSYREFLECTIONS_OFF
|
|
Material Toggle:SetShaderProperty:_GlossyReflections,[ToggleOff] _GlossyReflections("Reflections", Float) = 1.0
|
|
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:ExtraPrePass:pragma multi_compile_fog
|
|
true:SetDefine:ForwardBase:pragma multi_compile_fog
|
|
true:SetDefine:ForwardAdd:pragma multi_compile_fog
|
|
true:SetDefine:ASE_FOG
|
|
false:SetDefine:ExtraPrePass:pragma multi_compile_fog
|
|
false:SetDefine:ForwardBase:pragma multi_compile_fog
|
|
false:SetDefine:ForwardAdd:pragma multi_compile_fog
|
|
false:SetDefine:ASE_FOG
|
|
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:Write Depth:false,true:false
|
|
true:SetDefine:ASE_DEPTH_WRITE_ON
|
|
true:ShowPort:ForwardBase:_DeviceDepth
|
|
false,disable:RemoveDefine:ASE_DEPTH_WRITE_ON
|
|
false,disable:HidePort:ForwardBase:_DeviceDepth
|
|
Option:Extra Pre Pass:false,true:false
|
|
true:IncludePass:ExtraPrePass
|
|
false,disable:ExcludePass:ExtraPrePass
|
|
Option:Tessellation:false,true:false
|
|
true:SetDefine:ASE_TESSELLATION 1
|
|
true:SetDefine:pragma require tessellation tessHW
|
|
true:SetDefine:pragma hull HullFunction
|
|
true:SetDefine:pragma domain DomainFunction
|
|
true:ShowOption: Phong
|
|
true:ShowOption: Type
|
|
false,disable:RemoveDefine:ASE_TESSELLATION 1
|
|
false,disable:RemoveDefine:pragma require tessellation tessHW
|
|
false,disable:RemoveDefine:pragma hull HullFunction
|
|
false,disable:RemoveDefine:pragma domain DomainFunction
|
|
false,disable:HideOption: Phong
|
|
false,disable:HideOption: Type
|
|
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: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
|
|
*/
|
|
|
|
/*ase_unity_cond_begin:<=10000000*/
|
|
// A list of master node input port IDs; will be excluded from generated shaders.
|
|
// 0 => Frag: Albedo
|
|
// 1 => Frag: Normal
|
|
// 2 => Frag: Emission
|
|
// 3 => Frag: Specular
|
|
// 4 => Frag: Metallic
|
|
// 5 => Frag: Smoothness
|
|
// 6 => Frag: Occlusion
|
|
// 7 => Frag: Alpha
|
|
// 8 => Frag: Alpha Clip Threshold
|
|
// 9 => Frag: Alpha Clip Threshold Shadow
|
|
// 10 => Frag: Baked GI
|
|
// 13 => Frag: Transmission
|
|
// 14 => Frag: Translucency
|
|
// 15 => Vert: Vertex Offset
|
|
// 16 => Vert: Vertex Normal
|
|
// 17 => Vert: Vertex Tangent
|
|
// 28 => Frag: Depth
|
|
/*ase_unity_cond_end*/
|
|
|
|
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.5
|
|
|
|
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;
|
|
}
|
|
|
|
float4 ComputeClipSpacePosition( float2 screenPosNorm, float deviceDepth )
|
|
{
|
|
float4 positionCS = float4( screenPosNorm * 2.0 - 1.0, deviceDepth, 1.0 );
|
|
#if UNITY_UV_STARTS_AT_TOP
|
|
positionCS.y = -positionCS.y;
|
|
#endif
|
|
return positionCS;
|
|
}
|
|
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"
|
|
#if defined( ASE_GEOMETRY ) || defined( ASE_IMPOSTOR )
|
|
#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
|
|
#endif
|
|
#include "UnityShaderVariables.cginc"
|
|
#include "UnityCG.cginc"
|
|
#include "Lighting.cginc"
|
|
#include "UnityPBSLighting.cginc"
|
|
#include "AutoLight.cginc"
|
|
|
|
/*ase_pragma*/
|
|
|
|
struct appdata
|
|
{
|
|
float4 vertex : POSITION;
|
|
half3 normal : NORMAL;
|
|
half4 tangent : TANGENT;
|
|
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
|
|
{
|
|
float4 pos : SV_POSITION;
|
|
float4 positionWS : TEXCOORD0; // xyz = positionWS, w = fogCoord
|
|
half3 normalWS : TEXCOORD1;
|
|
half4 tangentWS : TEXCOORD2;
|
|
UNITY_LIGHTING_COORDS( 3, 4 )
|
|
/*ase_interp(5,):sp=sp;wp=tc0.xyz;wn=tc1.xyz;wt=tc2.xyz*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
#ifdef ASE_TESSELLATION
|
|
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*/;
|
|
|
|
float3 positionWS = mul( unity_ObjectToWorld, v.vertex ).xyz;
|
|
half3 normalWS = UnityObjectToWorldNormal( v.normal );
|
|
half3 tangentWS = UnityObjectToWorldDir( v.tangent.xyz );
|
|
|
|
o.pos = UnityObjectToClipPos( v.vertex );
|
|
o.positionWS.xyz = positionWS;
|
|
o.normalWS = normalWS;
|
|
o.tangentWS = half4( tangentWS, v.tangent.w );
|
|
|
|
UNITY_TRANSFER_LIGHTING(o, v.texcoord1.xy);
|
|
#if defined( ASE_FOG )
|
|
o.positionWS.w = o.pos.z;
|
|
#endif
|
|
return o;
|
|
}
|
|
|
|
#if defined(ASE_TESSELLATION)
|
|
struct VertexControl
|
|
{
|
|
float4 vertex : INTERNALTESSPOS;
|
|
half4 tangent : TANGENT;
|
|
half3 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
|
|
|
|
half4 frag( v2f IN /*ase_frag_input*/
|
|
#if defined( ASE_DEPTH_WRITE_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(ASE_LIGHTING_SIMPLE)
|
|
SurfaceOutput o = (SurfaceOutput)0;
|
|
#else
|
|
#if defined(_SPECULAR_SETUP)
|
|
SurfaceOutputStandardSpecular o = (SurfaceOutputStandardSpecular)0;
|
|
#else
|
|
SurfaceOutputStandard o = (SurfaceOutputStandard)0;
|
|
#endif
|
|
#endif
|
|
|
|
half atten;
|
|
{
|
|
#if defined( ASE_RECEIVE_SHADOWS )
|
|
UNITY_LIGHT_ATTENUATION( temp, IN, IN.positionWS.xyz )
|
|
atten = temp;
|
|
#else
|
|
atten = 1;
|
|
#endif
|
|
}
|
|
|
|
/*ase_local_var:wp*/float3 PositionWS = IN.positionWS.xyz;
|
|
/*ase_local_var:wvd*/half3 ViewDirWS = normalize( UnityWorldSpaceViewDir( PositionWS ) );
|
|
/*ase_local_var:spn*/float4 ScreenPosNorm = float4( IN.pos.xy * ( _ScreenParams.zw - 1.0 ), IN.pos.zw );
|
|
/*ase_local_var:sp*/float4 ClipPos = ComputeClipSpacePosition( ScreenPosNorm.xy, IN.pos.z ) * IN.pos.w;
|
|
/*ase_local_var:spu*/float4 ScreenPos = ComputeScreenPos( ClipPos );
|
|
/*ase_local_var:wn*/half3 NormalWS = IN.normalWS;
|
|
/*ase_local_var:wt*/half3 TangentWS = IN.tangentWS.xyz;
|
|
/*ase_local_var:wbt*/half3 BitangentWS = cross( IN.normalWS, IN.tangentWS.xyz ) * IN.tangentWS.w * unity_WorldTransformParams.w;
|
|
/*ase_local_var:latt*/half3 LightAtten = atten;
|
|
float FogCoord = IN.positionWS.w;
|
|
|
|
/*ase_frag_code:IN=v2f*/
|
|
|
|
half3 Color = /*ase_frag_out:Color;Float3;0;-1;_ColorP*/half3( 0, 0, 0 )/*end*/;
|
|
half Alpha = /*ase_frag_out:Alpha;Float;1;-1;_AlphaP*/1/*end*/;
|
|
half AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;2;-1;_AlphaClipP*/0.5/*end*/;
|
|
|
|
#if defined( ASE_DEPTH_WRITE_ON )
|
|
float DeviceDepth = /*ase_frag_out:Depth;Float;28;-1;_DeviceDepth*/IN.pos.z/*end*/;
|
|
#endif
|
|
|
|
half4 c = half4( Color, Alpha );
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
clip( Alpha - AlphaClipThreshold );
|
|
#endif
|
|
|
|
#if defined( ASE_DEPTH_WRITE_ON )
|
|
outputDepth = DeviceDepth;
|
|
#endif
|
|
|
|
#if defined( ASE_FOG )
|
|
UNITY_APPLY_FOG( 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"
|
|
#if defined( ASE_GEOMETRY ) || defined( ASE_IMPOSTOR )
|
|
#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
|
|
#endif
|
|
#include "UnityShaderVariables.cginc"
|
|
#include "UnityCG.cginc"
|
|
#include "Lighting.cginc"
|
|
#include "UnityPBSLighting.cginc"
|
|
#include "AutoLight.cginc"
|
|
|
|
#if defined( UNITY_INSTANCING_ENABLED ) && defined( ASE_INSTANCED_TERRAIN ) && ( defined(_TERRAIN_INSTANCED_PERPIXEL_NORMAL) || defined(_INSTANCEDTERRAINNORMALS_PIXEL) )
|
|
#define ENABLE_TERRAIN_PERPIXEL_NORMAL
|
|
#endif
|
|
|
|
/*ase_pragma*/
|
|
|
|
struct appdata
|
|
{
|
|
float4 vertex : POSITION;
|
|
half3 normal : NORMAL;
|
|
half4 tangent : TANGENT;
|
|
float4 texcoord : TEXCOORD0;
|
|
float4 texcoord1 : TEXCOORD1;
|
|
float4 texcoord2 : TEXCOORD2;
|
|
/*ase_vdata:p=p;t=t;n=n;uv0=tc0.xyzw;uv1=tc1.xyzw;uv2=tc2.xyzw*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct v2f
|
|
{
|
|
float4 pos : SV_POSITION;
|
|
float4 positionWS : TEXCOORD0; // xyz = positionWS, w = fogCoord
|
|
half3 normalWS : TEXCOORD1;
|
|
float4 tangentWS : TEXCOORD2; // holds terrainUV ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL
|
|
half4 ambientOrLightmapUV : TEXCOORD3;
|
|
UNITY_LIGHTING_COORDS( 4, 5 )
|
|
/*ase_interp(6,):sp=sp;wp=tc0.xyz;wn=tc1.xyz;wt=tc2.xyz*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
#ifdef ASE_TRANSMISSION
|
|
float _TransmissionShadow;
|
|
#endif
|
|
#ifdef ASE_TRANSLUCENCY
|
|
float _TransStrength;
|
|
float _TransNormal;
|
|
float _TransScattering;
|
|
float _TransDirect;
|
|
float _TransAmbient;
|
|
float _TransShadow;
|
|
#endif
|
|
#ifdef ASE_TESSELLATION
|
|
float _TessPhongStrength;
|
|
float _TessValue;
|
|
float _TessMin;
|
|
float _TessMax;
|
|
float _TessEdgeLength;
|
|
float _TessMaxDisp;
|
|
#endif
|
|
|
|
/*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*/;
|
|
|
|
float3 positionWS = mul( unity_ObjectToWorld, v.vertex ).xyz;
|
|
half3 normalWS = UnityObjectToWorldNormal( v.normal );
|
|
half3 tangentWS = UnityObjectToWorldDir( v.tangent.xyz );
|
|
|
|
o.pos = UnityObjectToClipPos( v.vertex );
|
|
o.positionWS.xyz = positionWS;
|
|
o.normalWS = normalWS;
|
|
o.tangentWS = half4( tangentWS, v.tangent.w );
|
|
|
|
o.ambientOrLightmapUV = 0;
|
|
#ifdef LIGHTMAP_ON
|
|
o.ambientOrLightmapUV.xy = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
|
|
#elif UNITY_SHOULD_SAMPLE_SH
|
|
#ifdef VERTEXLIGHT_ON
|
|
o.ambientOrLightmapUV.rgb += 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, positionWS, normalWS );
|
|
#endif
|
|
o.ambientOrLightmapUV.rgb = ShadeSHPerVertex( normalWS, o.ambientOrLightmapUV.rgb );
|
|
#endif
|
|
#ifdef DYNAMICLIGHTMAP_ON
|
|
o.ambientOrLightmapUV.zw = v.texcoord2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
|
|
#endif
|
|
|
|
#if defined(ENABLE_TERRAIN_PERPIXEL_NORMAL)
|
|
o.tangentWS.zw = v.texcoord.xy;
|
|
o.tangentWS.xy = v.texcoord.xy * unity_LightmapST.xy + unity_LightmapST.zw;
|
|
#endif
|
|
|
|
UNITY_TRANSFER_LIGHTING(o, v.texcoord1.xy);
|
|
#if defined( ASE_FOG )
|
|
o.positionWS.w = o.pos.z;
|
|
#endif
|
|
return o;
|
|
}
|
|
|
|
#if defined(ASE_TESSELLATION)
|
|
struct VertexControl
|
|
{
|
|
float4 vertex : INTERNALTESSPOS;
|
|
half4 tangent : TANGENT;
|
|
half3 normal : NORMAL;
|
|
float4 texcoord : TEXCOORD0;
|
|
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.texcoord = v.texcoord;
|
|
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.texcoord = patch[0].texcoord * bary.x + patch[1].texcoord * bary.y + patch[2].texcoord * 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
|
|
|
|
half4 frag( v2f IN /*ase_frag_input*/
|
|
#if defined( ASE_DEPTH_WRITE_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(ASE_LIGHTING_SIMPLE)
|
|
SurfaceOutput o = (SurfaceOutput)0;
|
|
#else
|
|
#if defined(_SPECULAR_SETUP)
|
|
SurfaceOutputStandardSpecular o = (SurfaceOutputStandardSpecular)0;
|
|
#else
|
|
SurfaceOutputStandard o = (SurfaceOutputStandard)0;
|
|
#endif
|
|
#endif
|
|
|
|
half atten;
|
|
{
|
|
#if defined( ASE_RECEIVE_SHADOWS )
|
|
UNITY_LIGHT_ATTENUATION( temp, IN, IN.positionWS.xyz )
|
|
atten = temp;
|
|
#else
|
|
atten = 1;
|
|
#endif
|
|
}
|
|
|
|
/*ase_local_var:wp*/float3 PositionWS = IN.positionWS.xyz;
|
|
/*ase_local_var:wvd*/half3 ViewDirWS = normalize( UnityWorldSpaceViewDir( PositionWS ) );
|
|
/*ase_local_var:spn*/float4 ScreenPosNorm = float4( IN.pos.xy * ( _ScreenParams.zw - 1.0 ), IN.pos.zw );
|
|
/*ase_local_var:sp*/float4 ClipPos = ComputeClipSpacePosition( ScreenPosNorm.xy, IN.pos.z ) * IN.pos.w;
|
|
/*ase_local_var:spu*/float4 ScreenPos = ComputeScreenPos( ClipPos );
|
|
/*ase_local_var:wn*/half3 NormalWS = IN.normalWS;
|
|
/*ase_local_var:wt*/half3 TangentWS = IN.tangentWS.xyz;
|
|
/*ase_local_var:wbt*/half3 BitangentWS = cross( IN.normalWS, IN.tangentWS.xyz ) * IN.tangentWS.w * unity_WorldTransformParams.w;
|
|
/*ase_local_var:latt*/half3 LightAtten = atten;
|
|
float FogCoord = IN.positionWS.w;
|
|
|
|
#if defined(ENABLE_TERRAIN_PERPIXEL_NORMAL)
|
|
float2 sampleCoords = (IN.tangentWS.zw / _TerrainHeightmapRecipSize.zw + 0.5f) * _TerrainHeightmapRecipSize.xy;
|
|
NormalWS = UnityObjectToWorldNormal(normalize(tex2D(_TerrainNormalmapTexture, sampleCoords).rgb * 2 - 1));
|
|
TangentWS = -cross(unity_ObjectToWorld._13_23_33, NormalWS);
|
|
BitangentWS = cross(NormalWS, -TangentWS);
|
|
#endif
|
|
|
|
/*ase_frag_code:IN=v2f*/
|
|
|
|
o.Albedo = /*ase_frag_out:Albedo;Float3;0;-1;_Albedo*/half3( 0.5, 0.5, 0.5 )/*end*/;
|
|
o.Normal = /*ase_frag_out:Normal;Float3;1;-1;_Normal*/half3( 0, 0, 1 )/*end*/;
|
|
|
|
half3 Specular = /*ase_frag_out:Specular;Float3;3;-1;_Specular*/half3( 0, 0, 0 )/*end*/;
|
|
half Metallic = /*ase_frag_out:Metallic;Float;4;-1;_Metallic*/0/*end*/;
|
|
half Smoothness = /*ase_frag_out:Smoothness;Float;5;-1;_Smoothness*/0/*end*/;
|
|
half Occlusion = /*ase_frag_out:Occlusion;Float;6;-1;_Occlusion*/1/*end*/;
|
|
|
|
#if defined(ASE_LIGHTING_SIMPLE)
|
|
o.Specular = Specular.x;
|
|
o.Gloss = Smoothness;
|
|
#else
|
|
#if defined(_SPECULAR_SETUP)
|
|
o.Specular = Specular;
|
|
#else
|
|
o.Metallic = Metallic;
|
|
#endif
|
|
o.Occlusion = Occlusion;
|
|
o.Smoothness = Smoothness;
|
|
#endif
|
|
|
|
o.Emission = /*ase_frag_out:Emission;Float3;2;-1;_Emission*/half3( 0, 0, 0 )/*end*/;
|
|
o.Alpha = /*ase_frag_out:Alpha;Float;7;-1;_Alpha*/1/*end*/;
|
|
half AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;8;-1;_AlphaClip*/0.5/*end*/;
|
|
half AlphaClipThresholdShadow = /*ase_frag_out:Alpha Clip Threshold Shadow;Float;9;-1;_AlphaClipShadow*/0.5/*end*/;
|
|
half3 BakedGI = /*ase_frag_out:Baked GI;Float3;10;-1;_BakedGI*/0/*end*/;
|
|
half3 Transmission = /*ase_frag_out:Transmission;Float3;13;-1;_Transmission*/1/*end*/;
|
|
half3 Translucency = /*ase_frag_out:Translucency;Float3;14;-1;_Translucency*/1/*end*/;
|
|
|
|
#if defined( ASE_DEPTH_WRITE_ON )
|
|
float DeviceDepth = /*ase_frag_out:Depth;Float;28;-1;_DeviceDepth*/IN.pos.z/*end*/;
|
|
#endif
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
clip( o.Alpha - AlphaClipThreshold );
|
|
#endif
|
|
|
|
#if defined( ASE_CHANGES_WORLD_POS )
|
|
{
|
|
#if defined( ASE_RECEIVE_SHADOWS )
|
|
UNITY_LIGHT_ATTENUATION( temp, IN, PositionWS )
|
|
LightAtten = temp;
|
|
#else
|
|
LightAtten = 1;
|
|
#endif
|
|
}
|
|
#endif
|
|
|
|
#if ( ASE_FRAGMENT_NORMAL == 0 )
|
|
o.Normal = normalize( o.Normal.x * TangentWS + o.Normal.y * BitangentWS + o.Normal.z * NormalWS );
|
|
#elif ( ASE_FRAGMENT_NORMAL == 1 )
|
|
o.Normal = UnityObjectToWorldNormal( o.Normal );
|
|
#elif ( ASE_FRAGMENT_NORMAL == 2 )
|
|
// @diogo: already in world-space; do nothing
|
|
#endif
|
|
|
|
#if defined( ASE_DEPTH_WRITE_ON )
|
|
outputDepth = DeviceDepth;
|
|
#endif
|
|
|
|
#ifndef USING_DIRECTIONAL_LIGHT
|
|
half3 lightDir = normalize( UnityWorldSpaceLightDir( PositionWS ) );
|
|
#else
|
|
half3 lightDir = _WorldSpaceLightPos0.xyz;
|
|
#endif
|
|
|
|
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 = PositionWS;
|
|
giInput.worldViewDir = ViewDirWS;
|
|
giInput.atten = atten;
|
|
#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
|
|
giInput.lightmapUV = IN.ambientOrLightmapUV;
|
|
#else
|
|
giInput.lightmapUV = 0.0;
|
|
#endif
|
|
#if UNITY_SHOULD_SAMPLE_SH && !UNITY_SAMPLE_FULL_SH_PER_PIXEL
|
|
giInput.ambient = IN.ambientOrLightmapUV.rgb;
|
|
#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(ASE_LIGHTING_SIMPLE)
|
|
#if defined(_SPECULAR_SETUP)
|
|
LightingBlinnPhong_GI(o, giInput, gi);
|
|
#else
|
|
LightingLambert_GI(o, giInput, gi);
|
|
#endif
|
|
#else
|
|
#if defined(_SPECULAR_SETUP)
|
|
LightingStandardSpecular_GI(o, giInput, gi);
|
|
#else
|
|
LightingStandard_GI(o, giInput, gi);
|
|
#endif
|
|
#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
|
|
|
|
half4 c = 0;
|
|
#if defined(ASE_LIGHTING_SIMPLE)
|
|
#if defined(_SPECULAR_SETUP)
|
|
c += LightingBlinnPhong (o, ViewDirWS, gi);
|
|
#else
|
|
c += LightingLambert( o, gi );
|
|
#endif
|
|
#else
|
|
#if defined(_SPECULAR_SETUP)
|
|
c += LightingStandardSpecular (o, ViewDirWS, gi);
|
|
#else
|
|
c += LightingStandard(o, ViewDirWS, gi);
|
|
#endif
|
|
#endif
|
|
|
|
#ifdef ASE_TRANSMISSION
|
|
{
|
|
half shadow = /*ase_inline_begin*/_TransmissionShadow/*ase_inline_end*/;
|
|
#ifdef DIRECTIONAL
|
|
half3 lightAtten = lerp( _LightColor0.rgb, gi.light.color, shadow );
|
|
#else
|
|
half3 lightAtten = gi.light.color;
|
|
#endif
|
|
half3 transmission = max(0 , -dot(o.Normal, gi.light.dir)) * lightAtten * Transmission;
|
|
c.rgb += o.Albedo * transmission;
|
|
}
|
|
#endif
|
|
|
|
#ifdef ASE_TRANSLUCENCY
|
|
{
|
|
half shadow = /*ase_inline_begin*/_TransShadow/*ase_inline_end*/;
|
|
half normal = /*ase_inline_begin*/_TransNormal/*ase_inline_end*/;
|
|
half scattering = /*ase_inline_begin*/_TransScattering/*ase_inline_end*/;
|
|
half direct = /*ase_inline_begin*/_TransDirect/*ase_inline_end*/;
|
|
half ambient = /*ase_inline_begin*/_TransAmbient/*ase_inline_end*/;
|
|
half strength = /*ase_inline_begin*/_TransStrength/*ase_inline_end*/;
|
|
|
|
#ifdef DIRECTIONAL
|
|
half3 lightAtten = lerp( _LightColor0.rgb, gi.light.color, shadow );
|
|
#else
|
|
half3 lightAtten = gi.light.color;
|
|
#endif
|
|
half3 lightDir = gi.light.dir + o.Normal * normal;
|
|
half transVdotL = pow( saturate( dot( ViewDirWS, -lightDir ) ), scattering );
|
|
half3 translucency = lightAtten * (transVdotL * direct + gi.indirect.diffuse * ambient) * Translucency;
|
|
c.rgb += o.Albedo * translucency * strength;
|
|
}
|
|
#endif
|
|
|
|
c.rgb += o.Emission;
|
|
|
|
#if defined( ASE_FOG )
|
|
UNITY_APPLY_FOG( 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( ASE_GEOMETRY ) || defined( ASE_IMPOSTOR )
|
|
#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
|
|
#endif
|
|
#include "UnityShaderVariables.cginc"
|
|
#include "UnityCG.cginc"
|
|
#include "Lighting.cginc"
|
|
#include "UnityPBSLighting.cginc"
|
|
#include "AutoLight.cginc"
|
|
|
|
#if defined( UNITY_INSTANCING_ENABLED ) && defined( ASE_INSTANCED_TERRAIN ) && ( defined(_TERRAIN_INSTANCED_PERPIXEL_NORMAL) || defined(_INSTANCEDTERRAINNORMALS_PIXEL) )
|
|
#define ENABLE_TERRAIN_PERPIXEL_NORMAL
|
|
#endif
|
|
|
|
/*ase_pragma*/
|
|
|
|
struct appdata
|
|
{
|
|
float4 vertex : POSITION;
|
|
half3 normal : NORMAL;
|
|
half4 tangent : TANGENT;
|
|
float4 texcoord : TEXCOORD0;
|
|
float4 texcoord1 : TEXCOORD1;
|
|
float4 texcoord2 : TEXCOORD2;
|
|
/*ase_vdata:p=p;t=t;n=n;uv0=tc0.xyzw;uv1=tc1.xyzw;uv2=tc2.xyzw*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct v2f
|
|
{
|
|
float4 pos : SV_POSITION;
|
|
float4 positionWS : TEXCOORD0; // xyz = positionWS, w = fogCoord
|
|
half3 normalWS : TEXCOORD1;
|
|
float4 tangentWS : TEXCOORD2; // holds terrainUV ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL
|
|
UNITY_LIGHTING_COORDS( 3, 4 )
|
|
/*ase_interp(5,):sp=sp;wp=tc0.xyz;wn=tc1.xyz*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
#ifdef ASE_TRANSMISSION
|
|
float _TransmissionShadow;
|
|
#endif
|
|
#ifdef ASE_TRANSLUCENCY
|
|
float _TransStrength;
|
|
float _TransNormal;
|
|
float _TransScattering;
|
|
float _TransDirect;
|
|
float _TransAmbient;
|
|
float _TransShadow;
|
|
#endif
|
|
#ifdef ASE_TESSELLATION
|
|
float _TessPhongStrength;
|
|
float _TessValue;
|
|
float _TessMin;
|
|
float _TessMax;
|
|
float _TessEdgeLength;
|
|
float _TessMaxDisp;
|
|
#endif
|
|
|
|
/*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*/;
|
|
|
|
float3 positionWS = mul( unity_ObjectToWorld, v.vertex ).xyz;
|
|
half3 normalWS = UnityObjectToWorldNormal( v.normal );
|
|
half3 tangentWS = UnityObjectToWorldDir( v.tangent.xyz );
|
|
|
|
o.pos = UnityObjectToClipPos( v.vertex );
|
|
o.positionWS.xyz = positionWS;
|
|
o.normalWS = normalWS;
|
|
o.tangentWS = half4( tangentWS, v.tangent.w );
|
|
|
|
UNITY_TRANSFER_LIGHTING(o, v.texcoord1.xy);
|
|
#if defined( ASE_FOG )
|
|
o.positionWS.w = o.pos.z;
|
|
#endif
|
|
|
|
#if defined(ENABLE_TERRAIN_PERPIXEL_NORMAL)
|
|
o.tangentWS.zw = v.texcoord.xy;
|
|
o.tangentWS.xy = v.texcoord.xy * unity_LightmapST.xy + unity_LightmapST.zw;
|
|
#endif
|
|
return o;
|
|
}
|
|
|
|
#if defined(ASE_TESSELLATION)
|
|
struct VertexControl
|
|
{
|
|
float4 vertex : INTERNALTESSPOS;
|
|
half4 tangent : TANGENT;
|
|
half3 normal : NORMAL;
|
|
float4 texcoord : TEXCOORD0;
|
|
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.texcoord = v.texcoord;
|
|
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.texcoord = patch[0].texcoord * bary.x + patch[1].texcoord * bary.y + patch[2].texcoord * 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
|
|
|
|
half4 frag ( v2f IN /*ase_frag_input*/
|
|
#if defined( ASE_DEPTH_WRITE_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(ASE_LIGHTING_SIMPLE)
|
|
SurfaceOutput o = (SurfaceOutput)0;
|
|
#else
|
|
#if defined(_SPECULAR_SETUP)
|
|
SurfaceOutputStandardSpecular o = (SurfaceOutputStandardSpecular)0;
|
|
#else
|
|
SurfaceOutputStandard o = (SurfaceOutputStandard)0;
|
|
#endif
|
|
#endif
|
|
|
|
half atten;
|
|
{
|
|
#if defined( ASE_RECEIVE_SHADOWS )
|
|
UNITY_LIGHT_ATTENUATION( temp, IN, IN.positionWS.xyz )
|
|
atten = temp;
|
|
#else
|
|
atten = 1;
|
|
#endif
|
|
}
|
|
|
|
/*ase_local_var:wp*/float3 PositionWS = IN.positionWS.xyz;
|
|
/*ase_local_var:wvd*/half3 ViewDirWS = normalize( UnityWorldSpaceViewDir( PositionWS ) );
|
|
/*ase_local_var:spn*/float4 ScreenPosNorm = float4( IN.pos.xy * ( _ScreenParams.zw - 1.0 ), IN.pos.zw );
|
|
/*ase_local_var:sp*/float4 ClipPos = ComputeClipSpacePosition( ScreenPosNorm.xy, IN.pos.z ) * IN.pos.w;
|
|
/*ase_local_var:spu*/float4 ScreenPos = ComputeScreenPos( ClipPos );
|
|
/*ase_local_var:wn*/half3 NormalWS = IN.normalWS;
|
|
/*ase_local_var:wt*/half3 TangentWS = IN.tangentWS.xyz;
|
|
/*ase_local_var:wbt*/half3 BitangentWS = cross( IN.normalWS, IN.tangentWS.xyz ) * IN.tangentWS.w * unity_WorldTransformParams.w;
|
|
/*ase_local_var:latt*/half3 LightAtten = atten;
|
|
float FogCoord = IN.positionWS.w;
|
|
|
|
#if defined(ENABLE_TERRAIN_PERPIXEL_NORMAL)
|
|
float2 sampleCoords = (IN.tangentWS.zw / _TerrainHeightmapRecipSize.zw + 0.5f) * _TerrainHeightmapRecipSize.xy;
|
|
NormalWS = UnityObjectToWorldNormal(normalize(tex2D(_TerrainNormalmapTexture, sampleCoords).rgb * 2 - 1));
|
|
TangentWS = -cross(unity_ObjectToWorld._13_23_33, NormalWS);
|
|
BitangentWS = cross(NormalWS, -TangentWS);
|
|
#endif
|
|
|
|
/*ase_frag_code:IN=v2f*/
|
|
|
|
o.Albedo = /*ase_frag_out:Albedo;Float3;0;-1;_Albedo*/half3( 0.5, 0.5, 0.5 )/*end*/;
|
|
o.Normal = /*ase_frag_out:Normal;Float3;1;-1;_Normal*/half3( 0, 0, 1 )/*end*/;
|
|
|
|
half3 Specular = /*ase_frag_out:Specular;Float3;3;-1;_Specular*/half3( 0, 0, 0 )/*end*/;
|
|
half Metallic = /*ase_frag_out:Metallic;Float;4;-1;_Metallic*/0/*end*/;
|
|
half Smoothness = /*ase_frag_out:Smoothness;Float;5;-1;_Smoothness*/0/*end*/;
|
|
half Occlusion = /*ase_frag_out:Occlusion;Float;6;-1;_Occlusion*/1/*end*/;
|
|
|
|
#if defined(ASE_LIGHTING_SIMPLE)
|
|
o.Specular = Specular.x;
|
|
o.Gloss = Smoothness;
|
|
#else
|
|
#if defined(_SPECULAR_SETUP)
|
|
o.Specular = Specular;
|
|
#else
|
|
o.Metallic = Metallic;
|
|
#endif
|
|
o.Occlusion = Occlusion;
|
|
o.Smoothness = Smoothness;
|
|
#endif
|
|
|
|
o.Emission = /*ase_frag_out:Emission;Float3;2;-1;_Emission*/half3( 0, 0, 0 )/*end*/;
|
|
o.Alpha = /*ase_frag_out:Alpha;Float;7;-1;_Alpha*/1/*end*/;
|
|
half AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;8;-1;_AlphaClip*/0.5/*end*/;
|
|
half3 Transmission = /*ase_frag_out:Transmission;Float3;13;-1;_Transmission*/1/*end*/;
|
|
half3 Translucency = /*ase_frag_out:Translucency;Float3;14;-1;_Translucency*/1/*end*/;
|
|
|
|
#if defined( ASE_DEPTH_WRITE_ON )
|
|
float DeviceDepth = /*ase_frag_out:Depth;Float;28;-1;_DeviceDepth*/IN.pos.z/*end*/;
|
|
#endif
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
clip( o.Alpha - AlphaClipThreshold );
|
|
#endif
|
|
|
|
#if defined( ASE_CHANGES_WORLD_POS )
|
|
{
|
|
#if defined( ASE_RECEIVE_SHADOWS )
|
|
UNITY_LIGHT_ATTENUATION( temp, IN, PositionWS )
|
|
LightAtten = temp;
|
|
#else
|
|
LightAtten = 1;
|
|
#endif
|
|
}
|
|
#endif
|
|
|
|
#if ( ASE_FRAGMENT_NORMAL == 0 )
|
|
o.Normal = normalize( o.Normal.x * TangentWS + o.Normal.y * BitangentWS + o.Normal.z * NormalWS );
|
|
#elif ( ASE_FRAGMENT_NORMAL == 1 )
|
|
o.Normal = UnityObjectToWorldNormal( o.Normal );
|
|
#elif ( ASE_FRAGMENT_NORMAL == 2 )
|
|
// @diogo: already in world-space; do nothing
|
|
#endif
|
|
|
|
#if defined( ASE_DEPTH_WRITE_ON )
|
|
outputDepth = DeviceDepth;
|
|
#endif
|
|
|
|
#ifndef USING_DIRECTIONAL_LIGHT
|
|
half3 lightDir = normalize( UnityWorldSpaceLightDir( PositionWS ) );
|
|
#else
|
|
half3 lightDir = _WorldSpaceLightPos0.xyz;
|
|
#endif
|
|
|
|
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;
|
|
|
|
half4 c = 0;
|
|
#if defined(ASE_LIGHTING_SIMPLE)
|
|
#if defined(_SPECULAR_SETUP)
|
|
c += LightingBlinnPhong (o, ViewDirWS, gi);
|
|
#else
|
|
c += LightingLambert( o, gi );
|
|
#endif
|
|
#else
|
|
#if defined(_SPECULAR_SETUP)
|
|
c += LightingStandardSpecular(o, ViewDirWS, gi);
|
|
#else
|
|
c += LightingStandard(o, ViewDirWS, gi);
|
|
#endif
|
|
#endif
|
|
|
|
#ifdef ASE_TRANSMISSION
|
|
{
|
|
half shadow = /*ase_inline_begin*/_TransmissionShadow/*ase_inline_end*/;
|
|
#ifdef DIRECTIONAL
|
|
half3 lightAtten = lerp( _LightColor0.rgb, gi.light.color, shadow );
|
|
#else
|
|
half3 lightAtten = gi.light.color;
|
|
#endif
|
|
half3 transmission = max(0 , -dot(o.Normal, gi.light.dir)) * lightAtten * Transmission;
|
|
c.rgb += o.Albedo * transmission;
|
|
}
|
|
#endif
|
|
|
|
#ifdef ASE_TRANSLUCENCY
|
|
{
|
|
half shadow = /*ase_inline_begin*/_TransShadow/*ase_inline_end*/;
|
|
half normal = /*ase_inline_begin*/_TransNormal/*ase_inline_end*/;
|
|
half scattering = /*ase_inline_begin*/_TransScattering/*ase_inline_end*/;
|
|
half direct = /*ase_inline_begin*/_TransDirect/*ase_inline_end*/;
|
|
half ambient = /*ase_inline_begin*/_TransAmbient/*ase_inline_end*/;
|
|
half strength = /*ase_inline_begin*/_TransStrength/*ase_inline_end*/;
|
|
|
|
#ifdef DIRECTIONAL
|
|
half3 lightAtten = lerp( _LightColor0.rgb, gi.light.color, shadow );
|
|
#else
|
|
half3 lightAtten = gi.light.color;
|
|
#endif
|
|
half3 lightDir = gi.light.dir + o.Normal * normal;
|
|
half transVdotL = pow( saturate( dot( ViewDirWS, -lightDir ) ), scattering );
|
|
half3 translucency = lightAtten * (transVdotL * direct + gi.indirect.diffuse * ambient) * Translucency;
|
|
c.rgb += o.Albedo * translucency * strength;
|
|
}
|
|
#endif
|
|
|
|
#if defined( ASE_FOG )
|
|
UNITY_APPLY_FOG( 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 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( ASE_GEOMETRY ) || defined( ASE_IMPOSTOR )
|
|
#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
|
|
#endif
|
|
#include "UnityShaderVariables.cginc"
|
|
#include "UnityCG.cginc"
|
|
#include "Lighting.cginc"
|
|
#include "UnityPBSLighting.cginc"
|
|
|
|
#if defined( UNITY_INSTANCING_ENABLED ) && defined( ASE_INSTANCED_TERRAIN ) && ( defined(_TERRAIN_INSTANCED_PERPIXEL_NORMAL) || defined(_INSTANCEDTERRAINNORMALS_PIXEL) )
|
|
#define ENABLE_TERRAIN_PERPIXEL_NORMAL
|
|
#endif
|
|
|
|
/*ase_pragma*/
|
|
|
|
struct appdata
|
|
{
|
|
float4 vertex : POSITION;
|
|
half3 normal : NORMAL;
|
|
half4 tangent : TANGENT;
|
|
float4 texcoord : TEXCOORD0;
|
|
float4 texcoord1 : TEXCOORD1;
|
|
float4 texcoord2 : TEXCOORD2;
|
|
/*ase_vdata:p=p;t=t;n=n;uv0=tc0.xyzw;uv1=tc1.xyzw;uv2=tc2.xyzw*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct v2f
|
|
{
|
|
float4 pos : SV_POSITION;
|
|
float4 positionWS : TEXCOORD0; // xyz = positionWS, w = fogCoord
|
|
half3 normalWS : TEXCOORD1;
|
|
float4 tangentWS : TEXCOORD2; // holds terrainUV ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL
|
|
half4 ambientOrLightmapUV : TEXCOORD3;
|
|
/*ase_interp(4,):sp=sp;wp=tc0.xyz;wn=tc1.xyz;wt=tc2.xyz*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
#ifdef LIGHTMAP_ON
|
|
float4 unity_LightmapFade;
|
|
#endif
|
|
half4 unity_Ambient;
|
|
#ifdef ASE_TESSELLATION
|
|
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*/;
|
|
|
|
float3 positionWS = mul( unity_ObjectToWorld, v.vertex ).xyz;
|
|
half3 normalWS = UnityObjectToWorldNormal( v.normal );
|
|
half3 tangentWS = UnityObjectToWorldDir( v.tangent.xyz );
|
|
|
|
o.pos = UnityObjectToClipPos( v.vertex );
|
|
o.positionWS.xyz = positionWS;
|
|
o.normalWS = normalWS;
|
|
o.tangentWS = half4( tangentWS, v.tangent.w );
|
|
|
|
o.ambientOrLightmapUV = 0;
|
|
#ifdef LIGHTMAP_ON
|
|
o.ambientOrLightmapUV.xy = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
|
|
#elif UNITY_SHOULD_SAMPLE_SH
|
|
#ifdef VERTEXLIGHT_ON
|
|
o.ambientOrLightmapUV.rgb += 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, positionWS, normalWS );
|
|
#endif
|
|
o.ambientOrLightmapUV.rgb = ShadeSHPerVertex( normalWS, o.ambientOrLightmapUV.rgb );
|
|
#endif
|
|
#ifdef DYNAMICLIGHTMAP_ON
|
|
o.ambientOrLightmapUV.zw = v.texcoord2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
|
|
#endif
|
|
|
|
#if defined(ENABLE_TERRAIN_PERPIXEL_NORMAL)
|
|
o.tangentWS.zw = v.texcoord.xy;
|
|
o.tangentWS.xy = v.texcoord.xy * unity_LightmapST.xy + unity_LightmapST.zw;
|
|
#endif
|
|
return o;
|
|
}
|
|
|
|
#if defined(ASE_TESSELLATION)
|
|
struct VertexControl
|
|
{
|
|
float4 vertex : INTERNALTESSPOS;
|
|
half4 tangent : TANGENT;
|
|
half3 normal : NORMAL;
|
|
float4 texcoord : TEXCOORD0;
|
|
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.texcoord = v.texcoord;
|
|
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.texcoord = patch[0].texcoord * bary.x + patch[1].texcoord * bary.y + patch[2].texcoord * 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
|
|
#if defined( ASE_DEPTH_WRITE_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(ASE_LIGHTING_SIMPLE)
|
|
SurfaceOutput o = (SurfaceOutput)0;
|
|
#else
|
|
#if defined(_SPECULAR_SETUP)
|
|
SurfaceOutputStandardSpecular o = (SurfaceOutputStandardSpecular)0;
|
|
#else
|
|
SurfaceOutputStandard o = (SurfaceOutputStandard)0;
|
|
#endif
|
|
#endif
|
|
|
|
/*ase_local_var:wp*/float3 PositionWS = IN.positionWS.xyz;
|
|
/*ase_local_var:wvd*/half3 ViewDirWS = normalize( UnityWorldSpaceViewDir( PositionWS ) );
|
|
/*ase_local_var:spn*/float4 ScreenPosNorm = float4( IN.pos.xy * ( _ScreenParams.zw - 1.0 ), IN.pos.zw );
|
|
/*ase_local_var:sp*/float4 ClipPos = ComputeClipSpacePosition( ScreenPosNorm.xy, IN.pos.z ) * IN.pos.w;
|
|
/*ase_local_var:spu*/float4 ScreenPos = ComputeScreenPos( ClipPos );
|
|
/*ase_local_var:wn*/half3 NormalWS = IN.normalWS;
|
|
/*ase_local_var:wt*/half3 TangentWS = IN.tangentWS.xyz;
|
|
/*ase_local_var:wbt*/half3 BitangentWS = cross( IN.normalWS, IN.tangentWS.xyz ) * IN.tangentWS.w * unity_WorldTransformParams.w;
|
|
|
|
#if defined(ENABLE_TERRAIN_PERPIXEL_NORMAL)
|
|
float2 sampleCoords = (IN.tangentWS.zw / _TerrainHeightmapRecipSize.zw + 0.5f) * _TerrainHeightmapRecipSize.xy;
|
|
NormalWS = UnityObjectToWorldNormal(normalize(tex2D(_TerrainNormalmapTexture, sampleCoords).rgb * 2 - 1));
|
|
TangentWS = -cross(unity_ObjectToWorld._13_23_33, NormalWS);
|
|
BitangentWS = cross(NormalWS, -TangentWS);
|
|
#endif
|
|
|
|
/*ase_frag_code:IN=v2f*/
|
|
|
|
o.Albedo = /*ase_frag_out:Albedo;Float3;0;-1;_Albedo*/half3( 0.5, 0.5, 0.5 )/*end*/;
|
|
o.Normal = /*ase_frag_out:Normal;Float3;1;-1;_Normal*/half3( 0, 0, 1 )/*end*/;
|
|
|
|
half3 Specular = /*ase_frag_out:Specular;Float3;3;-1;_Specular*/half3( 0, 0, 0 )/*end*/;
|
|
half Metallic = /*ase_frag_out:Metallic;Float;4;-1;_Metallic*/0/*end*/;
|
|
half Smoothness = /*ase_frag_out:Smoothness;Float;5;-1;_Smoothness*/0/*end*/;
|
|
half Occlusion = /*ase_frag_out:Occlusion;Float;6;-1;_Occlusion*/1/*end*/;
|
|
|
|
#if defined(ASE_LIGHTING_SIMPLE)
|
|
o.Specular = Specular.x;
|
|
o.Gloss = Smoothness;
|
|
#else
|
|
#if defined(_SPECULAR_SETUP)
|
|
o.Specular = Specular;
|
|
#else
|
|
o.Metallic = Metallic;
|
|
#endif
|
|
o.Occlusion = Occlusion;
|
|
o.Smoothness = Smoothness;
|
|
#endif
|
|
|
|
o.Emission = /*ase_frag_out:Emission;Float3;2;-1;_Emission*/half3( 0, 0, 0 )/*end*/;
|
|
o.Alpha = /*ase_frag_out:Alpha;Float;7;-1;_Alpha*/1/*end*/;
|
|
half AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;8;-1;_AlphaClip*/0.5/*end*/;
|
|
half3 BakedGI = /*ase_frag_out:Baked GI;Float3;10;-1;_BakedGI*/0/*end*/;
|
|
|
|
#if defined( ASE_DEPTH_WRITE_ON )
|
|
float DeviceDepth = /*ase_frag_out:Depth;Float;28;-1;_DeviceDepth*/IN.pos.z/*end*/;
|
|
#endif
|
|
|
|
#if ( ASE_FRAGMENT_NORMAL == 0 )
|
|
o.Normal = normalize( o.Normal.x * TangentWS + o.Normal.y * BitangentWS + o.Normal.z * NormalWS );
|
|
#elif ( ASE_FRAGMENT_NORMAL == 1 )
|
|
o.Normal = UnityObjectToWorldNormal( o.Normal );
|
|
#elif ( ASE_FRAGMENT_NORMAL == 2 )
|
|
// @diogo: already in world-space; do nothing
|
|
#endif
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
clip( o.Alpha - AlphaClipThreshold );
|
|
#endif
|
|
|
|
#if defined( ASE_DEPTH_WRITE_ON )
|
|
outputDepth = DeviceDepth;
|
|
#endif
|
|
|
|
#ifndef USING_DIRECTIONAL_LIGHT
|
|
half3 lightDir = normalize( UnityWorldSpaceLightDir( PositionWS ) );
|
|
#else
|
|
half3 lightDir = _WorldSpaceLightPos0.xyz;
|
|
#endif
|
|
|
|
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 = PositionWS;
|
|
giInput.worldViewDir = ViewDirWS;
|
|
giInput.atten = 1;
|
|
#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
|
|
giInput.lightmapUV = IN.ambientOrLightmapUV;
|
|
#else
|
|
giInput.lightmapUV = 0.0;
|
|
#endif
|
|
#if UNITY_SHOULD_SAMPLE_SH && !UNITY_SAMPLE_FULL_SH_PER_PIXEL
|
|
giInput.ambient = IN.ambientOrLightmapUV.rgb;
|
|
#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(ASE_LIGHTING_SIMPLE)
|
|
#if defined(_SPECULAR_SETUP)
|
|
LightingBlinnPhong_GI(o, giInput, gi);
|
|
#else
|
|
LightingLambert_GI(o, giInput, gi);
|
|
#endif
|
|
#else
|
|
#if defined(_SPECULAR_SETUP)
|
|
LightingStandardSpecular_GI(o, giInput, gi);
|
|
#else
|
|
LightingStandard_GI(o, giInput, gi);
|
|
#endif
|
|
#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(ASE_LIGHTING_SIMPLE)
|
|
#if defined(_SPECULAR_SETUP)
|
|
outEmission = LightingBlinnPhong_Deferred( o, ViewDirWS, gi, outGBuffer0, outGBuffer1, outGBuffer2 );
|
|
#else
|
|
outEmission = LightingLambert_Deferred( o, gi, outGBuffer0, outGBuffer1, outGBuffer2 );
|
|
#endif
|
|
#else
|
|
#if defined(_SPECULAR_SETUP)
|
|
outEmission = LightingStandardSpecular_Deferred( o, ViewDirWS, gi, outGBuffer0, outGBuffer1, outGBuffer2 );
|
|
#else
|
|
outEmission = LightingStandard_Deferred( o, ViewDirWS, gi, outGBuffer0, outGBuffer1, outGBuffer2 );
|
|
#endif
|
|
#endif
|
|
|
|
#if defined(SHADOWS_SHADOWMASK) && (UNITY_ALLOWED_MRT_COUNT > 4)
|
|
outShadowMask = UnityGetRawBakedOcclusions( IN.ambientOrLightmapUV.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( ASE_GEOMETRY ) || defined( ASE_IMPOSTOR )
|
|
#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
|
|
#endif
|
|
#include "UnityShaderVariables.cginc"
|
|
#include "UnityCG.cginc"
|
|
#include "Lighting.cginc"
|
|
#include "UnityPBSLighting.cginc"
|
|
#include "UnityMetaPass.cginc"
|
|
|
|
/*ase_pragma*/
|
|
|
|
struct appdata
|
|
{
|
|
float4 vertex : POSITION;
|
|
half3 normal : NORMAL;
|
|
half4 tangent : TANGENT;
|
|
float4 texcoord : TEXCOORD0;
|
|
float4 texcoord1 : TEXCOORD1;
|
|
float4 texcoord2 : TEXCOORD2;
|
|
/*ase_vdata:p=p;t=t;n=n;uv0=tc0.xyzw;uv1=tc1.xyzw;uv2=tc2.xyzw*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct v2f
|
|
{
|
|
float4 pos : SV_POSITION;
|
|
#ifdef EDITOR_VISUALIZATION
|
|
float2 vizUV : TEXCOORD0;
|
|
float4 lightCoord : TEXCOORD1;
|
|
#endif
|
|
/*ase_interp(2,):sp=sp*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
#ifdef ASE_TESSELLATION
|
|
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*/;
|
|
|
|
#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(ASE_TESSELLATION)
|
|
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
|
|
|
|
half4 frag( v2f IN /*ase_frag_input*/ ) : SV_Target
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID(IN);
|
|
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
UNITY_APPLY_DITHER_CROSSFADE(IN.pos.xy);
|
|
#endif
|
|
|
|
#if defined(ASE_LIGHTING_SIMPLE)
|
|
SurfaceOutput o = (SurfaceOutput)0;
|
|
#else
|
|
#if defined(_SPECULAR_SETUP)
|
|
SurfaceOutputStandardSpecular o = (SurfaceOutputStandardSpecular)0;
|
|
#else
|
|
SurfaceOutputStandard o = (SurfaceOutputStandard)0;
|
|
#endif
|
|
#endif
|
|
|
|
/*ase_frag_code:IN=v2f*/
|
|
|
|
o.Albedo = /*ase_frag_out:Albedo;Float3;0;-1;_Albedo*/half3( 0.5, 0.5, 0.5 )/*end*/;
|
|
o.Normal = half3( 0, 0, 1 );
|
|
o.Emission = /*ase_frag_out:Emission;Float3;2;-1;_Emission*/half3( 0, 0, 0 )/*end*/;
|
|
o.Alpha = /*ase_frag_out:Alpha;Float;7;-1;_Alpha*/1/*end*/;
|
|
half AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;8;-1;_AlphaClip*/0.5/*end*/;
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
clip( o.Alpha - AlphaClipThreshold );
|
|
#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"
|
|
#if defined( ASE_GEOMETRY ) || defined( ASE_IMPOSTOR )
|
|
#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
|
|
#endif
|
|
#include "UnityShaderVariables.cginc"
|
|
#include "UnityCG.cginc"
|
|
#include "Lighting.cginc"
|
|
#include "UnityPBSLighting.cginc"
|
|
|
|
/*ase_pragma*/
|
|
|
|
struct appdata
|
|
{
|
|
float4 vertex : POSITION;
|
|
half3 normal : NORMAL;
|
|
half4 tangent : TANGENT;
|
|
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(1,):sp=sp*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
#ifdef UNITY_STANDARD_USE_DITHER_MASK
|
|
sampler3D _DitherMaskLOD;
|
|
#endif
|
|
#ifdef ASE_TESSELLATION
|
|
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*/;
|
|
|
|
#if defined( ASE_IMPOSTOR )
|
|
// Disable "Normal Bias" because we're rendering billboard impostors and there's no vertex normals.
|
|
unity_LightShadowBias.z = 0;
|
|
#endif
|
|
|
|
TRANSFER_SHADOW_CASTER_NORMALOFFSET(o)
|
|
return o;
|
|
}
|
|
|
|
#if defined(ASE_TESSELLATION)
|
|
struct VertexControl
|
|
{
|
|
float4 vertex : INTERNALTESSPOS;
|
|
half4 tangent : TANGENT;
|
|
half3 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
|
|
|
|
half4 frag( v2f IN /*ase_frag_input*/
|
|
#if defined( ASE_DEPTH_WRITE_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(ASE_LIGHTING_SIMPLE)
|
|
SurfaceOutput o = (SurfaceOutput)0;
|
|
#else
|
|
#if defined(_SPECULAR_SETUP)
|
|
SurfaceOutputStandardSpecular o = (SurfaceOutputStandardSpecular)0;
|
|
#else
|
|
SurfaceOutputStandard o = (SurfaceOutputStandard)0;
|
|
#endif
|
|
o.Occlusion = 1;
|
|
#endif
|
|
|
|
/*ase_frag_code:IN=v2f*/
|
|
|
|
o.Normal = half3( 0, 0, 1 );
|
|
|
|
o.Alpha = /*ase_frag_out:Alpha;Float;7;-1;_Alpha*/1/*end*/;
|
|
half AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;8;-1;_AlphaClip*/0.5/*end*/;
|
|
half AlphaClipThresholdShadow = /*ase_frag_out:Alpha Clip Threshold Shadow;Float;9;-1;_AlphaClipShadow*/0.5/*end*/;
|
|
|
|
#if defined( ASE_DEPTH_WRITE_ON )
|
|
float DeviceDepth = /*ase_frag_out:Depth;Float;28;-1;_DeviceDepth*/IN.pos.z/*end*/;
|
|
#endif
|
|
|
|
#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
|
|
|
|
#ifdef UNITY_STANDARD_USE_DITHER_MASK
|
|
half alphaRef = tex3D(_DitherMaskLOD, float3(IN.pos.xy*0.25,o.Alpha*0.9375)).a;
|
|
clip(alphaRef - 0.01);
|
|
#endif
|
|
|
|
#if defined( ASE_DEPTH_WRITE_ON )
|
|
outputDepth = DeviceDepth;
|
|
#endif
|
|
|
|
SHADOW_CASTER_FRAGMENT(IN)
|
|
}
|
|
ENDCG
|
|
}
|
|
|
|
/*ase_pass*/
|
|
Pass
|
|
{
|
|
/*ase_hide_pass*/
|
|
Name "SceneSelectionPass"
|
|
Tags{ "LightMode" = "SceneSelectionPass" }
|
|
|
|
ZWrite On
|
|
|
|
CGPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
|
|
|
|
#pragma multi_compile_fwdbase
|
|
#ifndef UNITY_PASS_FORWARDBASE
|
|
#define UNITY_PASS_FORWARDBASE
|
|
#endif
|
|
#include "HLSLSupport.cginc"
|
|
#if defined( ASE_GEOMETRY ) || defined( ASE_IMPOSTOR )
|
|
#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
|
|
#endif
|
|
#include "UnityShaderVariables.cginc"
|
|
#include "UnityCG.cginc"
|
|
#include "Lighting.cginc"
|
|
#include "UnityPBSLighting.cginc"
|
|
#include "AutoLight.cginc"
|
|
|
|
/*ase_pragma*/
|
|
|
|
int _ObjectId;
|
|
int _PassValue;
|
|
|
|
struct appdata
|
|
{
|
|
float4 vertex : POSITION;
|
|
half3 normal : NORMAL;
|
|
half4 tangent : TANGENT;
|
|
/*ase_vdata:p=p;t=t;n=n*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct v2f
|
|
{
|
|
float4 pos : SV_POSITION;
|
|
float4 positionWS : TEXCOORD0; // xyz = positionWS
|
|
half3 normalWS : TEXCOORD1;
|
|
/*ase_interp(2,):sp=sp;wp=tc0.xyz;wn=tc1.xyz*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
#ifdef ASE_TESSELLATION
|
|
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*/;
|
|
|
|
float3 positionWS = mul( unity_ObjectToWorld, v.vertex ).xyz;
|
|
half3 normalWS = UnityObjectToWorldNormal( v.normal );
|
|
|
|
o.pos = UnityObjectToClipPos( v.vertex );
|
|
o.positionWS.xyz = positionWS;
|
|
o.normalWS = normalWS;
|
|
return o;
|
|
}
|
|
|
|
#if defined(ASE_TESSELLATION)
|
|
struct VertexControl
|
|
{
|
|
float4 vertex : INTERNALTESSPOS;
|
|
half3 normal : NORMAL;
|
|
/*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.normal = v.normal;
|
|
/*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.normal = patch[0].normal * bary.x + patch[1].normal * bary.y + patch[2].normal * 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
|
|
|
|
half4 frag( v2f IN /*ase_frag_input*/
|
|
#if defined( ASE_DEPTH_WRITE_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
|
|
|
|
/*ase_frag_code:IN=v2f*/
|
|
|
|
half Alpha = /*ase_frag_out:Alpha;Float;7;-1;_Alpha*/1/*end*/;
|
|
half AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;8;-1;_AlphaClip*/0.5/*end*/;
|
|
|
|
#if defined( ASE_DEPTH_WRITE_ON )
|
|
float DeviceDepth = /*ase_frag_out:Depth;Float;28;-1;_DeviceDepth*/IN.pos.z/*end*/;
|
|
#endif
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
clip( Alpha - AlphaClipThreshold );
|
|
#endif
|
|
|
|
#if defined( ASE_DEPTH_WRITE_ON )
|
|
outputDepth = DeviceDepth;
|
|
#endif
|
|
|
|
return float4( _ObjectId, _PassValue, 1.0, 1.0 );
|
|
}
|
|
ENDCG
|
|
}
|
|
|
|
/*ase_pass*/
|
|
Pass
|
|
{
|
|
/*ase_hide_pass*/
|
|
Name "ScenePickingPass"
|
|
Tags{ "LightMode" = "ScenePickingPass" }
|
|
|
|
ZWrite On
|
|
|
|
CGPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
|
|
|
|
#pragma multi_compile_fwdbase
|
|
#ifndef UNITY_PASS_FORWARDBASE
|
|
#define UNITY_PASS_FORWARDBASE
|
|
#endif
|
|
#include "HLSLSupport.cginc"
|
|
#if defined( ASE_GEOMETRY ) || defined( ASE_IMPOSTOR )
|
|
#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
|
|
#endif
|
|
#include "UnityShaderVariables.cginc"
|
|
#include "UnityCG.cginc"
|
|
#include "Lighting.cginc"
|
|
#include "UnityPBSLighting.cginc"
|
|
#include "AutoLight.cginc"
|
|
|
|
/*ase_pragma*/
|
|
|
|
float4 _SelectionID;
|
|
|
|
struct appdata
|
|
{
|
|
float4 vertex : POSITION;
|
|
half3 normal : NORMAL;
|
|
half4 tangent : TANGENT;
|
|
/*ase_vdata:p=p;t=t;n=n*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct v2f
|
|
{
|
|
float4 pos : SV_POSITION;
|
|
float4 positionWS : TEXCOORD0; // xyz = positionWS
|
|
half3 normalWS : TEXCOORD1;
|
|
/*ase_interp(2,):sp=sp;wp=tc0.xyz;wn=tc1.xyz*/
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
#ifdef ASE_TESSELLATION
|
|
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*/;
|
|
|
|
float3 positionWS = mul( unity_ObjectToWorld, v.vertex ).xyz;
|
|
half3 normalWS = UnityObjectToWorldNormal( v.normal );
|
|
|
|
o.pos = UnityObjectToClipPos( v.vertex );
|
|
o.positionWS.xyz = positionWS;
|
|
o.normalWS = normalWS;
|
|
return o;
|
|
}
|
|
|
|
#if defined(ASE_TESSELLATION)
|
|
struct VertexControl
|
|
{
|
|
float4 vertex : INTERNALTESSPOS;
|
|
half3 normal : NORMAL;
|
|
/*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.normal = v.normal;
|
|
/*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.normal = patch[0].normal * bary.x + patch[1].normal * bary.y + patch[2].normal * 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
|
|
|
|
half4 frag( v2f IN /*ase_frag_input*/
|
|
#if defined( ASE_DEPTH_WRITE_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
|
|
|
|
/*ase_frag_code:IN=v2f*/
|
|
|
|
half Alpha = /*ase_frag_out:Alpha;Float;7;-1;_Alpha*/1/*end*/;
|
|
half AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;8;-1;_AlphaClip*/0.5/*end*/;
|
|
|
|
#if defined( ASE_DEPTH_WRITE_ON )
|
|
float DeviceDepth = /*ase_frag_out:Depth;Float;28;-1;_DeviceDepth*/IN.pos.z/*end*/;
|
|
#endif
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
clip( Alpha - AlphaClipThreshold );
|
|
#endif
|
|
|
|
#if defined( ASE_DEPTH_WRITE_ON )
|
|
outputDepth = DeviceDepth;
|
|
#endif
|
|
|
|
return _SelectionID;
|
|
}
|
|
ENDCG
|
|
}
|
|
/*ase_pass_end*/
|
|
}
|
|
CustomEditor "AmplifyShaderEditor.MaterialInspector"
|
|
}
|