Terrain, Detail/Bump texture, OpenGL vs D3D
by Davor Slutej · in Torque Game Engine · 11/18/2006 (2:37 pm) · 16 replies
Just got started with Torque (1.5 indie) and this one just ate away quite a few hours. Perhaps I am missing something but it would seem that OpenGL and D3D modes render the terrain quite differently:
In OpenGL:
Detail texture works. Bump texture does something but not emboss bumping. Car shadow does not flicker.
In D3D:
Detail texture does not work. Bump texture works. Car shadow flickers.
ARGH. Please tell me that I am missing something very obvious and it's not the Engine normal behaviour.
I am running Nvidia 7800GTX with the latest drivers and everything at maximum quality. Windows XP.
In OpenGL:
Detail texture works. Bump texture does something but not emboss bumping. Car shadow does not flicker.
In D3D:
Detail texture does not work. Bump texture works. Car shadow flickers.
ARGH. Please tell me that I am missing something very obvious and it's not the Engine normal behaviour.
I am running Nvidia 7800GTX with the latest drivers and everything at maximum quality. Windows XP.
#2
11/18/2006 (3:39 pm)
The D3D wrapper did not do this in the past.
#3
I've also noticed that the terrain details and bumps do not work right with TGE 1.5. They are way over-bright and keep flashing between normal and over-bright intensity. Had to disable the TLK terrain lightmap texture code that brightens both the terrain details and bumps in terrRender. It also allowed me to have both terrain details and bumps enabled with D3D.
11/18/2006 (5:00 pm)
The D3D wrapper will not use all available TMUs, so you will not get the full multi-texturing needed for the terrain details and bumps, the terrain lightmap and the terrain texture.I've also noticed that the terrain details and bumps do not work right with TGE 1.5. They are way over-bright and keep flashing between normal and over-bright intensity. Had to disable the TLK terrain lightmap texture code that brightens both the terrain details and bumps in terrRender. It also allowed me to have both terrain details and bumps enabled with D3D.
#4
Admittedly, my expectations come form The Game Programmers Guide to Torque book which says nothing about these problems, perhaps the online docs did document these problems?
How is GarageGames handling these kinds of problems? Updates, how often? I undestand that the CVS is no longer available - even though the homepage is full of references to it.
11/19/2006 (1:29 am)
Well, neither OpenGL wrapper nor D3D wrapper work as expected.Admittedly, my expectations come form The Game Programmers Guide to Torque book which says nothing about these problems, perhaps the online docs did document these problems?
How is GarageGames handling these kinds of problems? Updates, how often? I undestand that the CVS is no longer available - even though the homepage is full of references to it.
#5
Personally, I never used the D3D wrapper because I never had to. OpenGL worked just fine.
With that said, if the issue has been there before 1.5 - then I would not expect a fix.
11/19/2006 (2:33 am)
There's no OpenGL wrapper in Torque.Personally, I never used the D3D wrapper because I never had to. OpenGL worked just fine.
With that said, if the issue has been there before 1.5 - then I would not expect a fix.
#6
Wrapper or no wrapper, the rendering using OpenGL does not produce emboss bumps on my hardware (tried with 6800 and 7800). Is the problem present with your systems?
"With that said, if the issue has been there before 1.5 - then I would not expect a fix." - This makes no sense to me.
11/19/2006 (2:51 am)
No wrapper? Enlighten me please.Wrapper or no wrapper, the rendering using OpenGL does not produce emboss bumps on my hardware (tried with 6800 and 7800). Is the problem present with your systems?
"With that said, if the issue has been there before 1.5 - then I would not expect a fix." - This makes no sense to me.
#7
No, OpenGL works just perfectly on my system. I got a 6800 on my gaming system.
Could you get a screenshot of the anomolities mentioned?
Thanks.
11/19/2006 (2:54 am)
D3D is wrapped ontop of OpenGL, which means it is not true Direct3D support. It is not emulated, but it helps people that do not want to use or can not use OpenGL.No, OpenGL works just perfectly on my system. I got a 6800 on my gaming system.
Could you get a screenshot of the anomolities mentioned?
Thanks.
#8
Screenshot on a 6800 system. Not the best bump texture (same as detail in fact) but the difference is clearly visible on the ground.
Thank you for quick replies. :)
11/19/2006 (3:09 am)
Stefan: http://www.cutoff.se/download/2.pngScreenshot on a 6800 system. Not the best bump texture (same as detail in fact) but the difference is clearly visible on the ground.
Thank you for quick replies. :)
#9
If I were you I would consider if I even need Direct3D. It will never overperform OpenGL in Torque simply because it is wrapped ontop and brings in additional overhead.
I know this is not a solution and yes - it is lame.
So my question is: Is there a specific reason you want Direct3D support?
Sorry. What I meant is that if it was introduced before 1.5, then I would not bet on a fix. Old bugs that do not critically affect the engine usually gets low priority.
11/19/2006 (4:43 am)
Aye, I agree the Direct3D version looks a bit oddly modulated.If I were you I would consider if I even need Direct3D. It will never overperform OpenGL in Torque simply because it is wrapped ontop and brings in additional overhead.
I know this is not a solution and yes - it is lame.
So my question is: Is there a specific reason you want Direct3D support?
Quote:
"With that said, if the issue has been there before 1.5 - then I would not expect a fix." - This makes no sense to me.
Sorry. What I meant is that if it was introduced before 1.5, then I would not bet on a fix. Old bugs that do not critically affect the engine usually gets low priority.
#10
In engine/terrain/terrRender.cc comment the following lines thusly.
Lines 1946 through 1951
That will disable the terrain lightmap, which for me enabled proper bumpmap in OpenGL and both Detail and Bumpmap in D3D.
11/19/2006 (5:07 am)
Try the following to see if it helps you:In engine/terrain/terrRender.cc comment the following lines thusly.
Lines 1946 through 1951
/*
// set this up for fog...
// disable so not on in all passes...
// base pass must turn fog on...
glClientActiveTextureARB(GL_TEXTURE2_ARB);
glActiveTextureARB(GL_TEXTURE2_ARB);
glDisable(GL_TEXTURE_2D);
*/Lines 2147 through 2168/*
if(blendedlighting)
{
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, mCurrentBlock->lightMapTexture.getGLName());
LightManager::sgSetupExposureRendering();
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
F32 offset = 1.0f / F32(mCurrentBlock->getSquareSize() * TerrainBlock::BlockSize);
glTexGenfv(GL_S, GL_OBJECT_PLANE, Point4F(offset, 0, 0, 0));
glTexGenfv(GL_T, GL_OBJECT_PLANE, Point4F(0, offset, 0, 0));
glActiveTextureARB(GL_TEXTURE2_ARB);
glEnable(GL_TEXTURE_2D);
glActiveTextureARB(GL_TEXTURE0_ARB);
}
*/Lines 2190 through 2202/*
if(blendedlighting)
{
glActiveTextureARB(GL_TEXTURE1_ARB);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
LightManager::sgResetExposureRendering();
glActiveTextureARB(GL_TEXTURE2_ARB);
glDisable(GL_TEXTURE_2D);
glActiveTextureARB(GL_TEXTURE0_ARB);
}
*/Lines 2221 through 2232 - This on its own will allow terrain details in D3D.glBlendFunc(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA);
/*
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE);
F32 gray[4] = {0.5, 0.5, 0.5, 0.5};
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, gray);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_CONSTANT);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_PRIMARY_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA);
glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR);
*/That will disable the terrain lightmap, which for me enabled proper bumpmap in OpenGL and both Detail and Bumpmap in D3D.
#11
11/19/2006 (5:43 am)
Why would you want to disable the terrain lightmap? That will look very bad.
#12
Paul: Cool! This looked good with D3D (except of framerate and shadow flickering). Less so in OpenGL (no light map). Nice, I'll take a dive into the terrRender.cc and see if what I can do.
11/19/2006 (6:34 am)
Oh just to clarify. I am not bias towards D3D. :)Paul: Cool! This looked good with D3D (except of framerate and shadow flickering). Less so in OpenGL (no light map). Nice, I'll take a dive into the terrRender.cc and see if what I can do.
#13
11/19/2006 (6:51 am)
Quote:Why would you want to disable the terrain lightmap? That will look very bad.I've not seen any difference other than when it would brighten the detail and bump textures when close to the player. I'll post some screens in a minute to show you what I mean.
#14
If it does not look like crap, then you probably disabled something else - and please do post a screenshot :)
11/19/2006 (7:22 am)
Well, disabling the lightmap will take away all the depth in your texture because you are no longer processing shadows/lights from the terrain. And that, quite honestly looks like crap.If it does not look like crap, then you probably disabled something else - and please do post a screenshot :)
#15
Either way, this isn't really a fix, it's just a hack to get rid of one annoyance but causes another.
Without fix:
OpenGL w/o detail and w/o bump

