Alpha LOD for TGE (1.5 & 1.5.2)
by Martin Busse · 02/16/2007 (9:20 am) · 31 comments
Download Code File
This small code patch enhanced static objects with alpha lod.
In scenes with lot static objects this little patch can give you a nice speed boost.
Based on the distance, static objects will smooth fade in/out.
All changes in the are marked with // AlphaLOD.
New Version, now with inverse AlphaLOD
If you are using the previous Version allready, you need to change the mission file (.mis). Open the .mis file with text editor and use find & replace.
AlphaLODStart -> ALODStart
AlphaLODEnd -> ALODEnd
New 1.5 and 1.5.2 Version
This small code patch enhanced static objects with alpha lod.
In scenes with lot static objects this little patch can give you a nice speed boost.
Based on the distance, static objects will smooth fade in/out.
All changes in the are marked with // AlphaLOD.
New Version, now with inverse AlphaLOD
If you are using the previous Version allready, you need to change the mission file (.mis). Open the .mis file with text editor and use find & replace.
AlphaLODStart -> ALODStart
AlphaLODEnd -> ALODEnd
New 1.5 and 1.5.2 Version
#22
09/07/2007 (6:15 am)
Thanks Martin, I had grasped some of the changes required, but clearly not all of them. I'll give it a whirl when I get home from work tonight.
#23
fixes wrong sorting ...
in TSStatic.cc (bool TSStatic::prepRenderImage(SceneState* state, ....)
09/07/2007 (11:50 am)
minor bugfix:fixes wrong sorting ...
in TSStatic.cc (bool TSStatic::prepRenderImage(SceneState* state, ....)
image->textureSortKey = mShapeHash;
state->insertRenderImage(image);
}
if (mShapeInstance->hasTranslucency()[b] || fAlphaLOD < 1.f[/b])
{
SceneRenderImage* image = new SceneRenderImage;
image->obj = this;
#24
Just to start off, this is a great resource, thank you. I'm wondering if anyone else has come across this same problem, so here it is. With the afx system you can use a method (afxModelData) to have particle effects work with a static dts object that will only appear in the game for a few moments, which ends up doing some fancy effects. Anyways, once I loaded in that alphaLOD it made my dts object disappear in the spell effect. It just simple won't show the dts object?
Does anybody have any idea how to fix this?
Thx.
09/20/2007 (10:38 pm)
Hello,Just to start off, this is a great resource, thank you. I'm wondering if anyone else has come across this same problem, so here it is. With the afx system you can use a method (afxModelData) to have particle effects work with a static dts object that will only appear in the game for a few moments, which ends up doing some fancy effects. Anyways, once I loaded in that alphaLOD it made my dts object disappear in the spell effect. It just simple won't show the dts object?
Does anybody have any idea how to fix this?
Thx.
#25
Hi,
maybe the afx system has a problem with state->getCameraPosition() or getRenderTransform() ...
insert into bool TSStatic::prepRenderImage(SceneSt... (tsStatic.cc)
When create a empty mission just a terrain, player and afxModelData Particle fx and tell me what you get in console.
09/21/2007 (1:17 pm)
@DALO:Hi,
maybe the afx system has a problem with state->getCameraPosition() or getRenderTransform() ...
insert into bool TSStatic::prepRenderImage(SceneSt... (tsStatic.cc)
if (mShapeInstance && state->isObjectRendered(this)) {
Point3F cameraOffset;
getRenderTransform().getColumn(3,&cameraOffset);
[b]Con::errorf("cameraOffset1: %f %f %f", cameraOffset.x, cameraOffset.y, cameraOffset.z);[/b]
cameraOffset -= state->getCameraPosition();
[b]Con::errorf("cameraOffset2: %f %f %f", cameraOffset.x, cameraOffset.y, cameraOffset.z);[/b]
F32 dist = cameraOffset.len();
if (dist < 0.01)
{When create a empty mission just a terrain, player and afxModelData Particle fx and tell me what you get in console.
#26
fxStatic->setAlphaLOD(mFieldData.fAlphaLODStart, mFieldData.fAlphaLODEnd, FieldData.bAlphaLODInverse);
03/24/2008 (1:06 am)
compiler error with "bAlphaLODInverse not found"fxStatic->setAlphaLOD(mFieldData.fAlphaLODStart, mFieldData.fAlphaLODEnd, FieldData.bAlphaLODInverse);
#27
you find this line in "fxShapeReplicator.cc".
replace to
then recompile.
10/16/2008 (4:40 am)
@ccljyc:you find this line in "fxShapeReplicator.cc".
fxStatic->setAlphaLOD(mFieldData.fAlphaLODStart, mFieldData.fAlphaLODEnd, [b]FieldData[/b].bAlphaLODInverse);
replace to
fxStatic->setAlphaLOD(mFieldData.fAlphaLODStart, mFieldData.fAlphaLODEnd, [b]mFieldData[/b].bAlphaLODInverse);
then recompile.
#28
anyone posting alphalod for tgea resource...
10/16/2008 (4:48 am)
i need this resource for TGEA.anyone posting alphalod for tgea resource...
#29
edit: I also haven't looked at AFXModel results. It wouldn't be tough to check for and skip those though, which is probably the simplest solution.
Also, having seen this effect in other AAA games (fallout3), I'd suggest a value combo of 10/50 for objects in the 1-4 meter size range, and leave building sized at the defaults (100/150).
12/15/2008 (4:31 am)
For TGEA 1.7.1 and 1.8; follow all the above, changing just the renderObject() function as follows....//AlphaLOD ->
if(mShapeInstance)
{
mShapeInstance->setAlphaAlways(fAlphaLOD);
S32 s = mShapeInstance->mMeshObjects.size();
for(S32 x = 0; x < s; x++)
{
mShapeInstance->mMeshObjects[x].visible = fAlphaLOD;
mShapeInstance->mMeshObjects[x].forceHidden = (fAlphaLOD == 0.f);
}
}
//<- AlphaLOD
mShapeInstance->animate();
mShapeInstance->render();I didn't check into adjustments for translucency, perhaps another time. This was tested though, and works well.edit: I also haven't looked at AFXModel results. It wouldn't be tough to check for and skip those though, which is probably the simplest solution.
Also, having seen this effect in other AAA games (fallout3), I'd suggest a value combo of 10/50 for objects in the 1-4 meter size range, and leave building sized at the defaults (100/150).
#30
i used Erik & Martin's resource.
but this code have sort problem.
i'm not network test.
www.mediafire.com/download.php?ymgwmjycwlk
01/06/2009 (9:30 pm)
i apply to tsShape & fxshapereplicator in TGEA 1.7.1(AFX112).i used Erik & Martin's resource.
but this code have sort problem.
i'm not network test.
www.mediafire.com/download.php?ymgwmjycwlk
#31
Thank you,
J
01/19/2010 (10:46 pm)
Anyone tried this in T3D? If so, does it help as much as it did in 1.5? I would greatly appreciate a link to the port if anyone had it?Thank you,
J

Torque Owner Martin Busse
Default Studio Name
Change in TSStatic.h (class TSStatic : public SceneObject)
U32 packUpdate (NetConnection *conn, U32 mask, BitStream *stream); void unpackUpdate(NetConnection *conn, BitStream *stream); [b]//AlphaLOD -> void setAlphaLOD(F32 start, F32 end, bool inverse) { fAlphaLODStart = start; fAlphaLODEnd = end; bAlphaLODInverse= inverse; } //<- AlphaLOD[/b] void inspectPostApply(); }; #endif // _H_TSSTATICChange in fxShapeReplicator.h (class fxShapeReplicator : public SceneObject -> class tagFieldData)
bool mShowPlacementArea; U32 mPlacementBandHeight; ColorF mPlaceAreaColour; [b]//AlphaLOD -> F32 fAlphaLODStart; F32 fAlphaLODEnd; bool bAlphaLODInverse; //<- AlphaLOD[/b] tagFieldData() { // Set Defaults. mSeed = gRandGen.randI(0, 1000000000); mShapeFile = StringTable->insert("");mShapeRotateMax .set(0, 0, 0); mTerrainAlignment .set(1, 1, 1); [b]//AlphaLOD -> fAlphaLODStart = 100.f; fAlphaLODEnd = 150.f; bAlphaLODInverse = false; //<- AlphaLOD[/b] } } mFieldData; // Declare Console Object.Change in fxShapeReplicator.c (void fxShapeReplicator::initPersistFields())
addField("useLightingOcclusion", TypeBool, Offset(useLightingOcclusion, SceneObject)); endGroup("Lighting"); [b]//AlphaLOD -> addGroup("AlphaLOD"); addField("ALODStart", TypeF32, Offset(mFieldData.fAlphaLODStart, fxShapeReplicator)); addField("ALODEnd", TypeF32, Offset(mFieldData.fAlphaLODEnd, fxShapeReplicator)); addField("ALODInverse", TypeBool, Offset(mFieldData.bAlphaLODInverse, fxShapeReplicator)); endGroup("AlphaLOD"); //<- AlphaLOD[/b] }in void fxShapeReplicator::CreateShapes(void)
fxStatic->lightGroupName = lightGroupName; fxStatic->useLightingOcclusion = useLightingOcclusion; [b]//AlphaLOD -> fxStatic->setAlphaLOD(mFieldData.fAlphaLODStart, mFieldData.fAlphaLODEnd, FieldData.bAlphaLODInverse); //<- AlphaLOD[/b] // Set the 'shapeName' field. fxStatic->setField("shapeName", mFieldData.mShapeFile); // Is this Replicator on the Server?in U32 fxShapeReplicator::packUpdate(NetConnection * con, U32 mask, BitStream * stream)
stream->writeInt(mFieldData.mPlacementBandHeight, 32); // Placement Area Height. stream->write(mFieldData.mPlaceAreaColour); [b]//AlphaLOD -> stream->write(mFieldData.fAlphaLODStart); stream->write(mFieldData.fAlphaLODEnd); stream->write(mFieldData.bAlphaLODInverse); //Con::errorf("writeAlphaLOD %f %f", mFieldData.fAlphaLODStart, mFieldData.fAlphaLODEnd); //<- AlphaLOD[/b] } // Were done ...in void fxShapeReplicator::unpackUpdate(NetConnection * con, BitStream * stream)
mFieldData.mPlacementBandHeight = stream->readInt(32); // Placement Area Height. stream->read(&mFieldData.mPlaceAreaColour); [b]//AlphaLOD -> stream->read(&mFieldData.fAlphaLODStart); stream->read(&mFieldData.fAlphaLODEnd ); stream->read(&mFieldData.bAlphaLODInverse); //Con::errorf("readAlphaLOD %f %f", mFieldData.fAlphaLODStart, mFieldData.fAlphaLODEnd); //<- AlphaLOD[/b] // Set Transform. setTransform(ReplicatorObjectMatrix);