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 Discussion / Realistic Shadows in DB Classic...(Might work in Pro as well)

Author
Message
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 7th Jul 2006 15:21
I have come up with a way to make realistic shadows in DB. These shadows can overlap without causing the shadow to go darker.

However....

This is extremely slow. Try the download including the source code. See if there is a way to speed this up. I need this fixing for my Greyhound racing project. I need six shadows running at once, so this really needs a good boost.

Attachments

Login to view attachments
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 7th Jul 2006 15:51
Haven't tried it yet because I'm not on my pc, but don't shadows go darker if they overlap?

Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 7th Jul 2006 16:21
Quote: "Haven't tried it yet because I'm not on my pc, but don't shadows go darker if they overlap?"


Shadows merge if they overlap.

Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 7th Jul 2006 16:54
They do if they come from the same light source... but from different ones they get darker.

Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 7th Jul 2006 17:00
Well ghosted plains are the other alternative, but they go black when they overlap, and black is not common in shadows that overlap in real life.

RUCCUS
20
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 7th Jul 2006 17:48 Edited at: 7th Jul 2006 17:50
@Zoto: I dont think thats right... Actually in some cases seperate light sources making over-lapping shadows will make lighter shadows overall because more light sources = more chances of light hitting the shaded area.

@Pincho: I doubt people will be playing your game and mentioning how the shadows darken when they overlap. Well, except for Megaton.

Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 7th Jul 2006 18:14
Well I did want them to work like DB Pro as part of my experiment to mimmick DB Pro, but nevermind.

Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 7th Jul 2006 21:45
@Ruc

Yeah but the shadow is where the light isn't there, and where the shadows overlap is where none of the lights hit, where they don't overlap then some lights are hitting them, which makes them lighter.

SFSW
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 8th Jul 2006 00:41 Edited at: 8th Jul 2006 01:06
When two shadows overlap, they should result in a darker appearance in that specific area. A lot of the result depends on the distance of the object(s) casting the shadow, direction of light(s), and the ambient light level. You can do pretty good looking shadows in DBC, ones that even follow the contours of an object. There are some tricks involved and you have to define your shadow conditions/angles/shapes a bit before rendering. But here's an example (attached) showing the concept that should run at acceptable performance on anyone's system. It's an early test I made when I was designing the shadow system for one of my games done entirely in DBC.

Attachments

Login to view attachments
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 8th Jul 2006 12:45 Edited at: 8th Jul 2006 12:49
Looks good. I can do that with a scrolling texture, but how can I use that for my greyhound racing game, on plains, for 6 dogs? Plus, shadows overlapping usually don't go darker. This picture shows what happens, especially in a dog racing game.



Attachments

Login to view attachments
Chris Franklin
19
Years of Service
User Offline
Joined: 2nd Aug 2005
Location: UK
Posted: 8th Jul 2006 17:14
For the shadows on them why not just paint the image black Flip it flat and place it under each of the dogs still animated?

Platformer Compo!
WHITEKNUCKLE IS BACK! Check the wip boards for more info
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 8th Jul 2006 18:18
Black is not going to look all that good. Ghosted might look OK, but a plain colour will look a bit 8bit. I might put some brown shadows in the distance... Sand is brown.

SFSW
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 8th Jul 2006 18:36 Edited at: 8th Jul 2006 18:59
Quote: "Looks good. I can do that with a scrolling texture, but how can I use that for my greyhound racing game, on plains, for 6 dogs? Plus, shadows overlapping usually don't go darker."


Depends on a number of factors (see below). Have you seen the original room demo by Lee with the Scorpion? You could make your shadows using that technique which employs flat versions of your animated object placed just above the floor (or race track, whatever it is you need the shadow on). Using that method, you can also stretch and distort the shadow object as needed.

Quote: "This picture shows what happens, especially in a dog racing game."


Those are funny looking dogs then Actually, that's what I'd expect when you only have one light source and 4 objects all standing at the same distance from the surface the shows are cast on. Like I said, a lot depends on the distance of the object(s) casting the shadow, direction of light(s), and the ambient light level. You'll also notice that due to those conditions, the edges of the shadows are highly diffused.

SFSW
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 8th Jul 2006 23:57 Edited at: 10th Jul 2006 20:14
Quote: "Plus, shadows overlapping usually don't go darker."


As I pointed out earlier, it depends on a number of factors, but shadows can get darker if they overlap under certain lighting conditions (such as more then one light source, distances of objects to the casting surface, transparency of the object(s), ambient conditions, etc). If you have a racetrack with several lights overhead, you'll encounter different degrees of shadow darkness at various angles. In fact, you can even get overlapping shadows producing darker areas from the same object, as shown in this image of a transparent ball:

-image removed-

And here's one of a person illustrating how a solid object can product the same varying degrees of shadow darkness when there are multiple light sources:

