Weird Shader Problem
by Damian Sloane · in Torque Game Engine Advanced · 02/22/2007 (3:56 am) · 5 replies
Hey all,
I just downloaded and compiled TGEA for the first time recently and am already pulling my hair out with this weird problem, that I can only guess is something to do with shaders.
If I install from scratch and run the demo applications, they work perfectly. No problems, everything displays without problems (do notice a minor glitch in the water rendering which seems to be due to having SLI mode enabled).
But as soon as I fire up the compiler and build the project for the first time I run into all sorts of graphical glitches when I try to rerun the applications.
The Terrain-Water demo starts looking like this:

And the main demo starts having all sorts of problems:



For some reason enabling Dynamic Range Lighting gives my viewport a nice yellow glow too.

The machine I'm using isn't the latest and greatest hardware by any means, but its clearly capable of rendering these scenes (as they work up until such point as I try and build the source code). All projects compile without any errors, get a few warnings about macro redefinitions but nothing thats ringing any alarm bells. Same problem in both release/debug builds. So I'm completely lost.
The computer im using is as follows:
Intel Core Duo 2.13GHz with 3.5GB RAM
2x Leadtek PX7950GT 512MB PCI-E cards
3.5GB DDR2
48GB HDD Free
Windows XP SP2
Visual C++ 2005 Express
DirectX February 2007 SDK
Microsoft XP SP2 Platform SDK
TGEA SDK 1.0
If its of any use, I did a clean/rebuild all, the log is below. Any help greatly appreciated.
insertdisk.com/BUILDLOG.TXT
I just downloaded and compiled TGEA for the first time recently and am already pulling my hair out with this weird problem, that I can only guess is something to do with shaders.
If I install from scratch and run the demo applications, they work perfectly. No problems, everything displays without problems (do notice a minor glitch in the water rendering which seems to be due to having SLI mode enabled).
But as soon as I fire up the compiler and build the project for the first time I run into all sorts of graphical glitches when I try to rerun the applications.
The Terrain-Water demo starts looking like this:
And the main demo starts having all sorts of problems:
For some reason enabling Dynamic Range Lighting gives my viewport a nice yellow glow too.
The machine I'm using isn't the latest and greatest hardware by any means, but its clearly capable of rendering these scenes (as they work up until such point as I try and build the source code). All projects compile without any errors, get a few warnings about macro redefinitions but nothing thats ringing any alarm bells. Same problem in both release/debug builds. So I'm completely lost.
The computer im using is as follows:
Intel Core Duo 2.13GHz with 3.5GB RAM
2x Leadtek PX7950GT 512MB PCI-E cards
3.5GB DDR2
48GB HDD Free
Windows XP SP2
Visual C++ 2005 Express
DirectX February 2007 SDK
Microsoft XP SP2 Platform SDK
TGEA SDK 1.0
If its of any use, I did a clean/rebuild all, the log is below. Any help greatly appreciated.
insertdisk.com/BUILDLOG.TXT
About the author
#2
I've read the DX documentation and all it seems to mention is compiling legacy shader models with the "fxc.exe" command-line tool using the /LD switch. However the shaders in TGEA are compiled at runtime in "gfxD3DShader.cpp" using the D3DXCompileShaderFromFileA() function, and the DX documentation doesnt mention anything about compiling legacy shaders with the function.
Don't suppose anyone can point me in the direction of this mystical "legacy fix"?
-----
Just found something about a flag called "D3DXSHADER_USE_LEGACY_D3DX9_31_DLL" and amended gfxD3DShader.cpp as follows:
-----
02/22/2007 (6:45 pm)
Thanks for that. Its starting to make some sense finally. Rather than downgrade the SDK I'd rather do this "legacy fix" but I can't for the life of me find anything about it on the forums.I've read the DX documentation and all it seems to mention is compiling legacy shader models with the "fxc.exe" command-line tool using the /LD switch. However the shaders in TGEA are compiled at runtime in "gfxD3DShader.cpp" using the D3DXCompileShaderFromFileA() function, and the DX documentation doesnt mention anything about compiling legacy shaders with the function.
Don't suppose anyone can point me in the direction of this mystical "legacy fix"?
-----
Just found something about a flag called "D3DXSHADER_USE_LEGACY_D3DX9_31_DLL" and amended gfxD3DShader.cpp as follows:
Quote:And did the same thing with all the CompileShader/AssembleShader functions in the source, but still have the same problem. An excerpt of the console log from the demo application is below, complains about being unable to open shdrConsts.h (guessing this is due to the compiler changes in DX).
res = GFXD3DX.D3DXCompileShaderFromFileA( pixFile, NULL, NULL, "main", pixTarget, D3DXSHADER_DEBUG && D3DXSHADER_USE_LEGACY_D3DX9_31_DLL, &code, &errorBuff, NULL );
-----
Quote:
Executing common/client/help.cs.
Executing common/client/recordings.cs.
Executing common/client/shaders.cs.
Executing common/lighting/sgShaders.cs.
shaders/legacyTerrain/terrainDynamicLightingMaskV.hlsl(2,10): error X1507: failed to open source file: '../shdrConsts.h'
GFXD3DShader::initVertShader - unable to compile shader!
error X3539: ps_1_x is not supported in this version of the compiler
shaders/legacyTerrain/terrainDynamicLightingV.hlsl(2,10): error X1507: failed to open source file: '../shdrConsts.h'
GFXD3DShader::initVertShader - unable to compile shader!
error X3539: ps_1_x is not supported in this version of the compiler
shaders/atlas/atlasSurfaceDynamicLightingMaskV.hlsl(2,10): error X1507: failed to open source file: '../shdrConsts.h'
GFXD3DShader::initVertShader - unable to compile shader!
error X3539: ps_1_x is not supported in this version of the compiler
shaders/atlas/atlasSurfaceDynamicLightingV.hlsl(2,10): error X1507: failed to open source file: '../shdrConsts.h'
GFXD3DShader::initVertShader - unable to compile shader!
error X3539: ps_1_x is not supported in this version of the compiler
shaders/lightingSystem/ShadowShaderV_1_1.hlsl(7,10): error X1507: failed to open source file: '../shdrConsts.h'
GFXD3DShader::initVertShader - unable to compile shader!
shaders/lightingSystem/ShadowBuilderShaderV.hlsl(7,10): error X1507: failed to open source file: '../shdrConsts.h'
GFXD3DShader::initVertShader - unable to compile shader!
shaders/lightingSystem/ShadowShaderV.hlsl(7,10): error X1507: failed to open source file: '../shdrConsts.h'
GFXD3DShader::initVertShader - unable to compile shader!
shaders/lightingSystem/ShadowShaderV.hlsl(7,10): error X1507: failed to open source file: '../shdrConsts.h'
GFXD3DShader::initVertShader - unable to compile shader!
shaders/lightingSystem/ShadowBuilderShaderV_1_1.hlsl(7,10): error X1507: failed to open source file: '../shdrConsts.h'
#3
www.garagegames.com/mg/forums/result.thread.php?qt=58098
You'll find the fix there with the new line numbers in the last post. Works for me and I'm using SLI as well.
I do however get weird magenta outlines on the shaders in the demo and I'd be interested in knowing if you do as well. I reported this on one of the early milestones and it still happens, but never I got any response from GG. Nobody else reported it but I was an early adopter of SLI with multiple GPUs so it might have got lost in space.
Dave.
02/23/2007 (12:55 am)
You should have looked on the general discussion forum, I had this problem a few days back :-)www.garagegames.com/mg/forums/result.thread.php?qt=58098
You'll find the fix there with the new line numbers in the last post. Works for me and I'm using SLI as well.
I do however get weird magenta outlines on the shaders in the demo and I'd be interested in knowing if you do as well. I reported this on one of the early milestones and it still happens, but never I got any response from GG. Nobody else reported it but I was an early adopter of SLI with multiple GPUs so it might have got lost in space.
Dave.
#4
garagegames.com/mg/forums/result.thread.php?qt=58390
I've tried all the different SLI modes from the nVidia control panel (alternate frame, etc) without any difference, tinkered with AA, and I've found the only thing that fixes it is going back to single GPU mode. The water demo gets magenta patches coming up randomly in the water, and the tech demo has strange bright magenta bits in some of the shaders as you described.
I'm not sure what can be done about it, I'm guessing its something to do with the shader code as the glitches only seem to appear in the materials which use shaders (I haven't even attempted to learn HLSL as yet- so don't ask me what the problem could be). But its definitely something I want to get sorted out, as I bought the video cards specifically to push out a few extra polygons with my Torque project.
----
ARGH! I just looked at the link you posted and realised why my change didnt work, I was having a blonde moment and using "&&" to combine the bit-flags. Can't believe I didn't pick that up, guess its what happens when you stare at the screen too many hours at a time. Thanks for the link, can finally get on with things :)
02/23/2007 (6:45 am)
I do get the same weird effects when running in SLI mode. I posted a message on the bug forum a bit earlier today about it.garagegames.com/mg/forums/result.thread.php?qt=58390
I've tried all the different SLI modes from the nVidia control panel (alternate frame, etc) without any difference, tinkered with AA, and I've found the only thing that fixes it is going back to single GPU mode. The water demo gets magenta patches coming up randomly in the water, and the tech demo has strange bright magenta bits in some of the shaders as you described.
I'm not sure what can be done about it, I'm guessing its something to do with the shader code as the glitches only seem to appear in the materials which use shaders (I haven't even attempted to learn HLSL as yet- so don't ask me what the problem could be). But its definitely something I want to get sorted out, as I bought the video cards specifically to push out a few extra polygons with my Torque project.
----
ARGH! I just looked at the link you posted and realised why my change didnt work, I was having a blonde moment and using "&&" to combine the bit-flags. Can't believe I didn't pick that up, guess its what happens when you stare at the screen too many hours at a time. Thanks for the link, can finally get on with things :)
#5
BTW this probably won't help your problems, but I was having an issue with the glow buffer showing through the orc in the demo a long time ago. There is a pref you can set to stop this (thanks Ben Garney).
Set $pref::Video::killFramesAhead to "zero", it's "one" by default.
02/23/2007 (9:11 am)
Thanks Damien, at least I'm not alone with the magenta thing. I'll bump it on the bug forum when I get a minute.BTW this probably won't help your problems, but I was having an issue with the glow buffer showing through the orc in the demo a long time ago. There is a pref you can set to stop this (thanks Ben Garney).
Set $pref::Video::killFramesAhead to "zero", it's "one" by default.
Torque 3D Owner Marc Dreamora Schaerer
Gayasoft