Compositor: Outputting to MRT's indiviual RT [with Patch]

What it says on the tin: a place to discuss proposed new features.
Post Reply
ming4883
Gnoblar
Posts: 11
Joined: Tue Aug 22, 2006 11:53 am
Location: Hong Kong

Compositor: Outputting to MRT's indiviual RT [with Patch]

Post by ming4883 » Mon Nov 24, 2008 9:46 am

Dear all,

In OGRE 1.6.0, a powerful feature (MRT support) has been added to the Compositor system; which simplifies the process to implement deferred shading (which is a recent hot topic) in OGRE.

However, after some experiments I found that it would be even greater if the new system does support outputting to MRT's indiviual RT.

Example:

Code: Select all

compositor DeferredShading
{
    technique
    {
        // render targets
        texture rt_gbuffer target_width target_height PF_FLOAT16_RGBA PF_FLOAT16_RGBA PF_FLOAT16_RGBA
        
        //------------------------------
        // scene pass for gbuffer setup
        // 0 - albedo & gloss
        // 1 - view space normal & depth
        // 2 - self-illumination or reflections
        target rt_gbuffer
        {
            input none
            
            material_scheme DeferredShading
            
            pass clear
            {
            }
            
            pass render_quad
            {
                identifier 1
                material PostProcessing/Clear
            }
            
            pass render_scene
            {
                first_render_queue 50
                last_render_queue 59
            }
        }
        
        //------------------------------
        // ambient colour
        // output to rt_gbuffer[2] only
        target "rt_gbuffer:2"
        {
            input none
            
            pass render_quad
            {
                material PostProcessing/AmbientLightNoSSAO
                input 0 rt_gbuffer 0
            }
        }
        
        //------------------------------
        // lighting
        // output to rt_gbuffer[2] only
        target "rt_gbuffer:2"
        {
            input none
            
            pass render_scene
            {
                first_render_queue 70
                last_render_queue 79
            }
        }
        
        //------------------------------
        // final output
        target_output
        {
            input none

            pass render_quad
            {
                material PostProcessing/Copy
                input 0 rt_gbuffer 2
            }
        }
        
    }
}
In the above example, the scene's albedo, normal & depth and self-illumination is first being rendered into rt_gbuffer[0], [1] and [2] respectively. Then the rt_gbuffer[2] is being re-used to accumulate the lightings so that one buffer can be saved.

This link is a patch which applies to the OGRE 1.6.0 source code; and it adds outputting to MRT's indiviual RT support to the Compositor system mentioned above. Please notice that in order to reference an individual RT in MRT, you must write the following format: target "target_name:index" {}

It has been tested with the Direct3D9 and the OpenGL render system.
0 x

Post Reply