Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (degenerate_762, AbrahamR, AndrewAMD, ozgur), 667 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Fading Detail Models(like in GTA) #51033
08/07/05 23:18
08/07/05 23:18
Joined: Sep 2004
Posts: 1,214
Austin, Texas
Josh_Arldt Offline OP
Senior Developer
Josh_Arldt  Offline OP
Senior Developer

Joined: Sep 2004
Posts: 1,214
Austin, Texas
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);
}
}
///////////////////////////////////////////

Re: Fading Detail Models(like in GTA) [Re: Josh_Arldt] #51034
08/08/05 05:20
08/08/05 05:20
Joined: Jul 2002
Posts: 5,181
Austria
Blattsalat Offline
Senior Expert
Blattsalat  Offline
Senior Expert

Joined: Jul 2002
Posts: 5,181
Austria
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


Models, Textures and Levels at:
http://www.blattsalat.com/
portfolio:
http://showcase.blattsalat.com/
Re: Fading Detail Models(like in GTA) [Re: Blattsalat] #51035
08/08/05 05:31
08/08/05 05:31
Joined: Sep 2004
Posts: 1,214
Austin, Texas
Josh_Arldt Offline OP
Senior Developer
Josh_Arldt  Offline OP
Senior Developer

Joined: Sep 2004
Posts: 1,214
Austin, Texas
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!

Re: Fading Detail Models(like in GTA) [Re: Josh_Arldt] #51036
08/08/05 07:32
08/08/05 07:32
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline
Serious User
Steempipe  Offline
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
Nice contrib. Just saved me some work!!

Re: Fading Detail Models(like in GTA) [Re: Steempipe] #51037
08/08/05 11:21
08/08/05 11:21
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
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

Re: Fading Detail Models(like in GTA) [Re: Josh_Arldt] #51038
08/08/05 11:58
08/08/05 11:58
Joined: May 2005
Posts: 50
D
dead_poet Offline
Junior Member
dead_poet  Offline
Junior Member
D

Joined: May 2005
Posts: 50
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

Re: Fading Detail Models(like in GTA) [Re: dead_poet] #51039
08/08/05 18:17
08/08/05 18:17
Joined: Sep 2004
Posts: 1,214
Austin, Texas
Josh_Arldt Offline OP
Senior Developer
Josh_Arldt  Offline OP
Senior Developer

Joined: Sep 2004
Posts: 1,214
Austin, Texas
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

Now Improving The Framerate a Ton!!! [Re: Josh_Arldt] #51040
08/09/05 04:06
08/09/05 04:06
Joined: Sep 2004
Posts: 1,214
Austin, Texas
Josh_Arldt Offline OP
Senior Developer
Josh_Arldt  Offline OP
Senior Developer

Joined: Sep 2004
Posts: 1,214
Austin, Texas
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);
}}
///////////////////////////////////////////


Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1