- Home /
Question by
TranceDreams · Mar 04, 2018 at 10:51 AM ·
lightingshadersbackfaceunlit transparent
How to make Legacy Transparent Cutout Softedge unlit shader.... lit?
Hello. I love the legacy soft-edge cutout unlit shader, but how do you make it "lit" ? I just want it to allow tinting to match the lighting of the level, now that I have a night and day script.
My characters are 2d. I need soft-edges, flat coloring, and to show backfaces.
I found this script that keeps things cutout, keeps the color flat, show backfaces, and tints based on global lighting which is darn close to what I'm looking for, but it has no soft-edging like the original shader.
You can test it against the original legacy shader to see what I'm talking about. Just darken the over lighting in the level like your making it night time.
How do I adjust this? thanks
Shader "Characters" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Main Texture", 2D) = "white" { }
_Cutoff ("Alpha cutoff", Float) = 0.5
_BaseLight ("Base Light", Float) = 0.5
_AO ("Amb. Occlusion", Float) = 0
_Occlusion ("Dir Occlusion", Float) = 0
// These are here only to provide default values
[HideInInspector] _TreeInstanceColor ("TreeInstanceColor", Vector) = (1,1,1,1)
[HideInInspector] _TreeInstanceScale ("TreeInstanceScale", Vector) = (1,1,1,1)
[HideInInspector] _SquashAmount ("Squash", Float) = 1
}
SubShader {
Tags {
"Queue" = "Transparent"
"IgnoreProjector"="True"
"RenderType" = "TreeTransparentCutout"
"DisableBatching"="True"
}
Cull Off
ColorMask RGB
Pass {
Lighting On
CGPROGRAM
#pragma vertex leaves
#pragma fragment frag
#pragma multi_compile_fog
#include "UnityBuiltin2xTreeLibrary.cginc"
sampler2D _MainTex;
fixed _Cutoff;
fixed4 frag(v2f input) : SV_Target
{
fixed4 c = tex2D( _MainTex, input.uv.xy);
c.rgb *= input.color.rgb;
clip (c.a - _Cutoff);
UNITY_APPLY_FOG(input.fogCoord, c);
return c;
}
ENDCG
}
Pass {
Name "ShadowCaster"
Tags { "LightMode" = "ShadowCaster" }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_shadowcaster
#include "UnityCG.cginc"
#include "TerrainEngine.cginc"
struct v2f {
V2F_SHADOW_CASTER;
float2 uv : TEXCOORD1;
};
struct appdata {
float4 vertex : POSITION;
float3 normal : NORMAL;
fixed4 color : COLOR;
float4 texcoord : TEXCOORD0;
};
v2f vert( appdata v )
{
v2f o;
TerrainAnimateTree(v.vertex, v.color.w);
TRANSFER_SHADOW_CASTER_NORMALOFFSET(o)
o.uv = v.texcoord;
return o;
}
sampler2D _MainTex;
fixed _Cutoff;
float4 frag( v2f i ) : SV_Target
{
fixed4 texcol = tex2D( _MainTex, i.uv );
clip( texcol.a - _Cutoff );
SHADOW_CASTER_FRAGMENT(i)
}
ENDCG
}
}
// This subshader is never actually used, but is only kept so
// that the tree mesh still assumes that normals are needed
// at build time (due to Lighting On in the pass). The subshader
// above does not actually use normals, so they are stripped out.
// We want to keep normals for backwards compatibility with Unity 4.2
// and earlier.
SubShader {
Tags {
"Queue" = "Transparent-99"
"IgnoreProjector"="True"
"RenderType" = "TransparentCutout"
}
Cull Off
ColorMask RGB
Pass {
Tags { "LightMode" = "Vertex" }
AlphaTest GEqual [_Cutoff]
Lighting On
Material {
Diffuse [_Color]
Ambient [_Color]
}
SetTexture [_MainTex] { combine primary * texture DOUBLE, texture }
}
}
Dependency "BillboardShader" = "Hidden/Nature/Tree Soft Occlusion Leaves Rendertex"
Fallback Off
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612153919im_/https://answers.unity.com/themes/thub/images/avi.jpg)