Login Action Required

The NinevehGL Forum uses a new concept of "socialized forum" or as we like to say "Tweet Forum".


Here is the deal:
  1. No new registration is required. Just sign in with your Twitter account and authorize the NinevehGL Forum.
  2. Once you’re in, you'll be able to "Follow a Thread", that means every time that thread receive a new post or update you'll receive a mention on your twitter.
  3. Besides, you can enable "Auto Share", then every new post and/or thread you make will be tweeted on your timeline. (By default, auto-share is enabled only for your threads)

Forum Rules:

1. We understand human comunication can become "hot" sometimes. So some insults and bad words ARE allowed. Just don't push too much being an asshole all the time.

2. SPAMMERS are not allowed. There are penalties for this kind of user and they can be banned forever.

3. You can report other users, if you judge necessary. An user reported many times by many people can also be banned forever. However you can also receive penalties for report deliberately for no apparent reason.

If there is a similar thread title, make sure the other one doesn't already have the answer you're looking for.

This forum uses the BBCode (Bulletin Board Code), here are some instructions:

Bold: [b]text[/b]
Italic: [i]text[/i]
Underline: [u]text[/u]

Code: [code]text[/code]
Quote:
[quote=@username]text[/quote]
[quote]text[/quote]

List:
[ul] [*]item [/ul]
[ol] [*]item [/ol]

URL:
[url]http://url.com[/url]
[url=http://url.com]text[/url]

Image:
[img]http://imageurl.com[/img]

Embed (videos, code, 3D):
[embed]http://url.com[/embed]

Welcome to the NinevehGL's world!
NinevehGL is a 3D engine forged with pure Obj-C.
Welcome to the
Forum!
Hello, Guest.

Your current vote:

You can change your vote many times. But it's still one single vote.

Depth of field realization in NinevehGL
Vote this thread:


@PetrBodnar

Posts: 17

NGLNewbie

Mon, Aug 27 2012


I want to use depth of field effect realtime effect in my app.
Realization of this effect that I want to use consists of 4 shader programs.
Here is a link to that realization ( the article is on Russian , but I think the code is clear):
http://steps3d.narod.ru/tutorials/depth-of-field-tutorial.html
There is an algorithm for applying this effect:

void display() {
program1.bind ();
program1.setUniformFloat ( "focalDistance", focalDistance );
program1.setUniformFloat ( "focalRange", focalRange );
camera.apply ();

displayBoxes ();

program1.unbind ();
buffer.unbind ( true );

glBindTexture ( GL_TEXTURE_2D, buffer.getColorBuffer () );

program2.bind ();
buffer2.bind ();
startOrtho ( 512/4, 512/4 );
drawQuad ( 512/4, 512/4 );
endOrtho ();
buffer2.unbind ( true );
program2.unbind ();

glBindTexture ( GL_TEXTURE_2D, buffer2.getColorBuffer () );

blur.bind ();
buffer3.bind ();
startOrtho ( 512/4, 512/4 );
drawQuad ( 512/4, 512/4 );
endOrtho ();
buffer3.unbind ( true );
blur.unbind ();

glActiveTextureARB ( GL_TEXTURE1_ARB );
glBindTexture ( GL_TEXTURE_2D, buffer2.getColorBuffer () );

glActiveTextureARB ( GL_TEXTURE0_ARB );
glBindTexture ( GL_TEXTURE_2D, buffer.getColorBuffer () );

program3.bind ();
program3.setUniformFloat ( "radiusScale", radiusScale );
startOrtho ( 512, 512 );
drawQuad ( 512, 512 );
endOrtho ();
program3.unbind ();

glutSwapBuffers ();
}

First three renders render offscreen (each use its own shader program), and the last fourth render - renders onscreen (using the last program).
Can I do this in NinevehGL?
That is, on each frame in
-(void) drawView {
[_camera drawCamera];
}
renders to texture , than apply other programs to that texture, and then render final image to screen?
Is that way correct?
Are there more appropriate ways of realization real-time depth of field effect?
0% like this - 0/0

@PetrBodnar

Posts: 17

NGLNewbie

Tue, Aug 28 2012


There is an articke s and similar code examples in English:
http://encelo.netsons.org/programming/opengl/
The code is in GL3_parallax_DoF section.
0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Tue, Aug 28 2012


In response to: @PetrBodnar

Unfortunately NinevehGL just make render of objects, so you can't create an abstract render without object.

You can use OpenGL outside NinevehGL contexts. You can use the "drawTo..." methods to get a snapshot from the current frame.
0% like this - 0/0

@PetrBodnar

Posts: 17

NGLNewbie

Tue, Aug 28 2012


In response to: @dineybomfim

Thank you for very fast reply!
You wrote
"You can use OpenGL outside NinevehGL contexts."
I'm totally new to OpenGL, can you explain this a little more?
0% like this - 0/0

@PetrBodnar

Posts: 17

NGLNewbie

Tue, Aug 28 2012


May be you know some realization of depth of field effect that can be used with NinevehGL?
I would be very grateful if you point me to such solution.
0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Tue, Aug 28 2012


In response to: @PetrBodnar

Well buddy,

This is the main reason we created NinevehGL... there are so many things you must write just to render a simple plane on the screen that it doesn't worth.

I can't describe everything you need here, but the point is that you can create another context and starting doing your own stuff.
0% like this - 0/0

@PetrBodnar

Posts: 17

NGLNewbie

Wed, Aug 29 2012


In response to: @dineybomfim

Ok, thanks.

If somebody knows a solution for realizing Depth of Field effect in NinevehGL, please post it in this thread!
0% like this - 0/0

@sooonism

Posts: 4

NGLNewbie

Fri, Nov 2 2012


In response to: @PetrBodnar

Hi,
Not sure how useful is this, but please check out this link:

http://devmaster.net/posts/3021/shader-effects-depth-of-field

in this site there are quite a lot of shader related articles.

Have fun!
0% like this - 0/0
Technology

NinevehGL is a 3D engine built right on top of OpenGL ES and it uses all the programmable pipeline power, making it easy for you to create great application with shaders.

Share on


Follow NinevehGL
Fastest way to contact us:

Copyright © 2011 db-in. All rights reserved.