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

Add debug draw modes to display UV1 and UV2 (lightmap) texel density in the 3D editor #3213

Open
Tracked by #56033
jcostello opened this issue Aug 27, 2021 · 10 comments

Comments

@jcostello
Copy link

Describe the project you are working on

3D environmnets

Describe the problem or limitation you are having in your project

There is no easy way to preview how much space a object takes into the lightmap

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Add a new view mode to see the texel resolution per object. Similar the lighting mode works. This could allow to update the texel scale in real time to improve the baking light

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

image

If this enhancement will not be used often, can it be worked around with a few lines of script?

Nope

Is there a reason why this should be core and not an add-on in the asset library?

Could be a plugin, not sure. Core makes more sense

@Calinou Calinou changed the title New View to display texel resolution per object Add a debug draw mode to display texel density in the 3D editor Aug 27, 2021
@Calinou
Copy link
Member

Calinou commented Aug 27, 2021

If you want to debug both the general texture density and lightmap texture density, we'd need to add two different debug draw modes (one for UV1, one for UV2). Adding a debug draw mode for texel density is a good idea, I'm not sure how often lightmap density debugging would be used in practice.

The texel density debug draw mode will be fairly involved to implement because you can't just override all existing materials. You need to account for the existing UV1 scale and triplanar mapping that may be used on materials. To display the checkerboard in different colors depending on the pixel-to-texel ratio, we can use shader operations or custom mipmaps.

To avoid adding two debug draw modes, we could add an option to bake a fixed-size checkerboard in BakedLightmap for debugging purposes, but this would require rebaking lightmaps when you toggle this option. In the meantime, you can add this checkerboard using an image editor and save the resulting EXR or PNG image. Godot will reimport it automatically once you focus back on the editor.

@jcostello
Copy link
Author

@Calinou the second idea is to bake an checkerboard image? If its fast enought could do the trick

@Janders1800
Copy link

Can this be extended to texturing as well?

@jcostello
Copy link
Author

Can this be extended to texturing as well?

What do you mean to texturing?

@williamd67
Copy link

I tried this via an extra LightmapGI option that will show the texel density (see samples below). The texture needs to be rebaked yet it only needs direct light, and no denoiser so it will be relatively fast.

Screenshot from 2021-11-14 13-53-13

Screenshot from 2021-11-14 13-56-18

Would this be an acceptable implementation?

@Zireael07
Copy link

Is that for UV2 (i.e. lightmap only) or for UV1 too?

@Calinou
Copy link
Member

Calinou commented Nov 14, 2021

The texture needs to be rebaked

See godotengine/godot#52166 which will likely be rejected in its current form. It seems that not having to rebake anything is a requirement.

@Calinou Calinou changed the title Add a debug draw mode to display texel density in the 3D editor Add a debug draw mode to display UV2 (lightmap) texel density in the 3D editor Dec 17, 2021
@Calinou Calinou changed the title Add a debug draw mode to display UV2 (lightmap) texel density in the 3D editor Add debug draw modes to display UV1 and UV2 (lightmap) texel density in the 3D editor Dec 17, 2021
@jcostello
Copy link
Author

jcostello commented Jan 14, 2022

@williamd67 If it requires bake is not acceptable. The idea is to debug the density before baking to have the correct density per object and save baking time. Have you tried it as a new debug view like the lighting one?

@Janders1800
Copy link

@jcostello What do you mean to texturing?

All textures get swapped to a checker board so it's easier to control texel density.

@jcostello
Copy link
Author

@Janders1800 Thats the idea, but instead of the textures being swapped, it should be a draw mode over the mesh with shaders so you can adjust the texel density in real time. Also it would be nice to have float value texel multiplier

#3893
#3233

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants