Playing around with postprocessing materials last couple of days I can conclude that they’re kinda… not working as I expected them to work in AAA engine.
I’m trying to capture the scene. Creating RenderTarget, adding SceneCaptured2D to MyCharacter, setting TextureTarget to created rendertarget, CaptureSource is LDR.
To see what I’ve captured I created simple blendable material, which draws captured rt into upper-left quarter of the screen. Then I found substantial difference in colors of the scene and captured rt. I think I tried all checkboxes I can change to see if that will work, but no success so far. What setting are required to catch properly?
Blendables don’t work with SceneCapture2D (created simple blendable which outputs red, but SceneCapture2D ignores it). Found several (some old) topics on forum/answerhub, so I’m not the first to find this bug.
Is there any way to create postprocessing chaining? I.e. I want to get scene texture, run some material with it, save the result to some render target, optionally downsample/upsample it to lower/higher resolution rt, use that render target in some other postprocessing material which will output to the screen (or save it for the next frame). So far I can’t find the way to make it work (nor can I find documentation how to make it).
Not being able to create/resize RenderTargets from blueprints was a surprise for me as well.
To summarize, my experience with postprocessing in UE4 was a pain so far, I hope it’ll get updated in the future.
Update:
SceneTexture node in postprocessing materials have Size and InvSize parameters which are undocumented (as the node itself undocumented as well). What are those params contain?
I am crazy or there are no loops in materials? (both graph and customnode)
Hey there! I know we have some improvements on the docket for postprocess (and how settings are exposed via blueprints) but I’ll make sure the devs see your feedback so that we can address in future versions.
Tell that to SSAO, blur and sheer of other algorithms Loops are almost always have to be unrolled, but we need them pretty often!
I actually did the search and people were complaining about this. Right now I need tex sampling inside the loop and I also remember that was a problem for custom node…
To answer onto my 1. from the first post (seems that I found settings combination):
-SceneCapture2D component
Below is a snippet of one of the Custom Nodes from my POM material. As you can see there is a texture sample (SampleGrad) done in a loop (while). I have also done for loops in other Custom Nodes. so it is certainly possible. The only downside I would say is having to reference the textures and samplers directly.
There may have been some issues with Custom Nodes at the beginning, but I have had no real problems with them now.
Texture2DSample is just a wrapper around Tex.Sample (So instead of PostprocessInput0.Sample( PostprocessInput0Sampler, … ); ) That also applies to PostprocessInput0 through to 6
Ok, I managed to resolve it! I had to change custom shader code a little bit, but I got functionality I needed.
Post from this topic helped me - in short - dummy SceneTexture node should be placed and connected to our Custom Code node, because it probably forces to define NEEDS_SCENE_TEXTURES, which includes SceneTextureLookup function in MaterialTemplate.usf during shader compilation.
In case anybody would have the same problem: here I done simple example, which should work (4.9 and 4.10 tested):
The best way to do Loops I’ve found is to create a material functions out of the part of the material you want to loop, and copy-pasterino it a few times into the graph and have it feedback into the next one and so on. This way it also takes full advantage of the cross-compiler and is probably a good practice to get into making Material Functions anyway.