ES 2.0 Multi-Pass & Render to Texture Implementation
iphone, opengl-es-2.0, shader
Solution
I wrote a short example of doing just this (multiple render-to-texture passes on the iPhone using OpenGL ES 2.0) a few weeks ago: http://www.mat.ucsb.edu/a.forbes/blog/?p=245
**
Edit, this post is a bit old, and it has moved here: http://blog.angusforbes.com/openglglsl-render-to-texture/
**
Problem
I need help setting up multi-pass rendering with OpenGL ES 2.0 on the iPhone. I haven't been able to find an example which implements both rendering to a texture and multi-pass shading. I'm looking for some instructions and sample code which implement: - First stage: Render to a texture - Second stage: Input that texture and render to screen I have referenced Apple's OpenGL ES Programming Guide, OpenGL Shading Language (Orange Book), and O'Reilly's iPhone 3D Programming Book. The Orange Book discusses deferred shading and provides two shader programs for first-pass and second-pass rendering, but doesn't provide example code to setup that application or show how to communicate data between both shaders. Questions: - How to render to texture? - Using glDrawElements - How to input that texture to the next pass? - How to implement two shading programs? - How to alternate first- and second-pass shading programs? - Need to attach, detach, and call 'use' for each pass? - How to implement multi-pass shading?