Direct rendering to BackBuffer from compositor

What it says on the tin: a place to discuss proposed new features.
Post Reply
iigor
Gnome
Posts: 387
Joined: Thu May 08, 2008 3:46 pm
Location: Russia, Moscow

Direct rendering to BackBuffer from compositor

Post 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.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post 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.
iigor
Gnome
Posts: 387
Joined: Thu May 08, 2008 3:46 pm
Location: Russia, Moscow

Post 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
			}
        }
    }
}
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post 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.
iigor
Gnome
Posts: 387
Joined: Thu May 08, 2008 3:46 pm
Location: Russia, Moscow

Post 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]
iigor
Gnome
Posts: 387
Joined: Thu May 08, 2008 3:46 pm
Location: Russia, Moscow

Post 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.
User avatar
iloseall
Gremlin
Posts: 156
Joined: Sun Sep 14, 2003 3:54 am
Location: Beijing China
Contact:

Post 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=
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post 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.
Post Reply