If you generate the random offset in the shader the only other thing you 
need to know is what to rotate the vertex about which means you need one 
extra vertex per vertex but that should be static if all the rectangles 
do is rotate about their centre.

On Saturday 26 September 2015 09:37:09 Joe Cross wrote:
> I'll see what I can find on vertex shaders.
> 
> Won't I still have to update the vertex buffer every time I update the
> rotation, per rectangle?  The only change is instead of recomputing
> buffer.vertices, I'm pushing new values for buffer[0g4f] (or
> something, I'm guessing here for a quaternion).  And I'd also be
> sending that quaternion per-vertex, since I can't use the same one
> for the whole buffer.  That doesn't seem like a huge savings.
> 
> If I rename Rectangle to Particle that's more or less where we're at,
> I think.  Is the next step to let the Particle class handle flushing
> a set of changes to the vertex buffer after updating each particle's
> rotation, instead of pushing the change to the buffer immediately?
> 
> On Sat, Sep 26, 2015 at 4:37 AM, Adam Bark <[email protected]> 
wrote:
> > On Friday 25 Sep 2015 15:51:43 Joe Cross wrote:
> > > I'm trying to render shapes efficiently in batches, but so far
> > > have
> > > run into some issues.
> > > 
> > >    - Using GL_TRIANGLE_FAN for rendering a circle breaks when
> > >    those
> > > 
> > > circles are batched together (bitbucket issue)
> > > 
> > >    <https://bitbucket.org/pyglet/pyglet/issues/64> (github code)
> > > 
> > > <https://github.com/numberoverzero/cells/blob/7989ed1a5af0199bf8df
> > > 96f
> > > 7293792f2ad127452/shapes.py#L72> .
> > > 
> > >    - Rotating individual rectangles when they're batched together
> > > 
> > > (github code)
> > > 
> > > <https://github.com/numberoverzero/cells/blob/7989ed1a5af0199bf8df
> > > 96f
> > > 7293792f2ad127452/shapes.py#L142> .
> > > 
> > > I'm working on a few ideas for the first (primarily, a new
> > > allocator
> > > that can toggle [or mark blocks ineligible for] merging/extending
> > > for
> > > adjacent alloc/realloc).  However, what is the recommended way to
> > > handle the latter case?
> > > 
> > > 
> > > The docs suggest I should batch triangles together for
> > > performance, so I'm creating all of my Rectangle instances with
> > > GL_TRIANGLE_STRIP (including degenerate vertices) in the same
> > > batch.  How then do I handle rotating each rectangle
> > > individually?  Let's say that I have 500 rectangles, all
> > > adjusting their rotation by a small random amount every 1/60 of a
> > > sec.  Is my only choice to re-calculate the vertices and bake the
> > > rotation in?  I'd love to use glRotatef or something, but that
> > > will apply a single rotation to all of my rectangles.
> > > 
> > > 
> > > This can't be a new problem.  Am I missing something obvious?
> > > 
> > > Right now I'm testing with this script
> > > <https://github.com/numberoverzero/cells/blob/7989ed1a5af0199bf8df
> > > 96f7 293792f2ad127452/main.py> which generates a bunch of
> > > rectangles and rotates them all whenever the mouse is
> > > clicked/dragged.  I'd expect the framerate to stay higher than
> > > the 30-40 I'm getting for 341 rectangles (2046 verts).
> > > 
> > > 
> > > python -O main.py
> > > 
> > > Python 3.5.0
> > > 
> > > Ubuntu 14.04 LTS on VMware Workstation 12.0.0 build-2985596
> > > (unlicensed) on Win7 SP1
> > 
> > I think you should do the rotations in a vertex shader but you will
> > have to pass the rotation centre of each vertex to the shader.
> > Write back if you need more help with how to implement that.
> > 


-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to