Hi Josh,
Nice work, if a bit different from how the batches and groups are currently
used within pyglet.
I was looking over your code, and thinking about your texture atlases
implementation. The current sprite groups are combined if possible if they
share the same textures, so I was thinking about how to utilize this with
your implementation.
I've also been reading up on different "order independent translucency"
techniques, and realized that my quick zsprite hack does already do basic
translucency correctly if you simply make sure to render all of the solid
or simple transparent (1/0) textures first. This can easily be done by
using the existing OrderedGroups, but putting all "solid" textures in one
group, and all textues that need translucency in another. So basically, two
OrderedGroups for all sprites. For example:
solid = pyglet.graphics.OrderedGroup(0)
translucent = pyglet.graphics.OrderedGroup(1)
pyglet_image = pyglet.image.load("examples/pyglet.png")
spritea = pyglet.sprite.Sprite(img=pyglet_image, x=120, y=150, z=3,
batch=batch, group=translucent)
spriteb = pyglet.sprite.Sprite(img=pyglet_image, x=140, y=170, z=2,
batch=batch, group=translucent)
spritec = pyglet.sprite.Sprite(img=pyglet_image, x=160, y=190, z=1,
batch=batch, group=solid)
sprited = pyglet.sprite.Sprite(img=pyglet_image, x=180, y=210, z=0,
batch=batch, group=solid)
spritea.opacity = 200
spriteb.opacity = 200
This all works as expected, with the normal blending quirks. I wonder if
this might be enough? It wouldn't be hard to tweak the SpriteGroup more so
that Sprite.opacity == 0 sprites are automatically in one group, and
sprites with non-0 opacity values are in another.
On Monday, October 24, 2016 at 9:54:24 AM UTC+9, Josh wrote:
>
> Got up to the initial test working. Animations are NOT supported right
> now. Batches are not supported and there's really no point in supporting
> them with this pipeline. The basic method for rendering sprites that you
> want to have sorted is:
>
> group = pyglet.sprite.DepthSpriteGroup(2048, 2048) #the size of the
> texture atlas
> #load some image as img
> my_sprites = [pyglet.sprite.DepthSprite(img, group, x=i*10) for i in range
> (10)]
> window = pyglet.window.Window(500, 500)
> @window.event
> def on_draw():
> window.clear()
> group.draw()
>
> Note that sprites are bound to their group, and can't be migrated between
> groups. Each sprite has a depth attribute that controls rendering order.
> There is a self-contained test depth_sprite_test.py. Appreciate anyone who
> who can give it a shot!
>
> - Josh
>
> On Sunday, October 23, 2016 at 5:49:23 PM UTC-5, Josh wrote:
>>
>> Hi, sorry I've been out of the loop a few days. I put the fork on
>> bitbucket, https://bitbucket.org/clockmarket/zsprites
>>
>> On Friday, October 21, 2016 at 3:43:14 AM UTC-5, Benjamin Moran wrote:
>>>
>>> If it's a public fork, it works be great if you could share the link.
>>
>>
--
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 https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.