jnsmalm / pixi3d

The 3D renderer for PixiJS. Seamless integration with 2D applications.
https://pixi3d.org
MIT License
752 stars 43 forks source link

Idea for sprite rendering with and without depth testing #117

Closed GordonTombola closed 2 years ago

GordonTombola commented 2 years ago

Not 100% certain that this would be the best way of handling this, thought it'd be best to get your thoughts on the premise at least

Why?

jnsmalm commented 2 years ago

Hello! I like the idea of this but I'm a bit busy right now - I'll take a look later. Just some quick thoughts:

GordonTombola commented 2 years ago

Hello! I like the idea of this but I'm a bit busy right now - I'll take a look later. Just some quick thoughts:

  • The NO_DEPTH_ZINDEX seems a bit random and may be difficult to understand from a API perspective.
  • Maybe it would just be simpler for a Sprite3D to have a property "depthTest", and all of those sprites gets rendered last after the meshes and other sprites?

I agree, the zindex determining depthtest is a bit arbitrary, there would still need to be some combination of negative zIndex being used as a way to draw before meshes

jnsmalm commented 2 years ago

In what circumstances do you think this level of control is needed? Could you give an example?

jnsmalm commented 2 years ago

@GordonTombola While thinking about this I got another idea which can be used for all objects, both mesh and sprite. What if mesh/sprite had an "layer" integer property. All objects with same layer is rendered, if another object exists with a different layer then it will clear the depth buffer between those layers. So everything with a higher layer number will always be on top of stuff with a lower layer property. With this solution there is basically no restrictions in which order you want to render objects.

What do you think?

GordonTombola commented 2 years ago

@GordonTombola While thinking about this I got another idea which can be used for all objects, both mesh and sprite. What if mesh/sprite had an "layer" integer property. All objects with same layer is rendered, if another object exists with a different layer then it will clear the depth buffer between those layers. So everything with a higher layer number will always be on top of stuff with a lower layer property. With this solution there is basically no restrictions in which order you want to render objects.

What do you think?

Sorry I've been busy past few days, that would make more sense, keeping a common property between the two types

GordonTombola commented 2 years ago

Closing this, will investigate the possibility of an ILayerObject interface that could be implemented to sprite3D and Container3D which could determine the depth buffer clearing