- Home /
flat material?(no light info)
Hi everyone.. newbie question here.. I'm looking for a "flat" material.. should be easy but I can't find it in unity. basically a material that receives no light/shadow info, only texture... any help is appreciated, thanks!
Answer by IJM · Oct 21, 2010 at 12:09 AM
You can use this shader for that:
Shader "CtrlJ/Unlit" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
}
Category {
Lighting Off
ZWrite On
Cull Back
SubShader {
Pass {
SetTexture [_MainTex] {
constantColor [_Color]
Combine texture * constant, texture * constant
}
}
}
}
}
Thanks. seems to be working.. One more thing, how do I do this to a diffuse transparent shader so that if I have the texture applied, i get the transparency as well? thanks!
Answer by Jessy · Oct 21, 2010 at 01:59 AM
Do what IJM said, or, if you need no tinting, make it even slightly faster and less complicated:
http://www.unifycommunity.com/wiki/index.php?title=Texture_Only#ShaderLab_-_Texture_Only.shader
Since the site is now dead (and why you copy-paste ins$$anonymous$$d of linking;) ):
Shader "Texture Only" {
Properties {
_$$anonymous$$ainTex ("Texture", 2D) = ""
}
SubShader {Pass { // iPhone 3GS and later
GLSLPROGRA$$anonymous$$
varying mediump vec2 uv;
#ifdef VERTEX
void main() {
gl_Position = gl_$$anonymous$$odelViewProjection$$anonymous$$atrix * gl_Vertex;
uv = gl_$$anonymous$$ultiTexCoord0.xy;
}
#endif
#ifdef FRAG$$anonymous$$ENT
uniform lowp sampler2D _$$anonymous$$ainTex;
void main() {
gl_FragColor = texture2D(_$$anonymous$$ainTex, uv);
}
#endif
ENDGLSL
}}
SubShader {Pass { // pre-3GS devices, including the September 2009 8GB iPod touch
SetTexture[_$$anonymous$$ainTex]
}}
}
Answer by Tobbe Olsson · Oct 21, 2010 at 02:06 AM
I use the various particle materials for materials where I don't need any lighting. There's alpha blended, additive, and just plain diffuse. All have tinting though so if you don't need that Jessy's reply is the best...
Answer by vikingfabian-com · Dec 07, 2013 at 09:39 AM
The "CtrlJ/Unlit"-shader worked fine until I used transparent textures. Later found this that is both self-lit, flat and transparent:
Shader "AlphaSelfIllum" {
Properties {
_Color ("Color Tint", Color) = (1,1,1,1)
_MainTex ("SelfIllum Color (RGB) Alpha (A)", 2D) = "white"
}
Category {
Lighting On
ZWrite Off
Cull Back
Blend SrcAlpha OneMinusSrcAlpha
Tags {Queue=Transparent}
SubShader {
Material {
Emission [_Color]
}
Pass {
SetTexture [_MainTex] {
Combine Texture * Primary, Texture * Primary
}
}
}
}
}
Your answer
Follow this Question
Related Questions
Add an image to a plane in a prefab hdrp 2021.2.12 1 Answer
dynamic images for textures ar runtime 2 Answers
Repeating Material texture 0 Answers
Set image as material 0 Answers
Rotate Material (Cylinder) 0 Answers