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 a debug draw mode for displaying UV2 (lightmap) texel density #96814

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

clayjohn
Copy link
Member

@clayjohn clayjohn commented Sep 10, 2024

Salvages and supersedes: #62987

This PR also implements instance uniforms for the Compatibility renderer as it was needed for the debug draw mode

Before merging:

Up close with bicubic filtering disabled so you can see individual texels. Note texels are aligned with the center of the square
Screenshot 2024-09-10 at 11 36 10 AM
Same as above but with bicubic on
Screenshot 2024-09-10 at 11 36 24 AM
Faint large scale checkerboard to easily tell scale
Screenshot 2024-09-10 at 11 36 57 AM
Looks fine from a distance
Screenshot 2024-09-10 at 11 37 08 AM

@passivestar
Copy link
Contributor

Will this work with #75164?

@jcostello
Copy link
Contributor

Will this work with #75164?

Good question. Ideally it should take any lightmap or mesh texel scale into account

@clayjohn
Copy link
Member Author

Will this work with #75164?

Good question. Ideally it should take any lightmap or mesh texel scale into account

Right now it will automatically take #75164 into account since it uses the scale that was calculated during lightmap baking.

However, I need to refactor things so you can preview a new scale without re-baking.

@Calinou
Copy link
Member

Calinou commented Sep 19, 2024

The checkerboard pattern in the screenshots looks a bit curious to me. Every 10 steps (when the large checkerboard changes color), it mirrors the pattern, which looks odd.

The number of steps between each large checkerboard step is also not a power of 2, so I think 8 steps would make more sense than 10 (since a lot of things in level design work with powers of 2). Contrast may need to be lowered slightly as well so it doesn't look overbearing in the process.

I'd expect it to look more like this instead (ignore the fact this is a 3-level checkerboard pattern, but look at the general contrast and the pattern not mirroring within each large checkerboard):

image

Note texels are aligned with the center of the square

This is also interesting to see; do any other programs do something similar? This may be confusing if the pattern drawn by Godot works differently to the one drawn by other 3D applications. I believe most of the time, the checkerboard pattern is exactly aligned with the texel grid as opposed to being offset by half a texel.

@clayjohn
Copy link
Member Author

The checkerboard pattern in the screenshots looks a bit curious to me. Every 8 steps (when the large checkerboard changes color), it mirrors the pattern, which looks odd.

I'd expect it to look more like this instead (ignore the fact this is a 3-level checkerboard pattern):

I originally had it like this, but it looks horrible with the 2-level checkerboard. the dark tiles of the light squares end up being close to the light tiles of the dark squares, so you see this weird pattern over everything. In your screenshot, the 3rd level really helps break it up

This is also interesting to see; do any other programs do something similar? This may be confusing if the pattern drawn by Godot works differently to the one drawn by other 3D applications. I believe most of the time, the checkerboard pattern is exactly aligned with the texel grid as opposed to being offset by half a texel.

I think you misunderstand. This is exactly aligned with the texel grid. I don't know what other programs do, but I think the most intuitive thing is for the squares to a visual representation of the pixel (if you consider the pixel as a little square). So the center of the pixel should sit in the center of the square.

@Calinou
Copy link
Member

Calinou commented Sep 19, 2024

In your screenshot, the 3rd level really helps break it up

That's interesting, I didn't think about it before. Here's the texture if you need it (CC0):

default

@jcostello
Copy link
Contributor

@clayjohn after this is merge #75164 can you take it in count for the texel density?

@clayjohn
Copy link
Member Author

@clayjohn after this is merge #75164 can you take it in count for the texel density?

I think so!

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

Successfully merging this pull request may close these issues.

5 participants