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);
}
Tags
light, Normal, tilemap
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

Related shaders

Normal map 2D

color splash (show only one color)

Clip Studio Gradient Map [ with blend mode ]

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments