Page 1 of 1

Direct rendering to BackBuffer from compositor

Posted: Fri Oct 10, 2008 10:37 am
by iigor
When i have different shemes on different objects, i need to use in final compositor pass copying of my rendering rezults from texture to backbuffer, and always copying takes about 80% of computiong power losses. So i't would be great if i can directly use backbuffer in compositor.

Posted: Fri Oct 10, 2008 6:01 pm
by sinbad
Explain.

You don't need to just copy the last texture to the compositor, the 'output' of the final compositor IS the backbuffer of the final output.

Posted: Mon Oct 13, 2008 9:42 am
by iigor
So i have compositor:

Code: Select all

//It's used to have 3 layers of objects
// 1-t layer is solids, 
// 2-d is additive transparent objects, 
// 3-d alpha transparent objects rendered by depth peel(only 1-t layer)
compositor Transparency_Slice_1
{
   technique
    {
		texture colour_texture_slice_1 target_width target_height PF_A8R8G8B8		
		target colour_texture_slice_1
        {
			input none
			pass clear
			{
			}
			pass render_scene
			{
				last_render_queue 51
			}
        }
		
		target colour_texture_slice_1
        {
			input none
			pass render_scene
			{
				first_render_queue 70
				last_render_queue 79
			}
        }
		
		target colour_texture_slice_1
        {
			input none
			material_scheme write_colour_slice
			pass render_scene
			{
				first_render_queue 59
				last_render_queue 61
			}
        }
		
		target colour_texture_slice_1
        {
			input none
			pass render_scene
			{
				first_render_queue 80
			}
        }
		
		target_output
		{
			input none
			pass render_quad
            {
                material texture_copy
                input 0 colour_texture_slice_1
            }
		}
    }
}
And here is results: with standart compositor i have 400 fps, with that i have 360, but if i comment out target_output(only render scene without copying results to the screen) i get 390 fps, so most expencive place in this compositor is copying results from texture to backbuffer using rendering screen aligned quad but it's about 20 times faster to use blitting, not rendering, and it's the easiest way is to use backbuffer without copying 8) , i want to have such compositor (or something like this):

Code: Select all

compositor Transparency_Slice_1
{
   technique
    {
		texture colour_texture_slice_1 back_buffer	
		target colour_texture_slice_1
        {
			input none
			pass clear
			{
			}
			pass render_scene
			{
				last_render_queue 51
			}
        }
		
		target colour_texture_slice_1
        {
			input none
			pass render_scene
			{
				first_render_queue 70
				last_render_queue 79
			}
        }
		
		target colour_texture_slice_1
        {
			input none
			material_scheme write_colour_slice
			pass render_scene
			{
				first_render_queue 59
				last_render_queue 61
			}
        }
		
		target colour_texture_slice_1
        {
			input none
			pass render_scene
			{
				first_render_queue 80
			}
        }
    }
}

Posted: Wed Oct 15, 2008 3:43 pm
by sinbad
I'll repeat my 'why'?

Your texture_copy pass is pointless, you can have the same effect by making the last 'target colour_texture_slice_1' the 'target_output' instead.

Posted: Wed Oct 15, 2008 4:13 pm
by iigor
O sorry i missed input directive:

Code: Select all

compositor Transparency_Slice_1
{
   technique
    {
		texture colour_texture_slice_1 target_width target_height PF_A8R8G8B8		
		
		target colour_texture_slice_1
        {
			input none
			pass clear
			{
			}
			pass render_scene
			{
				last_render_queue 51
			}
        }
		
		target colour_texture_slice_1
        {
			input previous
			pass render_scene
			{
				first_render_queue 70
				last_render_queue 79
			}
        }
		
		target colour_texture_slice_1
        {
			input previous
			material_scheme write_colour_slice
			pass render_scene
			{
				first_render_queue 59
				last_render_queue 61
			}
        }
		
		target_output
        {
			input previous
			pass render_scene
			{
				first_render_queue 80
			}
        }
    }
}
This code works pretty fine, thanks 8) , but i think that texture is unneded or Ogre after compiling such type of compositor will not create any textures?[/code]

Posted: Tue Nov 18, 2008 2:42 pm
by iigor

Code: Select all

compositor Transparency_Slice_1 
{ 
   technique 
    { 
      texture colour_texture_slice_1 target_width target_height PF_A8R8G8B8       
      target colour_texture_slice_1 
        { 
         input none 
         pass clear 
         { 
         } 
         pass render_scene 
         { 
            last_render_queue 51 
         } 
        } 
       
      target colour_texture_slice_1 
        { 
         input none 
         pass render_scene 
         { 
            first_render_queue 70 
            last_render_queue 79 
         } 
        } 
       
      target colour_texture_slice_1 
        { 
         input none 
         material_scheme write_colour_slice 
         pass render_scene 
         { 
            first_render_queue 59 
            last_render_queue 61 
         } 
        } 
       
      target_output 
      { 
         input none 
        pass render_scene 
         { 
            first_render_queue 80 
         } 
      } 
    } 
}
Before i resently updated Ogre, here is added new bug:
when i use described above compositor i have screen with uncleared contents of video memory.

Posted: Wed Nov 19, 2008 3:52 pm
by iloseall
sinbad wrote:I'll repeat my 'why'?

Your texture_copy pass is pointless, you can have the same effect by making the last 'target colour_texture_slice_1' the 'target_output' instead.
About "Why":
sometimes:
We can not making the last 'target colour_texture_slice_1' to 'target_output' when we want render the scene with same depth buffer .
In Ogre, rendertargets create in compositor can use same depth buffer if they has same size and etc.
But, the depth buffer used by main background buffer is not samed with this though with same size and etc.


see also:
//Question 2: IN
http://www.ogre3d.org/phpBB2/viewtopic. ... highlight=

Posted: Wed Nov 19, 2008 7:56 pm
by sinbad
Depth / stencil buffers are always shared between surfaces that are the same size & format (including AA modes). You can exploit this if you want to re-use depth results.