Game Development Community

dev|Pro Game Development Curriculum

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
Page «Previous 1 2
#1
02/15/2007 (2:25 am)
In the editor you can change beginning and end of the AlphaLOD Fading.
Turn AlphaLOD off with:
AlphaLODStart = 0
AlphaLODEnd = 0

Small bugfix:
in "bool TSStatic::prepRenderImage(..." remove the bold lines
//AlphaLOD ->
	  fAlphaLOD = 1.f;
	  if((fAlphaLODStart < fAlphaLODEnd) && fAlphaLODStart > 0.1f)
	  {
		if (dist >= fAlphaLODEnd)
		{
		  return false;
		}
		  
		[b]if((fAlphaLODStart < fAlphaLODEnd) && fAlphaLODStart > 0.1f) <-- remove line
		{ <-- remove line [/b]
		  if (dist > fAlphaLODStart)
		  {
			fAlphaLOD -= ((dist - fAlphaLODStart) / (fAlphaLODEnd - fAlphaLODStart));
		  }
		[b]} <-- remove line [/b]
	  }
	  //<- AlphaLOD

This is fixed in the new Version
#2
02/16/2007 (10:52 am)
This is good stuff!

I also have an Alpha LOD system, not as fancy as yours, plugged into ShapeBase.cc. I use fogAmount to calculate when to Alpha fade the mesh and dont render it when the alpha is over 90%. I am going to see if i can adopt your system, with individual mesh alpha fade settings, in place of mine in tsStatic, but still use fogAmount for ShapeBase alpha LOD.
#3
02/16/2007 (11:26 am)
@Caylo
With fogAmount?
Then all Static Object are using the same value / distance for fading?

I think it is better that every Static Object has it's own AlphaLOD settings.
#4
02/18/2007 (12:13 pm)
Yes, with fogAmount. I had it so all mesh would fade out INTO the fog. Very much like your system. But as i said, for tsStatic i like your system better. (I still have it so they all fade away into the fog, but your system allows SOME mesh to fade away faster.)
#5
02/19/2007 (12:31 pm)
this looks cool!
#6
02/20/2007 (11:05 pm)
this for TGEA ;) *hint hint*
#7
02/21/2007 (1:02 pm)
Inverse AlphaLOD

d4rkm4r3.com/AlphaLODInverse.jpgBillboard -> highdetail Mesh

d4rkm4r3.com/AlphaLODInverse2.jpgPoor man's SpeedTree ;-)

Download the trees (Public Domain)
Use values like:

treesbb.dts ->
Start: 60
End: 70
Inverse: off

treesbblowdetail.dts ->
Start: 50
End: 60
Inverse: on

Place both on the same Position. (move treesbblowdetail.dts a little bit up)
#8
02/21/2007 (1:10 pm)
Some Tips:
Use the Inverse AlphaLOD for
- Groundfog in your Dungeons.
- Spooky Lights in the distance
- Soft transitions from HighDetailMesh to LowDetailBillboards
#9
02/21/2007 (10:30 pm)
Thats very cool, thank you!
#10
02/28/2007 (7:14 pm)
Sweet! Thank You!
#11
05/18/2007 (6:00 pm)
does this code break any of the metrics for anyone else?
my metrics(fps) is returning only 0 or 1 when looking at TSStatics and normal values when looking elsewhere.
#12
05/25/2007 (5:07 am)
Great resource! - can this be adjusted to work in TGEA 1.01 + ??
#13
06/03/2007 (8:01 am)
Unfortunately my profile makes no reference to coding or scripting skills... So, I have had no luck merging this into 1.5.2 :( Anyone able to merge this successfully into 1.5.2?
Thanks
#14
06/06/2007 (4:16 am)
@Eric Johnson:
TGE 1.5.2 Version is comming soon. It's already done, but my PC is broken.

@Juha Eerola:
I own TGEA, but i don't use it in the moment because of the missing Linux and OpenGL support.
#15
06/06/2007 (2:51 pm)
Thank you!
#16
06/25/2007 (1:43 pm)
@Martin: how difficult would it be to port that to an older version? TGE 1.4+TLK for example
#17
06/25/2007 (2:37 pm)
TGEA port :) ?
#18
06/27/2007 (4:02 am)
@Stephan (viKKing) Bondier:
I think it should be easy, about 20 - 30 minutes. I marked all changes with "AlphaLOD" in side the source code. The AlphaLOD based on the Cloaking code of the torque engine.

@PuG:
I own TGEA, but i don't used it. At monent i had rewrote the sky-class of TGE and have alot of truble now with the FOG (water is pink and the rest is blue O_o ). All of my freetime is spend for my wife and TGE. :-)
#19
07/29/2007 (10:15 pm)
@Martin,
Great resource! Very nice looking in game.

@Stephan,
If you haven't tried it yet, it went into my build of 1.4 (with the MK) in about 20 minutes (actually would have been a lot faster, but I brought over a few things I shouldn't have, and had to backtrack once).
#20
09/05/2007 (8:06 pm)
@Martin,

What would I have to do to add the AlphaLOD setting controls to shape replicated objects? The are being controlled by the default settings. I can set an overall fade level for shape replicated objects, but it would be nice to have the same kind of controls as for single statics. I can see where it might go, but not really sure what code additions might be necessary in the fxshapeReplicator.

Thanks,
Alan
Page «Previous 1 2