godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.12k stars 69 forks source link

Add support for Multiple Render Targets (MRT) #495

Open samdze opened 4 years ago

samdze commented 4 years ago

Describe the project you are working on: Top-down 2D rpg with heavy use of visual effects, post-processing and custom depth tests.

Describe the problem or limitation you are having in your project: Right now, I can't fill several buffers when an object is drawn by Godot (I also need to progressively read some of these same buffers to perform depth tests and the like, multi-pass shaders needed) unless I duplicate each object in different Viewport, which is extremely inconvenient and a waste of resources.

The ViewportContainer -> Viewport -> World approach is also very tedious to just setup a render target, and it doesn't allow spread out nodes to render to it.

So, a more flexible and unrestricted way of assigning render targets would be great.

I know MRT is scheduled for 4.0 as @reduz said here, I hope it can be added as soon as possible as I need to prototype the related features in the game. I know that customizable render pipelines are scheduled too, together with MRT the possibilities will be very extensive.

Describe the feature / enhancement and how it helps to overcome the problem or limitation: MRT is a very useful feature of modern GPUs and every major engine in the market supports it. It is useful to create nice effects and post-processing in 3D and even in 2D when more than one buffer needs to be written at once by each object.

I think the rendering code rewrite in Vulkan is the perfect opportunity to add this feature, together with #496

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams: <>

If this enhancement will not be used often, can it be worked around with a few lines of script?: No, severe duplication of nodes would be needed and there would be many inconveniences.

Is there a reason why this should be core and not an add-on in the asset library?: This would be extremely inefficient to do in a way that is not core related.

reduz commented 4 years ago

This is planned for 4.0, still debating myself how to do it.

samdze commented 4 years ago

Thanks! Would also like to highlight this point for the proposal:

The ViewportContainer -> Viewport -> World approach is also very tedious to just setup a render target, and it doesn't allow spread out nodes to render to it.

So, a more flexible and unrestricted way of assigning render targets would be great.

Zireael07 commented 4 years ago

I ran into the limitation of screen reading shaders, namely that they happen before alpha pass. This would likely help a lot in such cases!

sserafimescu commented 1 year ago

I would really appreciate having MRTs in Godot. I hoped they will be here with Godot 4.

huyi7 commented 5 months ago

Been checking back from time to time hoping MRT can be implemented in Godot 4. That would enable us to do more efficiently GPGPU processing.

clayjohn commented 5 months ago

@huyi7 Check out https://github.com/godotengine/godot-proposals/issues/7916 as this is more likely the approach we would go with for MRTs