Compositor with nonlocal render texture and partial viewport

What it says on the tin: a place to discuss proposed new features.
Post Reply
mcspy0312
Halfling
Posts: 60
Joined: Sun Aug 08, 2004 5:26 pm
Location: Hong Kong, China

Compositor with nonlocal render texture and partial viewport

Post by mcspy0312 » Fri Mar 06, 2009 10:01 am

Hi
I wanted to use Compositor framework to do runtime partial texture update.
It can be supported by adding few lines of code to the framework. To allow compositor renders to non local render texture.
e.g.

Code: Select all

compositor TexUploadTest
{
    technique
    {
        target RTTTex
        {...
        }
    }
}
Since RTTTex is not defined in the compositor script, the compositor will find the Texture named RTTTex globally, and take it as Render target.


And the next thing to add, is to allow user specifying the viewport region on the render target. The current code always create the viewport covering the whole render target.
If a viewport covering only part of the render target can be constructed, then partial texture update can be done.
e.g.

Code: Select all

        target RTTTex
        {
             viewport_left       0
             viewport_up         0
             viewport_bottom    10
             viewport_right     10
        }
Is this a good idea? If it is, I can code it and submit a patch.
0 x

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19261
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
Contact:

Re: Compositor with nonlocal render texture and partial viewport

Post by sinbad » Fri Mar 06, 2009 7:30 pm

It's an interesting idea, I think the complication comes from how the viewport parameters are interpreted in the context of chaining compositors together. This needs some thought.

Also note that the compositor's use of textures has had some significant changes in trunk (textures can be shared, held in reserve between technique changes etc), so if you are to prepare a patch please do it against that.
0 x

mcspy0312
Halfling
Posts: 60
Joined: Sun Aug 08, 2004 5:26 pm
Location: Hong Kong, China

Re: Compositor with nonlocal render texture and partial viewport

Post by mcspy0312 » Fri Mar 13, 2009 12:02 pm

It is done.
The features can be used in the following example:

Code: Select all

compositor TextureCompose
{
    technique
    {
        use_global_render_texture yes // compositor will also search in global textures if the render target is not defined locally
        target RTTTex
        {
            // Start with clear output
            input none
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material Examples/OgreLogo
                viewport_dimension 0 0 0.5 0.5 // viewport_dimension left top width height, they are the scaling ratio to the texture size
            }
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material Ogre/Skin
                viewport_dimension 0 0.5 0.5 0.5
            }
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material Examples/BumpyMetal
                viewport_dimension 0.5 0 0.5 0.5
            }
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material Examples/Athene/Basic
                viewport_dimension 0.5 0.5 0.5 0.5
            }
        }
        
        target_output
        {
            // Render output from previous compositor (or original scene)
            input previous
        }
    }
}
The above script composes 4 different textures into a single one and tiling them next to each other.
0 x

User avatar
iloseall
Gremlin
Posts: 156
Joined: Sun Sep 14, 2003 3:54 am
Location: Beijing China
Contact:

Re: Compositor with nonlocal render texture and partial viewport

Post by iloseall » Tue Mar 17, 2009 3:00 pm

I like the feature!Thanks mcspy0312.
Has it been in trunk?

edit:
I got it from the patch system.
0 x

mcspy0312
Halfling
Posts: 60
Joined: Sun Aug 08, 2004 5:26 pm
Location: Hong Kong, China

Re: Compositor with nonlocal render texture and partial viewport

Post by mcspy0312 » Wed Mar 18, 2009 11:18 am

Hi iloseall,
It is good to see my patch is useful. :D
I'm just curious why are you using it?
0 x

User avatar
iloseall
Gremlin
Posts: 156
Joined: Sun Sep 14, 2003 3:54 am
Location: Beijing China
Contact:

Re: Compositor with nonlocal render texture and partial viewport

Post by iloseall » Thu Mar 19, 2009 3:31 pm

My plan:
create a texture(render target) named "DownSamplerDepth"
then downsampler depth target in compositor to it.
I can use the texture in a lot of material do depth sampler for soft particle or just like..

If no the global render target found,I must get the texture name from CompositorInstance and set it to every material in runtime.
0 x

mcspy0312
Halfling
Posts: 60
Joined: Sun Aug 08, 2004 5:26 pm
Location: Hong Kong, China

Re: Compositor with nonlocal render texture and partial viewport

Post by mcspy0312 » Thu Mar 19, 2009 4:19 pm

Hi
I'm using it to do more or less the same thing.
I've updated the patch. With the updated patch, you don't have to create a viewport on the global render texture manually.
0 x

User avatar
iloseall
Gremlin
Posts: 156
Joined: Sun Sep 14, 2003 3:54 am
Location: Beijing China
Contact:

Re: Compositor with nonlocal render texture and partial viewport

Post by iloseall » Thu Apr 30, 2009 8:24 am

I try use the render to global texture feature in my project.
But I got a question: the compositor cound not work with muilt viewport for Use Global Texture.

So I try to find another way to slove "Light entity's Material use compositor_instance's texture(gbuffer)" .
0 x

User avatar
Noman
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 714
Joined: Mon Jan 31, 2005 7:21 pm
Location: Israel
Contact:

Re: Compositor with nonlocal render texture and partial view

Post by Noman » Sat May 15, 2010 4:49 pm

Most of the features this patch added have been added to ogre in different ways. If we want the partial viewport update feature, it needs to be extracted from this patch. Also, documentation needs to be added.

Is there still a request for that feature?
0 x

User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
Contact:

Re: Compositor with nonlocal render texture and partial view

Post by Thieum » Wed Jun 02, 2010 1:04 pm

Yes, It could be useful for me to be able to create several viewports on a compositor target and render compositor passes on each viewport.
The partial viewport feature would also suit me
0 x

Post Reply