UV light (2D and 3D)
This is an example of a “UV light” shader, useful for secret messages.
Remember to:
* put the UV light source in a separate layer
* put secret objects in the same layer (`light_cull_mask`)
* remove normal light sources from that layer (`light_cull_mask`)
Shader code
// 2D objects, e.g. text on a wall, where the shape is defined by a texture
shader_type spatial;
uniform sampler2D tex;
uniform vec4 color: hint_color = vec4(0, 1, 1, 1);
uniform float energy: hint_range(0, 16) = 1;
void fragment() {
EMISSION = color.rgb * energy;
ALPHA = 0.0;
}
void light() {
vec4 pixel = textureLod(tex, UV, 1.0);
DIFFUSE_LIGHT = vec3(0.0);
ALPHA = length(ATTENUATION) * pixel.a;
}
// 3D objects, e.g. a ghost, where the shape is defined by geometry
shader_type spatial;
uniform vec4 color: hint_color = vec4(0, 1, 1, 1);
uniform float energy: hint_range(0, 16) = 1;
void fragment() {
EMISSION = color.rgb * energy;
ALPHA = 0.0;
}
void light() {
DIFFUSE_LIGHT = vec3(0.0);
SPECULAR_LIGHT = vec3(0.0);
ALPHA = length(ATTENUATION);
}