Compositor not working with GLES 2.0

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
Post Reply
edhel
Gnoblar
Posts: 5
Joined: Thu Sep 20, 2012 12:18 am

Compositor not working with GLES 2.0

Post by edhel » Sat Jun 01, 2013 2:55 am

Hi,

I have a simple compositor with one intermediate texture.
No matter what I do, the intermediate texture is always blank (black color and zero alpha).

Code: Select all

compositor simpleCompositor
{			
	technique
	{
		texture tex0 1024 1024 PF_R8G8B8A8
		
		target tex0
		{
			input previous			
		}
		
		target_output 
		{
			input none					
					
			pass render_quad
			{
				input 0 tex0
				material simpleMaterial
			}	
		}
	}
} 
I took a look at the render target statistics:
I've added a RenderTargetListener to the intermediate texture:

Code: Select all

mComp = CompositorManager::getSingleton().addCompositor(mViewport,"simpleCompositor");	
Ogre::CompositorManager::getSingleton().setCompositorEnabled(mViewport, "simpleCompositor", true);

RenderTarget * rt = mComp->getRenderTarget("tex0");
mMyListener = new myRenderTargetListener;
rt->addListener(mMyListener);
In the postRenderTargetUpdate event the render target statistics show the correct triangle count so it seems that something is rendered.

I've suspected that maybe worldviewproj_matrix passed to the shaders is not correct, so everything is rendered off screen.
I've added an unprojected quad to the scene (that is always visible independent of the camera position) but It was not rendered to the intermediate texture.

The target_output works correctly but not the intermediate render textures.
0 x

User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
Contact:

Re: Compositor not working with GLES 2.0

Post by masterfalcon » Sat Jun 01, 2013 3:12 am

A little more info might help. What platform? Version of Ogre? Also, what do your material and shaders look like?

I presume that everything renders properly without the compositor enabled?
0 x

edhel
Gnoblar
Posts: 5
Joined: Thu Sep 20, 2012 12:18 am

Re: Compositor not working with GLES 2.0

Post by edhel » Sat Jun 01, 2013 3:59 am

masterfalcon wrote:A little more info might help. What platform?
Android device and Windows (with emulation).
masterfalcon wrote: Version of Ogre?
Pretty recent version of 1.9.
I had to make some changes to the GLES 2.0 RS to get the Windows emulation working.
masterfalcon wrote: Also, what do your material and shaders look like?
The compositor code as above.
The material simply show a texture quad:

simple.material:

Code: Select all

vertex_program simpleVert glsles
{
    source simpleVert.glsles
    profiles glsles
    default_params
    {
        param_named_auto worldViewProj worldviewproj_matrix
    }
}

fragment_program simpleFrag glsles
{
    source simpleFrag.glsles
    profiles glsles 
}


material simpleMaterial
{
    technique 
    {
        pass 
        {
            cull_hardware none
            cull_software none
            depth_func always_pass

            vertex_program_ref simpleVert
            {
            }
			
            fragment_program_ref simpleFrag
            {
                param_named tex int 0
            }		
			
            texture_unit 
            {
                texture debris.png //to be override by compositor texture  
                tex_coord_set 0
                tex_address_mode mirror 
                filtering none 
            }	
        }
    }
} 	
Vertex shader - simpleVert.glsles:

Code: Select all

#version 100
precision mediump int;
precision mediump float;

uniform mat4 worldViewProj;
attribute vec4 vertex;
varying vec2 uv;

void main()
{
    gl_Position = worldViewProj * vertex;
    vec2 inPos = sign(vertex.xy);	
    uv = (vec2(inPos.x, -inPos.y) + 1.0) / 2.0;
}
Fragment shader - simpleFrag.glsles:

Code: Select all

#version 100
precision mediump int;
precision mediump float;

varying vec2 uv;
uniform sampler2D tex;

void main()
{	
    vec4 texColor = texture2D(tex, uv);
    gl_FragColor = texColor;
}
masterfalcon wrote:I presume that everything renders properly without the compositor enabled?
Yes, everything renders correctly without the compositor.
Moreover, the compositor itself works if I don't use the intermediate texture in the target_output (by commenting out input 0 tex0).
0 x

User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
Contact:

Re: Compositor not working with GLES 2.0

Post by masterfalcon » Sat Jun 01, 2013 4:55 am

Ok. First thing that I would try is changing your texture to PF_A8R8G8B8
0 x

edhel
Gnoblar
Posts: 5
Joined: Thu Sep 20, 2012 12:18 am

Re: Compositor not working with GLES 2.0

Post by edhel » Sat Jun 01, 2013 5:18 am

masterfalcon wrote:Ok. First thing that I would try is changing your texture to PF_A8R8G8B8
Tried that, still blank texture.
0 x

User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
Contact:

Re: Compositor not working with GLES 2.0

Post by masterfalcon » Sat Jun 01, 2013 5:30 am

Ok, next idea. The samplers are automatically bound by the compositor system so you can remove "param_named tex int 0". Also, following that, change "texture_unit" to "texture_unit tex". You can also remove the texture line from the texture_unit definition.
0 x

edhel
Gnoblar
Posts: 5
Joined: Thu Sep 20, 2012 12:18 am

Re: Compositor not working with GLES 2.0

Post by edhel » Sat Jun 01, 2013 6:08 am

No, still don't work ...

As far as I can tell all works fine except for the intermediate texture being empty.

Any obvious place to put a breakpoint?
0 x

User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
Contact:

Re: Compositor not working with GLES 2.0

Post by masterfalcon » Sat Jun 01, 2013 6:57 am

Hmm, do the compositors in the sample browser work for you?

When running your code do you get any errors in the log?
0 x

edhel
Gnoblar
Posts: 5
Joined: Thu Sep 20, 2012 12:18 am

Re: Compositor not working with GLES 2.0

Post by edhel » Sun Jun 02, 2013 9:03 pm

masterfalcon wrote:Hmm, do the compositors in the sample browser work for you?
The post process sample crashed the sample browser.

I've finaly got the compositors working on Windows after updating both Ogre and the PowerVR emulator.
As for Android: the updated version of Ogre fail to load, but that's a different story...
0 x

Post Reply