• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Lighting on objects

S

samyak

Guest
How to do a realistic lighting on objects? If a light directional light falls on an object, then the side of the object facing the light should be brighter than the other side.
 
2D or 3D?

If 3D well hopefully whatever 3D engine / method you are using supports lighting and will handle it naturally.

If 2D you want to look into normal mapping. You'll need the artist to create normal maps for all your sprites, and then pass the sprite and the normal map into an appropriate shader.

I was just reading a good introductory article on this not a minute ago:

https://www.gamasutra.com/view/news..._normal_maps_in_The_Siege_and_the_Sandfox.php

If you search these forums and the archived ones, there is some posts on doing this in GameMaker, but its not a beginner level topic, so depending on your skill level you may have to do some research into it.

https://www.gamasutra.com/view/news..._normal_maps_in_The_Siege_and_the_Sandfox.php
 

Joe Ellis

Member
the side of the object facing the light should be brighter than the other side.
This is normally done with dot_product, it basically gets the difference between the surface's direction and the light direction, the bigger the difference, the more light.

It returns between (-1 and 1) (if done using normals) so often to convert this result to pixel colors you * the result by 0.5 then + 0.5,
or + 1, then then * by 0.5
 
Top