Re: Fullscreen shaders and effects.

I updated MyGame example here : http://www.maratis3d.com/code/post-process/
It normally works cross-platform this time, I tested on iOS simulator.

Re: Fullscreen shaders and effects.

I got gray and black image (like stones or wall texture) both on Simulator and on the device.
I will try now to look whats wrong and debug opengl.

Last edited by Petr (2012-08-31 08:42:34)

Re: Fullscreen shaders and effects.

strange, it works good for me,
did your previous modifications merge with mine ? Maybe try to restart from fresh with the svn version ?

Re: Fullscreen shaders and effects.

I made checkout from svn and add last MyGame.h/.cpp,
and move

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

after

[self loadMaratisProject:filename];

What version of Simulator/Device you use?

Last edited by Petr (2012-08-31 11:09:28)

Re: Fullscreen shaders and effects.

I've got OpenGL error 0x500 in MyGame::MyGame() in

render->texImage(0, RESOL, RESOL, M_UBYTE, M_DEPTH, 0);

Also I've got OpenGL error  0x506  in MyGame::draw() in

render->clear(M_BUFFER_COLOR | M_BUFFER_DEPTH);

in if(camera) ..    block.
   
Also I've got 0x506 in  MyGame::draw()          scene->draw(camera);  in

glDrawElements(returnPrimitiveType(type), size, returnGLType(indicesType), indices);

Last edited by Petr (2012-08-31 12:00:50)

Re: Fullscreen shaders and effects.

last two errors occurs on each frame

I think there is some errors in creation of depth attachment texture in my project.
I will try to research this now.

Last edited by Petr (2012-08-31 12:05:30)

Re: Fullscreen shaders and effects.

I used simulator 4.3.

The errors looks like opengl is not initialized properly, something different to do with the more recent os ?

Re: Fullscreen shaders and effects.

I installed Simulator 4.3, and program runs ok on it, without gl errors.
Before that, I ran the program on simulator 5.1

Re: Fullscreen shaders and effects.

anael wrote:

I used simulator 4.3.

The errors looks like opengl is not initialized properly, something different to do with the more recent os ?

Looks like so.

I will try to run program on 4.* devices, and on Simulator 5.0 (when I download it).
I will try to google that.

Last edited by Petr (2012-08-31 12:52:06)

Re: Fullscreen shaders and effects.

thanks

Re: Fullscreen shaders and effects.

On 4.3 devices all is ok.
On iPhone 4 (with retina display) image occupies a quarter of the screen (I think I must set contentScalFactor somewhere)

Re: Fullscreen shaders and effects.

On iOS 5.* I also get 0x8cdd (GL_FRAMEBUFFER_UNSUPPORTED) in glCheckFramebufferStatus(GL_FRAMEBUFFER)  in

- (BOOL) resizeFromLayer:(CAEAGLLayer *)layer;

in ES2Renderer.mm.

Re: Fullscreen shaders and effects.

I not found the error for now.
I tried to compare initialization code in maratis ios project with initialization code in Cocos2D v 2.0.
In Cocos2d 2.0 init and creation of ramebuffer (with depth attachment) is ok both on 4.* and on 5.*.
Code in both projects looks equally, but in maratis I still have " Failed to make complete framebuffer object 8cdd" in glCheckFramebufferStatus(GL_FRAMEBUFFER).
I think that reason may be in maratis 3d code, which executed between calls to [ES2Renderer init] and [ES2Renderer resizeFromLayer:]
I will try to find it now.

Re: Fullscreen shaders and effects.

I've found that
glCheckFramebufferStatus(GL_FRAMEBUFFER)  returns error after

glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer);
[context renderbufferStorage:GL_RENDERBUFFER fromDrawable:layer];


in resizeFromLayer: in ES2Renderer.

Re: Fullscreen shaders and effects.

I add       glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer);    at start of the resizeFromLayer:  , and buffers are created  on 5.*
Now I have to deal with  0x500 in        render->texImage(0, RESOL, RESOL, M_UBYTE, M_DEPTH, 0); in MyGame.

Re: Fullscreen shaders and effects.

I change M_UBYTE  to M_UINT
render->texImage(0, RESOL, RESOL, M_UBYTE, M_DEPTH, 0); , and program began to work.
Now project works on 4.3.3 and 5.1 devices, and on simulator.
On Retina display, image takes only quarter of screen.
I will fix this now, and then I'll start to add Depth of Field to this app

Re: Fullscreen shaders and effects.

Hi,

well done, thanks,
that's a bit strange they changed the support of this,
so it will also need to be changed in MiOSStandardRenderer.cpp for the shadow texture

Re: Fullscreen shaders and effects.

Ok
For retina support I added   
self.contentScaleFactor  = [UIScreen mainScreen].scale;
  in  initRenderingContext in EAGLView,

#define SCREEN_WIDTH ( [UIScreen mainScreen].bounds.size.width * [UIScreen mainScreen].scale)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height * [UIScreen mainScreen].scale)
to MyGame , and change all occurrences of screenWidth/ screenHeight and RESOL macro with these macroses.
Its now works on Retina.

I've also found a bug on iPad 1 with iOS 4.3.3, where short after launches program crashes with EXC_BAD_ACCESS.
I will deploy my app on 5.* and newer firmwares, so I leave this bug for now.

Re: Fullscreen shaders and effects.

Nice, thanks,
I'll try to modify all examples to use M_UINT to be cross platform.

Re: Fullscreen shaders and effects.

I added post-process DoF to iOS example.

Re: Fullscreen shaders and effects.

Cool ! can we see a screenshot ? smile
how is the performance ?

Re: Fullscreen shaders and effects.

DoF screenshot

About performance - what is the best way to display FPS on screen?
I want to see it during development of my app.
Other statistics are also useful.

Re: Fullscreen shaders and effects.

To draw text on top of your game you can use a text object (MOText) in a separate scene.

In cpp like this : http://www.maratis3d.org/?p=563
Or in script (it's a new feature) : http://wiki.maratis3d.org/index.php?tit … ameraLayer

Re: Fullscreen shaders and effects.

Thanks!
From which object should I obtain the current FPS?

About post-processing:
Since I used  SCREEN_WIDTH * SCREEN_HEIGHT  (768 * 1204 on iPad , 640*960 on  Retina iPhone )  as texture dimensions, I added

render->setTextureUWrapMode(M_WRAP_CLAMP);
render->setTextureVWrapMode(M_WRAP_CLAMP);

in

render->createTexture(&m_depthTextureId);
render->bindTexture(m_depthTextureId);
render->setTextureFilterMode(M_TEX_FILTER_NEAREST, M_TEX_FILTER_NEAREST);
render->texImage(0, SCREEN_WIDTH, SCREEN_HEIGHT, M_UINT, M_DEPTH, 0);

after render->bindTexture(m_depthTextureId);