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

Refactor FogVolume, VoxelGI, ReflectionProbe code #54796

Closed
wants to merge 1 commit into from

Conversation

ator-dev
Copy link
Contributor

@ator-dev ator-dev commented Nov 9, 2021

Fix #54449

@ator-dev ator-dev requested review from a team as code owners November 9, 2021 10:25
@ator-dev ator-dev force-pushed the use-size-over-extents branch 2 times, most recently from 239390b to 3eeea74 Compare November 9, 2021 10:53
@ator-dev
Copy link
Contributor Author

ator-dev commented Nov 9, 2021

I accidentally left an incomplete change in one file that invalidated the tests, could they be restarted please? I'm not familiar with this process.
Also, is force-pushing the right way to apply a fix to my pull request?

@Calinou
Copy link
Member

Calinou commented Nov 9, 2021

I accidentally left an incomplete change in one file that invalidated the tests, could they be restarted please? I'm not familiar with this process.

Checks run automatically again whenever you (force-)push a commit to your branch.

Also, is force-pushing the right way to apply a fix to my pull request?

Yes, as it's the only way to ensure your PR continues to contain a single commit (rather than several) 🙂

@ator-dev ator-dev force-pushed the use-size-over-extents branch from 3eeea74 to fc81d66 Compare November 9, 2021 11:04
@ator-dev
Copy link
Contributor Author

ator-dev commented Nov 9, 2021

I accidentally left an incomplete change in one file that invalidated the tests, could they be restarted please? I'm not familiar with this process.

Checks run automatically again whenever you (force-)push a commit to your branch.

Also, is force-pushing the right way to apply a fix to my pull request?

Yes, as it's the only way to ensure your PR continues to contain a single commit (rather than several) slightly_smiling_face

