User Tag List

Page 1 of 5 1 2 3 ... LastLast
Results 1 to 10 of 46

Thread: Shader for lighting direction

  1. #1
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Tuna's Avatar
    Join Date
    Feb 2008
    Location
    Central Texas
    Posts
    1,853
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Shader for lighting direction

    In my latest project, i have an object that I have drawn using Adobe Fireworks. The object is "inner beveled" in a manner that gives it a top down but semi-3D look. To pull this off, on side and the bottom is "darker" while the opposite side and top are highlighted. This is very effective until you wish to set the angle of the object.





    Is there a way (using a shader) to always illuminate from a constant direction?

    Thank you in advance!

    Tuna

  2. #2
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Shader for lighting direction

    Yes, but only if you don't mind the object being solid-colour (apart from the lighting effects).

    To light from a direction you would need a normal or depth map for the object, and as MMF doesn't allow us to use texture parameters for a shader, that would have to be the object's image. Using that, a colour for the object and a light direction you could calculate the lighting and draw an object like the one you've pictured, but lit from the right angle.

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Tuna's Avatar
    Join Date
    Feb 2008
    Location
    Central Texas
    Posts
    1,853
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Shader for lighting direction

    Thanks for the quick reply...

    Making the object a solid color is easy enough... I expected that would be required.

    I don't quite understand depth maps and all things shader related.

    Does a shader already exist that would accomplish this? If not, I'm not qualified to produce my own. Is this something that's easy enough to develop?


  4. #4
    No Products Registered

    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    1,141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Shader for lighting direction

    Wouldn't it be possible to place the depthmap/normalmap in the alpha channel?

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Tuna's Avatar
    Join Date
    Feb 2008
    Location
    Central Texas
    Posts
    1,853
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Shader for lighting direction

    if you're asking me, I don't have a clue...

  6. #6
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Shader for lighting direction

    You could place a depth map in the alpha channel, but you'd be giving up alpha on your object. On top of that, a depth map isn't much good for fine detail calculations, because you have to sample it multiple times to get the slope at a point. The code for a normal map is much easier, so I'll have a go at it now.

  7. #7
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Tuna's Avatar
    Join Date
    Feb 2008
    Location
    Central Texas
    Posts
    1,853
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Shader for lighting direction

    I really appreciate that you're willing to take a stab at something like this for me. THANK YOU!

  8. #8
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Shader for lighting direction

    http://www.dynamicarcade.co.uk/downloads/extensions2/Shaders/Normal%20Map.zip

    You might need to google for normal maps to learn how to save one in your favourite program.
    EDIT: Shader expects X normal in R, Y normal in B, Z normal in G, -1.0 to +1.0 mapped to 0-255 in all three. (some things use 0.0 to +1.0 mapped to 0-255 on the Z/blue only).

  9. #9
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Tuna's Avatar
    Join Date
    Feb 2008
    Location
    Central Texas
    Posts
    1,853
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Shader for lighting direction

    Dynasoft,

    I would like to extend a very huge thank you for this!

    [size:23pt]THANK YOU![/size]

    I'll be using this in quite a few games!

    YOU ROCK!

  10. #10
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Tuna's Avatar
    Join Date
    Feb 2008
    Location
    Central Texas
    Posts
    1,853
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Shader for lighting direction

    I think everyone can benefit from this... imagine the possibilities! I am so excited, I can't wait to get home from work and apply this!

Page 1 of 5 1 2 3 ... LastLast

Similar Threads

  1. 3D lighting shader (2D Normal Mapping) w. 3 lights
    By Anders in forum Hardware Accelerated Runtime
    Replies: 33
    Last Post: 16th May 2021, 02:12 PM
  2. Lighting for IOS app
    By Shadeve in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 30th May 2013, 05:32 PM
  3. Tilemap Pixel Shader (aka "texture atlas" shader)
    By MuddyMole in forum Hardware Accelerated Runtime
    Replies: 3
    Last Post: 10th May 2013, 08:21 PM
  4. RTS "Lighting" possible?
    By Doc4 in forum Multimedia Fusion 2 - Technical Support
    Replies: 19
    Last Post: 2nd March 2007, 08:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •