-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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 #62987
base: master
Are you sure you want to change the base?
Add a debug draw mode for displaying UV2 (lightmap) texel density #62987
Conversation
fbca23f
to
21df074
Compare
So far is looking good |
As the maintainer of the import pipeline giving more ways to determine this crucial detail to art budget and quality is important. 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good so far.
I wonder if it wouldn't be easier to put the checkerboard code in the Godot shader code (i.e. here), rather than in the internal scene shader.
The lightmap size would be an instance uniform then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks amazing so far! I think this was definitely the general approach to take.
With a little bit of polish you should be able to finish this up pretty soon!
if (inst->data->base_type == RS::INSTANCE_MESH && inst->data->use_baked_light) { | ||
Size2 lightmap_size = mesh_storage->mesh_get_lightmap_size_hint(inst->data->base) * inst->data->lightmap_scale; | ||
|
||
if (inst->shader_parameters_offset == -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (inst->shader_parameters_offset == -1) { | |
if (inst->shader_parameters_offset == -1 && !inst->data->instance_allocated_shader_parameters && ) { |
In my test project I get a spammed error because global_variables_instance_allocate()
return -1
if the instance has already been allocated. Adding the check for instance_allocated_shader_parameters
ensures that this doesn't happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added appropriate checks to mitigate the spammed error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you test just adding && !inst->data->instance_allocated_shader_parameters
? From my test it was able to remove the spammed error and it is much simpler code
The CI build is failing because of missing documentation changes. When you add new features that are exposed, the docs need to be updated as well. You can update the docs by running the For example, here is how you run ``doctool` on 64 bit linux
For more information, we have a whole page on this in the docs: https://docs.godotengine.org/en/latest/community/contributing/updating_the_class_reference.html |
cba4f3a
to
9a3940b
Compare
I am still getting the instance buffer error when there are duplicate mesh resources in the scene:
Otherwise it looks great! The new shader looks amazing. I think to resolve the issue we need to add a function to material_storage to check if the global shader uniforms instance buffer contains the instance. Then we can make that check directly instead of relying on |
servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! I like the new approach. It is unfortunate to add more to the material storage API just for a debug feature. But it makes your actual debug code much more elegant.
servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp
Outdated
Show resolved
Hide resolved
servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp
Outdated
Show resolved
Hide resolved
662e080
to
d214f4a
Compare
servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
Outdated
Show resolved
Hide resolved
servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
Outdated
Show resolved
Hide resolved
d214f4a
to
e881a48
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left one final style nitpick on the code comments (sorry). I am happy with the code as it is and have tested it extensively and it seems to work great! Good work, this required a lot more intrusive changes than any of us originally envisioned, but the results a pretty good.
Before merging @reduz and @JFonS should take a look as well.
e881a48
to
4853932
Compare
@JFonS reduz was asking if this is intended to be merged before or after further changes you might have pending for UV2 layers? |
@akien-mga @clayjohn should this be taking into consideration? #64908 |
You can have multiple LightmapGI nodes in a scene, so I don't think you can have a 1:1 mapping between meshes and the LightmapGI they're using. Some nodes may not be included in any LightmapGI yet either. |
Possibly off-topic, but why would someone do that? Tricks using layers? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR looks good to me.
I still haven't looked at moving UV2 to a custom layer, but it should be pretty straightforward. I would merge this PR, and then I will see if anything needs to be changed later on.
Needs rebase, then should be good to merge if @clayjohn approves it too. |
4853932
to
c5c8a52
Compare
Updated with master. |
I'm happy with the changes. But it requires @reduz to take a quick look as well because of the additions to the MaterialStorage API. |
This PR is getting older. What can be done to merge it ASAP? |
@techiepriyansh Could you look into rebasing this pull request if you have time? If you don't have time, let us know and we can mark this PR as salvageable 🙂 |
Hi, as much as I'd like to get this PR merged myself, I'm afraid that I don't really have time right now. Please go ahead marking this PR as salvageable. When I get some time in the future, and it's still not taken up by anyone else, I'll do it. |
Adds a debug draw mode for displaying UV2 texel density. It displays the UV2 texel density of all
MeshInstance3Ds
which have theirGI_MODE
set toGI_MODE_STATIC
.Partially addresses godotengine/godot-proposals#3213.
Todo
mobile
backend.DEBUG_UV2_TEXEL_DENSITY
inside the scene shader instead of using a render mode define.