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.

DarkBASIC Professional Discussion / real time shadows

Author
Message
JDforce
21
Years of Service
User Offline
Joined: 27th Jul 2004
Location: Sea of Tranquility
Posted: 3rd Aug 2009 08:17
Hi,
Until now I had not any need of shadows. Now am making a project that will simulate object handling under heavy sunlight, with variable position of the sun and under local work lights when the simulation is at [virtual] night.

Can someone guide me to the correct method of having real time shadows? They are advertised in the DBpro features but so far I have not found any information or help about them. The "set shadow shading on" commands have not any example and the suggested fx procedure does not seem to work. In my darksource snippets there is a self shadowing example but it is the only example I found. Those artifacts are ugly.
Other than that, applying the stencilshadows.fx shader does not seem to work properly as I said before, but then again, there is not any guide for using it or what it does over the object or other objects to cast the shadow.

I found some old posts and a db classic exe that does not show how-to. The posts say dbpro is bad at shadows, but the most recent ones are from 2003 as I recall.

So, anyone knows how to do it?

May the 3d force B with U
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd Aug 2009 13:17 Edited at: 3rd Aug 2009 13:58
Spooky posted a good demo of how to use the shadow commands. I'll see if I can locate it.

Should show up on a search.

Edit It doesn't.

Either it wasn't Spooky - or he posted in another thread.

I'll dig it out somehow and post it.

Edit2 Found it! No idea where I got it from in the first place. I've capped the FPS to 60:



Hope this helps.
Mobiius
Valued Member
22
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 3rd Aug 2009 14:12
Nice.

Your signature has been erased by a mod because it is way too awesome!
JDforce
21
Years of Service
User Offline
Joined: 27th Jul 2004
Location: Sea of Tranquility
Posted: 3rd Aug 2009 18:46
Thanks Green Gandalf, will test it later today.

May the 3d force B with U
JDforce
21
Years of Service
User Offline
Joined: 27th Jul 2004
Location: Sea of Tranquility
Posted: 3rd Aug 2009 19:41
Green Gandalf, It works perfectly and will make a test with objects other than boxes to see if the logic fits my needs.

Upon checking the code, found some instructions that led me to dig a bit into the undocumented gamefx set of commands, and the sample for its use.
That set seem to be related to "static universe" and shadow casting. Not sure yet on what the terms mean, but will search.

Thanks!

May the 3d force B with U
GeeBee
16
Years of Service
User Offline
Joined: 26th Aug 2008
Location:
Posted: 4th Aug 2009 23:19
Would this shadowing work on an Advanced Terrain?

Design by Trial and eror...and errror...and errorr
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 5th Aug 2009 13:22
Good question.

Well, that's blown another quiet relaxing afternoon and evening.
JDforce
21
Years of Service
User Offline
Joined: 27th Jul 2004
Location: Sea of Tranquility
Posted: 7th Aug 2009 21:28
I guess it would work on advanced terrain. The only issue I have observed in my tests, is that memory is used astronomically when an object with too many faces is shadow shader applied. My program reported an out of memory when trying to shadow a 64x64 (longitude and latitude faces) sphere object. Since Adv Terrain is far from low poly, we should test it.

May the 3d force B with U
GeeBee
16
Years of Service
User Offline
Joined: 26th Aug 2008
Location:
Posted: 7th Aug 2009 22:14
Having now tried it, the answer is 'Sadly not' - shadowing works on the object itself, but no shadow is cast on the Advanced Terrain itself.

Even if it did, the hit on FPS makes it an impractical option (for me).

Design by Trial and eror...and errror...and errorr
JDforce
21
Years of Service
User Offline
Joined: 27th Jul 2004
Location: Sea of Tranquility
Posted: 7th Aug 2009 23:05
So bad. Shadows make the scene very realistic. I have been playing with conitec´s 3dgamestudio with this shadow issue. My license is commercial, but for shadowing purposes it works perfectly.
Shadows render on the terrain as you can see from the "earth" sample included also in the free version.

Another program that has shadows as a standard is 3dRAD, which now has been released fully as freeware at 3drad.com . I have used it since previous versions. Performance with many objects is not as fast, but it has its charm.

May the 3d force B with U
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Aug 2009 01:36
Quote: "Would this shadowing work on an Advanced Terrain?"


Quote: "Good question.

Well, that's blown another quiet relaxing afternoon and evening."


Quote: "Having now tried it, the answer is 'Sadly not' - shadowing works on the object itself, but no shadow is cast on the Advanced Terrain itself."


Well, I've just tried it and it works.
GeeBee
16
Years of Service
User Offline
Joined: 26th Aug 2008
Location:
Posted: 18th Aug 2009 08:24 Edited at: 18th Aug 2009 09:47
Grrrrr...

I'll try again, using a different test setup.

EDIT: Agreed. Works fine. My apologies for the duff information.

FPS still suffering however.

Design by Trial and eror...and errror...and errorr
NightX
16
Years of Service
User Offline
Joined: 3rd Apr 2009
Location: Australia, QueensLand
Posted: 20th Aug 2009 13:25
You can have a look at evolved shaders, there is some nice shadows there and lights

http://evolveduk.googlepages.com/Shaders.html

LoST The beginning of the EnD
GeeBee
16
Years of Service
User Offline
Joined: 26th Aug 2008
Location:
Posted: 20th Aug 2009 23:34
NightX - Thanks.

Using Evolved's shaders, the best FPS I get is the "2D Shadow Mapping" which still only gets 54FPS (16 bit depth - 32 bit is slower still).

I haven't tried it 'in game' yet, but I suspect it won't be viable. The option above from GG still wins (84-145FPS), despite the bad reviews on DBP's native shadowing capability.

While not an exact comparison & it is probably my poor graphics ability on my computer, it'd be nice to know other users feedback - What's anyone else getting?

Design by Trial and eror...and errror...and errorr
revenant chaos
DBPro Master
18
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 21st Aug 2009 06:43
GeeBee- when testing Evolved's demos, make sure to change the vsync mode to zero (in the set display mode command), and set the sync rate to zero.
NightX
16
Years of Service
User Offline
Joined: 3rd Apr 2009
Location: Australia, QueensLand
Posted: 21st Aug 2009 12:00
Thanks, im not on my computer currently, but i know the frame rate is very high when i run that example! and it runs so smooth and looks like magic. i think personaly evolved has the best lights that look nice and soft shadows.

when you ran it GeeBee, was the screen a type of white?
because on my other computer it was, my other computer dosent have a good graphcis card.

Physics to the MAXXXX
GeeBee
16
Years of Service
User Offline
Joined: 26th Aug 2008
Location:
Posted: 22nd Aug 2009 09:38
RC & NightX - thanks again.

I can't get Evolved's shaders to cast a shadow onto an Advanced Terrain. It would be useful if anyone could confirm:

a. Evolved's shaders definitely work on AT?

Even if they do, my game AT already has one of Green Gandalf's shaders already applied, so:

b. Can 2 shaders be applied to the same object at the same time?

Design by Trial and eror...and errror...and errorr
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Aug 2009 13:50
GeeBee

a. It should be possible to get Evolved's shaders working on AT - but they may need to be edited a bit. AT is awkward with shaders. I usually find it helps to change the AT fvf format so it has vertex normals but not vertex diffuse. Things then work as you expect. But I haven't tried shadows yet ...

b. No. You have to combine the code into a single shader in some way. An exception is a postprocessing effect.

Could you post a simple demo of what you are trying to use (and a link to Evolved's original demo) in case I can see a simple fix? I won't have much time this weekend but should be able to find time for a quick look.
GeeBee
16
Years of Service
User Offline
Joined: 26th Aug 2008
Location:
Posted: 23rd Aug 2009 22:04 Edited at: 23rd Aug 2009 22:09
GG

Managed to get Evolved's shader working with AT (after fixing normals as you suggested). At least I can now get shadows on the AT terrain (hills/valleys) as well as being cast from the object also - however, at 20FPS (on my machine) it would be unworkable. If you spot an obvious error/issue in the attached it would be good.

The original shader came from

http://evolveduk.googlepages.com/Shaders_Shadowing.html.

I used the '2D Shadow Mapping' one for this demo

Design by Trial and eror...and errror...and errorr
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 23rd Aug 2009 22:23 Edited at: 24th Aug 2009 01:01
Quote: "however, at 20FPS (on my machine) it would be unworkable"


Shadows are a real pain. How many games use real real time shadows I wonder? Most games I've seen seem to use pre-rendered shadow maps which speeds things up enormously (as in my self-shadowing demo for AT). Others use fake shadows.

Quote: "If you spot an obvious error/issue in the attached it would be good."


I rather doubt it, but I'll have a look anyway and report back.

Edit Can't see any obvious problems. I thought the main pixel shader which does the final render looked a bit "heavy" so I replaced it with a minimal texture look-up and the fps went up from about 40 to only 50, so the problem (if there is one) is somewhere else. Will have another look later.

Edit2 Actually, the low fps puzzles me. I've just tested one of my blend and bumpmapped terrain demos and the fps is about 600. It's possible the set camera to image stuff is responsible, but I'm not sure and can't see why if it is. I need to do a bit more delving to see which part of Evolved's demo is the real resource hog. Not tonight though.
JDforce
21
Years of Service
User Offline
Joined: 27th Jul 2004
Location: Sea of Tranquility
Posted: 24th Aug 2009 19:34
I get 50 FPS with the GeeBee sample, without any modification. Maybe the hidden renders have something to do with low FPS, as Green Gandalf suggest.

May the 3d force B with U
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 24th Aug 2009 21:44 Edited at: 25th Aug 2009 02:03
Quote: "Maybe the hidden renders have something to do with low FPS"


Possibly, but it's not obvious to me why it has such a major effect. On my main PC for example, my AT blending demo runs about 12 times faster than Evolved's demo, but on my laptop they run at about the same fps with Evolved's demo being rather faster despite the extra renders (actually Evolved's demo won't run correctly on the laptop - the depth map is produced OK, but the final render just seems to have the depth map tiled all over both objects - see attached screenshot). There's something else going on and I don't know what yet.

Edit Found out the problem with the screenshot - remembered that the laptop has an ATI GFX card so probably doesn't support PS2a. Changed the shader to use PS2b instead and it now works fine - same fps as before though.

No nearer understanding why Evolved's demo is so slow on my new machine though. That's now a task for another day.

Login to post a reply

Server time is: 2025-08-09 01:40:50
Your offset time is: 2025-08-09 01:40:50