Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / DBP Distance fadeout (culling)

Author
Message
Jack
20
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 29th Mar 2007 15:11 Edited at: 3rd Apr 2007 23:04
Hi, it was a very boring day so I created some functions which will increase your fps.

This code will fade objects out of your view if they are to far away.



Maybe somebody will combine this with the frustrum culling system from LiT. Here



[/center]
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 30th Mar 2007 02:56
You can easily add this without even checking the distances if you use my code. The return value for sphere in frustum is the distance it is from the camera. You could just add your code in there since I use it for the first check in all culling types.

Jack
20
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 30th Mar 2007 14:41 Edited at: 30th Mar 2007 15:13
Ok I'll see what I can do.

[/center]
Juso
22
Years of Service
User Offline
Joined: 23rd Sep 2002
Location: Finland
Posted: 3rd Apr 2007 12:12 Edited at: 3rd Apr 2007 12:15
Value of "Set alpha mapping on" needs a percentage value from 0 to 100. So its not 0 to 255

You need to change 2 lines in your code.
Turoid
21
Years of Service
User Offline
Joined: 1st Nov 2003
Location: The Netherlands
Posted: 3rd Apr 2007 15:26
its a pretty cool effect, but if you want to use it to speed it up you can better use ' set camera distance'.. only then you won't get that nice fade effect

Your code constantly calculates distances between objects and uses alpha mapping, that is more cpu intensive than just use set camera distance command.

anyway, nice effect, reminds me of gta 3

I am awesome and always right.
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 3rd Apr 2007 17:24 Edited at: 3rd Apr 2007 17:24
Quote: "set camera distance'"


Did you mean "Set Camera Range"?

Jack
20
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 3rd Apr 2007 22:52 Edited at: 3rd Apr 2007 23:01
@Turoid
You're right it is more CPU intensive but it's the fastest way to make the Effect in DBP. (Maybe Im Wrong)
The advantage is if you have a big terrain with a lot of objects and you don't want to cut your terrain but fade out the objects you can use this code.


BTW Ive edited the code.

€dit: There are only small FPS differences.

[/center]
Turoid
21
Years of Service
User Offline
Joined: 1st Nov 2003
Location: The Netherlands
Posted: 3rd Apr 2007 23:11
Quote: "The advantage is if you have a big terrain with a lot of objects and you don't want to cut your terrain but fade out the objects you can use this code.
"


True, I had not thought of that yet

@sixty:... eeeh whoops! yeah i meant set camera range..

I am awesome and always right.
Code Dragon
18
Years of Service
User Offline
Joined: 21st Aug 2006
Location: Everywhere
Posted: 4th Apr 2007 00:57
That fade effect looks sweet. I've only seen it done once before, that was in the days of the N64.

By reading this sentence you have given me brief control of your mind.
Turoid
21
Years of Service
User Offline
Joined: 1st Nov 2003
Location: The Netherlands
Posted: 4th Apr 2007 11:48
eeh hyperbyte can you please stop posting that link in all the threads... kinda pointless..

I am awesome and always right.
Scab
20
Years of Service
User Offline
Joined: 11th Feb 2004
Location:
Posted: 9th May 2007 22:41
Altered Jacks code to fade objects according to their distance. So they don't appear to pop out of nowhere.

Login to post a reply

Server time is: 2024-11-22 18:57:55
Your offset time is: 2024-11-22 18:57:55