Godot Version
4.3.1
Question
Is there an easy way to render only the normal maps of an entire 2D scene?
4.3.1
Is there an easy way to render only the normal maps of an entire 2D scene?
I think you can use a subviewport.
you could also use a custom shader i guess
This solution seemed just right to me, but I am trying to do it and nothing changes.
The subviewport is always rendering only the texture, no matter if I select Normal Buffer in Debug Draw.
I am trying with a simple subviewport and a 2D scene that is simply a Sprite2D with a texture and a normal map. The SubViewport is always showing just the texture, even selecting Normal Buffer.
Maybe it’s only applying to 3d scenes. I’m not quite sure how to properly set up subviewports for 2d scenes.
Just tried with a 3D scene and it is working there. I think you are right and it does not work only for 2D scenes, but i need it for 2D
I think a custom shader might work. This guy on reddit tried something like that but I have no idea of shaders in Godot.
https://www.reddit.com/r/godot/s/xpiblBspK5
From what I understand Godot does not keep the buffer of normal maps of 2D scenes in memory, as opposed to what it does in 3D.
I guess one solution would be as you say to create a custom shader that calculates the normal maps from the texture, except that being a shader on the whole viewport it would not have access to the individual sprites that make up the whole 2D scene, so it would have to calculate the normal map from the overall texture directly, ignoring those manually set on the individual sprites.
I think it would be an approximation, but not the result I would like.
Another option would be to use instead of the usual Sprite2Ds a scene that extends the Sprite2D with a script that would allow with a bool to replace the texture with the normal map, so that it would show directly.
However, this does not seem to me to be a very flexible solution, also with a view to in the future having to apply the same logic to other 2D nodes using normal maps, or worse to shaders; In addition to the fact that each 2D scene would have to be set up to pass this bool correctly.
May I ask what you even need rendered normal buffers for?
Sure, I am using a SubViewport to project complex 2D scenes onto 3D plane meshes, treating them as textures.
While I can assign these textures to the mesh material’s albedo, I would also like to assign their normal map so that the textures can interact with the lighting in the 3D environment. However, while this method successfully uses the scenes as textures, the normal maps are lost in the process, and it seems SubViewport has no way to retrieve them from 2D nodes.
Currently there is no solution for this problem. I opened an issue.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.