Fading Detail Models(like in GTA)

Posted By: Josh_Arldt

Fading Detail Models(like in GTA) - 08/07/05 23:18

This code fades a model out on distance from the camera.
Almost everything is tweekable in WED by resources/scripts/customize.
It's very simple, but I thought that some people could use it.

The only requirement from me is for you to post any cool moddifications of this code in this thread for others.

///////////////////////////////////////////
//Include this wdl as the first include
//in your main script. After the path definitions.
//Then choose the action that you want to have the
//detain model properties and put detail_model();
//at the top of its action.
///////////////////////////////////////////optimizer
var DM_Dist;
// entry: fading speed
// help: This is the fading speed of the model.
var DM_ClipAmt = 0.025;//fading speed
// entry: fading distance
// help: This is the fading distance of the model.
var DM_FadeDist = 999;//distance from cam
var DM_DistFromCam;

function detail_model()
{
while(1)
{
DM_DistFromCam = vec_dist(my.x, camera.x);
if(vec_dist(my.x, camera.x) > DM_FadeDist)
{
my.alpha = 100;
my.transparent = off;
}else{
my.transparent = on;
DM_Dist = 100 - DM_DistFromCam * DM_ClipAmt;
vec_set(my.alpha, DM_Dist);
}
wait(1);
}
}
///////////////////////////////////////////
Posted By: Blattsalat

Re: Fading Detail Models(like in GTA) - 08/08/05 05:20

this would be great if connected with the lod core of the gs engine so you dont need to trace twice and could manage it directy with the engine....would be a nice add in for the future/feature of gs.
Especially open space levels benefit from that.....just one more line in the starter: clip_fade_in_percentage = 0...100 (0 is lod stage 3 = pops out when it reaches the lod3 distance, and 100 is the distance of lod2 = set to 100 it will take till it reaches lod distance 2 to completele fade in)

cheers
Posted By: Josh_Arldt

Re: Fading Detail Models(like in GTA) - 08/08/05 05:31

Quote:

this would be great if connected with the lod core of the gs engine so you dont need to trace twice and could manage it directy with the engine....would be a nice add in for the future/feature of gs.
Especially open space levels benefit from that.....just one more line in the starter: clip_fade_in_percentage = 0...100 (0 is lod stage 3 = pops out when it reaches the lod3 distance, and 100 is the distance of lod2 = set to 100 it will take till it reaches lod distance 2 to completele fade in)

cheers




That would be a very neat feature!
Posted By: Steempipe

Re: Fading Detail Models(like in GTA) - 08/08/05 07:32

Nice contrib. Just saved me some work!!
Posted By: HeelX

Re: Fading Detail Models(like in GTA) - 08/08/05 11:21

Well, this could be easily done. Unfortunately, I'm on a seminar, so I can't write anything, but it might be integrated into the LOD core as well. You know, in GTA high res building models and low res building models are visible the same time when they blend. So, your routine has to recognize the change (over str_for_entfile for example or the LOD ranges) and immediately after this the high res model has been changed to the low res one by A6. To achieve this effect we need to reload the high res one and fade that out (or in). During the blend process we got more polygons than it should be, but it looks nice. When I come home during this week,, I will try to write a routine like that (this topic awaked my interest )

ciao
-Christian
Posted By: dead_poet

Re: Fading Detail Models(like in GTA) - 08/08/05 11:58

Code:
 
///////////////////////////////////////////
//Include this wdl as the first include
//in your main script. After the path definitions.
//Then choose the action that you want to have the
//detain model properties and put detail_model();
//at the top of its action.
///////////////////////////////////////////
var DM_DistFromCam;
///////////////////////////////////////////
Var DM_Fade_Start = 2000;
Var DM_Fade_End = 2500;
///////////////////////////////////////////
Starter Fading
{
DM_Fade_End -= DM_Fade_Start;
}
///////////////////////////////////////////
function detail_model()
{
while(me)
{
DM_DistFromCam = vec_dist (my.x, camera.x);
My.alpha = 100 - ((DM_DistFromCam - DM_Fade_Start) / DM_Fade_End) * 100;
my.transparent = ((DM_DistFromCam - DM_Fade_Start) > 0);

wait(1);
}
}
///////////////////////////////////////////




little more optimized...
DM_Fade_Start and DM_Fade_End are to use like fog_start and fog_end...
have fun
Posted By: Josh_Arldt

Re: Fading Detail Models(like in GTA) - 08/08/05 18:17

Quote:

Nice contrib. Just saved me some work!!




I'm glad this little snippet saved you some work Steempipe.

@ tramper, thanks for sharing your mod with the community. I like what you have done to it.

@ everyone else, this snippet was meant to be like the way models fade in GTA( cars, trash, people, ect... ), but if you turn the range higher and use it with LOD( making each section of your huge world map entities ) then it could help the framerate a bit like in GTA.

If you don't have the comm or pro versions and wish to use LOD in-turn with this little snippet, then you can use the fake LOD script contributed by Bright. Fake Geometric LOD
Posted By: Josh_Arldt

Now Improving The Framerate a Ton!!! - 08/09/05 04:06

After some testing I realised that this wasn't helping the framerate at all!
So I instantly realised why and fixed it.
Here is the working version.
I tested it with a massive level made out of seperate map entities.
In my massive test level using the old snippet my fps was usually 8FPS.
With this new snippet the average FPS was 50FPS.
Huge improvement!

///////////////////////////////////////////optimizer
//Include this wdl as the first include
//in your main script. After the path definitions.
//Then choose the action that you want to have the
//detain model properties and put detail_model();
//at the top of its action.
///////////////////////////////////////////
var DM_DistFromCam;
///////////////////////////////////////////
Var DM_Fade_Start =2000;
Var DM_Fade_End = 2200;//2500
///////////////////////////////////////////
Starter Fading{
DM_Fade_End -= DM_Fade_Start;
}
///////////////////////////////////////////
function detail_model(){
while(me)
{
DM_DistFromCam = vec_dist (my.x, camera.x);
My.alpha = 100 - ((DM_DistFromCam - DM_Fade_Start) / DM_Fade_End) * 100;
my.transparent = ((DM_DistFromCam - DM_Fade_Start) > 0);
if(my.alpha < 1)
{
my.invisible = on;
}else{
my.invisible = off;
}
wait(1);
}}
///////////////////////////////////////////
© 2024 lite-C Forums