Post your own tutorials, guides and demos.

### » Sat Feb 14, 2009 2:11 pm

Currently, the shadowcaster object only supports rectangular objects. Here's a way to make circular objects cast realistic-looking shadows, by generating a ring of rectangular shadowcasters around the edge of the circle.

You can do something similar by putting a single narrow box in the middle of the circle: viewtopic.php?f=16&t=2668 - but it's not accurate if the light source is close or the object is large, both of which I need at the moment.
B
5
S
2
G
4
Posts: 113
Reputation: 2,101

### » Sat Feb 14, 2009 2:43 pm

Slick!
B
62
S
21
G
13
Posts: 1,910
Reputation: 13,685

### » Sat Feb 14, 2009 3:00 pm

Nice
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

### » Sat Feb 14, 2009 3:24 pm

Nice effect.
I don't quite get how it works. Is there a possibility to adapt this effect into non-circular shapes?
B
6
S
3
G
6
Posts: 219
Reputation: 3,013

### » Sat Feb 14, 2009 4:49 pm

The Physics behaviour has 'elipse' collision mask, shadow casting is pretty much collision check (you keep casting rays and paint those that collide with the shadowcaster object).

B
62
S
21
G
13
Posts: 1,910
Reputation: 13,685

### » Sun Feb 15, 2009 12:26 am

Broo: This creates 36 square objects, sizes them proportional to the parent object, and puts them in a ring right next to the edge, on the inside of the object. Like... making a crude circle out of boxes, and using that to cast the shadow. (Sorry, I made them invisible - change the attribute 'invisible on start' and you should get an idea.)

Making a crude ellipse out of boxes is possible, I'm sure of it. I suppose you'd just need more, smaller box objects to prevent them from being seen, proportional to how elongated the ellipse is. But you'd also need different maths to actually get the boxes in the right elliptical shape. At the moment I'm just moving the boxes towards angles in every direction, proportional to the size of the circle. For an ellipse, I think trigonometry might be involved. I guess they were right and I should've paid attention in maths class.

(I hear the shadowcaster object is planned to support non-rectangular shapes eventually, like Mipey says. But I'm not sure what the priority is; probably after 1.0.)
B
5
S
2
G
4
Posts: 113
Reputation: 2,101

### » Sun Feb 15, 2009 2:36 am

I figured after seeing your post, I'd challenge myself to see if I could do it and learn some maths in the process. I gained some trig knowledge and a headache to boot! You math geniuses will probably be shocked at the way I went about it so go easy on a math noob!

Anyway my initial test with an ellipse didn't work so I'll look into that tomorrow. The shadow is a distortion map btw.

There are some obvious visual issues but I think you could probably tweak it or I may do tomorrow if I get the time.

B
15
S
5
G
7
Posts: 876
Reputation: 5,650

### » Sun Feb 15, 2009 4:27 am

I don't understand your maths yet, but I'm reading up on it!
B
5
S
2
G
4
Posts: 113
Reputation: 2,101

### » Sun Feb 15, 2009 4:52 am

I'm afraid to click on anything in this thread, for fear that my head will explode... again.

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
84
S
34
G
41
Posts: 3,032
Reputation: 30,999

### » Sun Feb 15, 2009 12:39 pm

sold: hahah yeah I'm the same as you but seriously.. and I know it's been said many many many times but if I can do it, anyone can. I didn't properly understand sin / cos / tan / asin / acos / atan until I set about this. I knew sin / cos obviously to create circles etc but I didn't understand them. The only thing I remember being told was SOH CAH TOA and that certainly came in handy.

mort: New version coming soon. Tidying it up and trying to put it into functions so you can just CreateShadowCircle(x,y,radius) and DrawShadowCircle(x,y) and create as many circles as you like. I'm not sure about ellipses just yet. I think that'll need some extra figuring out But before all that I need to fix the shadow so it clips at the edges of the display and doesn't leave a huge gap when the lightsource is too close.
B
15
S
5
G
7
Posts: 876
Reputation: 5,650

Next