mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +08:00
[unity] Update shaders.
This commit is contained in:
parent
87677c34e3
commit
52fc282984
@ -1,90 +0,0 @@
|
||||
//Shader written by Alex Dixon
|
||||
Shader "Spine/Special/SkeletonGhost"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color ("Main Color", Color) = (1,1,1,1)
|
||||
_MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {}
|
||||
_TextureFade ("Texture Fade Out", Range(0,1)) = 0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
|
||||
Tags {"Queue"="Transparent" "IgnoreProjector"="False" "RenderType"="Transparent"}
|
||||
Fog { Mode Off }
|
||||
Blend One OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
|
||||
Pass
|
||||
{
|
||||
Tags {"LightMode" = "Always"} // This Pass tag is important or Unity may not give it the correct light information.
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
//#pragma multi_compile_fwdbase // This line tells Unity to compile this pass for forward base.
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
//#include "AutoLight.cginc"
|
||||
|
||||
struct vertex_input
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
struct vertex_output
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
fixed4 _Color;
|
||||
fixed _TextureFade;
|
||||
|
||||
vertex_output vert (vertex_input v)
|
||||
{
|
||||
vertex_output o;
|
||||
o.pos = mul( UNITY_MATRIX_MVP, v.vertex);
|
||||
o.uv = v.texcoord.xy;
|
||||
o.color = v.color;
|
||||
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag(vertex_output i) : COLOR
|
||||
{
|
||||
fixed4 tex = tex2D(_MainTex, i.uv);
|
||||
|
||||
tex = fixed4(max(_TextureFade, tex.r), max(_TextureFade, tex.g), max(_TextureFade, tex.b), tex.a);
|
||||
|
||||
return tex * ((i.color * _Color) * tex.a);
|
||||
|
||||
|
||||
|
||||
//float finalAlpha = tex.a * i.color.a * _Color.a;
|
||||
|
||||
/*
|
||||
TODO: Add basic lighting stuff in later?
|
||||
|
||||
fixed4 c;
|
||||
c.rgb = (UNITY_LIGHTMODEL_AMBIENT.rgb * tex.rgb); // Ambient term. Only do this in Forward Base. It only needs calculating once.
|
||||
c.rgb += tex.rgb; // Diffuse and specular.
|
||||
//Unity 4: c.rgb = (UNITY_LIGHTMODEL_AMBIENT.rgb * tex.rgb * 2); // Ambient term. Only do this in Forward Base. It only needs calculating once.
|
||||
//Unity 4: c.rgb += (tex.rgb * _LightColor0.rgb * diff) * (atten * 2); // Diffuse and specular.
|
||||
c.a = tex.a; // + _LightColor0.a * atten;
|
||||
|
||||
return c;
|
||||
*/
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//FallBack "Transparent/Cutout/VertexLit" // Use VertexLit's shadow caster/receiver passes.
|
||||
}
|
||||
@ -0,0 +1,59 @@
|
||||
// - Unlit + no shadow
|
||||
// - Premultiplied Alpha Blending (One OneMinusSrcAlpha)
|
||||
// - Double-sided, no depth
|
||||
|
||||
Shader "Spine/Special/SkeletonGhost" {
|
||||
Properties {
|
||||
_Color ("Main Color", Color) = (1,1,1,1)
|
||||
_MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {}
|
||||
_TextureFade ("Texture Fade Out", Range(0,1)) = 0
|
||||
}
|
||||
SubShader {
|
||||
Tags {
|
||||
"Queue"="Transparent"
|
||||
"IgnoreProjector"="False"
|
||||
"RenderType"="Transparent"
|
||||
}
|
||||
Fog { Mode Off }
|
||||
Blend One OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
sampler2D _MainTex;
|
||||
fixed4 _Color;
|
||||
fixed _TextureFade;
|
||||
|
||||
struct VertexInput {
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
struct VertexOutput {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
VertexOutput vert (VertexInput v) {
|
||||
VertexOutput o;
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
o.color = v.color;
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (VertexOutput i) : COLOR {
|
||||
fixed4 tc = tex2D(_MainTex, i.uv);
|
||||
tc = fixed4(max(_TextureFade, tc.r), max(_TextureFade, tc.g), max(_TextureFade, tc.b), tc.a);
|
||||
return tc * ((i.color * _Color) * tc.a);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
// - Unlit + no shadow
|
||||
// - Premultiplied Alpha Blending (One OneMinusSrcAlpha)
|
||||
// - Double-sided, no depth
|
||||
|
||||
Shader "Spine/Skeleton Fill" {
|
||||
Properties {
|
||||
_FillColor ("FillColor", Color) = (1,1,1,1)
|
||||
_FillPhase ("FillPhase", Range(0, 1)) = 0
|
||||
[NoScaleOffset]_MainTex ("MainTex", 2D) = "white" {}
|
||||
}
|
||||
SubShader {
|
||||
Tags { "IgnoreProjector"="True" "Queue"="Transparent" "RenderType"="Transparent" "PreviewType"="Plane" }
|
||||
Blend One OneMinusSrcAlpha
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
Lighting Off
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
sampler2D _MainTex;
|
||||
float4 _FillColor;
|
||||
float _FillPhase;
|
||||
|
||||
struct VertexInput {
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertexColor : COLOR;
|
||||
};
|
||||
|
||||
struct VertexOutput {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertexColor : COLOR;
|
||||
};
|
||||
|
||||
VertexOutput vert (VertexInput v) {
|
||||
VertexOutput o = (VertexOutput)0;
|
||||
o.uv = v.uv;
|
||||
o.vertexColor = v.vertexColor;
|
||||
o.pos = UnityObjectToClipPos(v.vertex); // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag (VertexOutput i) : COLOR {
|
||||
float4 rawColor = tex2D(_MainTex,i.uv);
|
||||
float finalAlpha = (rawColor.a * i.vertexColor.a);
|
||||
float3 finalColor = lerp((rawColor.rgb * i.vertexColor.rgb), (_FillColor.rgb * finalAlpha), _FillPhase); // make sure to PMA _FillColor.
|
||||
return fixed4(finalColor, finalAlpha);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 45495790b394f894a967dbf44489b57b
|
||||
timeCreated: 1492385797
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -14,7 +14,6 @@ Shader "Spine/Skeleton Tint" {
|
||||
|
||||
SubShader {
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
|
||||
LOD 100
|
||||
|
||||
Fog { Mode Off }
|
||||
Cull Off
|
||||
@ -26,11 +25,10 @@ Shader "Spine/Skeleton Tint" {
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
//#pragma multi_compile_fwdbase
|
||||
#include "UnityCG.cginc"
|
||||
uniform sampler2D _MainTex; uniform float4 _MainTex_ST;
|
||||
uniform float4 _Color;
|
||||
uniform float4 _Black;
|
||||
sampler2D _MainTex;
|
||||
float4 _Color;
|
||||
float4 _Black;
|
||||
|
||||
struct VertexInput {
|
||||
float4 vertex : POSITION;
|
||||
@ -46,8 +44,8 @@ Shader "Spine/Skeleton Tint" {
|
||||
|
||||
VertexOutput vert (VertexInput v) {
|
||||
VertexOutput o;
|
||||
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
|
||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||
o.pos = UnityObjectToClipPos(v.vertex); // replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
|
||||
o.uv = v.uv;
|
||||
o.vertexColor = v.vertexColor * float4(_Color.rgb * _Color.a, _Color.a); // Combine a PMA version of _Color with vertexColor.
|
||||
return o;
|
||||
}
|
||||
@ -63,34 +61,35 @@ Shader "Spine/Skeleton Tint" {
|
||||
Name "Caster"
|
||||
Tags { "LightMode"="ShadowCaster" }
|
||||
Offset 1, 1
|
||||
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
|
||||
Fog { Mode Off }
|
||||
Cull Off
|
||||
Lighting Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_shadowcaster
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
struct v2f {
|
||||
sampler2D _MainTex;
|
||||
fixed _Cutoff;
|
||||
|
||||
struct VertexOutput {
|
||||
V2F_SHADOW_CASTER;
|
||||
float2 uv : TEXCOORD1;
|
||||
};
|
||||
|
||||
uniform float4 _MainTex_ST;
|
||||
|
||||
v2f vert (appdata_base v) {
|
||||
v2f o;
|
||||
VertexOutput vert (appdata_base v) {
|
||||
VertexOutput o;
|
||||
o.uv = v.texcoord;
|
||||
TRANSFER_SHADOW_CASTER(o)
|
||||
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
return o;
|
||||
}
|
||||
|
||||
uniform sampler2D _MainTex;
|
||||
uniform fixed _Cutoff;
|
||||
|
||||
float4 frag (v2f i) : COLOR {
|
||||
float4 frag (VertexOutput i) : COLOR {
|
||||
fixed4 texcol = tex2D(_MainTex, i.uv);
|
||||
clip(texcol.a - _Cutoff);
|
||||
SHADOW_CASTER_FRAGMENT(i)
|
||||
@ -1,3 +1,5 @@
|
||||
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
|
||||
|
||||
#ifndef SHADER_SHARED_INCLUDED
|
||||
#define SHADER_SHARED_INCLUDED
|
||||
|
||||
@ -14,7 +16,7 @@ inline float4 calculateWorldPos(float4 vertex)
|
||||
|
||||
inline float4 calculateLocalPos(float4 vertex)
|
||||
{
|
||||
return mul(UNITY_MATRIX_MVP, vertex);
|
||||
return UnityObjectToClipPos(vertex);
|
||||
}
|
||||
|
||||
inline half3 calculateWorldNormal(float3 normal)
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
// Upgrade NOTE: replaced 'UNITY_INSTANCE_ID' with 'UNITY_VERTEX_INPUT_INSTANCE_ID'
|
||||
|
||||
Shader "Hidden/Internal-SpriteDepthNormalsTexture" {
|
||||
|
||||
// Use this shader to render a DepthNormals texture for a camera with correct sprite normals (using camera.RenderWithShader)
|
||||
@ -210,7 +212,7 @@ struct appdata {
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
fixed4 color : COLOR;
|
||||
UNITY_INSTANCE_ID
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
v2f vert( appdata v ) {
|
||||
v2f o;
|
||||
|
||||
@ -50,31 +50,28 @@ Shader "Spine/SkeletonGraphic (Premultiply Alpha)"
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
fixed4 _Color;
|
||||
|
||||
struct VertexInput {
|
||||
float4 vertex : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
struct VertexOutput {
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
half2 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
fixed4 _Color;
|
||||
|
||||
v2f vert(appdata_t IN)
|
||||
{
|
||||
v2f OUT;
|
||||
OUT.vertex = mul(UNITY_MATRIX_MVP, IN.vertex);
|
||||
VertexOutput vert (VertexInput IN) {
|
||||
VertexOutput OUT;
|
||||
OUT.vertex = UnityObjectToClipPos(IN.vertex);
|
||||
OUT.texcoord = IN.texcoord;
|
||||
|
||||
#ifdef UNITY_HALF_TEXEL_OFFSET
|
||||
OUT.vertex.xy += (_ScreenParams.zw-1.0)*float2(-1,1);
|
||||
OUT.vertex.xy += (_ScreenParams.zw-1.0) * float2(-1,1);
|
||||
#endif
|
||||
|
||||
OUT.color = IN.color * _Color;
|
||||
@ -83,7 +80,7 @@ Shader "Spine/SkeletonGraphic (Premultiply Alpha)"
|
||||
|
||||
sampler2D _MainTex;
|
||||
|
||||
fixed4 frag(v2f IN) : SV_Target
|
||||
fixed4 frag (VertexOutput IN) : SV_Target
|
||||
{
|
||||
half4 color = tex2D(_MainTex, IN.texcoord) * IN.color;
|
||||
//clip(color.a - 0.01);
|
||||
@ -29,9 +29,9 @@ Shader "Spine/Skeleton Tint Black" {
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
uniform sampler2D _MainTex;
|
||||
uniform float4 _Color;
|
||||
uniform float4 _Black;
|
||||
sampler2D _MainTex;
|
||||
float4 _Color;
|
||||
float4 _Black;
|
||||
|
||||
struct VertexInput {
|
||||
float4 vertex : POSITION;
|
||||
@ -51,7 +51,7 @@ Shader "Spine/Skeleton Tint Black" {
|
||||
|
||||
VertexOutput vert (VertexInput v) {
|
||||
VertexOutput o;
|
||||
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
|
||||
o.pos = UnityObjectToClipPos(v.vertex); // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
|
||||
o.uv = v.uv;
|
||||
o.vertexColor = v.vertexColor * float4(_Color.rgb * _Color.a, _Color.a); // Combine a PMA version of _Color with vertexColor.
|
||||
o.uv1 = v.uv1;
|
||||
@ -80,6 +80,9 @@ Shader "Spine/Skeleton Tint Black" {
|
||||
#pragma multi_compile_shadowcaster
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
sampler2D _MainTex;
|
||||
fixed _Cutoff;
|
||||
|
||||
struct v2f {
|
||||
V2F_SHADOW_CASTER;
|
||||
float2 uv : TEXCOORD1;
|
||||
@ -92,9 +95,6 @@ Shader "Spine/Skeleton Tint Black" {
|
||||
return o;
|
||||
}
|
||||
|
||||
uniform sampler2D _MainTex;
|
||||
uniform fixed _Cutoff;
|
||||
|
||||
float4 frag (v2f i) : COLOR {
|
||||
fixed4 texcol = tex2D(_MainTex, i.uv);
|
||||
clip(texcol.a - _Cutoff);
|
||||
@ -3,10 +3,9 @@ Shader "Spine/Skeleton" {
|
||||
_Cutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
|
||||
[NoScaleOffset] _MainTex ("Texture to blend", 2D) = "black" {}
|
||||
}
|
||||
// 2 texture stage GPUs
|
||||
|
||||
SubShader {
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
|
||||
LOD 100
|
||||
|
||||
Fog { Mode Off }
|
||||
Cull Off
|
||||
@ -15,6 +14,7 @@ Shader "Spine/Skeleton" {
|
||||
Lighting Off
|
||||
|
||||
Pass {
|
||||
Fog { Mode Off }
|
||||
ColorMaterial AmbientAndDiffuse
|
||||
SetTexture [_MainTex] {
|
||||
Combine texture * primary
|
||||
@ -25,9 +25,10 @@ Shader "Spine/Skeleton" {
|
||||
Name "Caster"
|
||||
Tags { "LightMode"="ShadowCaster" }
|
||||
Offset 1, 1
|
||||
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
|
||||
Fog { Mode Off }
|
||||
Cull Off
|
||||
Lighting Off
|
||||
|
||||
@ -37,23 +38,21 @@ Shader "Spine/Skeleton" {
|
||||
#pragma multi_compile_shadowcaster
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
sampler2D _MainTex;
|
||||
fixed _Cutoff;
|
||||
|
||||
struct v2f {
|
||||
V2F_SHADOW_CASTER;
|
||||
float2 uv : TEXCOORD1;
|
||||
};
|
||||
|
||||
uniform float4 _MainTex_ST;
|
||||
|
||||
v2f vert (appdata_base v) {
|
||||
v2f o;
|
||||
TRANSFER_SHADOW_CASTER(o)
|
||||
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
o.uv = v.texcoord;
|
||||
return o;
|
||||
}
|
||||
|
||||
uniform sampler2D _MainTex;
|
||||
uniform fixed _Cutoff;
|
||||
|
||||
float4 frag (v2f i) : COLOR {
|
||||
fixed4 texcol = tex2D(_MainTex, i.uv);
|
||||
clip(texcol.a - _Cutoff);
|
||||
@ -62,10 +61,9 @@ Shader "Spine/Skeleton" {
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
// 1 texture stage GPUs
|
||||
|
||||
SubShader {
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
|
||||
LOD 100
|
||||
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
9
spine-unity/Assets/spine-unity/Shaders/Utility.meta
Normal file
9
spine-unity/Assets/spine-unity/Shaders/Utility.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bc59776133d26dc469c8ba66bdc647e4
|
||||
folderAsset: yes
|
||||
timeCreated: 1492387122
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,3 +1,5 @@
|
||||
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
|
||||
|
||||
Shader "Hidden/Spine/Bones" {
|
||||
Properties {
|
||||
_Color ("Color", Color) = (0.5,0.5,0.5,0.5)
|
||||
@ -44,7 +46,7 @@ Category {
|
||||
|
||||
v2f vert (appdata_t v) {
|
||||
v2f o;
|
||||
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
// #ifdef SOFTPARTICLES_ON
|
||||
// o.projPos = ComputeScreenPos (o.vertex);
|
||||
// COMPUTE_EYEDEPTH(o.projPos.z);
|
||||
Loading…
x
Reference in New Issue
Block a user