pixijs / lights

Adds dynamic lighting via deferred shading to PixiJS
https://pixijs.io/lights/docs/index.html
MIT License
198 stars 29 forks source link

Can't mix lighting and sorting? #37

Closed NathanHawks closed 5 years ago

NathanHawks commented 5 years ago

Apologies if I'm just missing something obvious due to being new at PIXI. Also apologies because I edit a lot :-/

As I understand it...

Currently I can have one of these lines uncommented and get layer sorting; or I can uncomment the other line and get lighting. Is there another pattern I'm missing?

//    sprite.parentGroup = PIXI.lights.diffuseGroup;  // uncomment and lighting works
//    sprite.parentGroup = entityGroup; // uncomment and layer sorting works

I tried this in order to get both features:

PIXI.lights.diffuseGroup.on('sort', (sprite) => { sprite.zOrder = -sprite.y; })

But no sorting occurs; I then also added a sort to the normal, also no change. I've tried adding the container holding the diffuse/normal pair, to the entity group, but still no sorting.

Thank you very much for these libraries and for any help past either my blindness or whatever's going on here :)

EDIT: Probably found the answer already: https://pixijs.io/examples/#/layers/normals-drag.js

will close asap after confirming.

ivanpopelyshev commented 5 years ago

Currently its possible to sort&light using sortPriority field. Sort the containers, each container has two sprites inside - one for diffuse, one for normals.

https://pixijs.io/examples/#/layers/normals-drag.js

Next version of pixi-layers will allow muti-render-target, only one sprites will be needed.

NathanHawks commented 5 years ago

Yep, I would have commented a couple of hours ago when I got it right, but internet was down... thankfully I already had your example code up ;)

Thank you!