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 ability to mark regions of the world as dirty for SDFGI #7741

Open
wareya opened this issue Sep 19, 2023 · 0 comments
Open

Add ability to mark regions of the world as dirty for SDFGI #7741

wareya opened this issue Sep 19, 2023 · 0 comments

Comments

@wareya
Copy link

wareya commented Sep 19, 2023

Describe the project you are working on

An infinite open world voxel sandbox game.

Describe the problem or limitation you are having in your project

If I enable SDFGI, then when I create or destroy voxels in my game, weird splotches of bleeding shadow and light appear when I destroy voxels, because SDFGI's view of the world is unchanged:

2023-09-19_03-08-54.mp4

This is a problem for level streaming and open world games in general, not just games with editable terrain. Areas of the world that stream in have incorrect lighting until I disable and reenable SDFGI. For example, this happens if I fly around with SDFGI enabled, stop, start recording, then disable and reenable SDFGI:

2023-09-19_05-12-52.mp4

The shadows are broken because the information calculated for this region of the world came from a version of it that wasn't loaded yet.

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

A new method would be added to RenderingServer to instruct it that a specific region of the world is "dirty" and needs its SDF information (or however SDFGI works internally) to be recalculated.

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

RenderingServer.environment_inform_sdfgi_dirty_region(RID env, AABB aabb)

This would mark the region of the world described by the given aabb as being "dirty" and cause it to be recalculated. This recalculation would have the same effect on that region of the world as you can currently get by moving far away from that region (so that it's outside of the largest SDFGI cascade) and then coming back.

I'm not privy to how SDFGI works internally so there might need to be more arguments, or a sphere might be better than an AABB, or the method name given here might not conform to Godot's guidelines. But something like this would be enough. I could call it when new chunks load in and also when voxels are created or destroyed.

Potential Problem!

Some open world games, like mine, move the world around the player when they move too far away from the origin, to make sure that floating point weirdness doesn't start happening far away from the logical origin of the world. If this only happens occasionally, then being able to mark the entire world as dirty would probably be sufficient:

RenderingServer.environment_inform_sdfgi_dirty(RID env)

However, if the world is moved around the player very frequently, like whenever they go outside of a small 16x16 region, then to prevent it being obvious that the light is constantly breaking, it might be necessary to tell SDFGI that the world got "moved" instead of marking it all as dirty:

RenderingServer.environment_inform_sdfgi_moved(RID env, Vector3 offset)

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

No.

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

Core rendering functionality.

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

2 participants