Skip to content

Access different viewport buffers through ViewportTextures ("G-buffer") #798

@SIsilicon

Description

@SIsilicon

Describe the project you are working on:
This proposal applies to any project involving screen space shaders.

Describe the problem or limitation you are having in your project:
You see, what I'd like to access the depth texture of the scene for a shader of mine. However, because shader is so expensive, I wanted to render the effect at half or even quarter resolution to composite on top of the scene. But then I would have no access to the depth texture as it would not be accessible from any other viewport.
Plus, I have another project that requires access to the material buffers (normal, metalness, etc.) for a screenspace effect, but those aren't accessible period!

Describe the feature / enhancement and how it helps to overcome the problem or limitation:
What I propose is that user should be given access to these buffers from viewport textures, maybe like give viewport textures a buffer_mode (with color being the default). This way, a lot more 3D visual effects can be achieved, such as screen space global illumination, and the ability to use a viewport's depth texture from another viewport.

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

Starting from this function:
https://github.com/godotengine/godot/blob/4d2c8ba922085a94ab7e963d23289fb8ed9c1f08/drivers/gles3/rasterizer_storage_gles3.cpp#L7530-L7540
we could expose the buffers to the front end. However, I also see that the buffers are set as Renderbuffer Objects. They would need to be initialized as textures in order to be accessible.

If this enhancement will not be used often, can it be worked around with a few lines of script?:
No, 'cause this requires low level access to the rendering API.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions