Custom Buffer output into post process

Hi all

I thought I’d make a new thread as the previous discussion I was having was over in the events section and it seems more relevant to have it here.

I’ve managed to take advantage of the fact that there is a customData channel in the GBuffer which the Default Lit and Unlit shaders dont use. All of the others (clear coat, hair, subsurface) use it.

I’ve added an output node int the material editor that lets you write whatever you want to it from a material.

I throught from discussions on the forum that I would have to access this custom data through a custom node. Doing this was giving me a failed assertion that told me that the GBuffer resource wasn’t valid. BUT then I had a look at the GBuffer visualisation and I saw my pass in the subsurface output! :slight_smile: I then worked out that the customData get’s written there and I wouldn’t have to go through a custom node.

It actually didn’t take too much to do (well after having to figure out how the shader compiler works with all its defines when you add an output. I’m thankful for visual studios ‘go to defintion’ because documentation surely didn’t help me.

I can create a pull request for this. is this something that is likely to be accepted @DanielW, ? Or should I just keep my own custom build?

The first thing that I can see people being worried about is mixing the subsurface output with these arbitrary ones. Well because the Gbuffer is limited in how many passes it can do (or more to the point how many epic want to put in for performance reasons), I don’t see any extra custom passes being added. One workaround I have thought about it to use the stencil buffer to send material/mask IDs through so that you can do your own masking in post process. So all SS materials would be given a stencil id of 1 or something and anything else would be a custom thing. This would be up to the user though.

I’m interested to hear everyone’s thoughts on if this is a useful feature.


1 Like

I’ve gone ahead and create a pull request…

Feel free to leave feedback and requests.

hi , no link with this topic but i know your skills and i’d like to know if never know you can come and bring your talent here :
Ori and the blind forest GPU Water and dynamic wave - Rendering - Epic Developer Community Forums , i guess for everyone working or loving modern 2D it can be very interesting.
thanks in advance

Hi , I found that trick with materials awesome because there isn’t any way to pass custom data to post process from fragment shaders (materials) implemented by Epic Games, so, can I ask you if you could post the steps to create that node in materials, please?.

Thanks in advance

HI DeleoDev.

it required adding a few lines to the source code and recompiling. It was rejected on github and I haven’t looked at it in a while. I heard that there was some change to the engine recently which allowed rendering code as plugins but I haven’t looked into it. I’ll have a look and see if its possible. In the meantime you are welcome to look at the pull request and get the code yourself if you want to compile it.

I’ve tried to visit the link but it gives me a 404 error. I think that they deleted your request

You need to connect your GitHub account to Epic one (int in the profile).

@ Do you know if it’s possible to write to custom buffers on recent UE4 versions?

This is interesting, but would it possible for you to hook customData node to PostProcessingInput5 or 6, rather than overriding SSS.

Hi all. I’ve jsut dug this out and managed to get it working in UE5. Needed a tiny bit more work than before but its all behaving nicely. As far as I can tell, when I write into the customData channel of the GBuffer, then that automatically gets written to the subsurface color. What I can do though is write to the PostProcess 5 as well though, so technically its duplicated. Maybe there’s a way to create another output for the GBuffer and reroute it to the PP5/PP6 but thats not something I’ll probably do right away.

1 Like

Hey, I’m here in 2022 wanting to know how to get this working in UE5. Any hints/git pull requests for this ? I saw the UE4 one and it seems fairly straight forward, but porting to UE5 I am a touch lost.

Not to worry, found it, here for those of us who stumble across this post :slight_smile:

This seems to be the only thing that can save me atm. I managed to get it working with opaque/masked materials but when the material is translucent nothing is written to the custom buffer output → SubsurfaceColor/PPInput05 is all black. I cannot figure out why this would be the case because all of the code seems to be built around shading model e.g. lit/unlit etc. not translucent or opaque property. Any ideas?