Thank you, that makes sense (;

@ator-dev
Copy link
Contributor Author

ator-dev commented Nov 9, 2021

@Calinou Since only one of the tests has failed, and that because of a documentation error, is it possible to accept the suggested changes and/or retry only the failed test? It seems like a waste to restart all of them again when only the failed one is affected by doc changes.

@sairam4123
Copy link

Why was size chosen instead of extents though? Just wondering.

@ator-dev
Copy link
Contributor Author

ator-dev commented Nov 9, 2021

Why was size chosen instead of extents though? Just wondering.

See #54449 (probably there are other related issues as well) - in Godot 3 many of the 3D nodes with a concept of size (as a Vector3) utilised an extents property which was essentially half the actual size - so a MeshInstance with extents (1,2,1.5) took up 2×4×3 units of space. In Godot 4 the API and UI is being mostly standardised to use a size property instead, which is the actual size (or double the value of extents).
I'm not really refactoring apart from applying some of this standardisation now so that compatibility doesn't have to be broken later.
(Also, size does exist in a few places in 3.x and is used in exactly the same way.)

Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good! Just a few problems to iron out.

For future reference, it looks like there was agreement to expose size to users instead of extents but to use extents internally where it makes sense (Comment from Akien here)

@@ -263,7 +263,7 @@ void light_compute(

uniform highp mat4 refprobe1_local_matrix;
out mediump vec4 refprobe1_reflection_normal_blend;
uniform highp vec3 refprobe1_box_extents;
uniform highp vec3 refprobe1_box_size;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of converting the shader to use use size, you should convert from size to extents before sending to the shader.

That being said, this code is all unused right now and will be rewritten soon. So for now you can just revert all the changes to this file

@@ -5268,7 +5268,7 @@ void RendererSceneRenderRD::init() {
actions.renames["WORLD_POSITION"] = "world.xyz";
actions.renames["OBJECT_POSITION"] = "params.position";
actions.renames["UVW"] = "uvw";
actions.renames["EXTENTS"] = "params.extents";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have changed the name of the parameter, but you didn't change the name in the actual shader (here). So this isn't going to compile. Further, above you are still passing the extents to the shader as you convert size into an extent in the line just above. You will also need to convert the CPU-side uniform to size if you are going to change the shader parameter (here)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, yeah - I had problems with the shader code, partly because I don't fully understand how it's called yet (and I also don't have error detection/squiggles for GLSL currently)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind pointing me towards where the values are passed into the relevant shaders please? I just can't seem to find it, so can't currently fix the input problem (I'm making the shaders use extents internally again).
By the way, should the visual shader expose extents (actually in the shader code) or size to the user?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The visual shader should use the same variable names as the text shader.

The CPU side variable is defined here:

It is set here:

volumetric_fog.push_constant.extents[0] = extents.x;
volumetric_fog.push_constant.extents[1] = extents.y;
volumetric_fog.push_constant.extents[2] = extents.z;

And in the shader it is defined here:

@@ -158,7 +158,7 @@ uniform sampler3D density_texture: hint_white;
void fog() {
DENSITY = density * clamp(exp2(-height_falloff * (WORLD_POSITION.y - OBJECT_POSITION.y)), 0.0, 1.0);
DENSITY *= texture(density_texture, UVW).r;
DENSITY *= pow(clamp(-SDF / min(min(EXTENTS.x, EXTENTS.y), EXTENTS.z), 0.0, 1.0), edge_fade);
DENSITY *= pow(clamp(-SDF / min(min(SIZE.x, SIZE.y), SIZE.z), 0.0, 1.0), edge_fade);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a change in logic as size is twice as big as extents.

@ator-dev
Copy link
Contributor Author

ator-dev commented Nov 9, 2021

Looks mostly good! Just a few problems to iron out.

For future reference, it looks like there was agreement to expose size to users instead of extents but to use extents internally where it makes sense (Comment from Akien here)

Thanks, I knew there'd probably be a few issues with my changes - I did my best to understand everything I was dealing with but had trouble with some of it (;
I'll start working on a fix soon.

@ator-dev ator-dev force-pushed the use-size-over-extents branch from e8410ad to c5e3215 Compare November 10, 2021 20:32
@ator-dev ator-dev requested review from clayjohn and removed request for a team November 10, 2021 20:33
@ator-dev ator-dev force-pushed the use-size-over-extents branch 3 times, most recently from 85f37c9 to 9c1ea56 Compare November 10, 2021 21:05
@ator-dev ator-dev requested review from a team as code owners November 10, 2021 21:05
@ator-dev
Copy link
Contributor Author

I just realised that after using --doctool (thinking it would update the docs and so prevent the unit tests failing due to being outdated by my changes), the quality of the offline documentation has largely been decreased. I'll push a fix for this later; until then, don't worry about the newly missing bits, I wasn't actually intending to remove things like descriptions.

@ator-dev ator-dev force-pushed the use-size-over-extents branch 3 times, most recently from 80c941a to 097254f Compare November 20, 2021 18:20
@ator-dev ator-dev requested review from a team as code owners November 20, 2021 18:20
@ator-dev ator-dev force-pushed the use-size-over-extents branch from 097254f to 21db9df Compare November 20, 2021 18:23
Refactor FogVolume code

Fix FogVolume refactoring

Refactor VoxelGI code

Refactor ReflectionProbe code
@ator-dev ator-dev force-pushed the use-size-over-extents branch from 21db9df to 9b28bce Compare November 20, 2021 18:25
@ator-dev
Copy link
Contributor Author

@clayjohn Sorry, could you help me with the conflicts please? I don't really understand what's gone wrong, and can't seem to fix it.

@clayjohn
Copy link
Member

It looks like in rebasing you have picked up changes from unrelated PRs. Can you undo the changes that are not relevant to this PR?

@ator-dev
Copy link
Contributor Author

You're right... I'm just going to delete this branch and copy the relevant changes across. I've tried several times now to fix it and every time it somehow gets more convoluted.

@ator-dev ator-dev closed this Nov 21, 2021
@ator-dev ator-dev deleted the use-size-over-extents branch November 21, 2021 00:02
@Calinou
Copy link
Member

Calinou commented Nov 21, 2021

Superseded by #55178.

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.

VoxelGI, ReflectionProbe FogVolume Extents should be replaced with Size for consistency with CSGBox3D
4 participants