Re: [PyOpenGL-Users] Instanced rendering of 2D textured quads
Brought to you by:
mcfletch
From: Mike C. F. <mcf...@vr...> - 2013-12-13 14:02:04
|
On 13-12-13 07:50 AM, Robert Kent wrote: > Hi Guys, > > I've been trying to get my head around instanced rendering and > failing. Currently I have the following: You may find the OpenGLContext tutorial here: http://pyopengl.sourceforge.net/context/tutorials/shader_instanced.xhtml helpful. It draws 15,000 spheres with position controlled by a numpy (random) array. That's around 3.3 million textured triangles. It's using the OpenGLContext scenegraph nodes, but those are just very thin wrappers around the various calls to Uniform setup (the scenegraph just automates the bookkeeping of getting everything set up). The only difference you have here is that you want to make the 2D texture a 2-component FBO-based texture (the sample above uses a 3-component jpeg image) and you're rendering far more instances with far fewer faces. > As you can see, this iteratively renders a texture from a frame buffer > object (fbo) on to a quad of fixed size. The only variable here is the > (x,y) position of the quad. I'm guessing that to render this using > glDrawArraysInstanced I'm going to have to load the quad vertices into > one VBO, the position vertices ((x,y) only, no z) into another and use > a shader to apply the texture. I've tried multiple ways of doing this > with result varying from blank windows, screwed up geometry for other > elements, seg faults and machine crashes… all in all not a success! > I'm wondering if anyone has an example of doing this (or can point me > to one). For a position array with x,y but without z you'll likely need to use a Luminance-Alpha texture and you'll have to play around a bit, your sampler likely will give you (l,l,l,a) format values, so you just use .x and .a as your x and y offsets. Hope that helps, Mike -- ________________________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com |