Normal Map not appearing after putting a shader in the material

Godot Version

4.4

Question

I have a shader activated in a MeshInstance3D and now for some reason the Normal Map option doesnt appear inside the material. How do I put a normal map?

Also this is the shader Im using:

shader_type spatial;
render_mode blend_mix,
	cull_disabled,
	depth_prepass_alpha,
	shadows_disabled,
	specular_disabled,
	vertex_lighting;

uniform bool affine_mapping = false;
uniform sampler2D albedo : source_color, filter_nearest;
uniform float alpha_scissor : hint_range(0, 1) = 0.5;
uniform float jitter: hint_range(0, 1) = 0.25;
uniform ivec2 resolution = ivec2(320, 240);

vec4 snap_to_position(vec4 base_position)
{
	vec4 snapped_position = base_position;
	snapped_position.xyz = base_position.xyz / base_position.w;
	
	vec2 snap_resulotion = floor(vec2(resolution) * (1.0 - jitter));
	snapped_position.x = floor(snap_resulotion.x * snapped_position.x) / snap_resulotion.x;
	snapped_position.y = floor(snap_resulotion.y * snapped_position.y) / snap_resulotion.y;
	
	snapped_position.xyz *= base_position.w;
	return snapped_position;
}

void vertex()
{
	vec4 snapped_position = snap_to_position(PROJECTION_MATRIX * MODELVIEW_MATRIX * vec4(VERTEX, 1.0));
	if (affine_mapping)
	{
		POSITION = snapped_position;
		POSITION /= abs(POSITION.w);
	}
	else
	{
		POSITION = snapped_position;
	}
}

void fragment()
{
	vec4 color_base = COLOR;
	vec4 texture_color = texture(albedo, UV);

	ALBEDO = (color_base * texture_color).rgb;
	ALPHA = texture_color.a * color_base.a;
	ALPHA_SCISSOR_THRESHOLD = alpha_scissor;
}

You have to program the normal map. Your render mode vertex_lighting also prevents normal mapping in any useful sense.

uniform sampler2D normal_map: hint_normal;
void fragment() {
    NORMAL = texture(normal_map, UV).xyz;
}

Your parameters are located under “Shader Parameters”

ok so, do I delete vertex_lighting in line 7? and modify the uniform sampler2D in line 10?

Yes

No, you can add another uniform near the others.

OK deleted the vertex_lighting in line 7 but now for “uniform bool afine_mapping = false;” it gives an error saying [Expected and identifier for render mode], do I just delete that line too?

Sounds like you deleted the whole line rather than deleting the vertex_lighting element in the list of render mode options. when removing from such a list keep the comma seperated pattern.

render_mode blend_mix,
	cull_disabled,
	depth_prepass_alpha,
	shadows_disabled,
	specular_disabled; // semicolon to end statement

ok thanks a ton, now it gives me error in line 45 “void fragment()” whats going on there? “Redefinition of “fragment””

Also now the texture is completelly gone for some reason

Means you’ve defined the fragment function twice, rather than combining my example into the fragment function

While erroring shader materials don’t work, so they cannot display any texture/material until the error is fixed.

it worked thankss :3