OpenGL w detail and w/o bump

OpenGL w/o detail and w bump angle 1

OpenGL w/o detail and w bump angle 2

OpenGL w/o detail and w bump angle 3

OpenGL w/o detail and w bump angle 4

OpenGL w/o detail and w bump angle 5

OpenGL w/o detail and w bump angle 6

OpenGL w detail and w bump

DirectX w detail and w/o bump

With bumpmapping, the light intensity changes at different angles, which is visually annoying. Also, both the detail and bumpmap textures are too bright, but that's really just personal taste.
With fix:
OpenGL w/o detail and w/o bump

OpenGL w detail and w/o bump

OpenGL w/o detail and w bump

OpenGL w detail and w bump

DirectX w detail and w/o bump
11/19/2006 (7:43 am)
Oops, you would be right about the static terrain shadows and lights, only just noticed. I'll still post the screens to show what the lightmap is doing to the detail and bump textures. You'll also see that the lightmap still works with D3D, so i'm a little confused.Either way, this isn't really a fix, it's just a hack to get rid of one annoyance but causes another.
Without fix:
OpenGL w/o detail and w/o bump

OpenGL w detail and w/o bump

OpenGL w/o detail and w bump angle 1

OpenGL w/o detail and w bump angle 2

OpenGL w/o detail and w bump angle 3