-image removed-

Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 9th Jul 2006 00:03
I said Usually... and those examples are deffinately not usual.

Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 9th Jul 2006 01:24
Well it looks like there's only two lights (maybe three for the girl) pointing at the objects. In a race track there's normally 4+

SFSW
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 9th Jul 2006 02:36 Edited at: 10th Jul 2006 20:14
The situation where you'll really only get static mono-tone shadows is if you're dealing with one object and one light source, or multiple objects that are exactly the same distance from the light source and the surface the shadow is cast upon (such as the people standing side by side in your example image). Vary the distances and you'll find that when shadows overlap, you often get a darker result where they cross. You'll also get shadows that are sharper or more diffused depending on distance. Here's an example of both (notice the hand casting a dark shadow at the edge of the larger one, but lighter on its own):

-image removed-

Shadows are quite dynamic, they distort, diffuse, layer, and fade under a variety of conditions. Not that it makes a whole lot of difference in a game, where single tone shadows often look just fine to the eye and that's what most games use. If you were to be picky about your shadow presentation in your game, you'd need to account for however many light sources your racetrack would have for each object's shadow set.

Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 9th Jul 2006 14:59 Edited at: 9th Jul 2006 15:01
I think you are missing the point. My greyhound racing is happening in sunlight. There is no night racing. There are no lights. Overlapping shadows merge even with lights most of the time. Overlapping shadows that get darker are made by overlapping plains which everyone can already do, so there is no point in even mentioning them, because everyone can already do them. Unless you are going to post some source code of how to do diffused edges then that is a waste of time mentioning as well. And 3 shadows overlapping would be slow for this game anyway. I wish I knew what you were trying to say.

SFSW
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 9th Jul 2006 22:01
Just chatting about shadows Nothing too important I guess. You can do diffused edges for shadows by simply applying a blur filter to your casting texture. You can do that in memblocks, bitmap functions, or create what you need in an image editor first. You can basically control however you want your shadows to look. If you want single tone overlapping shadows, go for it, I'm sure it will look great.

I'll try to think of ways to increase the speed of that example routine you posted, but whatever you do, you'll need to somehow take out the copy bitmap concept... it's just far too slow. I still think you could get acceptable looking shadows using the technique Lee used for the scorpion in his room demo.

Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 10th Jul 2006 00:17 Edited at: 10th Jul 2006 00:19
Ok I can diffuse the edges in Photoshop. I can overlap dogs by putting all of the shadows on the same image before I texture a plane. That needs testing for speed as well. I can make distant shadows solid colour. If this all ends up too slow, I might just stick an oval shape under the dogs, and the oval can never overlap because it is smaller than the dogs collision zone.

Or I can do the Scorpion squashed model shadow. Is that solid black? I can't remember. I remeber Iced demo uses squashed models.

SFSW
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 10th Jul 2006 01:20
Yeah, squashed model, good term for it. I think Lee used a solid black one, I lost the original source code, maybe someone can point us to where it can be found. Even if it was solid black, you could still inverse ghost it and increase the grayscale a bit for a semi-transparent look.

SFSW
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 14th Jul 2006 09:34
I couldn't find the code to the room demo with the scorpion, so I put together a quick example of the type of shadow I think it used. This is using the dog from the DarkMatter CD. Nothing complex, but produces an ok looking shadow (using the same method) that could be fine tuned to look pretty good and respond to a moving light source. The white sphere represents the light source.

Attachments

Login to view attachments
Steve Fash
22
Years of Service
User Offline
Joined: 31st Dec 2002
Location: Doncaster, UK
Posted: 14th Jul 2006 10:14
Room demo source+media attached guys...
Hope ya get your shadows sorted Pincho

For game/demo music for YOUR PC productions visit:-www.futuredevelopments.org.uk

Attachments

Login to view attachments
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 14th Jul 2006 10:27 Edited at: 14th Jul 2006 10:27
Thanks for the help guys..but, Well my greyhounds arent models, they are 2D on plains, so I don't think I can have squashed models. I can just have plains.

SFSW
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 14th Jul 2006 10:54 Edited at: 14th Jul 2006 10:55
Plains or ok also. Are you using frames of animation as textures on the plains? If so, you can use the same technique and just inverse ghost another plain object where you want the shadow to be, then use a similar animation sequence applied to the shadow plain for the full effect.

Thanks for posting that Steve.

Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 14th Jul 2006 13:28
Yes my animations are textures on plains. I can make seperate shadow animations from above. My only problem was that they can't ovelap, or they have to be black, or brown. I originally wanted to make a way to have overlapping transparent shadows, but it was too slow.

SFSW
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 14th Jul 2006 21:37
If you're dealing with a highly lit area, a black shadow won't look too bad at all. Then if they overlap, they can't go any darker, so they'll still look good. And I think a shaped shadow would look much better then an oval.

Login to post a reply

Server time is: 2025-05-25 08:22:24
Your offset time is: 2025-05-25 08:22:24