tommybazar / UE4GlobalShaderRaymarcher

22 stars 5 forks source link

All ok, but how about fullscreen post effect? #1

Open MASTER-OF-ORION opened 5 years ago

MASTER-OF-ORION commented 5 years ago

Hi man! I'm worn out to understand the mechanism of adding shaders ti UnrealEngine4.20.2, your lesson really helped, but how do I do drawing on the whole fullscreen? (not on 3d volume cube on scene) Is see, you set GlobalPostProcessVolume Infinity Extent falg, ok... but how to render something on fullscreen? I think, i should to add PostProcessMaterial array element and set there my own material, bot how to use custom plugin shaders in material?

tommybazar commented 5 years ago

There's a blueprint called GetViewPortSize(), that will give you current resolution of the screen. If you then call the InitializeRenderResources again with the new size, it should work.

Also, I'm not drawing on a 3D cube in the scene. I'm drawing to a texture and then putting this texture over the screen. If you remove the transformation calculations for the cube and instead use vertices at the corners of the screen, you will get a full-screen rendering.

Find the line where I do DrawIndexedPrimitiveUP(....)

and replace it with something like

        // draw full-size quad
    FVector4 Vertices[4];
    Vertices[0].Set(-1.0f,  1.0f, 1.0f, 1.0f); // Top Left
    Vertices[1].Set( 1.0f,  1.0f, 1.0f, 1.0f); // Top Right
    Vertices[2].Set(-1.0f, -1.0f, 1.0f, 1.0f); // Bottom Left
    Vertices[3].Set( 1.0f, -1.0f, 1.0f, 1.0f); // Bottom Right

    DrawPrimitiveUP(RHICmdList, PT_TriangleStrip, 2, Vertices, sizeof(Vertices[0]));

This should do a full-screen render. Try searching in UE4 source codes for DrawPrimitiveUP and DrawIndexedPrimitiveUP and you'll find them using this for full-screen quads sometimes.