Game Development Community

[beta 4 bug] Water Invisible with FullReflect On

by Ryan Mounts · in Torque 3D Professional · 07/20/2009 (12:15 pm) · 12 replies

If fullReflect is turned on for a waterblock, I cannot see that water. Once I go underwater, I see the fog and refraction like normal. But from outside the water, it is absolutely invisible. If I turn fullReflect off, I can see the water. There are no errors or warnings associated with the water material in the console log. Maybe my graphics card does not like the new changes in "waterP.hlsl".

Windows XP Pro
Intel Core 2, 2.0 Ghz
1 GB RAM
NVIDIA Quadro NVS 135M

#1
07/20/2009 (1:08 pm)
I had a similar problem like that in beta3, but it was something I did in the scripts. I don't have that problem in beta 4 though, and the water shader looks a lot better. I've got a 9800 512mb card and a 4870 1GB in my other workstation no problems at all. I wonder if there is something up with your quadros driver?
#2
07/20/2009 (6:34 pm)
I just downloaded the latest certified drivers off the Dell website, and still no water. There is a newer driver on the Nvidia website, but I don't typically install uncertified drivers. I've had no problems with the water until beta 4.
#3
07/23/2009 (2:39 pm)
Maybe James has some ideas as there were changes between beta 3 and 4 on water. In general Quatro cards are usually difficult to work with... but if it worked in beta 3 it should be easy to fix it back.
#4
07/24/2009 (7:31 am)
Well, I compiled a debug build to look at something else and got this for the water:

Invalid call - Failed to draw indexed primitive

And here's the callstack associated with the debugbreak:

Full_DEBUG.dll!D3D9Assert(HRESULT hr=-2005530516, const char * info=0x11055228)  Line 43
Full_DEBUG.dll!GFXD3D9Device::drawIndexedPrimitive(GFXPrimitiveType primType=GFXTriangleList, unsigned int startVertex=0, unsigned int minIndex=0, unsigned int numVerts=10201, unsigned int startIndex=0, unsigned int primitiveCount=20000)  Line 691 + 0x5f bytes
Full_DEBUG.dll!WaterPlane::innerRender(SceneState * state=0x052abd40)  Line 554
Full_DEBUG.dll!WaterObject::renderObject(ObjectRenderInst * ri=0x05841844, SceneState * state=0x052abd40, BaseMatInstance * overrideMat=0x00000000)  Line 528
Full_DEBUG.dll!fastdelegate::FastDelegate3<ObjectRenderInst *,SceneState *,BaseMatInstance *,void>::operator()(ObjectRenderInst * p1=0x05841844, SceneState * p2=0x052abd40, BaseMatInstance * p3=0x00000000)  Line 1163 + 0x22 bytes
Full_DEBUG.dll!RenderObjectMgr::render(SceneState * state=0x052abd40)  Line 49
Full_DEBUG.dll!RenderPassManager::render(SceneState * state=0x052abd40)  Line 282
Full_DEBUG.dll!SceneState::renderCurrentImages()  Line 159
Full_DEBUG.dll!SceneGraph::_traverseSceneTree(SceneState * pState=0x052abd40)  Line 234
Full_DEBUG.dll!SceneGraph::renderScene(SceneState * sceneState=0x052abd40, unsigned int objectMask=4294967295)  Line 196
Full_DEBUG.dll!SceneGraph::renderScene(ScenePassType passType=SPT_Diffuse, unsigned int objectMask=4294967295)  Line 165
Full_DEBUG.dll!GameRenderWorld()  Line 309
Full_DEBUG.dll!GameTSCtrl::renderWorld(const RectI & updateRect={...})  Line 41
Full_DEBUG.dll!GuiTSCtrl::onRender(Point2I offset={...}, const RectI & updateRect={...})  Line 226
Full_DEBUG.dll!GameTSCtrl::onRender(Point2I offset={...}, const RectI & updateRect={...})  Line 74
Full_DEBUG.dll!GuiCanvas::renderFrame(bool preRenderOnly=false, bool bufferSwap=true)  Line 1495
Full_DEBUG.dll!GuiCanvas::handlePaintEvent(unsigned int did=0)  Line 203
Full_DEBUG.dll!fastdelegate::FastDelegate1<unsigned int,void>::operator()(unsigned int p1=0)  Line 993 + 0x1a bytes
Full_DEBUG.dll!Signal<void __cdecl(unsigned int)>::trigger(unsigned int a=0)  Line 323 + 0x17 bytes
Full_DEBUG.dll!Journal::Call<Signal<void __cdecl(unsigned int)>,unsigned int>(Signal<void __cdecl(unsigned int)> * obj=0x021108d8, void (unsigned int)* method=0x1054a7d4, unsigned int a=0)  Line 541 + 0xa8 bytes
Full_DEBUG.dll!JournaledSignal<void __cdecl(unsigned int)>::trigger(unsigned int a=0)  Line 52 + 0x12 bytes
Full_DEBUG.dll!GuiCanvas::paint()  Line 1326
Full_DEBUG.dll!fastdelegate::FastDelegate0<void>::operator()()  Line 908 + 0x16 bytes
Full_DEBUG.dll!Signal<void __cdecl(void)>::trigger()  Line 312 + 0x13 bytes
Full_DEBUG.dll!Process::processEvents()  Line 62
Full_DEBUG.dll!StandardMainLoop::doMainLoop()  Line 512 + 0x5 bytes
Full_DEBUG.dll!torque_enginetick()  Line 78 + 0x5 bytes
Full_DEBUG.dll!TorqueMain(int argc=1, const char * * argv=0x00aa77b0)  Line 369 + 0x5 bytes
Full_DEBUG.dll!torque_winmain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * __formal=0x00000000, char * lpszCmdLine=0x00151f25, HINSTANCE__ * __formal=0x00000000)  Line 423 + 0x17 bytes
Full_DEBUG.exe!WinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpszCmdLine=0x00151f25, int nCommandShow=1)  Line 47 + 0x16 bytes
Full_DEBUG.exe!__tmainCRTStartup()  Line 263 + 0x2c bytes
Full_DEBUG.exe!WinMainCRTStartup()  Line 182
#5
07/24/2009 (1:12 pm)
20000 triangles in a single draw call seems like a lot, maybe you hit some limit on your card? Try reducing the WaterPlane's gridSize.

