51

(48 replies, posted in General)

Thank you! If you can do so it would be very good.

52

(48 replies, posted in General)

I have found this bug too (GL_COLOR_ATTACHMENT0 + ((int)type - 2);), and fix it,
I also replace

render->bindFrameBuffer(0);

with

unsigned int currentFrameBuffer = 0;
render->getCurrentFrameBuffer(&currentFrameBuffer);
render->bindFrameBuffer(currentFrameBuffer);

but program continue to  run with red/black screen.
I have found that after

    render->texImage(0, [UIScreen mainScreen].bounds.size.width,  [UIScreen mainScreen].bounds.size.height, M_UBYTE, M_DEPTH, 0);

in MyGame:MyGame() call to glGetError() returns 0x500   (1280 in dec), GL_INVALID_ENUM.
I was not able to fix it yet.

If you have a working code of post processing on iOS ,can you post it please?

Also

unsigned int currentFrameBuffer = 0;
render->getCurrentFrameBuffer(&currentFrameBuffer);
render->bindFrameBuffer(currentFrameBuffer);

sets the frame buffer to m_renderBufferId, which is used to render into textures.
I think we need to set

render->bindFrameBuffer(1);

to make it work.

53

(48 replies, posted in General)

I replaced shadow="true" with shadow="false" where it occurs. Nothing changed.
I've tried to add

 render->bindFrameBuffer(1);

in MyGame::draw() before

// draw the rendered textured with a shader effect
    render->setViewport(0, 0, screenWidth, screenHeight);
    render->setClearColor(MVector3(1, 0, 0));
    render->clear(M_BUFFER_COLOR | M_BUFFER_DEPTH);
    
    set2dMode(screenWidth, screenHeight);
    
    render->bindFX(m_fx);
    render->bindTexture(m_colorTextureId);
    drawTexturedQuad(MVector2((float)screenWidth, (float)screenHeight));
    render->bindFX(0);

(1 is a framebuffer that created in ES2Renderer)
Now screen blinks with red/black color every 3-5 seconds (I think, this is due to     render->setClearColor(MVector3(1, 0, 0));
), but no game image appears on screen.
Also there is no message "Failed to make complete framebuffer object 8cdd" when device change its orientation.
Looks like that scene is not drawn into the texture.
I will check  attachFrameBufferTexture now , may be it is not valid/allowed in GL ES or iOS.

54

(48 replies, posted in General)

Ok, I will try

Where should I check for them?

55

(48 replies, posted in General)

I  MyGame::drawTexturedQuad there are lines

int texId = 0;
render->sendUniformInt(m_fx, "Texture", &texId);

Is that right?
Or it must be

int texId = m_colorTextureId;
render->sendUniformInt(m_fx, "Texture", &texId);

?

56

(48 replies, posted in General)

I've changed shader to include #ifdef GL_ES ... and placed

MGame *game = new MyGame();
engine->setGame(game);

after loadMaratisProject.
Also, I set  [UIScreen mainScreen].bounds.size.height and ...width instead of  RESOL macro in MyGame.cpp  :

render->texImage(0, [UIScreen mainScreen].bounds.size.width , [UIScreen mainScreen].bounds.size.height, M_UBYTE, M_RGB, 0);
...
render->texImage(0, [UIScreen mainScreen].bounds.size.width , [UIScreen mainScreen].bounds.size.height, M_UBYTE, M_RGB, 0);
...
render->setViewport(0, 0,  [UIScreen mainScreen].bounds.size.width,  [UIScreen mainScreen].bounds.size.height);

Program runs , there is no errors in console.
Screen remains black.
Program responds on touches - messages like "2012-08-30 10:23:20.941 example[9002:707] Updated Touch 0 at position 651, 259." appears in the console.
I will try to compare code of MGame::draw() and MyGame::draw() and change the latter.
Can you give me a quick tip how to do that correctly?

Also, when I launch program with MyGame, when the device changes its orientation, message
"Failed to make complete framebuffer object 8cdd" appears in the console.
When I launch project with MGame, all works fine and there is no such message

57

(48 replies, posted in General)

Seems like it is my mistake.
I will try to fix it tomorrow.

I'm developing app for iOS with maratis3d.
I made checkout of maratis3d.
I tried to replace MGame object in iOS example project in EAGLView.mm with object of MyGame class from Post Processing example (http://www.maratis3d.com/code/post-process/.).

        game = new MyGame();
//        new MGame();

I ran this project on the device (iPad), and it stops in the debugger in MyGame.cpp with EXC_BAD_ACCESS, because MEngine::getInstance()->getRenderingContext() returns NULL.
I tried to place

  game = new MyGame();
 engine->setGame(game);

after

[self loadMaratisProject:filename];

.
App runs with black screen.
What I'm doing wrong?
How should I replace MGame  with MyGame?

Ok, thanks

anael wrote:

Depth of Field is more complex yes, you need the depth information to blur the image.
I must say it can be very slow on iOS, depend if you target only the last iPhone.

You need to render the scene to a texture with a depth texture like the example :

render->bindFrameBuffer(m_renderBufferId);
render->attachFrameBufferTexture(M_ATTACH_COLOR0, m_colorTextureId);
render->attachFrameBufferTexture(M_ATTACH_DEPTH, m_depthTextureId);

Then you render the texture with a shader like the example, but you also need to pass the depth texture (witch the example doesn't do). The depth texture will be used to specify the blur influence or the blur size.

In realization of DoF that I use blur size stored in alpha component of each fragment
vsh:

precision mediump float;

attribute vec2 a_texcoord;
varying vec2 v_texcoord;

varying float z;

void main(void)
{
    vec4 pos = ModelViewProjectionMatrix * gl_Vertex;

    z               = pos.z;
    v_texcoord = a_texcoord;
    gl_Position     = pos;
}

fsh:

precision mediump float;

uniform sampler2D tex;
uniform float focalDistance, focalRange;

varying float z;
varying vec2 v_texcoord;

void main (void)
{
    float    blur = clamp ( abs ( focalDistance  + z ) / focalRange, 0.0, 1.0 );
    gl_FragColor = vec4 ( texture2D ( tex, v_texcoord ).rgb, blur );
}

This is the first shader, which applied while drawing meshes.

The in last three shaders information in alpha component of pixel is used to make blur.

Ok, thanks
This must be done once, after loading scene?

Thanks!
I want to add post processing Depth of Field effect in my app.
My current realization of that effect consist of 4 shaders.
First shader must be applied when drawing meshes.
Last three shaders must be applied to entire screen image consequentially.
As I realized, I must apply first shader  as you described in post above,
and last three must be applied as you show in Post Process example in http://www.maratis3d.com/code/post-process/.
Is that way right?
Or may be exist more simple and correct way to add this effect to app?

Thank you for very fast reply!
Is there any constraints / limitations in iOS version of Maratis compared to desktop version?
I have noticed that Maratis3D uses scripts somehow. Couldnt that be a reason for rejection in AppStore?
I asked this because there is only one app (as I realized) in App Store that uses maratis3d.
Is there any issues or problems with performance of engine on iOS ?

Sorry for my English, I will try to improve it.

Hello!
I'm developing iOS app that uses maratis3d.
I want to add custom GLSL shader (vertex and fragment) to all my meshes.
How to do this best?
I have my models in 3ds format.
Thank you.

Can I use maratis3d in commercial iOS app?
What licenses/acknowledgements should I include in my app docs or show in app page in AppStore?
Are there any apps in AppStore that use maratis3d?