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 »

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.
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:

Re: Compositor with nonlocal render texture and partial viewport

Post by sinbad »

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.
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 »

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.
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 »

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

edit:
I got it from the patch system.
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 »

Hi iloseall,
It is good to see my patch is useful. :D
I'm just curious why are you using it?
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 »

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.
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 »

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.
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 »

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)" .
User avatar
Noman
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 714
Joined: Mon Jan 31, 2005 7:21 pm
Location: Israel
x 2
Contact:

Re: Compositor with nonlocal render texture and partial view

Post by Noman »

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?
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2
Contact:

Re: Compositor with nonlocal render texture and partial view

Post by Thieum »

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