I'm glad that my branch was at least a little useful. 

Just for future reference in case others come across this thread, there is 
an OpenGL wiki page here that has an overview of the "problem": 
https://www.opengl.org/wiki/Transparency_Sorting



On Wednesday, October 19, 2016 at 6:41:58 AM UTC+9, Charles wrote:
>
> I apologize for the delay, I didn't really check back here after there 
> wasn't much activity for a few weeks and figured I wouldn't be able to do 
> what I needed.
>
> Thanks for taking the time to test this! I did not realize the sprite 
> group resets things as well. I did try it and it does seem a lot better 
> than what I had implemented. However, the same alpha issues do arise; some 
> things on the same z level will have proper alpha while other objects may 
> not. I did have to change to 0.1 instead of 0.5 for it to even show up at 
> all. I suspect this might be part of the opacity stuff you were talking 
> about. 
>
> On Friday, September 30, 2016 at 9:30:19 AM UTC-5, Benjamin Moran wrote:
>>
>> Hi Charles,
>>
>> I have a zsprite branch (that probably has the same changes that you've 
>> already made) that can be found here: 
>> https://bitbucket.org/treehousegames/pyglet/branch/z_sprite
>>
>> The OpenGL blending/code you posted looks fine,  but it might be getting 
>> overridden by the SpriteGroup (pyglet.sprite.SpriteGroup) . My branch is 
>> not yet complete, but I've also modified the SpriteGroup class so that it's 
>> at least working OK for me. it only works right for simple 
>> transparent/solid alpha (not opacity), but it does render all sprites in 
>> the correct z order. Give it a try and see if it works for you.  The z 
>> scale is set to be from -255 to 255. 
>>
>> I will probably fix the opacity stuff at some point...
>>
>>
>>
>> On Thursday, September 1, 2016 at 8:28:43 AM UTC+9, Charles wrote:
>>>
>>> I am using a standard blending of GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA. 
>>> Here is an example of what doesn't work:
>>>
>>> import pyglet, random
>>> from pyglet.gl import *
>>>
>>> window = pyglet.window.Window(800,600, vsync=False)
>>>
>>> fps = pyglet.clock.ClockDisplay()
>>>
>>> groups = []
>>> group = pyglet.graphics.Group()
>>>
>>> tileImages = [pyglet.image.load("tile_test.png")]
>>>         
>>> batch = pyglet.graphics.Batch()
>>>
>>> fadedImage = pyglet.image.load("wide-shadow-faded.png").get_texture()
>>> playerImage = pyglet.image.load("player.png").get_texture()
>>> treeImage = pyglet.image.load("tree.png").get_texture()
>>>
>>>
>>> glEnable(GL_DEPTH_TEST)
>>> glEnable(GL_BLEND)
>>> glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
>>> glAlphaFunc ( GL_GREATER, 0.1 ) ;
>>> glEnable ( GL_ALPHA_TEST ) ;
>>>
>>> tiles = []
>>> for i in range(40):
>>>     for j in range(40):
>>>         tile = pyglet.sprite.Sprite(random.choice(tileImages), 
>>> batch=batch, x=i*24, y=j*24, usage='static', group=group, subpixel=True)
>>>         tiles.append(tile)
>>>     
>>> print len(tiles)
>>>
>>>
>>> player = pyglet.sprite.Sprite(playerImage, batch=batch, group=group, 
>>> x=10, y=10, z=0.3, subpixel=True)
>>>
>>> tree = pyglet.sprite.Sprite(treeImage, batch=batch, group=group, x=30, 
>>> y=30, z=0.5, subpixel=True)
>>>
>>> fadedSprite = pyglet.sprite.Sprite(fadedImage, batch=batch, group=group, 
>>> x=100, y=100, z=0.5, subpixel=True)
>>>
>>>
>>> @window.event
>>> def on_draw():
>>>     window.dispatch_events()
>>>     window.clear()
>>>     batch.draw()
>>>     fps.draw()
>>>     
>>> pyglet.app.run()
>>>     
>>>
>>>
>>> The 'fadedImage' is basically just any image that has pixels of alpha 
>>> between 0 and 1 like a fade. If you take out the player and sprite, it may 
>>> sometimes show up properly, but if you reload it may change to all black, 
>>> it's never consistent.
>>>
>>>
>>> On Tuesday, August 30, 2016 at 11:53:29 PM UTC-5, magu...@gmail.com 
>>> wrote:
>>>>
>>>> In what way are you blending objects? The source of that issue could be 
>>>> a number of things, could you provide a working example? Generally you 
>>>> should only have to update each visible objects vertices and Z axis every 
>>>> update cycle.
>>>>
>>>> Also, you can increase the depth range of the Z axis by setting up a 
>>>> custom config:
>>>>
>>>> config = Config(sample_buffers=1, samples=4, depth_size=1000, 
>>>> double_buffer=True)
>>>>
>>>> class Example(pyglet.window.Window):
>>>>     def __init__(self):
>>>>         super(Example, self).__init__(640, 480, resizable=True, 
>>>> fullscreen=False, caption="Example", config=config)
>>>>
>>>>
>>>>

-- 
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 pyglet-users+unsubscr...@googlegroups.com.
To post to this group, send email to pyglet-users@googlegroups.com.
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to