Search Tools Links Login

Direct3D -> 2D Part 2, Faking Light!!


Visual Basic 6, or VB Classic

After figuring out how to rotate 2D sprites using Direct3D (check my other submissions), I wanted to do lighting. After reading some tutorials I gave up, they all used 3D, while I wanted to do 2D. There are other ways of faking light; making tiles in multiple shades at either design time or run time, but they're limited...


So here it is: faked light using Direct3D to simulate 2D! It looks great, runs fast (if you've got a 3D card, my P133 with Voodoo 3 could easily run it, although not on software rendering mode), and allows dynamic setting of light brightness and color.

So how does it work? Easy: it sets the color of a vertex (corner) to the brightness of the light at that specific place, after which Direct3D automatically adjusts the texture!



Some limitations though:





Enjoy, and don't forget to leave comments and vote!



(You're free to use this code in your own programs/games, but I would appreciate it if you gave me some credit, thanks!)

Original Author: Mark van Renswoude

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 102 times

Categories

Visual Basic 6

Attachments

CODE_UPLOAD15702322001.zip
Posted: 9/3/2020 3:45:00 PM
Size: 9,162 bytes


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.