Thanks for your ever precious help claudio ! I'll give shaders a go... Hope it doesn't prove too hard for me.
I tried your ColorLayer approach, which gave good results visually, but the performance hit drove me away from it (I used 10+ Layers), and I went back to modifying every sprites' vertex_list's colors. The good thing is that there is no performance hit once the update is done. The problem is the update can become a bit slow (the blackness is refreshed with user input) when I have many sprites on many batches. For now I'll stick to this solution, but I'll look into shaders too. thanks again Le samedi 2 novembre 2013 22:06:09 UTC+1, Claudio Canepa a écrit : > > > > > On Fri, Nov 1, 2013 at 7:46 PM, Nitneroc <[email protected]<javascript:> > > wrote: > >> Hi everyone, >> >> I'm a total newbie with pyglet and openGL, but I'd like to know if it's >> possible to add an effect (shader, opacity, or anything) to a whole batch. >> Could it be something as easy as modifying a bit the batch visit function ? >> >> What I'd love would be to make a fog, that would darken the lowest >> batches but leave the top batch unchanged. I could change the color >> attribute of every sprite in the batch, but that seems tedious and shaders >> would be much funnier... >> > > > Maybe > > - You must define a group for each batch, > - the group' s set_state should bind the shader program and send > the uniforms required by the shader (probably an opacity or blackness value) > - the group' s unset_state should unbind your program > - if needed, bind and unbind of textures, set and unset blend mode > > - you must write the shader(s) code > > The core of this feature is knowledge about openGL shaders: If you have > that, the thing is easy, if not you are headed to invest a considerable > amount of time learning shaders. > > You could explore alternative ways to darken lower batches; methods would > depend on exactly what you need to draw. > > By example, if the batches draws the k most far layers of terrain, meaning > something like > > scene > actors > terrain_batches > > you can do > > scene > actors > batch1 > ColorLayer(0, 0, 0, 20) > batch2 > ColorLayer(0, 0, 0, 20) > batch3 > > Here you will be painting a bit of transparent black over each batch. > Deeper layers will be more darkened. > > > > -- You received this message because you are subscribed to the Google Groups "cocos2d discuss" 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/cocos-discuss. For more options, visit https://groups.google.com/groups/opt_out.
