Godot Version
4.2 c#
Question
So ; Im Using Isometric 2.5d with 3D hand-drawn Sprite on a 3D canvas
I made My normal Maps as a PNG sequance (On Laigter)
My sprite is animated , and im eagerly searching for a way to Add my Normals onto my frames
Thanks !
I think you will have to add a shader, a simple one like this might work well for you on a quad mesh instance.
shader_type spatial;
uniform sampler2D diffuse: source_color, repeat_disable;
uniform sampler2D normal_map: source_color, hint_normal;
uniform uint frame = 0;
uniform uint h_frames = 1;
uniform uint v_frames = 1;
void vertex() {
vec2 uv_mod = 1.0 / vec2(float(h_frames), float(v_frames));
float uv_off_x = uv_mod.x * float(frame % h_frames);
float uv_off_y = uv_mod.y * float(frame / h_frames);
UV = UV * uv_mod + vec2(uv_off_x, uv_off_y);
}
void fragment() {
vec4 color = texture(diffuse, UV);
if (color.a <= 0.0f) { // alpha scissor
discard;
}
ALBEDO = color.rgb;
ALPHA = color.a; // regular alpha
NORMAL = texture(normal_map, UV).rbg;
}
gertkeno:
shader_type spatial;
uniform sampler2D diffuse: source_color, repeat_disable;
uniform sampler2D normal_map: source_color, hint_normal;
uniform uint frame = 0;
uniform uint h_frames = 1;
uniform uint v_frames = 1;
void vertex() {
vec2 uv_mod = 1.0 / vec2(float(h_frames), float(v_frames));
float uv_off_x = uv_mod.x * float(frame % h_frames);
float uv_off_y = uv_mod.y * float(frame / h_frames);
UV = UV * uv_mod + vec2(uv_off_x, uv_off_y);
}
void fragment() {
vec4 color = texture(diffuse, UV);
if (color.a <= 0.0f) { // alpha scissor
discard;
}
ALBEDO = color.rgb;
NORMAL = texture(normal_map, UV).rbg;
}
Should i apply a quadMesh Over or Under My Animation Sprite ?
As opposed to the animated sprite 3d
How do i attach each UVMap PNG to each frames ?
The shader code I posted assumes the normal map is a spritesheet that matches the diffuse/albedo spritesheet.
OH OKAY , im sorry i never did Shader coding
TYSM for the help <3
Ima try it
It will be harder to use than your animated sprite 3d, including needing to script the frame-by-frame animation or use an AnimationPlayer. Might not be a good fit if you aren’t comfortable with glsl, but I don’t think it will need much modification, maybe you will want alpha, so I will edit that inclusion.
Thank , it would be great if you could add alpha !
2 Likes
Hey mate Were you able to implement normal map on animatedsprite3d? I am facing the same issue