ES 2.0 Multi-Pass & Render for Texture Implementation

I need help setting up multi-pass rendering from OpenGL ES 2.0 to iPhone. I could not find an example that implements both rendering for texture and multi-pass shading.

I am looking for some instructions and sample code that implement:

  • Stage one: texture rendering
  • Second stage: entering texture and rendering on the screen

I refer to the Apple OpenGL ES Programming Guide , OpenGL Shading Language (Orange Book) and the 3D O'Reilly Programming Book for iPhone.

The orange book discusses deferred shading and provides two shader programs for rendering the first and second passes, but does not provide sample code to configure this application or shows how to transfer data between both shaders.

Questions:

  • How to render a texture?
    • Using glDrawElements
    • How to introduce this texture in the next pass?
  • How to implement two shading programs?
  • How to alternate the hatching programs of the first and second pass?
    • Need to attach, disconnect and call “use” for each pass?
  • How to implement multi-pass shading?
+7
iphone shader
source share
2 answers

I wrote a short example of how to do this (a few walkthroughs on the iPhone through OpenGL ES 2.0) a few weeks ago: http://www.mat.ucsb.edu/a.forbes/blog/?p=245

**

Edit, this post is a little old, and it has moved here: http://blog.angusforbes.com/openglglsl-render-to-texture/

**

+4
source share

Well, first of all: I'm not an expert on OpenGL ES 2.0. I was in the same situation when I wanted to do a multi-pass rendering setup in one of my first OpenGL ES applications.

I also used an orange book. Check out Chapter 12. Framebuffer Objects> Examples. The first example demonstrates how to use the framebuffer to render a texture, and then draws that texture for display.

Basically, using this example, I created an application that renders some texture geometry using the shader effect, then displays this texture for display, overlays other content using a different shader.

I am not sure if this is the best approach, but it works for my purposes. My setup:

  • I create two framebuffers, the default and off-screen. Same thing for rendering buffers
  • I create a texture that the application will display for
  • I bind an external framebuffer and attach a texture to it using glFramebufferTexture2D

My rendering:

  • binds an external framebuffer.
  • use my first shader program
  • draw my geometry
  • binds default framebuffer
  • use my second shader program
  • draw a full-screen quad-core processor with a texture attached to it.
+3
source share

All Articles