In your first post you said this was for WaterBlock, but that assert was for WaterPlane. So, is this a problem for all of the WaterObject classes or only some of them, and if so which ones?
#6
07/24/2009 (1:45 pm)
GFXD3D9Shader::_compileShader - Error compiling shader: E_FAIL: An undetermined error occurred (80004005)
   C:/Torque/Torque 3D 2009 Beta 4/Templates/Full/game/shaders/common/water/waterP.hlsl(137,23): error X3004: undeclared identifier 'prepassUncondition'

Sorry, don't know how I missed this before, but here's the shader error I'm getting in the console. Doesn't matter if its the waterplane or waterblock, the fullreflect shader is not getting compiled. If I turn 'fullreflect' off, the water shows up, so the cubemap reflection shader is working fine, and my card is handling the triangle count.
#7
07/24/2009 (3:13 pm)
I don't really understand this error, since 'prepassUncondition' seems to be used in quite a few other shaders that are getting compiled just fine.
#8
07/28/2009 (6:53 am)
Well, I figured out how I missed the shader compiler error before... the error only shows up in the console when I start T3D up in basic lighting mode, and I typically work with advanced lighting. The reflective water, however, shows up in neither lighting mode.
#9
07/28/2009 (12:42 pm)
Yea... only in BL will you normally see the 'prepassUncondition' errors as it compiles shaders which won't work in that lighting mode. So its just the bug or a bug... its just a wart when switching lighting modes.

Do you happen to have the DX debug runtime enabled? Try turning it on and running with the debugger attached and look in the VisualStudio output window for DX debug messages when or before the crash occurs.
#10
07/30/2009 (6:54 am)
Yes, I have the DX debug runtime enabled... here's the output:

D3D9 Helper: IDirect3DDevice9::DrawIndexedPrimitive failed: D3DERR_INVALIDCALL
DirectInput deactivated.
Direct3D9: VS->PS Linker: X442: (Error) Current pixel shader declares that a cube texture must be at sampler [4]. However, sampler [4] currently has a 2d texture set.
First-chance exception at 0x7c812a6b in Full_DEBUG.exe: Microsoft C++ exception: long at memory location 0x0012bad8..
Direct3D9: (ERROR) :DrawIndexedPrimitive failed.
#11
07/30/2009 (10:30 am)
Ok, I tracked down the error above and here's my fix... in "environmentwaterObject.cpp", add these lines in "WaterObject::setCustomTextures()":

// Only use the cubemap if fullReflect is off.
   if ( !mPlaneReflector.isEnabled() )
   {      
      if ( mCubemap )      
         GFX->setCubeTexture( 4, mCubemap->mCubemap );
      else
         GFX->setCubeTexture( 4, NULL );   
   }
   else                                  // Add this line
	   GFX->setCubeTexture( 4, NULL );   // Add this line

Apparently others have not run into this issue, so maybe it's isolated to my graphics card, but this fixed the issue for me.
#12
07/30/2009 (10:55 am)
Nice one Ryan! I was actually wondering if that was going to be necessary. Committed this fix in the repo.