Hi there,
First of all thanks for this awesome soft 🙂
I'm trying to get a shader wich can use Normal Map and Spine entities. I've seen a lot of topics on the net but none of them fit really well. So I decided to
modify the Unity 5 Standard Shader, I kept only the Forward and Forward Add pass (lighting is set to Forward in the project).
(The spine export is done with premultiplied alpha checked.)
I came to two results pretty cool but with some troubles with non-directional lights.
In the image attached you can see (left to right)
- Directional Light only : everything is OK
- Directional + Point Light : ForwardAdd pass Alpha blend set to : Blend SrcAlpha One, some transparency issues
- Directional + Point Light : ForwardAdd pass Alpha blend set to : Blend One OneMinusAlphaSrc. You can see a cut : the right part is not affected by the point light and is Ok, but the left is very dark.
I'm not very familiar with shader so if someone can help me with that I would be grateful.
Here is the shader code (the properties are the same as Standard Shader)
SubShader
{
Tags { "RenderType"="Opaque" "PerformanceChecks"="False" }
LOD 300
//
// Base forward pass (directional light, emission, lightmaps, ...)
Pass
{
Name "FORWARD"
Tags { "LightMode" = "ForwardBase" }
Cull Back
Blend [_SrcBlend] [_DstBlend]
ZWrite [_ZWrite]
CGPROGRAM
#pragma target 3.0
// TEMPORARY: GLES2.0 temporarily disabled to prevent errors spam on devices without textureCubeLodEXT
#pragma exclude_renderers gles
//
#pragma shader_feature _NORMALMAP
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
#pragma shader_feature _EMISSION
#pragma shader_feature _METALLICGLOSSMAP
#pragma shader_feature ___ _DETAIL_MULX2
#pragma shader_feature _PARALLAXMAP
#pragma multi_compile_fwdbase
#pragma multi_compile_fog
#pragma vertex vertForwardBase
#pragma fragment fragForwardBase
#include "UnityStandardCore.cginc"
ENDCG
}
//
// Additive forward pass (one light per pass)
Pass
{
Name "FORWARD_DELTA"
Tags { "LightMode" = "ForwardAdd" "Queue" = "Transparent" "RenderType" = "Transparent" "IgnoreProjector"="True"}
//Blend SrcAlpha One
Blend One OneMinusSrcAlpha
Fog { Color (0,0,0,0) } // in additive pass fog should be black
Cull Off
ZWrite Off
ZTest LEqual
CGPROGRAM
#pragma target 3.0
// GLES2.0 temporarily disabled to prevent errors spam on devices without textureCubeLodEXT
#pragma exclude_renderers gles
//
#pragma shader_feature _NORMALMAP
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
#pragma shader_feature _METALLICGLOSSMAP
#pragma shader_feature ___ _DETAIL_MULX2
#pragma shader_feature _PARALLAXMAP
#pragma multi_compile_fwdadd_fullshadows
#pragma multi_compile_fog
#pragma vertex vertForwardAdd
#pragma fragment fragForwardAdd
#include "UnityStandardCore.cginc"
ENDCG
}
}
FallBack "VertexLit"
CustomEditor "StandardShaderGUI"
Thanks for reading 🙂