aoikonom
09-08-2012 12:56:23
I am trying to use MyGUI with OgreGLES2RenderSystem in an Ogre3d4Marmalade (an Ogre fork for the Marmalade framework).
At first it did not work because MyGUI does not bind any gpu program. Then following instructions from another thread
http://www.ogre3d.org/forums/viewtopic.php?f=21&t=63824 I used the suggested simple verted/fragment shader programs, and now MyGUI works.
Problem is that text is drawn white, while I want multi-coloured text (some portions red, other white, etc).
I guess the problem is that _setTextureBlendMode is not supported in OgreGLES2RenderSystem. Maybe I should write a more sophisticated vertex/fragment program but I'm not sure how to do so.
My current vertex/fragment programs :
vertex
#version 100
precision mediump int;
precision mediump float;
attribute vec4 position;
attribute vec4 uv0;
varying vec4 outUV0;
/*
Basic texturing vertex program for GLSL ES
*/
void main()
{
gl_Position = position;
outUV0 = uv0;
}
fragment
#version 100
precision mediump int;
precision mediump float;
uniform sampler2D sampler;
varying vec4 outUV0;
/*
Basic texturing fragment program for GLSL ES
*/
void main()
{
gl_FragColor = texture2D(sampler, outUV0.xy) ;
}
Any ideas?
scrawl
11-08-2012 16:08:55
Just a guess: Maybe the font coloring in MyGUI uses vertex colors? Vertex colors are not handled in your shader..
scrawl
11-08-2012 16:16:00
I was bored so here's the same shader as yours but with vertex colors, haven't tested but should be fine:
#version 100
precision mediump int;
precision mediump float;
attribute vec4 position;
attribute vec4 uv0;
attribute vec4 colour;
varying vec4 outUV0;
varying vec4 outColour;
/*
Basic texturing vertex program for GLSL ES
*/
void main()
{
gl_Position = position;
outUV0 = uv0;
outColour = colour;
}
#version 100
precision mediump int;
precision mediump float;
uniform sampler2D sampler;
varying vec4 outUV0;
varying vec4 outColour;
/*
Basic texturing fragment program for GLSL ES
*/
void main()
{
gl_FragColor = texture2D(sampler, outUV0.xy) * outColour;
}
simed
03-09-2012 22:12:40
@aoikonom I don't know much about these things but am also working towards MyGUI in GLES2 (for iOS). I'm confused, doesn't using the RTSS mean you can avoid creating these shaders manually?
Altren
04-09-2012 01:33:59
I consulted one guy not so long ago about MyGUI and OpenGL ES and we succeeded on creating render for Android an iOS. He said, that public sources will be ready in next weekend.
wangdy
19-07-2013 18:54:16
attribute vec3 a_position;
attribute vec4 a_color;
attribute vec2 a_texCoord;
uniform mat4 u_MVPMatrix;
varying lowp vec4 v_fragmentColor;
varying mediump vec2 v_texCoord;
void main()
{
gl_Position = (vec4(a_position,1));
v_fragmentColor = a_color;
v_texCoord = a_texCoord;
}
precision lowp float;
varying vec4 v_fragmentColor;
varying vec2 v_texCoord;
uniform sampler2D u_texture;
void main(void) {
gl_FragColor = texture2D(u_texture, v_texCoord);
}
oscar
16-09-2013 18:07:52
I consulted one guy not so long ago about MyGUI and OpenGL ES and we succeeded on creating render for Android an iOS. He said, that public sources will be ready in next weekend.
I'm very interested on this! I've started the same adventure for myself, but if this is already done... I could help on it, instead of doing it again. Where are those expected sources?
aoikonom
18-11-2013 22:03:32
This one worked for me
Add this to
MyGUI_OgreRenderManager.h
Ogre::HighLevelGpuProgramPtr vertProg; Ogre::HighLevelGpuProgramPtr fragProg;
Load shaders in MyGUIOgrePlatform\src\MyGUI_OgreRenderManager.cpp in
void OgreRenderManager::initialise
vertProg = Ogre::HighLevelGpuProgramManager::getSingleton().createProgram("MGuiVP", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
"glsles",
Ogre::GPT_VERTEX_PROGRAM);
vertProg->setSourceFile( "MyGuiVP.glsles" );
vertProg->load();
fragProg = Ogre::HighLevelGpuProgramManager::getSingleton().createProgram("MyGuiFP",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
"glsles",
Ogre::GPT_FRAGMENT_PROGRAM);
fragProg->setSourceFile( "MyGuiFP.glsles" );
fragProg->load();
Add the following shaders to your resources
MyGuiVP.glsles
#version 100
precision highp int;
precision highp float;
attribute vec4 position;
attribute vec4 uv0;
attribute vec4 colour;
varying vec4 outUV0;
varying vec4 outColor;
/*
Basic texturing vertex program for GLSL ES
*/
void main()
{
gl_Position = position;
outUV0 = uv0;
outColor = colour;
}
MyGuiFP.glsles
#version 100
precision highp int;
precision highp float;
uniform sampler2D sampler;
varying vec4 outUV0;
varying vec4 outColor;
/*
Basic texturing fragment program for GLSL ES
*/
void main()
{
vec4 cl = outColor;
vec4 tc = texture2D(sampler, outUV0.xy) ;
vec4 fc = outColor * tc;
gl_FragColor = fc;
}
in
void OgreRenderManager::prepareForRender(Ogre::RenderSystem* rs) comment out the following lines
rs->unbindGpuProgram(Ogre::GPT_FRAGMENT_PROGRAM); rs->unbindGpuProgram(Ogre::GPT_VERTEX_PROGRAM);
and add the following instead
rs->bindGpuProgram( vertProg->_getBindingDelegate() );
rs->bindGpuProgram( fragProg->_getBindingDelegate() );