A shadow map is usually a technique of making realtime shadows in a 3D engine involving GLSL shader capbilities. I wanted to have a shadow for a project, but the distance to cover with a GLSL shadow map would be very great. So, a baked shadow map may have been a good idea. But, I wanted to still retain the capability to go into shadows and be shaded. So, I've implemented a method of getting shading for a baked shadow map that actually isn't too complex, and it's both GLSL-less and fairly flexible in terms of capability.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIOlzaU0ZH-k5ZQJ6iczTliYQpyHdwqeghKFENeC0NUd5JAPDJDjCbHTKh_4eP4Y-Ih3fhj7E0j2QNrGhyphenhyphenCgUsLPuDRSZbuVTwj61rOL8O0U2cD_YlzpKgOA6pmuMpM4BPV3tf2qKv3wI/s200/lightmapshade.png)
After this, I use a function that I made to find the color value of an image given its array of color values, X and Y position, and size. By getting the color of the lightmap, the Player object can discern whether he's standing in a shaded area or a lit area. After this, it's just a simple matter of changing his color to fit his lighting environment. It works very well.
A nice addition is that because the external image is obtained through code, the texture doesn't even have to be visible on the mesh - you can have an image just for data and reference to shade characters, while having the much more attractive texture be present on the mesh in-game. So, that's about it. Download the Realtime Shadowmap file here, and as always, have fun!
EDIT: I found after posting this that this method didn't work in a standalone executable because of how I set up my script - I fixed it and updated the download. Now you can make a standalone executable that should use this baked shadowmap method flawlessly.
Just the thing i was looking for.
ReplyDeleteThis is very useful!!!!
ReplyDeleteThanks for share with us!!!!