399 lines
11 KiB
Plaintext
399 lines
11 KiB
Plaintext
![]() |
Shader /*ase_name*/ "Hidden/Universal/Experimental/2D Lit" /*end*/
|
||
|
{
|
||
|
Properties
|
||
|
{
|
||
|
/*ase_props*/
|
||
|
}
|
||
|
|
||
|
SubShader
|
||
|
{
|
||
|
/*ase_subshader_options:Name=Additional Options
|
||
|
Option:Vertex Position:Absolute,Relative:Relative
|
||
|
Absolute:SetDefine:ASE_ABSOLUTE_VERTEX_POS 1
|
||
|
Absolute:SetPortName:Sprite Lit:4,Vertex Position
|
||
|
Relative:RemoveDefine:ASE_ABSOLUTE_VERTEX_POS 1
|
||
|
Relative:SetPortName:Sprite Lit:4,Vertex Offset
|
||
|
*/
|
||
|
|
||
|
Tags
|
||
|
{
|
||
|
"RenderPipeline" = "UniversalPipeline"
|
||
|
"RenderType" = "Transparent"
|
||
|
"Queue" = "Transparent+0"
|
||
|
}
|
||
|
|
||
|
Cull Off
|
||
|
HLSLINCLUDE
|
||
|
#pragma target 2.0
|
||
|
|
||
|
#pragma prefer_hlslcc gles
|
||
|
#pragma exclude_renderers d3d11_9x
|
||
|
|
||
|
ENDHLSL
|
||
|
|
||
|
/*ase_pass*/
|
||
|
Pass
|
||
|
{
|
||
|
Name "Sprite Lit"
|
||
|
Tags { "LightMode" = "Universal2D" }
|
||
|
|
||
|
Blend SrcAlpha OneMinusSrcAlpha, One OneMinusSrcAlpha
|
||
|
ZTest LEqual
|
||
|
ZWrite Off
|
||
|
Offset 0,0
|
||
|
ColorMask RGBA
|
||
|
/*ase_stencil*/
|
||
|
|
||
|
HLSLPROGRAM
|
||
|
|
||
|
#pragma vertex vert
|
||
|
#pragma fragment frag
|
||
|
|
||
|
#pragma multi_compile _ ETC1_EXTERNAL_ALPHA
|
||
|
#pragma multi_compile _ USE_SHAPE_LIGHT_TYPE_0
|
||
|
#pragma multi_compile _ USE_SHAPE_LIGHT_TYPE_1
|
||
|
#pragma multi_compile _ USE_SHAPE_LIGHT_TYPE_2
|
||
|
#pragma multi_compile _ USE_SHAPE_LIGHT_TYPE_3
|
||
|
|
||
|
#define _SURFACE_TYPE_TRANSPARENT 1
|
||
|
#define SHADERPASS_SPRITELIT
|
||
|
|
||
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
||
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
||
|
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/LightingUtility.hlsl"
|
||
|
|
||
|
#if USE_SHAPE_LIGHT_TYPE_0
|
||
|
SHAPE_LIGHT(0)
|
||
|
#endif
|
||
|
|
||
|
#if USE_SHAPE_LIGHT_TYPE_1
|
||
|
SHAPE_LIGHT(1)
|
||
|
#endif
|
||
|
|
||
|
#if USE_SHAPE_LIGHT_TYPE_2
|
||
|
SHAPE_LIGHT(2)
|
||
|
#endif
|
||
|
|
||
|
#if USE_SHAPE_LIGHT_TYPE_3
|
||
|
SHAPE_LIGHT(3)
|
||
|
#endif
|
||
|
|
||
|
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/CombinedShapeLightShared.hlsl"
|
||
|
|
||
|
/*ase_pragma*/
|
||
|
|
||
|
/*ase_globals*/
|
||
|
|
||
|
struct VertexInput
|
||
|
{
|
||
|
float4 vertex : POSITION;
|
||
|
float3 normal : NORMAL;
|
||
|
float4 tangent : TANGENT;
|
||
|
float4 uv0 : TEXCOORD0;
|
||
|
float4 color : COLOR;
|
||
|
/*ase_vdata:p=p;n=n;t=t;c=c;uv0=tc0*/
|
||
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||
|
};
|
||
|
|
||
|
struct VertexOutput
|
||
|
{
|
||
|
float4 clipPos : SV_POSITION;
|
||
|
float4 texCoord0 : TEXCOORD0;
|
||
|
float4 color : TEXCOORD1;
|
||
|
float4 screenPosition : TEXCOORD2;
|
||
|
/*ase_interp(3,):sp=sp;uv0=tc0;*/
|
||
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||
|
UNITY_VERTEX_OUTPUT_STEREO
|
||
|
};
|
||
|
|
||
|
#if ETC1_EXTERNAL_ALPHA
|
||
|
TEXTURE2D(_AlphaTex); SAMPLER(sampler_AlphaTex);
|
||
|
float _EnableAlphaTexture;
|
||
|
#endif
|
||
|
|
||
|
/*ase_funcs*/
|
||
|
|
||
|
VertexOutput vert ( VertexInput v /*ase_vert_input*/ )
|
||
|
{
|
||
|
VertexOutput o = (VertexOutput)0;
|
||
|
UNITY_SETUP_INSTANCE_ID(v);
|
||
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||
|
|
||
|
/*ase_vert_code:v=VertexInput;o=VertexOutput*/
|
||
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
||
|
float3 defaultVertexValue = v.vertex.xyz;
|
||
|
#else
|
||
|
float3 defaultVertexValue = float3(0, 0, 0);
|
||
|
#endif
|
||
|
float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;4;-1;_Vertex*/defaultVertexValue/*end*/;
|
||
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
||
|
v.vertex.xyz = vertexValue;
|
||
|
#else
|
||
|
v.vertex.xyz += vertexValue;
|
||
|
#endif
|
||
|
v.normal = /*ase_vert_out:Vertex Normal;Float3;5;-1;_VNormal*/v.normal/*end*/;
|
||
|
v.tangent.xyz = /*ase_vert_out:Vertex Tangent;Float3;6;-1;_VTangent*/v.tangent.xyz/*end*/;
|
||
|
|
||
|
VertexPositionInputs vertexInput = GetVertexPositionInputs(v.vertex.xyz);
|
||
|
|
||
|
o.texCoord0 = v.uv0;
|
||
|
o.color = v.color;
|
||
|
o.clipPos = vertexInput.positionCS;
|
||
|
o.screenPosition = ComputeScreenPos( o.clipPos, _ProjectionParams.x );
|
||
|
return o;
|
||
|
}
|
||
|
|
||
|
half4 frag ( VertexOutput IN /*ase_frag_input*/ ) : SV_Target
|
||
|
{
|
||
|
UNITY_SETUP_INSTANCE_ID( IN );
|
||
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( IN );
|
||
|
|
||
|
/*ase_frag_code:IN=VertexOutput*/
|
||
|
float4 Color = /*ase_frag_out:Color;Float4;1;-1;_Color*/float4( 1, 1, 1, 1 )/*end*/;
|
||
|
float Mask = /*ase_frag_out:Mask;Float;2;-1;_Mask*/1/*end*/;
|
||
|
float3 Normal = /*ase_frag_out:Normal;Float3;3;-1;_Normal*/float3( 0, 0, 1 )/*end*/;
|
||
|
|
||
|
#if ETC1_EXTERNAL_ALPHA
|
||
|
float4 alpha = SAMPLE_TEXTURE2D(_AlphaTex, sampler_AlphaTex, IN.texCoord0.xy);
|
||
|
Color.a = lerp ( Color.a, alpha.r, _EnableAlphaTexture);
|
||
|
#endif
|
||
|
|
||
|
Color *= IN.color;
|
||
|
|
||
|
return CombinedShapeLightShared( Color, Mask, IN.screenPosition.xy / IN.screenPosition.w );
|
||
|
}
|
||
|
|
||
|
ENDHLSL
|
||
|
}
|
||
|
|
||
|
/*ase_pass*/
|
||
|
Pass
|
||
|
{
|
||
|
/*ase_hide_pass:SyncP*/
|
||
|
Name "Sprite Normal"
|
||
|
Tags { "LightMode" = "NormalsRendering" }
|
||
|
|
||
|
Blend SrcAlpha OneMinusSrcAlpha, One OneMinusSrcAlpha
|
||
|
ZTest LEqual
|
||
|
ZWrite Off
|
||
|
Offset 0,0
|
||
|
ColorMask RGBA
|
||
|
/*ase_stencil*/
|
||
|
|
||
|
HLSLPROGRAM
|
||
|
|
||
|
#pragma vertex vert
|
||
|
#pragma fragment frag
|
||
|
|
||
|
#define _SURFACE_TYPE_TRANSPARENT 1
|
||
|
#define SHADERPASS_SPRITENORMAL
|
||
|
|
||
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
||
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
||
|
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/NormalsRenderingShared.hlsl"
|
||
|
|
||
|
/*ase_pragma*/
|
||
|
|
||
|
/*ase_globals*/
|
||
|
|
||
|
struct VertexInput
|
||
|
{
|
||
|
float4 vertex : POSITION;
|
||
|
float3 normal : NORMAL;
|
||
|
float4 tangent : TANGENT;
|
||
|
float4 uv0 : TEXCOORD0;
|
||
|
float4 color : COLOR;
|
||
|
/*ase_vdata:p=p;n=n;t=t;c=c;uv0=tc0*/
|
||
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||
|
};
|
||
|
|
||
|
struct VertexOutput
|
||
|
{
|
||
|
float4 clipPos : SV_POSITION;
|
||
|
float4 texCoord0 : TEXCOORD0;
|
||
|
float4 color : TEXCOORD1;
|
||
|
float3 normalWS : TEXCOORD2;
|
||
|
float4 tangentWS : TEXCOORD3;
|
||
|
float3 bitangentWS : TEXCOORD4;
|
||
|
/*ase_interp(5,):sp=sp;uv0=tc0;c=tc1;wn=tc2;wt=tc3;wbt=tc4*/
|
||
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||
|
UNITY_VERTEX_OUTPUT_STEREO
|
||
|
};
|
||
|
|
||
|
/*ase_funcs*/
|
||
|
|
||
|
VertexOutput vert ( VertexInput v /*ase_vert_input*/ )
|
||
|
{
|
||
|
VertexOutput o = (VertexOutput)0;
|
||
|
UNITY_SETUP_INSTANCE_ID(v);
|
||
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||
|
|
||
|
/*ase_vert_code:v=VertexInput;o=VertexOutput*/
|
||
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
||
|
float3 defaultVertexValue = v.vertex.xyz;
|
||
|
#else
|
||
|
float3 defaultVertexValue = float3(0, 0, 0);
|
||
|
#endif
|
||
|
float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;3;-1;_Vertex*/defaultVertexValue/*end*/;
|
||
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
||
|
v.vertex.xyz = vertexValue;
|
||
|
#else
|
||
|
v.vertex.xyz += vertexValue;
|
||
|
#endif
|
||
|
v.normal = /*ase_vert_out:Vertex Normal;Float3;4;-1;_VNormal*/v.normal/*end*/;
|
||
|
v.tangent.xyz = /*ase_vert_out:Vertex Tangent;Float3;5;-1;_VTangent*/v.tangent.xyz/*end*/;
|
||
|
|
||
|
VertexPositionInputs vertexInput = GetVertexPositionInputs(v.vertex.xyz);
|
||
|
|
||
|
o.texCoord0 = v.uv0;
|
||
|
o.color = v.color;
|
||
|
o.clipPos = vertexInput.positionCS;
|
||
|
|
||
|
float3 normalWS = TransformObjectToWorldNormal( v.normal );
|
||
|
o.normalWS = NormalizeNormalPerVertex( normalWS );
|
||
|
float4 tangentWS = float4( TransformObjectToWorldDir( v.tangent.xyz ), v.tangent.w );
|
||
|
o.tangentWS = normalize( tangentWS );
|
||
|
o.bitangentWS = cross( normalWS, tangentWS.xyz ) * tangentWS.w;
|
||
|
return o;
|
||
|
}
|
||
|
|
||
|
half4 frag ( VertexOutput IN /*ase_frag_input*/ ) : SV_Target
|
||
|
{
|
||
|
UNITY_SETUP_INSTANCE_ID( IN );
|
||
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( IN );
|
||
|
|
||
|
/*ase_frag_code:IN=VertexOutput*/
|
||
|
float4 Color = /*ase_frag_out:Color;Float4;1;-1;_Color*/float4( 1, 1, 1, 1 )/*end*/;
|
||
|
float3 Normal = /*ase_frag_out:Normal;Float3;2;-1;_Normal*/float3( 0, 0, 1 )/*end*/;
|
||
|
|
||
|
Color *= IN.color;
|
||
|
|
||
|
return NormalsRenderingShared( Color, Normal, IN.tangentWS.xyz, IN.bitangentWS, IN.normalWS);
|
||
|
}
|
||
|
|
||
|
ENDHLSL
|
||
|
}
|
||
|
|
||
|
/*ase_pass*/
|
||
|
Pass
|
||
|
{
|
||
|
/*ase_hide_pass:SyncP*/
|
||
|
Name "Sprite Forward"
|
||
|
Tags { "LightMode" = "UniversalForward" }
|
||
|
|
||
|
Blend SrcAlpha OneMinusSrcAlpha, One OneMinusSrcAlpha
|
||
|
ZTest LEqual
|
||
|
ZWrite Off
|
||
|
Offset 0,0
|
||
|
ColorMask RGBA
|
||
|
/*ase_stencil*/
|
||
|
|
||
|
HLSLPROGRAM
|
||
|
|
||
|
#pragma vertex vert
|
||
|
#pragma fragment frag
|
||
|
|
||
|
#pragma multi_compile _ ETC1_EXTERNAL_ALPHA
|
||
|
|
||
|
#define _SURFACE_TYPE_TRANSPARENT 1
|
||
|
#define SHADERPASS_SPRITEFORWARD
|
||
|
|
||
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
||
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
||
|
|
||
|
/*ase_pragma*/
|
||
|
|
||
|
/*ase_globals*/
|
||
|
|
||
|
struct VertexInput
|
||
|
{
|
||
|
float4 vertex : POSITION;
|
||
|
float3 normal : NORMAL;
|
||
|
float4 tangent : TANGENT;
|
||
|
float4 uv0 : TEXCOORD0;
|
||
|
float4 color : COLOR;
|
||
|
/*ase_vdata:p=p;n=n;t=t;c=c;uv0=tc0*/
|
||
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||
|
};
|
||
|
|
||
|
struct VertexOutput
|
||
|
{
|
||
|
float4 clipPos : SV_POSITION;
|
||
|
float4 texCoord0 : TEXCOORD0;
|
||
|
float4 color : TEXCOORD1;
|
||
|
/*ase_interp(2,):sp=sp;uv0=tc0;c=tc1*/
|
||
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||
|
UNITY_VERTEX_OUTPUT_STEREO
|
||
|
};
|
||
|
|
||
|
#if ETC1_EXTERNAL_ALPHA
|
||
|
TEXTURE2D( _AlphaTex ); SAMPLER( sampler_AlphaTex );
|
||
|
float _EnableAlphaTexture;
|
||
|
#endif
|
||
|
|
||
|
/*ase_funcs*/
|
||
|
|
||
|
VertexOutput vert( VertexInput v /*ase_vert_input*/ )
|
||
|
{
|
||
|
VertexOutput o = (VertexOutput)0;
|
||
|
UNITY_SETUP_INSTANCE_ID( v );
|
||
|
UNITY_TRANSFER_INSTANCE_ID( v, o );
|
||
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o );
|
||
|
|
||
|
/*ase_vert_code:v=VertexInput;o=VertexOutput*/
|
||
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
||
|
float3 defaultVertexValue = v.vertex.xyz;
|
||
|
#else
|
||
|
float3 defaultVertexValue = float3( 0, 0, 0 );
|
||
|
#endif
|
||
|
float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;3;-1;_Vertex*/defaultVertexValue/*end*/;
|
||
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
||
|
v.vertex.xyz = vertexValue;
|
||
|
#else
|
||
|
v.vertex.xyz += vertexValue;
|
||
|
#endif
|
||
|
v.normal = /*ase_vert_out:Vertex Normal;Float3;4;-1;_VNormal*/v.normal/*end*/;
|
||
|
|
||
|
VertexPositionInputs vertexInput = GetVertexPositionInputs( v.vertex.xyz );
|
||
|
|
||
|
o.texCoord0 = v.uv0;
|
||
|
o.color = v.color;
|
||
|
o.clipPos = vertexInput.positionCS;
|
||
|
|
||
|
return o;
|
||
|
}
|
||
|
|
||
|
half4 frag( VertexOutput IN /*ase_frag_input*/ ) : SV_Target
|
||
|
{
|
||
|
UNITY_SETUP_INSTANCE_ID( IN );
|
||
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( IN );
|
||
|
|
||
|
/*ase_frag_code:IN=VertexOutput*/
|
||
|
float4 Color = /*ase_frag_out:Color;Float4;1;-1;_Color*/float4( 1, 1, 1, 1 )/*end*/;
|
||
|
|
||
|
#if ETC1_EXTERNAL_ALPHA
|
||
|
float4 alpha = SAMPLE_TEXTURE2D( _AlphaTex, sampler_AlphaTex, IN.texCoord0.xy );
|
||
|
Color.a = lerp( Color.a, alpha.r, _EnableAlphaTexture );
|
||
|
#endif
|
||
|
|
||
|
Color *= IN.color;
|
||
|
|
||
|
return Color;
|
||
|
}
|
||
|
|
||
|
ENDHLSL
|
||
|
}
|
||
|
/*ase_pass_end*/
|
||
|
}
|
||
|
CustomEditor "UnityEditor.ShaderGraph.PBRMasterGUI"
|
||
|
FallBack "Hidden/InternalErrorShader"
|
||
|
}
|