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 arbitrary buffers that are accessible in post-processing shaders #2675

Open
mnkylord opened this issue Apr 30, 2021 · 1 comment
Open

Comments

@mnkylord
Copy link

Describe the project you are working on

I am working on a stylized 3D JRPG game. This game will make use of post-process to achieve effects such as outline.

Describe the problem or limitation you are having in your project

I need to access normal (and other arbitrary data) to find edge between overlapping objects (ocean and land).

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

It will be extremely helpful if shaders can write to arbitrary buffers that post-process shaders can access. For example, I can create an int buffer that stores object IDs. Post-process can easily identify which pixel belongs to which object and we can easily outline around some, but not others. We can also darken some, but not others. The possibilities are endless. A very popular way of creating outline is the convex hull method which essentially draws the object twice (doesn't scale up well). But at the memory cost of buffers, we can achieve not only a nicer and more controlled effect, but also (I believe) at lower GPU cost. I am actually getting a nice outline around some parts of my geo using depth. But depth doesn't work for all of my needs. I will need to access normal or ideally arbitrary buffers.

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

If I wanted to export surface normal and access in post-process, I would do this...
shader code allows export(vec3, "normal", NORMAL); in fragment()
post-process fragment() allows vec3 normal = import(vec3, "normal", SCREEN_UV);

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

As far as I understand, access to normal and arbitrary buffers is not possible.

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

I am not sure if add-ons can offer this functionality in shader/post-process.

@Calinou Calinou changed the title arbitrary buffers that are accessible in post-process Add arbitrary buffers that are accessible in post-processing shaders Apr 30, 2021
@clayjohn
Copy link
Member

clayjohn commented Apr 30, 2021

Related: #495, #2196, and #895

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

3 participants