mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 09:16:01 +08:00
[unity] Spine LWRP shaders package: Added LWRP version of "Spine/Skeleton" shader. The normal shader no longer worked in LWRP setting on Unity 2019.1.6+ on Android GLES 3.0 (due to instancing problems). Closes #1446.
This commit is contained in:
parent
c24b8b348d
commit
2ef2e70210
@ -0,0 +1,43 @@
|
||||
#ifndef SKELETON_FORWARD_PASS_LW_INCLUDED
|
||||
#define SKELETON_FORWARD_PASS_LW_INCLUDED
|
||||
|
||||
struct appdata {
|
||||
float3 pos : POSITION;
|
||||
half4 color : COLOR;
|
||||
float2 uv0 : TEXCOORD0;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct VertexOutput {
|
||||
half4 color : COLOR0;
|
||||
float2 uv0 : TEXCOORD0;
|
||||
float4 pos : SV_POSITION;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
VertexOutput vert(appdata v) {
|
||||
VertexOutput o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
float3 positionWS = TransformObjectToWorld(v.pos);
|
||||
o.pos = TransformWorldToHClip(positionWS);
|
||||
o.uv0 = v.uv0;
|
||||
o.color = v.color;
|
||||
return o;
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
|
||||
half4 frag(VertexOutput i) : SV_Target{
|
||||
float4 texColor = tex2D(_MainTex, i.uv0);
|
||||
|
||||
#if defined(_STRAIGHT_ALPHA_INPUT)
|
||||
texColor.rgb *= texColor.a;
|
||||
#endif
|
||||
|
||||
return (texColor * i.color);
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b0e8ff465c74264ab0348b088f52d7e
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,155 @@
|
||||
Shader "Lightweight Render Pipeline/Spine/Skeleton" {
|
||||
Properties {
|
||||
_Cutoff("Shadow alpha cutoff", Range(0,1)) = 0.1
|
||||
[NoScaleOffset] _MainTex("Main Texture", 2D) = "black" {}
|
||||
[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
|
||||
[HideInInspector] _StencilRef("Stencil Reference", Float) = 1.0
|
||||
[Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp("Stencil Comparison", Float) = 8 // Set to Always as default
|
||||
}
|
||||
|
||||
SubShader {
|
||||
// Lightweight Pipeline tag is required. If Lightweight render pipeline is not set in the graphics settings
|
||||
// this Subshader will fail.
|
||||
Tags { "RenderPipeline" = "LightweightPipeline" "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
|
||||
LOD 100
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
Blend One OneMinusSrcAlpha
|
||||
|
||||
Stencil {
|
||||
Ref[_StencilRef]
|
||||
Comp[_StencilComp]
|
||||
Pass Keep
|
||||
}
|
||||
|
||||
Pass {
|
||||
Name "Forward"
|
||||
Tags{"LightMode" = "LightweightForward"}
|
||||
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
Blend One OneMinusSrcAlpha
|
||||
|
||||
HLSLPROGRAM
|
||||
// Required to compile gles 2.0 with standard srp library
|
||||
#pragma prefer_hlslcc gles
|
||||
#pragma exclude_renderers d3d11_9x
|
||||
#pragma target 2.0
|
||||
|
||||
// -------------------------------------
|
||||
// Lightweight Pipeline keywords
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
|
||||
#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
|
||||
#pragma multi_compile _ _SHADOWS_SOFT
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
#pragma multi_compile_fog
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
//--------------------------------------
|
||||
// Spine related keywords
|
||||
#pragma shader_feature _ _STRAIGHT_ALPHA_INPUT
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
|
||||
#undef LIGHTMAP_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
#define USE_LWRP
|
||||
#define fixed4 half4
|
||||
#define fixed3 half3
|
||||
#define fixed half
|
||||
#include "CGIncludes/Spine-Skeleton-ForwardPass-LW.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "ShadowCaster"
|
||||
Tags{"LightMode" = "ShadowCaster"}
|
||||
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
// Required to compile gles 2.0 with standard srp library
|
||||
#pragma prefer_hlslcc gles
|
||||
#pragma exclude_renderers d3d11_9x
|
||||
#pragma target 2.0
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature _ALPHATEST_ON
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
#pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
|
||||
#pragma vertex ShadowPassVertexSkeletonLit
|
||||
#pragma fragment ShadowPassFragmentSkeletonLit
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.lightweight/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.lightweight/Shaders/ShadowCasterPass.hlsl"
|
||||
|
||||
#define USE_LWRP
|
||||
#define fixed4 half4
|
||||
#define fixed3 half3
|
||||
#define fixed half
|
||||
#include "CGIncludes/Spine-Input-LW.hlsl"
|
||||
#include "CGIncludes/Spine-SkeletonLit-ShadowCasterPass-LW.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "DepthOnly"
|
||||
Tags{"LightMode" = "DepthOnly"}
|
||||
|
||||
ZWrite On
|
||||
ColorMask 0
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
// Required to compile gles 2.0 with standard srp library
|
||||
#pragma prefer_hlslcc gles
|
||||
#pragma exclude_renderers d3d11_9x
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma vertex DepthOnlyVertexSprite
|
||||
#pragma fragment DepthOnlyFragmentSprite
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature _ALPHATEST_ON
|
||||
#pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.lightweight/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.lightweight/Shaders/DepthOnlyPass.hlsl"
|
||||
|
||||
#define USE_LWRP
|
||||
#define fixed4 half4
|
||||
#define fixed3 half3
|
||||
#define fixed half
|
||||
#include "CGIncludes/Spine-Input-LW.hlsl"
|
||||
#include "CGIncludes/Spine-DepthOnlyPass-LW.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
FallBack "Hidden/InternalErrorShader"
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 65857b179c43d9c49ba05eeb3e483e87
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
x
Reference in New Issue
Block a user