- Home /
Unlit, Transparent and Slice Shader
Mornin' all.
I'm having some real trouble trying to combine some shader scripts features together. I simply want a transparent unlit texture that can be sliced. Good news is that the slicing works good, but making it unlit is the real problem.
My shader writing skills are pretty much guesswork, and I can see this can be optimized and trimmed a good deal. Too bad I have no idea what needs to go, trial and error only got me this far.
Here is my code;
Shader "Custom Shaders/AlphaUnlitSlice" {
Properties {
_MainTex ("SelfIllum Color (RGB) Alpha (A)", 2D) = "white"
_SliceGuide ("_SliceGuide (RGB)", 2D) = "white" {}
_SliceAmount ("Slice Amount", Range(0.0, 1.0)) = 0.5
}
SubShader {
Tags { "RenderType" = "Opaque" }
Lighting Off
ZWrite Off
Cull Back
CGPROGRAM
#pragma surface surf Lambert
struct Input {
float2 uv_MainTex;
float2 uv_SliceGuide;
float _SliceAmount;
};
sampler2D _MainTex;
sampler2D _SliceGuide;
float _SliceAmount;
void surf (Input IN, inout SurfaceOutput o) {
clip(tex2D (_SliceGuide, IN.uv_SliceGuide).rgb - _SliceAmount);
o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;
}
ENDCG
}
Fallback "Diffuse"
}
All advice will be greatly appreciated, I just need to alpha this and optimize it a bit.
Answer by electricsauce · Sep 16, 2012 at 04:11 AM
I think you need an 0.alpha to get any output on that channel. You might have better luck using the strumpy shader editor.
Answer by Seizure · Jul 11, 2013 at 12:38 PM
Ok I have the answer for you, however if you can figure out how to make it not tile any more that would be awesome!
Shader "Custom Shaders/AlphaUnlitSlice" {
Properties {
_MainTex ("SelfIllum Color (RGB) Alpha (A)", 2D) = "white"
_SliceGuide ("_SliceGuide (RGB)", 2D) = "white" {}
_SliceAmount ("Slice Amount", Range(0.0, 1.0)) = 0.5
}
SubShader {
Tags { "RenderType" = "Opaque" }
Lighting Off
ZWrite Off
Cull Back
CGPROGRAM
//#pragma surface surf Lambert //Instead of this line add the next 8
#pragma surface surf NoLighting
fixed4 LightingNoLighting(SurfaceOutput s, fixed3 lightDir, fixed atten)
{
fixed4 c;
c.rgb = s.Albedo;
c.a = s.Alpha;
return c;
}
struct Input {
float2 uv_MainTex;
float2 uv_SliceGuide;
float _SliceAmount;
};
sampler2D _MainTex;
sampler2D _SliceGuide;
float _SliceAmount;
void surf (Input IN, inout SurfaceOutput o) {
clip(tex2D (_SliceGuide, IN.uv_SliceGuide).rgb - _SliceAmount);
o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;
}
ENDCG
}
Fallback "Diffuse"
}
It seems the tiling circles are gone, adding an orthographic camera did the trick.