Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎮 Unity

Sorting Subsets

Started by Jiia Jul 9, 2004 at 11:59 AM 4 replies 800+ views
Original Post
Jiia
Jiia
Hey :) I'm in the middle of writing my scene graph. Or at least I think I am, since I have no idea what defines a scene graph. Anyways, I've come up with a method where objects in my game world "register" subsets of their meshes. The subsets are stored in two arrays of pointers (pointers to the objects who registered them). One for opaque textures, to be rendered in order of textures. And one for transparent textures, to be ordered by distance from the camera, each frame. However, I'm unsure of how to best sort the transparent subsets. The problem is that my subsets have no "point of position". Do I generate a center point for each transparent subset using the vertices at startup, then transform that point with the object's final matrix? Or is there something blindingly simple that I've missed? I would appreciate any suggestions or advice. Thanks much!
Etnu
Etnu
Why not pass a pointer to the mesh itself when registering the group of polys? That way the class doing the 'registering' can always check the mesh's origin to determine proper transformation.

Hell, doing it that way, you could even pre-transform your vertices for static meshes, theoretically saving you one transform per mesh subset per frame...which could possibly have a significant impact on frame rates.
---------------------------Hello, and Welcome to some arbitrary temporal location in the space-time continuum.
Jiia
Jiia
Well, I believe one would like to think that very little of the world in creation would not be interactive, or static. Moving vertices is kind of like puting a static sign up saying "don't move this!".

My problem is that the same object can have several subsets, which all need sorted with each other. For example, a room with two windows, and a glass lamp sitting on a stand. All one mesh, but with several subsets. If you look through the lamp at the window, there will be problems unless you sort them so that the lamp is rendered last.

This is a dumb example. Another would be a character with eyelashes and hair. Or Eyelashes, hair, and glasses :) When you really get into it, it would be very difficult to create objects for all of these components, which only move with one object vector.
Etnu
Etnu
Objects that are fully opaque should always be rendered first (front to back), followed by translucent objects, which should be sorted back to front. That's the only way you're going to get the desired results.

My suggestion about passing the pointer to the mesh was to make it easier to determine the proper back-> front ordering.
---------------------------Hello, and Welcome to some arbitrary temporal location in the space-time continuum.
Jiia
Jiia
Right, that's easy, and done. But I'm saying a single mesh can have several transparent subsets, that can overlap each other in the view. So the subsets need sorted, rather than the entire mesh position.

How else can you achieve the same results? This is the only way I know that makes it possible, without seperating all transparent parts into their own objects. And that can be a real pain when it comes to skinned meshes.

Another great thing that could be done with this is to have a single solid round transparent mesh which overlaps itself. If you make each strip a subset, you don't have to resort to sorting by polygons.

So far, the only way I know to do this is to..
MATRIX State;State.Translate(SubsetCenterPoint);State.MultiplyWith(MeshesFinalMatrixState);VECTOR FinalPosition = VECTOR(State._41, State._42, State._43);
Anything stupid I'm doing here?
Etnu
Etnu
Triangle strips are frequently a pain in the ass, but anyway.

Matrix stacks could work well, I suppose.
---------------------------Hello, and Welcome to some arbitrary temporal location in the space-time continuum.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.