Normal Map Only Shader
Hi, I was having a headache setting up tilemaplayers to render 2D light using Canvasitems as tilemaps, so I decided to move the normal map to a seperate layer, and just render the light pass for that layer so that I can adjust underlying colours without needing to redo the normals.
Just make a tilemaplayer with your normals as the texture, and slap this code on it. Or test it on any canvas with your normals as a texture. Shown here with a tilemap layer filled with normals over the godot icon. Just make sure that this layer is above whatever you want providing colour.
Shader code
shader_type canvas_item;
render_mode light_only,blend_mul;
void vertex() {
}
void fragment() {
NORMAL_MAP = COLOR.rgb;
vec4 color = COLOR;
COLOR = vec4(0.0,0.0,0.0,1.0);
}
void light() {
float cNdotL = max(0.0, dot(NORMAL, LIGHT_DIRECTION));
LIGHT = vec4(LIGHT_COLOR.rgb * LIGHT_ENERGY, LIGHT_COLOR.a* cNdotL);
}