- Home /
How can I change a shader to be "unlit" while keeping its other properties?
I have a shader that I found searching around on the forums that blends between two textures, but I need to modify it so that it behaves like an Unlit shader would. Having it be mobile-friendly would be good as well since this is for an iOS/Android game. My knowledge of shaders is basically non-existent and I've tried researching but it hasn't worked out thus far.
Here's the shader as is currently:
Shader "Custom/ChangeMaterial"
{
Properties
{
_Tint ("Tint Color", Color) = (.9, .9, .9, 1.0)
_TexMat1 ("Base (RGB)", 2D) = "white" {}
_TexMat2 ("Base (RGB)", 2D) = "white" {}
_Blend ("Blend", Range(0.0,1.0)) = 0.0
}
Category
{
ZWrite On
Alphatest Greater 0
Tags {Queue=Transparent}
Blend SrcAlpha OneMinusSrcAlpha
ColorMask RGB
SubShader
{
Pass
{
Material
{
Diffuse [_Tint]
Ambient [_Tint]
}
Lighting On
SetTexture [_TexMat1] { combine texture }
SetTexture [_TexMat2] { constantColor (0,0,0,[_Blend]) combine texture lerp(constant) previous }
SetTexture [_TexMat2] { combine previous +- primary, previous * primary }
}
}
FallBack " Diffuse", 1
}
}
Any and all help is appreciated. Thanks in advance!
This is not so much a technical query as it is a "write my code for me" request. What have you tried? What did you get stuck on?
Does switching "Lighting On" to "Lighting Off" do anything?
http://answers.unity3d.com/questions/272749/how-to-write-unlit-surface-shader.html
$$anonymous$$aybe you can get something from this. I don't know much about shaders, yet, but I notice in your script it is written
Lighting On
@tanoshimi Sorry, I really don't know anything about shaders and have been trying to learn but so far it has lead nowhere. I really just need this one shader so the idea of potentially spending days learning how to write them seems ridiculous to me at the moment. I've tried pasting in code from other Unlit shaders, but that didn't work.
@thomas and @meat5000, I tried changing lighting to off and that just ignores light, it doesn't have the same effect that an Unlit shader has.
Answer by Guidolatry · Jul 18, 2014 at 01:43 PM
I figured this out, finally. And of course the answer was a lot simpler than I thought. Here's the shader if anyone needs it:
Shader "Custom/Blend Textures" {
Properties {
_Blend ("Blend", Range (0, 1) ) = 0.0
_MainTex ("Texture 1", 2D) = ""
_Texture2 ("Texture 2", 2D) = ""
}
SubShader {
Pass {
SetTexture[_MainTex]
SetTexture[_Texture2] {
ConstantColor (0,0,0, [_Blend])
Combine texture Lerp(constant) previous
}
}
}
}