[Odessey] Creating my own G-Buffer in UE4

Thanks! The final part is up now at http://

Ooooh I am definitly following this, very fascinating! Sadly I don’t have the time to test it at the moment, but I’ll keep my eye on it. Keep it up :slight_smile:

‘Keep your eye on it’? The thread reached it’s conclusion months ago :stuck_out_tongue:

This might still happen at some point :smiley:

(but oh my, I haven’t looked at the date, sorry for digging up such an old thread again :o )

Its very nice work, . We all appriciate this. =)

Could you make step by step tutorial of implementing custom buffer please?

****, this was just what I was looking for… at least it’s possible, guess I’ll start learning from scratch :confused:

Hello! Even though I can’t make a tutorial, I still have all the code I wrote available on my ! As long as you have access to the UE4 source, you can check out/ fork my stuff.

https://.com//UnrealEngine/tree/4.6CustomTagBuffer

While I haven’t made an update for 4.7 it should be fairly easy to port from my 4.6 stuff :slight_smile:

Best regards,

Thank you, I hadn’t setup the account and linked it to my profile here. Now I see it and was able to download the ZIP, thank you so much Termaran!

Hi,

great work! I’m currently fiddling with outline materials and got to the point where I need exactly that.
I also want to be able to fade in and out the outline drawing later.

Any chance that the work of will be available in the release branch?

Thanks,
Dennis

I’ve mentioned it before in the thread, but I don’t think this will make a good pull request since it is kind of niche.
If a lot of people would like it though, I might create one (pull request that is). I mean, unless you actually render something, it is basically free.
There is some overhead in the render thread where it will test if there are any render proxies that would like the functionality, but other than that everything is only done on demand.

I also think there might be some bugs, as I haven’t really looked into different corner cases. I’m not sure it works for some types of materials for example (transparent, masked etc.).
I could of course fix that though. :slight_smile:

The final concern is whether it is simply too much code. I know that Epic is unwilling to accept pull requests containing code that they themselves do not use, since they still have to QA everything that goes into the release branch. So unless they would actually want to use the code in one of their projects, I don’t think it is even an option if it were not for pressure from the community.

The best way would be to make this a . There are a few problems with this too however. It requires pretty tight integration with the rendering code, so first there would have to be support for that in the renderer itself. Maybe a hooking API or something along those lines. If that is the case, I or someone else would have to add that first.

Now I’ve actually considered doing that as my next odyssey, since it’s been a while since this one and I have lots of other ideas how that would be useful. But it would take considerable effort to make it good enough to make an acceptable pull request. Anyways, it’s something to think about.

All in all, it would have to go something like this:

  • Create a hooking API in the rendering engine source, possibly as the next odyssey.
  • Make a proper pull request for this API.
  • Remake the tag buffer branch to use this API instead of how it is integrated now
  • Publish the "Tag buffer " somehow.

I think that the API + solution would be much more powerful because of the flexibility it adds, not only for the tag buffer, but for the engine in general. It is also a lot more work though :slight_smile:

Best regards,

Hey, I’d just like to thank you for documenting your work on implementing a custom G-Buffer, it helped me tremendously.

It would be awesome to have it in the engine, so I hope you would try submitting a pull request. For our game just the custom depth isn’t enough for all the crucial feedback elements we would want, but at the same time we can’t really work with a custom UE4 build.

Ooooh, very cool project Pikkukatit!

I can make no promises, but I have some ideas of how I could make it work in a binary build. I’ll keep you posted if I actually do something with it :slight_smile:

/

Thank you , it’s a great piece of work and we would be eternally grateful if you can pull some magic to make it happen for the binary build.

Cheers!

Hi ,

This looks really useful to something I’m trying to do at the moment. Thanks for writing all this up.

A couple questions; did you actually get extra nodes appearing in the material editor doing this? I can’t quite work out how these are being generated. And could you do something similar to render to a custom color buffer to use in the post processing stage?

What I basicly want to do is render certain objects, or parts of them, to a custom color buffer to use for post processing glow. The bloom provided by the engine doesn’t quite suit my purposes.

Hello !

Yes, the use case you are talking about was one of my mail goals. You can get bloom by simply doing the outline shader I did and pulling up the emissive really high.
Regarding the node, the pictures I posted above were created using the material editor. I didn’t create a separate node, but instead I added the custom tag buffer to the SceneTexture node, much like the Custom depth target.

Now it was quite a long time ago I fiddled with this, and there are some steps to it, but the lines that actually exposes the buffer to the material system are in MaterialExpressionSceneTexture.h:41, HLSLMaterialTranslator:2435 and MaterialTemplate.usf:952 I believe.

I’m going to try to find some time to make an update for 4.8 and maybe 4.7, not sure when though.

I hope that helps :slight_smile:

Best regards,

That makes sense, having it in the SceneTexture node. Thanks for the tips with it. I’m working with the 4.8 source so I’ll let you know if I come across anything that’s different with it compared to what you’ve done.

I’m thinking I’ll want to have more fine grained control than just having an entire component rendered in a custom pass, I’d like to be able to specify what goes into the custom colour buffer though materials so it can be masked using textures or something similar. I guess this would result in an extra output node for the base material.

Did you come across anything that might help with this? Do you know if it’s even possible from a hardware point of view to render to more than one colour buffer in a single pass?

If you make it work for 4.8, you’re more than welcome to do a pull request!

I’m not entirely sure what you mean with the middle paragraph… If I understood correctly, you want to render different things to the custom buffer depending on parameters in the material you have on the objects you want to render? If that is what you mean, it could probably be accomplished somehow, you probably want to look into the tag buffer global shader for that: TagRendering.cpp and then like set resources to the shader (TagBufferShader.usf) depending on the object you are rendering. From there on you can basically render however you want. The only difference really is that you have to use HLSL instead of the material editor. If you’re fine with that, then most things should be possible :slight_smile:

If you’re just after rendering more GBuffers, then that is definitely possible.

Best regards,

Hi ,

Sorry what I mean is I’d like to be able to write to the custom buffer using a material output. The way the outline works is by writing the whole primate component to the custom GBuffer right? But I might just want to write part of it to the buffer, which I think could be accomplished by making an extra output node which you could just write raw color values to using an ordinary material.

I’m more used to writing HLSL than materials but it would be nice to get it integrated with material editor for others who aren’t.

I’ll probably start by upgrading your code to 4.8 just to get myself familiar with the system. I’ll let you know how it all goes!

Ah, hmm, I’m still not sure what you mean I’m afraid.

Do you mean that you would basically like to render the output of one UMaterial to the buffer? Like a cutout from the main back buffer? You could accomplish this using the tag buffer by simply using it like a stencil buffer, and then doing a post process shader where you use the tag buffer to stencil out parts of the PostProcess0 scenetexture (just get all pixels that are not black).

Do you mean like only outputting the emissive from the UMaterial for example? I’m not sure how I would accomplish something like that to be honest. Some of these outputs end up in their own GBuffers, but some of them are written to the same one afaik. if you would like to “intercept” these, I guess that could be done somehow by making more stuff happen in DeferredShadingRenderer.cpp, but I think that might be a challenge to be honest.

Regarding the outline, it works like you say by rendering a solid color at all rasterized pixels for the object. That data is then used in a post process material that has a sobel operator (Sobel operator - Wikipedia) and simply colors the result of the sobel with the color found in the buffer.

But like I said, you can probably do most stuff by simply working directly with the tag buffer global shader :smiley:

Best regards,