Faked Shadow Example (Updated)

This forum is currently in read-only mode.
0 favourites
From the Asset Store
Fantasy Game includes more than 600 sound effects inspired by hit computer games like World of Warcraft and Diablo.
  • <img src="http://dl.dropbox.com/u/7658043/screenshotf.jpg">

    http://dl.dropbox.com/u/7658043/FakeShadowDemo.cap

    Here is a little Example showing how you can use a fake shadow.Move the arrow keys left and right to see how the shadows behave as the sun moves.

    <img src="http://dl.dropbox.com/u/7658043/screens2.jpg">

    http://dl.dropbox.com/u/7658043/ShadowplusDN.cap

    I have added day and night now. Press the Up And Down keys to change day into night and vice versa.

  • nice

    to make it more versatile though, you might want to change it so instead of rotating the shadow when you press the button, it rotates the shadow to "always" be at some angle relative to the sun

    here's an alternate version with skewing instead of angling: (drag and drop sun)

    http://dl.dropbox.com/u/1013446/fluid/fakeshadow2.cap

  • Thank you very much lucid for correcting my problem.Now i will know what to do in the future with shadows.

  • no prob, there was a mistake with my last cap though,

    shadows should grow longer the closer the sun is to the horizon,

    skew should also grow less pronounced the further above it is:

    http://dl.dropbox.com/u/1013446/fluid/fs.cap

  • Wow!.The last cap you send looks great that's exactly what i wanted to do but i didn't know how to do it.Thank's once again lucid.I want to change to sun into the moon once the sun is behind the horizon ,How can i achieve this Lucid?

  • This is very nice, i love it

    Can i use it in my game?

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • [quote:7owy8rjj]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.

    It's fine with me anyway - no one's gonna ever see the sun in my game

    I'm using this (yes i know...) with lamps. It doesn't look very realistic (due to the lamps position) but still better than blobs.

  • one thing is missing. transperency.

    shadows, when sun is low, not only grow longer - but also less visible. .

    easily remedied:

    http://dl.dropbox.com/u/1013446/fs3.cap

    (drag and drop sun with mouse)

  • + 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:3uddm35y]
    
    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 [b]178[/b] ? random value?
    what about skew with sun.y /[b]70[/b]?
    
    This is making my head spin... also, i suck at maths, and that really doesn't help me at all here lol
    
    Thanks
  • + 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 [b]178[/b] ? random value?
    what about skew with sun.y /[b]70[/b]?
    
    This is making my head spin... also, i suck at maths, and that really doesn't help me at all here lol
    
    Thanks
    

    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.

  • 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

  • > one thing is missing. transperency.

    > shadows, when sun is low, not only grow longer - but also less visible. .

    >

    easily remedied:

    http://dl.dropbox.com/u/1013446/fs3.cap

    (drag and drop sun with mouse)

    now its perfect kudos

  • http://dl.dropbox.com/u/7658043/fs4.cap

    Fixed a little problem that everyone overlooked,The Shadow is supposed to pass over the boxes Not underneath them.

  • http://dl.dropbox.com/u/7658043/fs4.cap

    Fixed a little problem that everyone overlooked,The Shadow is supposed to pass over the boxes Not underneath them.

    you sure have eyes for the details DravenX top quality as always

Jump to:
Active Users
There are 2 visitors browsing this topic (0 users and 2 guests)