更新,spine和很多优化
This commit is contained in:
+47
@@ -0,0 +1,47 @@
|
||||
#ifndef SKELETONLIT_UNLIT_PASS_INCLUDED
|
||||
#define SKELETONLIT_UNLIT_PASS_INCLUDED
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float3 positionOS : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
TEXTURE2D(_MainTex);
|
||||
SAMPLER(sampler_MainTex);
|
||||
float4 _MainTex_ST;
|
||||
|
||||
Varyings UnlitVertex(Attributes attributes)
|
||||
{
|
||||
Varyings o = (Varyings)0;
|
||||
|
||||
o.positionCS = TransformObjectToHClip(attributes.positionOS);
|
||||
o.uv = TRANSFORM_TEX(attributes.uv, _MainTex);
|
||||
o.uv = attributes.uv;
|
||||
o.color = attributes.color;
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 UnlitFragment(Varyings i) : SV_Target
|
||||
{
|
||||
half4 tex = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
|
||||
half4 main;
|
||||
#if defined(_STRAIGHT_ALPHA_INPUT)
|
||||
main.rgb = tex.rgb * i.color.rgb * tex.a;
|
||||
#else
|
||||
main.rgb = tex.rgb * i.color.rgb;
|
||||
#endif
|
||||
main.a = tex.a * i.color.a;
|
||||
|
||||
return main;
|
||||
}
|
||||
|
||||
#endif
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 580dd7e812fc63c4a9330abe519946de
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
#ifndef SPRITE_NORMALS_PASS_URP_INCLUDED
|
||||
#define SPRITE_NORMALS_PASS_URP_INCLUDED
|
||||
|
||||
#include "Packages/com.esotericsoftware.spine.urp-shaders/Shaders/Include/SpineCoreShaders/ShaderShared.cginc"
|
||||
#include "Packages/com.esotericsoftware.spine.urp-shaders/Shaders/Include/SpineCoreShaders/SpriteLighting.cginc"
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 uv : TEXCOORD0;
|
||||
float3 normalWS : TEXCOORD1;
|
||||
float3 tangentWS : TEXCOORD2;
|
||||
float3 bitangentWS : TEXCOORD3;
|
||||
};
|
||||
|
||||
SAMPLER(sampler_BumpMap);
|
||||
float4 _BumpMap_ST;
|
||||
|
||||
Varyings NormalsRenderingVertex(VertexInput attributes)
|
||||
{
|
||||
Varyings o = (Varyings)0;
|
||||
|
||||
o.positionCS = calculateLocalPos(attributes.vertex);
|
||||
o.uv = attributes.texcoord.xy;
|
||||
o.color = attributes.color;
|
||||
o.normalWS = TransformObjectToWorldDir(float3(0, 0, -1));
|
||||
|
||||
float3 positionWS = TransformObjectToWorld(attributes.vertex.xyz);
|
||||
|
||||
float backFaceSign = 1;
|
||||
#if defined(FIXED_NORMALS_BACKFACE_RENDERING)
|
||||
backFaceSign = calculateBackfacingSign(positionWS.xyz);
|
||||
#endif
|
||||
|
||||
half3 normalWS = calculateSpriteWorldNormal(attributes, -backFaceSign);
|
||||
o.normalWS.xyz = normalWS;
|
||||
|
||||
#if defined(_NORMALMAP)
|
||||
o.tangentWS.xyz = calculateWorldTangent(attributes.tangent);
|
||||
o.bitangentWS.xyz = calculateSpriteWorldBinormal(attributes, o.normalWS.xyz, o.tangentWS.xyz, backFaceSign);
|
||||
#endif
|
||||
return o;
|
||||
}
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/NormalsRenderingShared.hlsl"
|
||||
half4 NormalsRenderingFragment(Varyings i) : SV_Target
|
||||
{
|
||||
half4 mainTex = i.color * tex2D(_MainTex, i.uv);
|
||||
|
||||
#if defined(_NORMALMAP)
|
||||
half3 normalTS = normalize(UnpackScaleNormal(tex2D(_BumpMap, i.uv.xy), _BumpScale));
|
||||
return NormalsRenderingShared(mainTex, normalTS, i.tangentWS.xyz, i.bitangentWS.xyz, i.normalWS.xyz);
|
||||
#else
|
||||
half3 normalTS = half3(0, 0, 1);
|
||||
half3 tangentWS = half3(0, 0, 0);
|
||||
half3 bitangentWS = half3(0, 0, 0);
|
||||
half3 normalWS = i.normalWS.xyz;
|
||||
return NormalsRenderingShared(mainTex, normalTS, tangentWS, bitangentWS, normalWS);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9057c6890fc765846aa6561463305af9
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+145
@@ -0,0 +1,145 @@
|
||||
#ifndef SPRITE_STANDARD_PASS_URP_INCLUDED
|
||||
#define SPRITE_STANDARD_PASS_URP_INCLUDED
|
||||
|
||||
#include "Packages/com.esotericsoftware.spine.urp-shaders/Shaders/Include/SpineCoreShaders/ShaderShared.cginc"
|
||||
#include "Packages/com.esotericsoftware.spine.urp-shaders/Shaders/Include/SpineCoreShaders/SpriteLighting.cginc"
|
||||
#if defined(_ALPHAPREMULTIPLY_ON)
|
||||
#undef _STRAIGHT_ALPHA_INPUT
|
||||
#elif !defined(_STRAIGHT_ALPHA_INPUT)
|
||||
#define _STRAIGHT_ALPHA_INPUT
|
||||
#endif
|
||||
#include "Packages/com.esotericsoftware.spine.urp-shaders/Shaders/Include/SpineCoreShaders/Spine-Skeleton-Tint-Common.cginc"
|
||||
|
||||
#if UNITY_VERSION < 60030000 // before Unity 6000.3
|
||||
#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
|
||||
#endif // #if UNITY_VERSION < 60030000 // before Unity 6000.3
|
||||
|
||||
TEXTURE2D(_MaskTex);
|
||||
SAMPLER(sampler_MaskTex);
|
||||
|
||||
struct VertexOutputSpriteURP2D
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
half4 vertexColor : COLOR;
|
||||
float3 texcoord : TEXCOORD0;
|
||||
float2 lightingUV : TEXCOORD1;
|
||||
|
||||
half3 viewDirectionWS : TEXCOORD2;
|
||||
|
||||
#if defined(_NORMALMAP)
|
||||
half4 normalWorld : TEXCOORD4;
|
||||
half4 tangentWorld : TEXCOORD5;
|
||||
half4 binormalWorld : TEXCOORD6;
|
||||
#else
|
||||
half3 normalWorld : TEXCOORD4;
|
||||
#endif
|
||||
#if defined(_RIM_LIGHTING)
|
||||
float4 positionWS : TEXCOORD8;
|
||||
#endif
|
||||
|
||||
#if defined(_TINT_BLACK_ON)
|
||||
float3 darkColor : TEXCOORD9;
|
||||
#endif
|
||||
};
|
||||
|
||||
VertexOutputSpriteURP2D CombinedShapeLightVertex(VertexInput input)
|
||||
{
|
||||
VertexOutputSpriteURP2D output = (VertexOutputSpriteURP2D)0;
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
|
||||
output.pos = calculateLocalPos(input.vertex);
|
||||
float4 clipVertex = output.pos / output.pos.w;
|
||||
output.lightingUV = ComputeScreenPos(clipVertex).xy;
|
||||
|
||||
output.vertexColor = calculateVertexColor(input.color);
|
||||
#if defined(_TINT_BLACK_ON)
|
||||
output.darkColor = GammaToTargetSpace(
|
||||
half3(input.tintBlackRG.r, input.tintBlackRG.g, input.tintBlackB.r)) + (_Black.rgb * input.color.a);
|
||||
#endif
|
||||
|
||||
output.texcoord = float3(calculateTextureCoord(input.texcoord), 0);
|
||||
|
||||
float3 positionWS = TransformObjectToWorld(input.vertex.xyz);
|
||||
|
||||
float backFaceSign = 1;
|
||||
#if defined(FIXED_NORMALS_BACKFACE_RENDERING)
|
||||
backFaceSign = calculateBackfacingSign(positionWS.xyz);
|
||||
#endif
|
||||
output.viewDirectionWS = GetCameraPositionWS() - positionWS;
|
||||
|
||||
#if defined(_RIM_LIGHTING)
|
||||
output.positionWS = float4(positionWS, 1);
|
||||
#endif
|
||||
half3 normalWS = calculateSpriteWorldNormal(input, -backFaceSign);
|
||||
output.normalWorld.xyz = normalWS;
|
||||
|
||||
#if defined(_RIM_LIGHTING)
|
||||
#if defined(_NORMALMAP)
|
||||
output.tangentWorld.xyz = calculateWorldTangent(input.tangent);
|
||||
output.binormalWorld.xyz = calculateSpriteWorldBinormal(input, output.normalWorld.xyz, output.tangentWorld.xyz, backFaceSign);
|
||||
#endif
|
||||
#endif
|
||||
return output;
|
||||
}
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/CombinedShapeLightShared.hlsl"
|
||||
|
||||
half4 CombinedShapeLightFragment(VertexOutputSpriteURP2D input) : SV_Target
|
||||
{
|
||||
fixed4 texureColor = calculateTexturePixel(input.texcoord.xy);
|
||||
RETURN_UNLIT_IF_ADDITIVE_SLOT_TINT(texureColor, input.vertexColor, input.darkColor, _Color.a, _Black.a) // shall be called before ALPHA_CLIP
|
||||
ALPHA_CLIP(texureColor, input.vertexColor)
|
||||
#if defined(_TINT_BLACK_ON)
|
||||
half4 main = fragTintedColor(texureColor, input.darkColor, input.vertexColor, _Color.a, _Black.a);
|
||||
#else
|
||||
half4 main = texureColor * input.vertexColor;
|
||||
#endif
|
||||
|
||||
half4 mask = SAMPLE_TEXTURE2D(_MaskTex, sampler_MaskTex, input.texcoord.xy);
|
||||
// un-premultiply for additive lights in CombinedShapeLightShared, reapply afterwards
|
||||
main.rgb = main.a < 0.001 ? main.rgb : main.rgb / main.a; // < epsilon prevents imprecision issues on some HW.
|
||||
#if UNITY_VERSION < 202120
|
||||
half4 pixel = half4(CombinedShapeLightShared(half4(main.rgb, 1), mask, input.lightingUV).rgb * main.a, main.a);
|
||||
#else
|
||||
SurfaceData2D surfaceData;
|
||||
InputData2D inputData;
|
||||
surfaceData.albedo = main.rgb;
|
||||
surfaceData.alpha = 1;
|
||||
surfaceData.mask = mask;
|
||||
inputData.uv = input.texcoord.xy;
|
||||
inputData.lightingUV = input.lightingUV;
|
||||
half4 pixel = half4(CombinedShapeLightShared(surfaceData, inputData).rgb * main.a, main.a);
|
||||
#endif
|
||||
|
||||
#if defined(_RIM_LIGHTING)
|
||||
#if defined(_NORMALMAP)
|
||||
half3 normalWS = calculateNormalFromBumpMap(input.texcoord.xy, input.tangentWorld.xyz, input.binormalWorld.xyz, input.normalWorld.xyz);
|
||||
#else
|
||||
half3 normalWS = input.normalWorld.xyz;
|
||||
#endif
|
||||
|
||||
pixel.rgb = applyRimLighting(input.positionWS.xyz, normalWS, pixel);
|
||||
#endif
|
||||
|
||||
APPLY_EMISSION(pixel.rgb, input.texcoord.xy)
|
||||
pixel = prepareLitPixelForOutput(pixel, texureColor.a, input.vertexColor.a);
|
||||
COLORISE(pixel)
|
||||
return pixel;
|
||||
}
|
||||
|
||||
#endif
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9f1eb74802463764986790ef549c5bbe
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user