How to add a normal map to a shader material?
Asked Answered
C

4

0

I have a shader material that Id like to add a normal map to. It doesnt have a slot for the normal map, and I assume I need to add it programmatically.
Can anyone link to an example project? Im using Godot 4.
Thanks!

Crispy answered 13/1, 2023 at 2:1 Comment(0)
M
0

The easiest way is to use a standard material. Add all the feature you want, then convert it to a shader material (there is a button on the drop down).

Mcclean answered 13/1, 2023 at 2:29 Comment(0)
K
0

Add a texture uniform named normalmap, and that is where it would plug into, then in the shaders fragment program you would pipe it into the NORMAL NORMALMAP.

https://docs.godotengine.org/en/stable/tutorials/shaders/shader_reference/spatial_shader.html#fragment-built-ins

Kendra answered 13/1, 2023 at 9:46 Comment(0)
M
0

Kendra Add a texture uniform named normalmap, and that is where it would plug into, then in the shaders fragment program you would pipe it into the NORMAL.

If I remember correctly, there is additional logic for the calculations (TANGENT, BINORMAL, etc.) and you'll end up having to rewrite some of these calculations if you do it by hand.

Mcclean answered 13/1, 2023 at 9:55 Comment(0)
K
0

Mcclean If the normalmap is already of correct format then I don't think that's necessary, but in the basic setup you won't have any control for 'bump strength' or any such thing. And the normalmap bake has to be perfectly catered to use in godot. So the TL;DR is that it is indeed best to convert a standard material with all the relevant functions enabled into a shadermaterial and go from there.

edit: ah and I meant to specify NORMALMAP not NORMAL in my previous post, that's likely the source of the confusion. It's what I get for replying before I've even had my morning coffee. 😅

Kendra answered 13/1, 2023 at 11:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.