Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.3&4.4-dev7] Light: Gdshader Normal assignment seems wrong. #101262

Closed
RickyYCheng opened this issue Jan 8, 2025 · 1 comment
Closed

[4.3&4.4-dev7] Light: Gdshader Normal assignment seems wrong. #101262

RickyYCheng opened this issue Jan 8, 2025 · 1 comment
Labels

Comments

@RickyYCheng
Copy link

RickyYCheng commented Jan 8, 2025

Tested versions

Godot v4.3.stable.mono - Windows 10.0.22631 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3050 Laptop GPU (NVIDIA; 32.0.15.6094) - AMD Ryzen 7 5800U with Radeon Graphics (16 Threads)
Godot v4.4.dev7.mono - Windows 11 (build 22631) - Multi-window, 1 monitor - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3050 Laptop GPU (NVIDIA; 32.0.15.6094) - AMD Ryzen 7 5800U with Radeon Graphics (16 threads)

System information

Windows 10.0.22631 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3050 Laptop GPU (NVIDIA; 32.0.15.6094) - AMD Ryzen 7 5800U with Radeon Graphics (16 Threads)

Issue description

Chech this image (dir light, 45 deg, .25 height):
Image

Left: gdshader with Canvas Texture (with albedo and normal)
Right: Canvas Texture (with albedo and normal) without gdshader

shader_type canvas_item;

uniform sampler2D albedo : filter_nearest;
uniform sampler2D normal : filter_nearest; // add hint_normal

void fragment() {
	COLOR = texture(albedo, UV);
	NORMAL = texture(normal, UV).rgb;
}

Steps to reproduce

Check MRP.

Minimal reproduction project (MRP)

NormalTest.zip

@RickyYCheng RickyYCheng changed the title Gdshader Normal assignment seems wrong. [4.3] Gdshader Normal assignment seems wrong. Jan 8, 2025
@RickyYCheng RickyYCheng changed the title [4.3] Gdshader Normal assignment seems wrong. [4.3&4.4-dev7] Gdshader Normal assignment seems wrong. Jan 8, 2025
@RickyYCheng RickyYCheng changed the title [4.3&4.4-dev7] Gdshader Normal assignment seems wrong. [4.3&4.4-dev7] Light: Gdshader Normal assignment seems wrong. Jan 8, 2025
@clayjohn
Copy link
Member

clayjohn commented Jan 8, 2025

This isn't a problem in Godot. You are calculating your normal incorrectly in the shader. You need to assign normal map values to NORMAL_MAP, not to NORMAL. Correcting that in your shader fixes it

There is a section in the docs that explains the correct way of handling normals in shaders in detail https://docs.godotengine.org/en/latest/tutorials/shaders/shader_reference/canvas_item_shader.html#normal

@clayjohn clayjohn closed this as not planned Won't fix, can't repro, duplicate, stale Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants