How to implements post effect with compute shader?

Problems building or running the engine, queries about how to use features etc.
Post Reply
nanophoto
Gnoblar
Posts: 7
Joined: Wed May 04, 2022 7:35 am
x 2

How to implements post effect with compute shader?

Post by nanophoto »

Ogre Version: 14.1.0
Operating System: Windows 10
Render System: Direct3D11

Code: Select all

compositor GrayScale
{
    technique
    {
        texture rt0 target_width target_height PF_FLOAT32_RGBA
        texture rt1 target_width target_height PF_FLOAT32_RGBA

    target rt0
    {
        //After drawing geometries.
        input previous
    }

    target rt1
    {
        //For example, I want to implements color-gray convertion with compute shader
        input none
        pass compute
        {
            material ComputeShader/GrayScale
            thread_groups 32 32 1
            input 0 rt0
            input 1 rt1
        }
    }

    target_output
    {
        input none
        pass render_quad
        {
            //simply draw quad.
            material RenderQuad
            input 0 rt1
        }
    }
}
}

I want to implements post effect with direct3d11 compute shader.
And I read Sample_Compute example.
However I cannot understand how to write compositor to execute post effect with compute shader.

In the example above, I would like to perform Gaussian blur or grayscale conversion etc... after drawing other geometry. It is possible with the traditional Compositor example, but I'd like to know how to implements it with Compute Shader.

Best regards.

paroj
OGRE Team Member
OGRE Team Member
Posts: 1937
Joined: Sun Mar 30, 2014 2:51 pm
x 1034
Contact:

Re: How to implements post effect with compute shader?

Post by paroj »

pass compute merely tells when to execute the compute shader relative to the rest.
Compute shaders themselves are not part of the rendering pipeline, so it does not matter which target section they belong to. You reference the data you want to process in the material.
See also: https://github.com/OGRECave/ogre/blob/6 ... #L783-L792

nanophoto
Gnoblar
Posts: 7
Joined: Wed May 04, 2022 7:35 am
x 2

Re: How to implements post effect with compute shader?

Post by nanophoto »

Thank you, paroj.
I will try to rewrite the script based on the information you provided.

Post Reply