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 / Bendy plain shadows - re-posted

Author
Message
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 25th Jan 2005 02:56
Hi all,
Just a snippet someone asked for so I thought I might as well repost it, uses a boned plain to mould onto terrain for better plain shadows.


Van-B


It's c**p being the only coder in the village.
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 25th Jan 2005 10:20
what a coincidence, I was just about to look for that. hehe!

"eureka" - Archimedes
BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 25th Jan 2005 18:36
You should rename yourself Van Bone. More good work, Mr B!

BatVink
Dr_Z
21
Years of Service
User Offline
Joined: 22nd Jan 2005
Location: Behind the code
Posted: 25th Jan 2005 19:09
This is it! Thank you SOOO much!
Now, I'll try some weird experiments (hehe)...
... before I post some "nice way to cast shadows in DBP"
I'm on it.
If someone wants to give a hand...

"Never give up! Never surreeendeeer!"
Erick G
Retired Moderator
21
Years of Service
User Offline
Joined: 2nd Oct 2004
Location: Texas, USA
Posted: 29th Jan 2005 01:13
Hey Van B

First off, awsome snippet man !!

Is it ok if I steal your lens flare code ?

Could you maybe explain it some ? I converted it to the dark SDK, but does not line up 100%, maybe some vals I can tweak ?
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 29th Jan 2005 01:44
Cheers Erick, of course you can use the lens flare .

It locks the plains to the screen, then uses the screen location of the sun to work out a scale to position the locked plains. I worked it out with trial and error (like moving a plain in 3D while locked on X and Y then checking the screen coordinates). This bit works out the positions (comments added):

`position object 2 which is hidden at the position of light 0 - which you should try to get at the sun position on the skybox
position object 2,light position x(0),light position y(0),light position z(0)
`if the sun is in screen position and show the flare plains
if object in screen(2)=1
`0.15625 is the number I came up with to convert the screen position into 3D locked positions
lensx#=(object screen x(2)-(screen width()/2.0))*-0.15625
lensy#=(object screen y(2)-(screen height()/2.0))*0.15625

`Now multiplying lensx# and lensy# would calculate the sun location, so using different multipliers makes the flare effect
position object 40,lensx#*-0.5,lensy#*-0.5,100
position object 41,lensx#*0.2,lensy#*0.2,100.001
position object 42,lensx#*0.9,lensy#*0.9,100.002

show object 40
show object 41
show object 42
else
`Hide them if the sun is not in screen
hide object 40
hide object 41
hide object 42
endif


Van-B


It's c**p being the only coder in the village.
Erick G
Retired Moderator
21
Years of Service
User Offline
Joined: 2nd Oct 2004
Location: Texas, USA
Posted: 29th Jan 2005 04:44 Edited at: 29th Jan 2005 04:48
Ah ok cool, yeah those decimated numbers you used as multipliers for trial and error, threw me off on the DarkSDK conversion, I think I will mess around with them a bit

Thanks so much for the help, this really did the trick

My terrain and game is coming along nicely now and this effect will really help aisthetically

Thanks again man !
Baggers
22
Years of Service
User Offline
Joined: 31st May 2004
Location: Yonder over dem dere hills
Posted: 29th Jan 2005 07:04
Very nice routine, I was just looking into how to do this for jazz jackrabbit!
squirrel 890
21
Years of Service
User Offline
Joined: 18th Jan 2005
Location: aaaaaaaaaaaaaaaaaaaaa i remeber i forgot
Posted: 24th Feb 2005 06:02
hey can i use this in my game
and awsome this is relly good
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Feb 2005 20:51
Off course Squirrel, anything I post in Code Snippets is public domain.


Van-B


It's c**p being the only coder in the village.

Login to post a reply

Server time is: 2026-07-05 02:58:00
Your offset time is: 2026-07-05 02:58:00