Post your own tutorials, guides and demos.

### » Sat Nov 27, 2010 7:11 am

[quote="prawnsushi":38xc7ddl][code:38xc7ddl]+ System: Always (every tick)
-> sun: Set Y to clamp(.y,23,200)
-> Sprite: Set horizontal skew to [b](sun.y/70)[/b]*(Sprite.x-sun.x)
-> Sprite: Set height to [b]178[/b]-(Sprite.y-sun.y)
-> sun2: Set opacity to lerp(70,0[b],clamp((sun.y-100),0,100)/100[/b])
-> Sprite: Set opacity to lerp(70,10,[b]clamp((sun.y-100),0,100)/100[/b])
[/code:38xc7ddl]

Nice, but i wonder how you come up with such things as "clamp((sun.y-100),0,100)/100". Why sun.y-100?

Also, i know you didn't write all this code, but why is the shadows height set to 178 ? random value?
what about skew with sun.y /70?

This is making my head spin... also, i suck at maths, and that really doesn't help me at all here lol

Thanks[/quote:38xc7ddl]

First question: with that clamp values devided by 100, you get a value from 0 to 1. This is needed to interpolate between 70 and 10. In result the opacity will be 70, if the suns y < 100, and 10, if the suns y > 200, in between 100 and 200 the opacity reduces from 70 to 10. sun.y = 200 happens to be the highest possible value, because it is clamped to [23, 200], so you could have used max((sun.y - 100), 0) instead of clamping as well.

Second question: Sprite.y = 191, suns lowest y is 23, 191-23 = 168. The value 178 was chosen to have a minimum height of 10.

Third question: I think, that's a decision based on the visuals. The goal is to let the shadows virtual origin seem to be the sun. I would have set this to (sun.y/23)*((Sprite.x-sun.x) / 2), so that when the sun is at its (visually) highest possible position, the factor would be 1.
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

### » Sat Nov 27, 2010 8:33 am

Tulamide to the rescue!

Thanks, it's a bit more clear now

When i see such expressions , my brain just stops working...
Next time i'll just put these expressions in a text object at runtime and see what happens...

Thanks again Tulamide
B
4
S
1
G
2
Posts: 91
Reputation: 1,057

### » Sat Nov 27, 2010 9:01 am

[quote="lucid":ronguqod][quote="irbis":ronguqod]one thing is missing. transperency.
shadows, when sun is low, not only grow longer - but also less visible. .[/quote:ronguqod]
easily remedied:
http://dl.dropbox.com/u/1013446/fs3.cap
(drag and drop sun with mouse)[/quote:ronguqod]

now its perfect kudos
B
26
S
7
G
7
Posts: 568
Reputation: 6,089

### » Sun Dec 05, 2010 6:56 pm

[url:1xrqd972]http://dl.dropbox.com/u/7658043/fs4.cap[/url:1xrqd972]

Fixed a little problem that everyone overlooked,The Shadow is supposed to pass over the boxes Not underneath them.
B
22
S
3
G
6
Posts: 1,356
Reputation: 7,141

### » Sun Dec 05, 2010 7:08 pm

[quote="DravenX":1h6jf21o][url:1h6jf21o]http://dl.dropbox.com/u/7658043/fs4.cap[/url:1h6jf21o]

Fixed a little problem that everyone overlooked,The Shadow is supposed to pass over the boxes Not underneath them.[/quote:1h6jf21o]

you sure have eyes for the details DravenX top quality as always
B
26
S
7
G
7
Posts: 568
Reputation: 6,089

### » Fri Dec 10, 2010 3:19 pm

[quote="irbis":35cou0mr]one thing is missing. transperency.
shadows, when sun is low, not only grow longer - but also less visible. in that last cap - try and drag the sun far away offscreen and see what happends.[/quote:35cou0mr]

Actually, the shadows stay the same, It's everything around that gets darker.

This thread is getting interesting. How much more realistic can we make this?

10 points to anyone who finds something to improve.
B
8
S
2
G
5
Posts: 744
Reputation: 3,288

### » Fri Dec 10, 2010 3:27 pm

[quote:3qtvx0zh]This thread is getting interesting. How much more realistic can we make this? [/quote:3qtvx0zh]
to the point when i will need to turn my desk lamp on and itll also cast shadows ingame
B
26
S
7
G
7
Posts: 568
Reputation: 6,089

### » Fri Dec 10, 2010 3:46 pm

Don't laugh with a webcam we MIGHT JUST BE ABLE TO DO THAT

Ok it would probably require a custom plugin but still.
Moderator
B
84
S
31
G
33
Posts: 3,002
Reputation: 27,266

### » Fri Dec 10, 2010 5:34 pm

[quote="Arima":25q8qocy]Don't laugh with a webcam we MIGHT JUST BE ABLE TO DO THAT

Ok it would probably require a custom plugin but still.[/quote:25q8qocy]

Probably wouldn't be too hard. The only info you'd really need for something simple is the average brightness of the picture feed. From there, you could adjust the brightness of the room, or create a shadows that responds to the light feed.

For something a bit more complex, factor in webcam position and split the average brightness into smaller sectors.

I'm no programmer however, so I might be making it sound a lot simpler than it is.
B
51
S
10
G
7
Posts: 184
Reputation: 6,825

### » Fri Dec 10, 2010 5:40 pm

...what have i started!?!
B
26
S
7
G
7
Posts: 568
Reputation: 6,089

PreviousNext