Open GL ES 3.0

I’ve been away a long time, but I just got an iPad pro, so when my keyboard cover arrives I want to get back into it. With the availability of Open GL ES 3.0, what’s the goodness I can start playing with?

Anyone read any good books that gave them a leg up on the new shader capabilities?

Anything it does that Codea doesn’t support?

Thanks

SM

Specifically, I’ve just found this one

https://software.intel.com/en-us/articles/deferred-rendering-for-opengl-es30-on-android

It has code on GitHub, this one

https://gamedevelopment.tutsplus.com/articles/forward-rendering-vs-deferred-rendering--gamedev-12342

has a better description and pictures of the approach…

Basically you do a render first to a color and normal buffer, then do a second pass which applies lighting. This means a scene with multiple lights potentially becomes a lot less expensive to render… Sounds like fun.

For the first pass it needs multiple output buffers linked to the fragment shader

/* Framebuffer */ 
ASSERT_GL(glBindFramebuffer(GL_FRAMEBUFFER, R->gbuffer_framebuffer)); 
ASSERT_GL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, R->gbuffer[0], 0)); 
ASSERT_GL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, R->gbuffer[1], 0)); 
ASSERT_GL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, R->depth_buffer, 0)); 

Can be done with 2 separate passes in an OpenGL ES 2.0 way, but I wonder if Codea lets you bind multiple buffers?

I don’t think Codea supports deferred rendering.

Re GLES 3.0, there’s this thread with experiments with geometry instancing:

https://codea.io/talk/discussion/6991/gles-3-0-instancing-and-other-changes-to-shaders-in-codea-2-3-2

And @MMGames is really pushing the envelope with GLES 3 shaders, the video/ code here is amazing:

https://codea.io/talk/discussion/7672/update-global-illumination#latest

Very interesting thanks.

The issue isn’t deferred rendering, it’s multiple render targets. In MMGames code he is effectively doing deferred lighting very similar to the article I’d read (although his lights are voxel based, but I haven’t delved into that fully yet).

So he first renders mesh color and depth, the second renders the normal. The final pass takes these as textures and lights the scene.

Multiple render targets would mean the first and second renders could be done as a single pass rather than two separate passes.

I’m going to dig into MMGames code more, but broadly that’s what I’m interested in playing with as a first project.

I guess if Codea were to do multiple render targets in the future it’d be an extension to SetContext so you could do for instance,

SetContext(Color, Normal, Depth)

Also, in Codea we don’t have stencils for OpenGL.

@Simeon any thoughts on multiple render targets or stencils in a future version. I know they are fairly niche and probably aren’t interesting to the wider audience…

@spacemonkey I like your overload of setContext. So you give it a bunch of textures, then the output locations would have to be specified in your fragment shader, is that right?

@Simeon Exactly, so the example was from an android OpenGL ES 3.0 code base, but effectively in the C++ end of things they are doing:

/* Framebuffer */ 
ASSERT_GL(glBindFramebuffer(GL_FRAMEBUFFER, R->gbuffer_framebuffer)); 
ASSERT_GL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, R->gbuffer[0], 0)); 
ASSERT_GL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, R->gbuffer[1], 0)); 
ASSERT_GL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, R->depth_buffer, 0)); 

I assume right now if you set context with a depth buffer you are doing the 1st and 3rd Attachment call or something similar. If the overload of set context attached multiple buffers in some OpenGL way similar to this (but IOS of course) then in the fragment shader you can do

/** GBuffer format 
     *  [0] RGB: Albedo 
     *  [1] RGB: VS Normal 
     *  [2] R: Depth 
     */ 
gl_FragData[0] = vec4(albedo, 1.0); 
gl_FragData[1] = encode(normal); 

Where you are explicitly saying which render target the result goes to with fl_FragData[X] and presumably the depth buffer gets done automatically by OpenGL.

In fact for apple flavor see this article, it has a section specifically on multiple render targets and how you do it in the fragment which is a slightly newer syntax than my example above.
https://developer.apple.com/library/content/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/OpenGLESApplicationDesign/OpenGLESApplicationDesign.html

Even guccier would be if you also allowed us to receive the depth buffer as an image rather than it just being a flag for depth buffer on/off…

For learning OpenGL ES 3.0 I recommend this book <OpenGL ES 3.0 Programming Guide> which I have bought one, maybe it will be useful to you.

@binaryblues Did you miss dropping in a URL to the book?

Oh, I used a symbol, it make the book disappear, it is “OpenGL ES 3.0 Programming Guide”

I found this link for the OpenGL ES 3.0 Programming Guide Second Edition book.

http://1.droppdf.com/files/v4voM/addison-wesley-opengl-es-3-0-programming-guide-2nd-2014.pdf