Shadow Rendering Crash Bug
by Mark Dynna · in Torque Game Engine Advanced · 12/06/2007 (11:06 am) · 2 replies
We had a crash bug recently that traced back to the code that draws object shadows. We had set some shadow settings on a base datablock and had several objects in a scene that all used those same shadow settings. When several of them were in the field of view at the same time the engine would crash. When the shadow settings were commented out the crash went away. In Debug mode the engine stops on the Assert shown below in gfxDevice.cpp
These are the scripted shadow settings that were used:
void GFXDevice::drawPrimitive( U32 primitiveIndex )
{
if( mStateDirty )
updateStates();
[b] AssertFatal( mCurrentPrimitiveBuffer.isValid(), "Trying to call drawPrimitive with no current primitive buffer, call setPrimitiveBuffer()" );[/b]
AssertFatal( primitiveIndex < mCurrentPrimitiveBuffer-mPrimitiveCount, "Out of range primitive index.");
GFXPrimitive *info = &mCurrentPrimitiveBuffer-mPrimitiveArray[primitiveIndex];
// Do NOT add index buffer offset to this call, it will be added by
drawIndexedPrimitive
drawIndexedPrimitive( info-type, info-minIndex,
info-numVertices, info-startIndex, info-numPrimitives );
}These are the scripted shadow settings that were used:
// Shadow related settings shadowEnable = true; shadowSelfShadow = true; shadowCanAnimate = true; shadowDTSShadow = true; // shadow texture size, must be a power of 2 shadowSize = 512; // maximum distance from the object that the shadow is visible shadowMaxVisibleDistance = 100; // maximum distance the shadow can project from the object shadowProjectionDistance = 200; // a multipler to the object's bounding box for maximum shadow > projection distance shadowSphereAdjust = 2.0; // an error correction constant shadowBias = 0.005;
#2
12/06/2007 (5:23 pm)
Something further we now discovered: The scripted shadow settings work fine if we set "multiple dynamic shadows" to false in Preferences.
Torque 3D Owner Mark Dynna
ntdll.dll!7c901230() [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll] Chariots_DEBUG.exe!Platform::debugBreak() Line 15 + 0x8 bytes C++ Chariots_DEBUG.exe!PlatformAssert::process(PlatformAssert::Type assertType=Fatal, const char * filename=0x0093d39c, unsigned int lineNumber=410, const char * message=0x0093d520) Line 93 C++ Chariots_DEBUG.exe!PlatformAssert::processAssert(PlatformAssert::Type assertType=Fatal, const char * filename=0x0093d39c, unsigned int lineNumber=410, const char * message=0x0093d520) Line 113 + 0x25 bytes C++ Chariots_DEBUG.exe!GFXDevice::drawPrimitive(unsigned int primitiveIndex=0) Line 410 + 0x2f bytes C++ Chariots_DEBUG.exe!TSMesh::render() Line 305 + 0x10 bytes C++ Chariots_DEBUG.exe!sgShadowProjector::sgRenderShape(TSShapeInstance * shapeinst=0x032349b4, const MatrixF & trans1={...}, int vertconstindex1=4, const MatrixF & trans2={...}, int vertconstindex2=0) Line 478 + 0xf bytes C++ Chariots_DEBUG.exe!sgShadowProjector::sgRender(TSShapeInstance * shapeinstance=0x067a7740, float camdist=45.940056) Line 827 C++ Chariots_DEBUG.exe!sgObjectShadows::sgRender(SceneObject * parentobject=0x067a5070, TSShapeInstance * shapeinstance=0x067a7740, float camdist=45.940056) Line 314 + 0x1a bytes C++ Chariots_DEBUG.exe!ShapeBase::renderShadow(SceneState * state=0x014f9b5c, RenderInst * ri=0x06877a84) Line 2330 C++ Chariots_DEBUG.exe!RenderObjectMgr::render() Line 17 + 0x25 bytes C++ Chariots_DEBUG.exe!RenderInstManager::render() Line 286 + 0x2c bytes C++ Chariots_DEBUG.exe!SceneState::renderCurrentImages() Line 144 C++ Chariots_DEBUG.exe!SceneGraph::traverseSceneTree(SceneState * pState=0x014f9b5c) Line 364 C++ Chariots_DEBUG.exe!SceneGraph::renderScene(const unsigned int objectMask=4294967295) Line 190 C++ Chariots_DEBUG.exe!GameRenderWorld() Line 721 C++ Chariots_DEBUG.exe!GameTSCtrl::renderWorld(const RectI & updateRect={...}) Line 52 C++ Chariots_DEBUG.exe!GuiTSCtrl::onRender(Point2I offset={...}, const RectI & updateRect={...}) Line 117 + 0x16 bytes C++ Chariots_DEBUG.exe!GameTSCtrl::onRender(Point2I offset={...}, const RectI & updateRect={...}) Line 112 C++ Chariots_DEBUG.exe!GuiCanvas::renderFrame(bool preRenderOnly=false) Line 1273 C++ Chariots_DEBUG.exe!DemoGame::processTimeEvent(TimeEvent * event=0x0012fc9c) Line 755 C++ Chariots_DEBUG.exe!GameInterface::processEvent(Event * event=0x0012fc9c) Line 74 + 0x13 bytes C++ Chariots_DEBUG.exe!GameInterface::postEvent(Event & event={...}) Line 156 + 0x13 bytes C++ Chariots_DEBUG.exe!TimeManager::process() Line 1049 + 0x19 bytes C++ Chariots_DEBUG.exe!DemoGame::main(int argc=1, const char * * argv=0x010d32e0) Line 542 C++ Chariots_DEBUG.exe!run(int argc=1, const char * * argv=0x010d32e0) Line 922 + 0x1c bytes C++ Chariots_DEBUG.exe!main(int argc=1, const char * * argv=0x010d32e0) Line 1000 + 0xd bytes C++ Chariots_DEBUG.exe!__tmainCRTStartup() Line 597 + 0x19 bytes C Chariots_DEBUG.exe!mainCRTStartup() Line 414 C kernel32.dll!7c816fd7() Chariots_DEBUG.exe!PixelSpecular::processVert(Vector<ShaderComponent * & componentList={...}, GFXShaderFeatureData & fd={...}) Line 110 + 0x42 bytes C++ Chariots_DEBUG.exe!GuiMenuBar::onMouseUp(const GuiEvent & event={...}) Line 862 + 0x10 bytes C++ Chariots_DEBUG.exe!ccontainerRayCast(SimObject * __formal=0x003d0065, int argc=7864354, const char * * argv=0x00360038) Line 237 + 0x4a bytes C++ Chariots_DEBUG.exe!ccontainerRayCast(SimObject * __formal=0x003d0065, int argc=7864354, const char * * argv=0x00360038) Line 237 + 0x4a bytes C++ Chariots_DEBUG.exe!ccontainerRayCast(SimObject * __formal=0x002c0022, int argc=7667824, const char * * argv=0x006c0062) Line 237 + 0x4a bytes C++If whoever is working on this would like the model we were using (all objects were using the same DTS, different textures) please email me. Thanks.