Game Development Community

Sorting render order

by Chris \"Hobbiticus\" Weiland · in Torque Game Engine · 03/30/2003 (7:35 pm) · 11 replies

I'm trying to do a shield effect that makes a translucent bubble around an object, but when I render it when the object is rendered, I get all "sorts" (HA!) of things going on because of the render order. How do I push this back in the render order but keep everything else the same?

#1
03/30/2003 (8:15 pm)
It depends on how you have it coded to render. If you just used a function call in the main render cycle then simply moving it up a few lines will make that render first therebefore making it appear behind objects and then of course moving it down will make it render last and make it appear right up front of everything.

Does that make sense?
#2
03/30/2003 (8:28 pm)
I think you misunderstood me...

Transparent/lucent objects have to be rendered after ALL opaque objects. Then the transparent/lucent objects have to be sorted and rendered from back to front. I've heard of a sorting mechanism in torque that sorts all of this for you by putting the transparent/lucent objects sorta in a queue for render. I don't know where it is or how to use it though...
#3
03/30/2003 (10:36 pm)
Take a look at the sortType property of the RenderImage for your object, Hobbiticus. You can set it so the engine knows it's translucent. Melv's fxRenderObject has some documentation about it if you can't find what you need in the scene graph itself.
#4
03/31/2003 (11:53 am)
Ah ha, got it. Thanks for the tip on fxRenderObject...that helped a LOT.
#5
04/22/2003 (1:25 pm)
Question... how do you handle translucent objects in the middle of a scene? e.g. Say you have a translucent object with multiple translucent layers, but it should be subject to occlusion if a bot or some terrain moves in front of it... you want it to be partially obscured by various objects passing in front of it, but at the same time, it should have its multiple layers blended.

As it stands, the current approach that is doing this correctly is to enable depth-testing, and drawing the object twice in two opposite orders. If I draw it in only one order, then the entire object fails the depth-test throughout a 90-degree arc of view. There has to be a more elegant approach than drawing the entire object twice at half-alpha.
#6
04/23/2003 (1:23 pm)
give it Sort::Point and give it a point in world space. It'll handle everything from there.
#7
04/28/2003 (8:05 am)
Already tried that... It would still render the object before the water layer, so I ended up with a object that would "x-ray" through the water if you looked through any transparent portions. Interesting result, but hardly appropriate.
#8
04/28/2003 (10:05 am)
Quote:
As it stands, the current approach that is doing this correctly is to enable depth-testing, and drawing the object twice in two opposite orders. If I draw it in only one order, then the entire object fails the depth-test throughout a 90-degree arc of view. There has to be a more elegant approach than drawing the entire object twice at half-alpha.

I don't understand the problem that you're having. Why would the object fail the depth test one way, but somehow pass if you draw it twice?
#9
05/03/2003 (4:56 pm)
for Sort::Point you have to give it a point for it to sort properly. Look at the documentation of fxRenderObject by melv may for more details.
#10
05/06/2003 (7:49 am)
Perhaps I should explain what I'm doing. I'm basically doing some simple dynamic volume rendering effects in Torque. So to draw the volumes, I'm simply doing a series of slices in U space and then again in V space.

When I tried Sort::Point and used the state->setImageRefPoint(this, image); and all, for some odd reason, Torque would still want to render the object before rendering water whether the volume was below or above the water surface.

So as it stands, I'm doing a dual-rendering with depth-testing enabled. As for why it's failing depth-test in certain cases, the volume slices are being drawn in a particular order... e.g., the U-space slices are drawn from 0..1. So in order to get it to pass the depth test from all views, I'm drawing the slices in increasing order, and then again in decreasing order. This way, at least one order of drawing is passing the depth-test.
#11
05/06/2003 (8:28 am)
Ah-hah.

Your objects are transparent, right?

If so, you should be rendering them after all opaque objects, with depth testing ON and depth writing OFF.

From your description, it sounds like you have depth writes turned on.