New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebGLRenderer: Added SortingGroup #14433

Closed
wants to merge 8 commits into
base: dev
from

Conversation

Projects
None yet
3 participants
@Mugen87
Collaborator

Mugen87 commented Jul 8, 2018

Fixes #14415

The PR introduces a new class SortingGroup which can be used to group objects within the render list. So it's somewhat similar to Unity's SortingGroup API.

@Mugen87 Mugen87 changed the title from WebGLRenderer: Added .sortGroups to WebGLRenderer: Added SortingGroup Jul 8, 2018

@WestLangley

This comment has been minimized.

Collaborator

WestLangley commented Jul 8, 2018

So, within a sorting group, object.renderOrder only applies relative to the objects within the sorting group. Is that your intention?

If so, I expect SortingGroup will have to have its renderOrder property honored so the sorting groups can be sorted.

@WestLangley

This comment has been minimized.

Collaborator

WestLangley commented Jul 8, 2018

And a sorting group should not contain both opaque and transparent renderable objects. I think that is OK, though.

@WestLangley

This comment has been minimized.

Collaborator

WestLangley commented Jul 8, 2018

@mrdoob I wonder if SVGLoader could make use of this feature to ensure the shapes are rendered in the proper order -- especially if there are multiple SVG objects, or other objects in the scene.

@Mugen87

This comment has been minimized.

Collaborator

Mugen87 commented Jul 8, 2018

So, within a sorting group, object.renderOrder only applies relative to the objects within the sorting group. Is that your intention?

Yes. And if SortingGroup groups are not used at all, renderOrder has still the highest priority.

If so, I expect SortingGroup will have to have its renderOrder property honored so the sorting groups can be sorted.

Um, I'm not sure how to solve this. Objects of type SortingGroup are not added to the render list so it's not possible to sort them right now. I guess we need some additional logic for this use case...

@WestLangley

This comment has been minimized.

Collaborator

WestLangley commented Jul 8, 2018

Yes. You have to be able to sort the sorting groups themselves.

@Mugen87

This comment has been minimized.

Collaborator

Mugen87 commented Jul 9, 2018

Sorting groups via renderOrder should be possible now. You can see the effect if you change the properties in this fiddle: https://jsfiddle.net/f2Lommf5/8890/

BTW: It's now necessary to set new property of WebGLRenderer (sortingGroupsEnabled) to true so SortingGroups can be used. The sorting of groups needs an additional traversal through the scene graph. The flag was introduced in order to avoid this overhead if you don't need SortingGroups in your app.

@navigator117

This comment has been minimized.

navigator117 commented Jul 10, 2018

Mesh without SortingGroup parent should be able to compare renderOrder with SortingGroup, as unity does this.

@Mugen87

This comment has been minimized.

Collaborator

Mugen87 commented Jul 10, 2018

This should work now, too. The code is also slightly refactored so changes to projectObject() are not necessary anymore.

@Mugen87

This comment has been minimized.

Collaborator

Mugen87 commented Jul 10, 2018

Nevertheless the holistic implementation of this approach feels hacky. Besides, the current way WebGLSortingGroups and WebGLRenderList are working together is no good. I'm closing the PR for now and try to think of a different approach.

@Mugen87 Mugen87 closed this Jul 10, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment