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 / Black floor, and huge fps drop with shadows!

Author
Message
WAKS
11
Years of Service
User Offline
Joined: 5th Oct 2013
Location: Oslo, Norway
Posted: 1st Apr 2014 19:22 Edited at: 1st Apr 2014 19:23
Hello everybody!

I’m back, after 3 months with no DBP programming, and no activity on the forum (because of much schoolwork). About a week ago, I decided to start again and continue with my previous project Brutal space (NB! now I have changed the name to Dark matter). Dark matter is a topdown surviving 3D game. Yesterday, I thought about the idea to implement shadows to the game, and it's here the problem starts on. When I use the syntax set shadow shading on the floor automatically became black. The shadows works fine on the walls and objects, but the whole floor became black. What is the problem? I have also noticed that I am getting a huge fps drop when the shadow is on. Nevertheless, the weird thing is that I'm only getting fps drops when I import my own made model(DirectX file).



If I change my own made modell into a sphere (using the make object sphere syntax) I get immediately stable 60 fps.

Here is my part 1 of my code:



Here is my part 2 of my code:



Image of black floor

[/img]

Image of Normal floor

[/img]

Thanks for answers
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 1st Apr 2014 20:38
Probably best to attach any media as well, it might be the object that's causing the slowdown.

I am the one who knocks...
WAKS
11
Years of Service
User Offline
Joined: 5th Oct 2013
Location: Oslo, Norway
Posted: 1st Apr 2014 21:02 Edited at: 1st Apr 2014 21:03
@Van B

Quote: "Probably best to attach any media as well, it might be the object that's causing the slowdown."


I'm not home right now, so I will attach the media as soon as possible
Lukas W
21
Years of Service
User Offline
Joined: 5th Sep 2003
Location: Sweden
Posted: 1st Apr 2014 21:09 Edited at: 1st Apr 2014 21:10
It has been a while since I looked at shadows in dbp, but maybe this old code may help, updated for dbp U77:





IS that a game, a program, or 3 year old drawing.

Attachments

Login to view attachments
wattywatts
15
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 1st Apr 2014 22:38
Not to discredit any of the above posts, but I really think you'd be better off performance wise using a shader. Evolved has some nice ones.
WAKS
11
Years of Service
User Offline
Joined: 5th Oct 2013
Location: Oslo, Norway
Posted: 1st Apr 2014 23:59 Edited at: 2nd Apr 2014 00:01
@Van B

Quote: "Probably best to attach any media as well, it might be the object that's causing the slowdown."


Now I have attach the media file as you requested

@Wattywatts

Quote: "Not to discredit any of the above posts, but I really think you'd be better off performance wise using a shader. Evolved has some nice ones."


Sounds interesting,but I have no experience/knowlegde about using shaders. Could you explain a bit further about the Evolved shader, and how to use it (maybe some examples would be nice)?

Attachments

Login to view attachments
WAKS
11
Years of Service
User Offline
Joined: 5th Oct 2013
Location: Oslo, Norway
Posted: 2nd Apr 2014 00:05
@Lukas W

Quote: "It has been a while since I looked at shadows in dbp, but maybe this old code may help, updated for dbp U77:"


Thanks for the example! I have not tried your example yet, but I think it not will work since it use the syntax SET SHADOW SHADER ON, and it's this syntax that makes the problem for me
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Apr 2014 00:40
Quote: "but I think it not will work since it use the syntax SET SHADOW SHADER ON"


His snippet uses SET SHADOW SHADING ON.



Powered by Free Banners
WAKS
11
Years of Service
User Offline
Joined: 5th Oct 2013
Location: Oslo, Norway
Posted: 2nd Apr 2014 23:36
Now I have also find out that the floor appear black when I have the light 0 hidden (hide light 0). So it's not only when I use the syntax set shadow shader on. Any idea of what the problem could be?
Thanks for answers
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd Apr 2014 01:32
I can't get your code snippets to compile.

It wouldn't surprise me if part of your problem is this bit of your code:



I'm fairly sure that set shadow shading on should be before the main game loop - but without runnable code I can't help you more than that.



Powered by Free Banners
Lukas W
21
Years of Service
User Offline
Joined: 5th Sep 2003
Location: Sweden
Posted: 3rd Apr 2014 01:42 Edited at: 3rd Apr 2014 01:47
Waks,
The built-in shadows in dbpro is only affected by light 0, so if you wanted to use shadows it will only be cast from light source 0 (at least in older versions of dbp). Set Shadow Position should be -1 in order to reposition the "shadow light". Set Shadow Shading On should indeed not appear inside a loop, furthermore setting a distance value of 10 might be too small a value for your model. And you might have better result without using hardware shadows but instead use software shadows. For example on my pc shadows does not work at all in hardware mode.
Review my code snippet above if you do not understand what I mean.

IS that a game, a program, or 3 year old drawing.
WAKS
11
Years of Service
User Offline
Joined: 5th Oct 2013
Location: Oslo, Norway
Posted: 3rd Apr 2014 08:51 Edited at: 3rd Apr 2014 09:02
Thanks for fast answers

Quote: "I can't get your code snippets to compile."


Whoops... I forget to post all the sourche files, my fault. Here is the rest of my the sourche files, I have allready worked a little bit further with my project, so I post the new code snippets, and attach a new media file







Quote: "I'm fairly sure that set shadow shading on should be before the main game loop "


Quote: "Set Shadow Shading On should indeed not appear inside a loop"


Hmm... that could be the problem, but I think this will lead to a another problem, and that is how I could get the shadows to move with my player. I have used this syntax to get the shadows to appear along the side with my player, and I have no idea of how I could be able to make how the shadows follow my players movement outside the do/loop?



Quote: "And you might have better result without using hardware shadows but instead use software shadows. For example on my pc shadows does not work at all in hardware mode.
"


I have heard about a software shader called the Evolved shader, but I dont know have I use it

Attachments

Login to view attachments
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd Apr 2014 12:54
Quote: "but I think this will lead to a another problem, and that is how I could get the shadows to move with my player"


Study this snippet from Spooky:





Powered by Free Banners
WAKS
11
Years of Service
User Offline
Joined: 5th Oct 2013
Location: Oslo, Norway
Posted: 3rd Apr 2014 16:18
@Green Gandalf

Thanks for the example you gave me, It helped me to finally get rid off the huge frame drop. The next problem now is that the floor still appear black. It's almost impossible to see anything, the only thing i can se is the ligh from the flashlight on the walls
WAKS
11
Years of Service
User Offline
Joined: 5th Oct 2013
Location: Oslo, Norway
Posted: 3rd Apr 2014 18:13
Never mind, I fix the problem. The problem was that I had forget to turn the fog off... whoops my fault But when I turn the fog off, I immediately found an another problem. The problem now is that I have made a flashlight, but it's only light on the end of the light shaft (P.S sorry for my bad english and bad explanation )

[/img]

Thanks for answers
Lukas W
21
Years of Service
User Offline
Joined: 5th Sep 2003
Location: Sweden
Posted: 3rd Apr 2014 21:51
DBPro uses an objects polygon to set light data, in order to view light on that object you need to choose:
A) increase polygon count on floor

B) Use per-pixel shader [recommend evolved's shaders]

IS that a game, a program, or 3 year old drawing.
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 3rd Apr 2014 23:18
Weird how my snippet written over 8 years ago is still helping today!

Boo!
WAKS
11
Years of Service
User Offline
Joined: 5th Oct 2013
Location: Oslo, Norway
Posted: 3rd Apr 2014 23:36 Edited at: 3rd Apr 2014 23:55
Thanks for fast answer

Quote: "Weird how my snippet written over 8 years ago is still helping today!"


Thanks Spooky, they have helped a lot

Quote: "A) increase polygon count on floor"


Now I have tested your example, but I can't get it to work have you any idea of what I do wrong? I also tried your code outside my project as a new project, but it seems like mye computer (laptop) dosen't support shaders. Tomorrow I will try on my high end gaming computer

Quote: "B) Use per-pixel shader [recommend evolved's shaders]"


Both you and Wattywatts recommend the evolved's per-pixel shader, but could you tell my a little bit further about how to use it, and which of the shaders I should download?

sorry for noob questions, but I have not so much experience with 3D programming, before this project I had only programmed 2D games
wattywatts
15
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 4th Apr 2014 17:43
Quote: "but could you tell my a little bit further about how to use it, and which of the shaders I should download? "

I'm using the cubic shadow mapping shader on this page: http://www.evolved-software.com/shaders/shadowing
If you download it, take a look at the code used to make it work, it should be pretty easy to implement.

Login to post a reply

Server time is: 2025-05-14 15:42:15
Your offset time is: 2025-05-14 15:42:15