OpenGL w/o detail and w bump angle 4

OpenGL w/o detail and w bump angle 5

OpenGL w/o detail and w bump angle 6

OpenGL w detail and w bump

DirectX w detail and w/o bump

With bumpmapping, the light intensity changes at different angles, which is visually annoying. Also, both the detail and bumpmap textures are too bright, but that's really just personal taste.
With fix:
OpenGL w/o detail and w/o bump

OpenGL w detail and w/o bump

OpenGL w/o detail and w bump

OpenGL w detail and w bump

DirectX w detail and w/o bump
#16
I'm also unsure what adverse effects disabling blended lighting would cause, as it still disables one of the texture passes. It is more than likely the cause of my problem is elsewhere in terrRender, but my pushing of buttons and pulling of leavers got me this far (read: I don't know what I'm doing :P).
11/19/2006 (8:36 am)
Oh, one other thing, without the hack fix you can use $pref::LightManager::sgBlendedTerrainDynamicLighting = false; to disable blended lighting. This will render the bumpmaps correctly, but you still lose the detail texture in D3D unless you keep the detail over-bright removal code I posted earlier.I'm also unsure what adverse effects disabling blended lighting would cause, as it still disables one of the texture passes. It is more than likely the cause of my problem is elsewhere in terrRender, but my pushing of buttons and pulling of leavers got me this far (read: I don't know what I'm doing :P).
Torque Owner Stefan Lundmark