[Fixed]DetailTexture Glowing Squares Bug
by CSMP · in Torque Game Engine · 02/04/2009 (9:54 pm) · 15 replies
Ok, I've been having a problem with the Terrain DetailTexture since i started putting things in TGE, now im going to post this as i have searched multiple times to no avail.
1. when i use the DetailTexture in my missions there are instances where if i place an interior and move the view to certain angles (usually facing toward the interiors) there is a terrain "Glowing Square" lighting bug around the avatar.
2. if i dont use the DetailTexture or dont use any interiors there is no problem with the "Glowing Squares"
P.S. OpenGL is affected by this bug, DirectX is not.

1. when i use the DetailTexture in my missions there are instances where if i place an interior and move the view to certain angles (usually facing toward the interiors) there is a terrain "Glowing Square" lighting bug around the avatar.
2. if i dont use the DetailTexture or dont use any interiors there is no problem with the "Glowing Squares"
P.S. OpenGL is affected by this bug, DirectX is not.

#2
03/13/2009 (5:13 am)
The average brightness of your detail texture is at 128 (RGB color Palette)? Also grey scale helps (but 32bit do work), and 1024x1024 or lower power of 2 is best.
#3
I also think it has something to do with the camera being too far in front of the model.
I'll try and fix what i can with the model and see if it works.
03/13/2009 (4:29 pm)
It seems like my character may be modelled incorrectly as the feet are going through the ground, and the only time i actually see my gun is a split second when i jump... at the same time the tileglowing disappears.I also think it has something to do with the camera being too far in front of the model.
I'll try and fix what i can with the model and see if it works.
#4
03/13/2009 (8:32 pm)
Have you checked the player bounding box, from the player data block?
#5
This has been a very annoying bug and for some reason i never thought about the bounding box, i don't know why i modified its values without more testing but i am very grateful that you could help me out.
03/14/2009 (12:07 am)
That was the solution for the GlowBug and player equipment hiding.This has been a very annoying bug and for some reason i never thought about the bounding box, i don't know why i modified its values without more testing but i am very grateful that you could help me out.
#6
For example say theres an interior out of view to my left and right...
If I keep the screen between them then the Glowbug shows, but if i move the screen toward either interior then the second it loads into memory (visible or not) the Glowbug stops.
P.S. I'll get Pics of this a.s.a.p.
03/16/2009 (1:29 pm)
OK, thank you caylo as that fixed the "bugs" from rendering in FirstPerson, Now I can only notice it when in the FreeCamera Mode.For example say theres an interior out of view to my left and right...
If I keep the screen between them then the Glowbug shows, but if i move the screen toward either interior then the second it loads into memory (visible or not) the Glowbug stops.
P.S. I'll get Pics of this a.s.a.p.
#7
However I'm still getting this to happen when the Observer/Spectator camera is the ControlObject with ONLY interiors on the screen, and whenever I move the screen to iclude the other objects on my map the bug stops and renders the terrain correctly.
A pic of the bug...
torque.abigholeintheweb.com/public_system/useruploads/TerrainGlowBug.jpg
07/05/2009 (5:17 pm)
Ok, scaling the BoundingBox bigger around the character (to make sure the eyeNode does not leave the BoundingBox) fixes this bug when the player is the ControlObject.However I'm still getting this to happen when the Observer/Spectator camera is the ControlObject with ONLY interiors on the screen, and whenever I move the screen to iclude the other objects on my map the bug stops and renders the terrain correctly.
A pic of the bug...
torque.abigholeintheweb.com/public_system/useruploads/TerrainGlowBug.jpg
#8
I am not willing to sacrifice the DetailTexture on the terrain and seeing this with the observer is still a showstopping bug, since the observer is the first control object the players have.
07/08/2009 (1:08 pm)
At this point I would almost say adding a bounding box to the observer camera (???) might fix this, as my character does not have this problem anymore. (knock on wood)I am not willing to sacrifice the DetailTexture on the terrain and seeing this with the observer is still a showstopping bug, since the observer is the first control object the players have.
#9
In terrain/terrRender.cc at around line 2188, use the following:
07/08/2009 (2:10 pm)
The easiest way around this that I have found is to comment out the detail texture overbright code in source.In terrain/terrRender.cc at around line 2188, use the following:
if(renderDetails && mCurrentBlock->mDetailTextureHandle.getGLName() != 0)
{
PROFILE_START(TerrainRenderDetails);
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(EdgePoint), &mXFVertices->detailColor);
glBindTexture(GL_TEXTURE_2D, mCurrentBlock->mDetailTextureHandle.getGLName());
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
if(vertexBuffer)
mXFVertices = (EdgePoint *) glLockVertexBufferEXT(block->mVertexBuffer, VertexBufferSize);
doTexGens(detTexGenS, detTexGenT);
if(vertexBuffer)
glUnlockVertexBufferEXT(block->mVertexBuffer);
glEnable(GL_BLEND);
glBlendFunc(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA);
// Do not brighten the detail texture
/*
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE);
const F32 gray[4] = {0.5f, 0.5f, 0.5f, 0.5f};
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);
*/
// End
glActiveTextureARB(GL_TEXTURE1_ARB);
glDisable(GL_TEXTURE_2D);
renderXFCache();
glEnable(GL_TEXTURE_2D);
glActiveTextureARB(GL_TEXTURE0_ARB);
glDisable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glDisableClientState(GL_COLOR_ARRAY);
PROFILE_END();
}
#10
torque.abigholeintheweb.com/public_system/useruploads/TerrainGlowBugFix.jpg
Edit: This photo was what happened when I only commented out the code, to actually fix this bug you must replace the entire stock tge "if(renderDetails && mCurrentBlock->...)" function with Paul's code fix.
Appreciate the help!
07/08/2009 (3:30 pm)
Ok just recompiled with your changes and it seems like it would work if the gray section wasnt being blended, and the gray blending is happening everywhere now.torque.abigholeintheweb.com/public_system/useruploads/TerrainGlowBugFix.jpg
Edit: This photo was what happened when I only commented out the code, to actually fix this bug you must replace the entire stock tge "if(renderDetails && mCurrentBlock->...)" function with Paul's code fix.
Appreciate the help!
#11
Thank you so much, You and Caylo will be mentioned in my Credits as you all have helped me to fix a couple annoying bugs!
07/08/2009 (3:46 pm)
Ok, Seemed like I just needed to replace the entire function that you have posted for the fix.Thank you so much, You and Caylo will be mentioned in my Credits as you all have helped me to fix a couple annoying bugs!
#12
07/09/2009 (6:09 am)
Also, if you try to use the terrain bumpmap texture feature you'll need another "fix". I find having both terrain details and bumps improves the look of the terrain quite a lot.
#13
What exactly would need to be fixed with the TerrainBump's?
07/09/2009 (12:58 pm)
I'm using both, and at this point it looks awesome without those bugs!What exactly would need to be fixed with the TerrainBump's?
#14
In lightingSytem/sgLightManager.cc add/replace the following:
~line 18
~line 147
07/10/2009 (2:59 am)
When using the newer terrain LM with TGE 1.5.2, the bumpmap will stop rendering depending on the angle and distance of the camera to the terrain. The "fix" simply turns off the newer terrain LM when terrain bumpmaps are used. If you do not have this issue, then there's no reason to use the "fix".In lightingSytem/sgLightManager.cc add/replace the following:
~line 18
#include "terrain/terrRender.h"
~line 147
bool LightManager::sgAllowBlendedTerrainDynamicLighting()
{
if(!sgBlendedTerrainDynamicLighting || TerrainRender::mEnableTerrainEmbossBumps)
return false;
return (dglGetMaxTextureUnits() > 2);
}
#15
Thank you again, You have been a major help!
07/10/2009 (9:42 am)
Well I'm glad you could describe the problem and the fix, If I see that happening then I will use your codefix!Thank you again, You have been a major help!
Torque Owner CSMP
MP Studios
(http://tdn.garagegames.com/wiki/Torque/LightingSystem/Rendering_Effects)
This article explains more of what is happening, only im seeing that within the terrain squares.
Very bright terrain squares and it seems the detailtexture disappears!?
Edit: Does not disappear but glows 2x as bright in large tile radius.
I have the perfect demonstration bug pictures though im not sure where to load them to view easily.