This commit is contained in:
SoulliesOfficial
2026-04-03 10:53:11 -04:00
parent e7b890686d
commit 1bc9af280b
177 changed files with 4029 additions and 3302 deletions

View File

@@ -11,7 +11,7 @@ Shader "Soullies/BlendUnlit"
Properties
{
[Header(Texture)]
_MainTexture ("Main Texture", 2D) = "white" {}
_MainTex ("Main Texture", 2D) = "white" {}
[Space(8)]
[Header(Color)]
@@ -19,14 +19,14 @@ Shader "Soullies/BlendUnlit"
[Space(8)]
[Header(Emission)]
[Toggle(_EMISSION_ON)] _EnableEmission ("Enable Emission", Float) = 0
[Toggle] _EnableEmission ("Enable Emission", Float) = 0
[HDR] _EmissionColor ("Emission Color (HDR)", Color) = (0, 0, 0, 1)
[Space(8)]
[Header(Alpha Source)]
// When toggled ON : uses the Red channel of the texture as Alpha (for single-channel masks).
// When toggled OFF : uses the A channel of the texture (standard RGBA sprite).
[Toggle(_USEREDASALPHA_ON)] _UseRedAsAlpha ("Use Red Channel as Alpha", Float) = 0
[Toggle] _UseRedAsAlpha ("Use Red Channel as Alpha", Float) = 0
[Space(8)]
[Header(Blend Mode)]
@@ -94,9 +94,6 @@ Shader "Soullies/BlendUnlit"
#pragma multi_compile_instancing
#pragma multi_compile_vertex _ SKINNED_SPRITE
// Feature toggles local so they only generate variants for this material
#pragma shader_feature_local_fragment _EMISSION_ON
#pragma shader_feature_local_fragment _USEREDASALPHA_ON
// Blend mode variants (local_fragment: blend equation changes are per-draw, not per-pass)
#pragma shader_feature_local _BLENDMODE_ALPHA _BLENDMODE_ADDITIVE _BLENDMODE_MULTIPLY _BLENDMODE_PREMULTIPLIED
@@ -106,10 +103,10 @@ Shader "Soullies/BlendUnlit"
// -----------------------------------------------------------------------
// Shared CBUFFER (SRP Batcher compatible)
// -----------------------------------------------------------------------
TEXTURE2D(_MainTexture); SAMPLER(sampler_MainTexture);
TEXTURE2D(_MainTex); SAMPLER(sampler_MainTex);
CBUFFER_START(UnityPerMaterial)
float4 _MainTexture_ST;
float4 _MainTex_ST;
half4 _BaseColor;
half4 _EmissionColor;
float _ZWrite;
@@ -143,14 +140,10 @@ Shader "Soullies/BlendUnlit"
// -----------------------------------------------------------------------
half4 ComputeColor(float2 uv, half4 vertexColor)
{
half4 texSample = SAMPLE_TEXTURE2D(_MainTexture, sampler_MainTexture, uv);
half4 texSample = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uv);
// Alpha channel selection
#if defined(_USEREDASALPHA_ON)
half texAlpha = texSample.r;
#else
half texAlpha = texSample.a;
#endif
// Alpha channel selection (Lerp instead of macro avoids variant stripping issues)
half texAlpha = lerp(texSample.a, texSample.r, _UseRedAsAlpha);
// Reconstruct colour from texture
half4 texColor = half4(texSample.rgb, texAlpha);
@@ -159,10 +152,8 @@ Shader "Soullies/BlendUnlit"
half4 color = texColor * _BaseColor;
// Emission multiply
#if defined(_EMISSION_ON)
color *= _EmissionColor;
#endif
// (when emission is OFF we simply skip the multiply equivalent to multiplying by white)
half4 emissionMult = lerp(half4(1, 1, 1, 1), _EmissionColor, _EnableEmission);
color *= emissionMult;
// Vertex color (Sprite tint / SpriteRenderer.color)
color *= vertexColor;
@@ -186,7 +177,7 @@ Shader "Soullies/BlendUnlit"
VertexPositionInputs vpi = GetVertexPositionInputs(IN.positionOS);
OUT.positionCS = vpi.positionCS;
OUT.uv = TRANSFORM_TEX(IN.uv, _MainTexture);
OUT.uv = TRANSFORM_TEX(IN.uv, _MainTex);
OUT.color = IN.color * unity_SpriteColor;
return OUT;
}
@@ -225,19 +216,19 @@ Shader "Soullies/BlendUnlit"
#pragma multi_compile_instancing
#pragma multi_compile_fog
#pragma shader_feature_local_fragment _EMISSION_ON
#pragma shader_feature_local_fragment _USEREDASALPHA_ON
#pragma shader_feature_local _BLENDMODE_ALPHA _BLENDMODE_ADDITIVE _BLENDMODE_MULTIPLY _BLENDMODE_PREMULTIPLIED
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl"
TEXTURE2D(_MainTexture); SAMPLER(sampler_MainTexture);
TEXTURE2D(_MainTex); SAMPLER(sampler_MainTex);
CBUFFER_START(UnityPerMaterial)
float4 _MainTexture_ST;
float4 _MainTex_ST;
half4 _BaseColor;
half4 _EmissionColor;
float _EnableEmission;
float _UseRedAsAlpha;
float _ZWrite;
float _SrcBlendRGB;
float _DstBlendRGB;
@@ -263,20 +254,15 @@ Shader "Soullies/BlendUnlit"
half4 ComputeColor(float2 uv, half4 vertexColor)
{
half4 texSample = SAMPLE_TEXTURE2D(_MainTexture, sampler_MainTexture, uv);
half4 texSample = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uv);
#if defined(_USEREDASALPHA_ON)
half texAlpha = texSample.r;
#else
half texAlpha = texSample.a;
#endif
half texAlpha = lerp(texSample.a, texSample.r, _UseRedAsAlpha);
half4 texColor = half4(texSample.rgb, texAlpha);
half4 color = texColor * _BaseColor;
#if defined(_EMISSION_ON)
color *= _EmissionColor;
#endif
half4 emissionMult = lerp(half4(1, 1, 1, 1), _EmissionColor, _EnableEmission);
color *= emissionMult;
color *= vertexColor;
return color;
@@ -291,7 +277,7 @@ Shader "Soullies/BlendUnlit"
VertexPositionInputs vpi = GetVertexPositionInputs(IN.positionOS);
OUT.positionCS = vpi.positionCS;
OUT.uv = TRANSFORM_TEX(IN.uv, _MainTexture);
OUT.uv = TRANSFORM_TEX(IN.uv, _MainTex);
OUT.color = IN.color;
OUT.fogFactor = ComputeFogFactor(vpi.positionCS.z);
return OUT;
@@ -329,7 +315,7 @@ Shader "Soullies/BlendUnlit"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
CBUFFER_START(UnityPerMaterial)
float4 _MainTexture_ST;
float4 _MainTex_ST;
half4 _BaseColor;
half4 _EmissionColor;
float _ZWrite;
@@ -378,7 +364,7 @@ Shader "Soullies/BlendUnlit"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
CBUFFER_START(UnityPerMaterial)
float4 _MainTexture_ST;
float4 _MainTex_ST;
half4 _BaseColor;
half4 _EmissionColor;
float _ZWrite;