Why is "BeginSort" sceneObject rendering in front of terrain
by Steven Peterson · in Torque Game Engine · 05/03/2006 (8:58 am) · 3 replies
I'm working on new cloudLayers, which are derived from sceneObject.
According to all the docs that block in CloudLayer::PrepRenderImage() should cause the layer to be rendered after/in-front-of the sky but before/behind the terrain or anything else. Instead it is rendering in-front-of everything! In fact there is no discernable difference between using: "BeginSort", "Normal", or "EndSort".
Changing "isTranslucent" never seems to change anything either, except that setting it to True and using "SceneRenderImage::Sky;" is a run-time error on mission-load.
The clouds look great excet that they are in the wrong render-Order. Using a "SceneRenderImage::Sky;" (and isTranslucent=false) pins the clouds to the sky correctly. However, if I have multiple layers in this case, as the player walks/looks around the sky flickers between: no-layers, layer1, layer2, both.
I think using "SceneRenderImage::BeginSort;" for my sort-type is the correct setting, and the problem may be in renderObject(). However I don't really understand everything thats happening here. What might be causing this object to render out-of-order regardless? Can anyone point me in the right direction?
NOTE: The renerObject() function is a descendent of the one found in sky.cc.
Thanks for any help!
Steven
if (state->isObjectRendered(this))
{
SceneRenderImage* image = new SceneRenderImage;
image->obj = this;
image->isTranslucent = true;
image->sortType = SceneRenderImage::BeginSort;
state->insertRenderImage(image);
}According to all the docs that block in CloudLayer::PrepRenderImage() should cause the layer to be rendered after/in-front-of the sky but before/behind the terrain or anything else. Instead it is rendering in-front-of everything! In fact there is no discernable difference between using: "BeginSort", "Normal", or "EndSort".
Changing "isTranslucent" never seems to change anything either, except that setting it to True and using "SceneRenderImage::Sky;" is a run-time error on mission-load.
The clouds look great excet that they are in the wrong render-Order. Using a "SceneRenderImage::Sky;" (and isTranslucent=false) pins the clouds to the sky correctly. However, if I have multiple layers in this case, as the player walks/looks around the sky flickers between: no-layers, layer1, layer2, both.
I think using "SceneRenderImage::BeginSort;" for my sort-type is the correct setting, and the problem may be in renderObject(). However I don't really understand everything thats happening here. What might be causing this object to render out-of-order regardless? Can anyone point me in the right direction?
NOTE: The renerObject() function is a descendent of the one found in sky.cc.
Thanks for any help!
Steven
Torque Owner Steven Peterson
CloudLayer.h
CloudLayer::CloudLayer()
CloudLayer::prepRenderImage()
... if (state->isObjectRendered(this)) { SceneRenderImage* image = new SceneRenderImage; image->obj = this; image->isTranslucent = false; image->sortType = SceneRenderImage::[b]Sky[/b]; [b]image->textureSortKey = 200 - mThisLayer;[/b] state->insertRenderImage(image); } ...So the correct sortType turned out to be "Sky". The "flicker" I was getting between multiple layers was fixed by dynamically assigning each layer its own "textureSortKey".
Thanks to RayG for helping out! :-)