I’ve already posted a question on answerhub https://answers.unrealengine.com/questions/478911/proper-way-to-invoke-post-process-shader.html, but it barely caught anyones attention, so i’m asking here.
What am i trying to do:
- post-process shader, which has several settings as inputs (among them occlusion map, light position, strengh, color etc.);
- plugin, which contains and handles this shader;
Using PostProcessDOF class as an example, i’ve tried to create my own shader executor class. It seems to compile, though not working - at the moment i’m getting “Access violation” error, when try to SetTextureParameter. So i’m having a lot of questions about getting all the data, i asume, is needed for shader to work. How to render scene as texture and get ViewInfo correctly? How to setup render target and shader texture parameter properly? What’s the right way to invoke my own shader, set its input and output? And lot more.
Would really appreciate any kind of help and information!
Best regards, Dennie.
Still hope to get help or at least a tip.
There are lots of information to handle, and i’m afraid, i’m missing some small but crucial detail. If anyone’s got ideas, how to setup input texture and how to get back result, your advise would be really helpful!
Have you already tried Material function with post process domain? It can access most of the render target textures and you can setup your own textures too. No c++ needed.
Hi! Yes, i have. In fact, i’m using one to test if temp shader itself does actually work. But i cannot use this direction because of two reasons: first, i’ll need much more specific inputs to the shader, which i cannot get within material function; second - the final shader is pretty big and complex to implement it via custom hlsl nodes. Dunno, maybe i should try and search a way to create similar type of material in c++, this may help, though it doesn’t seem to be the right approach.
What are those more spesufuc inputs? I think there is way to call function that is declated as .usf from custom node. So you could add code to file. Then just call it from post process material.
Inputs are: light positions, numbers of samples, amount of rays etc. I haven’t found this type of fuction yet, need to look again. At the moment i know only custom node, there hlsl code may be put into. Will search for the one you’ve mentioned, thanks!
Materials can have multiple Vector,scalar and texture paramers. I know that I can call functions in Common.usf and some other shader files directly from Custom Node.
Yes, materials can have them - the question is, how to setup and change these parameters in runtime? Right now i cannot visualize for myself this process clearly. For sure, i need to take a deeper look into materials.
Found what you where talking about (calling specific function from custom node)! Apparently, i had to include my shader .usf to MaterialTemplate.usf to be able to reach its namespace. This isn’t perfect solution, but atm this will do.
Thank you so much, you gave me hope!
I’ve found another global shader example, so i again will try to create post-process via c++, while my teammates use this variant.
For passing parameters to materials you simple make Dynamic Material instance and call “Set Vector/Scalar Parameter” on blueprint/c++. You can also use Paramater Collections if you don’t want to use dynamic material instances.
Understood. Now i can see kinda architecture of this approach. Thank you again for helping me!