Rendering to custom GBuffer or rendertarget from material

Hello!

I’ve been playing around with creating outline effects in post process using the material editor, and I have it working for a single-color pass. The problem is I want to be able to color the outline differently depending on some parameter on the objects I add to the custom depth draw. I have a few running theories, but I don’t know enough about the rendering system yet to complete any of them.

My first idea was to do an outline at all was to do it in the normal rendering procedure (instead of post process) by first rendering my actor with my base material, and then render the object a second time using a different material. I can’t seem to figure out how to force a second render of a particular actor though.
I’m guessing I can make this work by creating a material function and then adding that to every single material I want this support for. But I’m not very interested in this solution as it is not post process, and that’s what I’m interested to learn more about this time around :slight_smile:

My inital idea on how to achieve this using the post processing system was to create an additional GBuffer with a relatively low bit depth (4bbp or so) where I could render my objects with a key color, and then use this key color as input for the outline color. I could even skip the edge detection I do now with the depth buffer and use a sobel operator on the key color buffer. There doesn’t seem to be any obvious way to create a custom GBuffer though. I’ve looked a bit at the rendering code, but from what I can tell, there seems to be quite a few steps to create a custom buffer, and that’s not even taking into account exposing it in GUI.

So I started looking at another way, and thought I might be able to do the same idea but instead of using a GBuffer I’d use a render target instead and set it to a texture parameter on my post process material. The obvious problem here though is similar to my initial problem. I’ve looked at SceneCaptureComponent2D which is close to what would be needed, but it only seems to render a complete scene, and I couldn’t find a way to only render select materials, or render stages to that texture.

Has anyone else tackled this problem and has some insight they would be willing to share?

I’m going to spend this week playing around with the rendering system, and hopefully create a tutorial for the wiki if I find out something interesting :slight_smile:

Best regards,
Temaran

Something that I found curious was the SceneTexture:PostProcessInputN nodes that are available. It seems that SceneTexture:PostProcessInput0 represents the compelete renderer output (the complete composite), but there is nothing whatsoever documenting the other SceneTexture:PostProcessInput1 to SceneTexture:PostProcessInput6 variables. Grep:ing the source, I found some references to the other targets however, interestingly enough, in the PostProcessSelectionOutline.cpp global shader. I’m guessing this is the shader that the editor uses for its outlines. The problem is, there does not seem to be an easy way to leverage the 1-6 targets even from here. Looking at that code, it is basically setting up binds (I guess these are the same as DX11 resource views kind of?) like so:
PostprocessInput1MS.Bind(Initializer.ParameterMap, TEXT(“PostprocessInput1MS”));

I’m assuming this means that I would have to create my own global shader to make use of this, and that there is no real way to write to these targets just from client code.

I of course might be wrong… In any case, this is the best lead I have right now so I guess I’ll poke around a bit more. :slight_smile:

/Temaran

I’m currently trying to solve this problem myself, and I think I’m almost there…
I have a chronicle on the forum for anyone interested or for anyone who would like to help me out :slight_smile:

/Temaran