TLK doesn't light Translucent Interiors
by Adib Murad · in Torque Game Engine · 10/11/2005 (7:42 pm) · 16 replies
Hey John,
If you remember, I applied the resource you recommended here for translucency on interiors. It worked very well, except that TLK wasn't lighting it. Could you take a look at it?
Thanks in advance.
If you remember, I applied the resource you recommended here for translucency on interiors. It worked very well, except that TLK wasn't lighting it. Could you take a look at it?
Thanks in advance.
#2
Did you got some time to take a look at this one?
I was thinking, it's probably just an "if", where the "trans" entity would be included, right? If you give me a direction, maybe I can find it by myself.
Cheers
11/21/2005 (5:24 pm)
Hi John,Did you got some time to take a look at this one?
I was thinking, it's probably just an "if", where the "trans" entity would be included, right? If you give me a direction, maybe I can find it by myself.
Cheers
#3
So the problem is that the transparent surfaces are not using the light maps, right?
-John
11/22/2005 (7:10 am)
Doh, (*feeling embarrassed*) ok I'll look at this today. Sorry, I got side tracked and forgot.So the problem is that the transparent surfaces are not using the light maps, right?
-John
#4
11/22/2005 (8:02 am)
Adib, can you send me a test dif (with its textures) that I can use to test out the resource?
#5
Yes, everything around look correctly lit, but the trans stuff is not affected.
EDIT: just sent it. Keep us posted!
11/22/2005 (5:39 pm)
Sure! It's on its way...Yes, everything around look correctly lit, but the trans stuff is not affected.
EDIT: just sent it. Keep us posted!
#6
11/28/2005 (7:39 am)
Cool, I got it - will check this out. Thanks for sending those files over, they'll help a lot, while debugging the code.
#7
11/28/2005 (10:21 am)
Can't wait :P
#8
11/28/2005 (2:26 pm)
Ok, try replacing the InteriorTrans::renderObject code with this:void InteriorTrans::renderObject(SceneState* state, SceneRenderImage*)
{
// Check we are in Canonical State.
AssertFatal(dglIsInCanonicalState(), "Error, GL not in canonical state on entry");
// Set up the model view and the global render state...
RectI viewport;
dglGetViewport(&viewport);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
dglMultMatrix(&mRenderObjToWorld);
glScalef(mObjScale.x, mObjScale.y, mObjScale.z);
const Interior::Surface& rSurface = pInterior->mSurfaces[surfaceIndex];
// Lightmaps
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
U32 lm = gInteriorLMManager.getHandle(pInterior->getLMHandle(),
pInteriorInstance->getLMHandle(),
pInterior->getNormalLMapIndex(surfaceIndex))->getGLName();
glBindTexture(GL_TEXTURE_2D, lm);
// Base textures
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBindTexture(GL_TEXTURE_2D, textureName);
pInterior->sgInteriorData.sgRenderARBFCBegin();
// setup render
OutputPoint* pFirstOutputPoint = (OutputPoint*)sgRenderBuffer;
U32 currRenderBufferPoint = 0;
U32 currIndexPoint = 0;
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(OutputPoint), &pFirstOutputPoint->point);
glClientActiveTextureARB(GL_TEXTURE1_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, sizeof(OutputPoint), &pFirstOutputPoint->texCoord);
glClientActiveTextureARB(GL_TEXTURE0_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, sizeof(OutputPoint), &pFirstOutputPoint->lmCoord);
glEnable(GL_CULL_FACE);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.01f);
glEnable(GL_BLEND);
glBlendFunc(rSurface.alphaSrc, rSurface.alphaDst);
glColor4f(1, 1, 1, F32(rSurface.alpha * 0.01));
dMemcpy(texGen0, &pInterior->mTexGenEQs[rSurface.texGenIndex], sizeof(F32)*8);
dMemcpy(texGen1, &pInterior->mLMTexGenEQs[surfaceIndex], sizeof(F32)*8);
emitPrimitive(&sgRenderBuffer[currRenderBufferPoint],
&sgRenderIndices[currIndexPoint],
&pInterior->mWindings[rSurface.windingStart],
rSurface.windingCount,
currRenderBufferPoint,
&pInterior->mPoints[0]);
currRenderBufferPoint += rSurface.windingCount;
currIndexPoint += (rSurface.windingCount - 2) * 3;
// Render
flushPrimitives(sgRenderIndices, currIndexPoint, currRenderBufferPoint);
glClientActiveTextureARB(GL_TEXTURE1_ARB);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glClientActiveTextureARB(GL_TEXTURE0_ARB);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glDisable(GL_ALPHA_TEST);
glBlendFunc(GL_ONE, GL_ZERO);
glDisable(GL_BLEND);
glColor4f(1, 1, 1, 1);
pInterior->sgInteriorData.sgRenderARBFCEnd();
glActiveTextureARB(GL_TEXTURE1_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glDisable(GL_TEXTURE_2D);
glActiveTextureARB(GL_TEXTURE0_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glDisable(GL_TEXTURE_2D);
glBlendFunc(GL_ONE, GL_ZERO);
glDisable(GL_CULL_FACE);
glDepthMask(GL_TRUE);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
dglSetViewport(viewport);
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
AssertFatal(dglIsInCanonicalState(), "Error, GL not in canonical state on exit");
}
#9
Maybe it's being affected just by sunlight, not the sgLight entities.
11/28/2005 (5:28 pm)
Oh, almost there. The trans brush doesn't look full-bright (not affected by lightmaps) in game anymore. But if I move a light entity around it, the bright don't change. All the other difs around are affected properly while I move the light, except the trans brush.Maybe it's being affected just by sunlight, not the sgLight entities.
#10
11/28/2005 (6:15 pm)
Not following you there, but I know from the code that it purposely ignores dynamic lights, is that what you mean - static lights work correctly, but dynamics don't?
#11
I can use static lights, all right. But why ignore the dynamic lights?
11/28/2005 (7:24 pm)
Ok, I tested the static lights (didn't have any on my level, just dynamic ones) and it seem to work fine.I can use static lights, all right. But why ignore the dynamic lights?
#12
11/30/2005 (11:04 am)
The resource ignores the dynamics in the interior code because those surfaces are actually being drawn by a separate object and the object itself doesn't support dynamic lights, so they're totally ignored.
#13
Thank you very much John.
11/30/2005 (6:18 pm)
I see. Well, the statics are working fine. Now everybody has a fix to the translucent interiors resource to use with TLK.Thank you very much John.
#14
Since the Lighting Kit is not integrated into the engine and I have notices many of the variables and functions are different in name and design now.
02/28/2007 (2:45 am)
How much will your update here to the code have changed if I were to use it in 1.5? Since the Lighting Kit is not integrated into the engine and I have notices many of the variables and functions are different in name and design now.
#15
03/02/2007 (1:23 pm)
Probably a good bit - it would be awesome if someone could try porting this resource over to TGE 1.5.
#16
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4199
03/02/2007 (1:41 pm)
This one works with TGE 1.5.0.www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4199
Torque Owner John Kabus (BobTheCBuilder)
-John