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 force_draw method for viewports #75436

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

danielryb
Copy link

@danielryb danielryb commented Mar 28, 2023

Implements a force_draw method for viewports, which allows to update an individual viewport and it's children manually.

This method works similarly to RenderingServer.force_draw, but instead of drawing all active viewports it affects only a given subset.

@danielryb danielryb requested review from a team as code owners March 28, 2023 23:40
@danielryb danielryb force-pushed the force-draw-viewport branch 2 times, most recently from 33b9bdf to bf1ec2a Compare March 29, 2023 00:14
@Calinou Calinou added this to the 4.x milestone Mar 29, 2023
@danielryb danielryb force-pushed the force-draw-viewport branch from bf1ec2a to a715c9f Compare March 29, 2023 04:06
@danielryb danielryb requested a review from a team as a code owner March 29, 2023 04:06
@danielryb danielryb force-pushed the force-draw-viewport branch 2 times, most recently from b2e1efe to 74adad0 Compare April 3, 2023 23:37
@danielryb danielryb changed the title Added force_draw method for viewports Add force_draw method for viewports Apr 3, 2023
@danielryb danielryb force-pushed the force-draw-viewport branch from 74adad0 to b25df69 Compare April 4, 2023 08:15
@danielryb danielryb force-pushed the force-draw-viewport branch from b25df69 to 0722f1c Compare July 19, 2023 10:50
@reduz
Copy link
Member

reduz commented Jul 26, 2023

I have the feeling that, even if we implement this, this is not the solution to what users are asking for. My understanding is that, instead, you want to have a proper blit support into textures in real-time to make all sort of effects, right?

@reduz
Copy link
Member

reduz commented Jul 26, 2023

I opened a proposal for this, which I believe should make it easier to handle these kind of use cases, Feedback welcome:

godotengine/godot-proposals#7379

@danielryb
Copy link
Author

No, I'd like to have a method which mimics Unity's Camera.Render in functionality.

Currently, if my understanding of Godot's renderer is correct, my code is missing a part which synchronizes scene data with the GPU. But since it isn't a part of Rendering Server's draw method, I wonder if it shouldn't be implemented as a separate method.

@SlugFiller
Copy link
Contributor

@danielryb Could you describe your specific use case in a bit more detail? Because it sounds somewhat different from what was discussed in the linked proposal so far.

P.S. I'm aware you didn't link the proposal yourself. But it's generally the case that feature PRs are linked with a proposal, so that the need for the feature, and whether the PR actually answers said need to the extent users might expect, is properly understood.

@danielryb
Copy link
Author

@SlugFiller I use this to render selected viewports in desired moments. Namely, in my portal implementation, I use this method to render two subviewports, where I apply changes to shader globals between the renders. With scene-GPU synchronization added, this will also come handy in creating an effect where you can see the same portal through itself multiple times.

@reduz
Copy link
Member

reduz commented Jul 26, 2023

@danielryb

No, I'd like to have a method which mimics Unity's Camera.Render in functionality.

That will probably never happen because Godot is just not designed to operate that way, at least not in the way this PR intends to do it. What will most likely happen is that you will be able to add usercode in the render thread to better customize the rendering process at some point, but not directly control it.

@reduz
Copy link
Member

reduz commented Jul 26, 2023

To clarify further, rendering in Godot is not intended to happen at any time outside the server, as it eventually we want to move it to run all the time in a thread by default for performance reasons. So you will not be able to control when something happens from outside RenderingServer.

The plan is to eventually give you access to modify the whole rendering process (more in a compositor way) where you can hook up callbacks and trigger renders, but this will be all code running in the render thread, not exposed to nodes.

@reduz
Copy link
Member

reduz commented Jul 26, 2023

That said we are likely a year away from implementing something like this. Maybe I can open a proposal so you and others can discuss on what implementation you would like better?

@danielryb
Copy link
Author

Seems good.

@reduz
Copy link
Member

reduz commented Jul 26, 2023

Still, I apologize you took all this work to do this PR and it can't be merged yet. We are only beginning right now to expose the RenderingServer internals so you can put custom code in there. The API will likely still change a bit and there is not much documentation. The ultimate goal is that you can have compositor style access and control the whole rendering process of the frame.

@danielryb
Copy link
Author

I don't mind it. I'm glad that a proper solution is in the works. It looks very promising.

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.

Add the ability to update/re-render a Viewport manually
4 participants