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.
http://pixelkick.com/bevelExample.png
http://pixelkick.com/bevelExample2.png
Is there a way (using a shader) to always illuminate from a constant direction?
Thank you in advance!
Tuna
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.
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?
Re: Shader for lighting direction
Wouldn't it be possible to place the depthmap/normalmap in the alpha channel?
Re: Shader for lighting direction
if you're asking me, I don't have a clue...
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.
Re: Shader for lighting direction
I really appreciate that you're willing to take a stab at something like this for me. THANK YOU!
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).
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!
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!