PDA

View Full Version : Bump mapping 2D


gasto
07-29-2007, 12:35 PM
Hello there.

I was wondering if you have any idea as to implement a 2D (that is only textures) graphic sceme, in where the light source and the target are in 2D space if using Direct graphics 9.0, and/or fx shaders.

The idea is to create a 2D sprite and put it in a 3D space(Although we wouldnīt use 3D since it is a 2D game, it actually getīs to use the graphics card for computation). In other words Z would be always set so zero, unless some zoom in/out effect is desired (or background 3D models)| The source of light moves in realtime as does the target. And to shade, the sprites would be rendered with a Bump mapping-like technique, where different intensities of gray( in a second image), represent the lightning computation. That is, the darker it is, the nearer to the screen it is| so it would actually be a pixel level shading| And of course, if the source would be pointing to a dark area, then that part would be somewhat illuminated, but immediately after a white part, if the line of the light ray continues further and finds a dark part in the bump image, the color intensity in the original image would diminsh(thus causing a rounded 3D effect).


http://www.dropfiles.net//files/103/shady.jpg


Do you have any references as to implement this kind of algorithm ?

Thanks for your time.

Sol_HSA
07-29-2007, 01:30 PM
I suppose you could project the "light" texture (the 2d image) from screen space and then use the object's bump map to change the sampling point.. but I don't really see what's the point, as you can already do that in 3d.

gasto
07-29-2007, 05:11 PM
Well the point is that there we are talking about sprites, flat images. So I donīt know at what exempt from 3D bump mapping it is.

Another question would be. Do you know of any 2D game that uses bumpmaping?

Reedbeta
07-29-2007, 07:10 PM
It sounds to me like you should just process your bump map into a normal map and apply standard per pixel lighting techniques, perhaps using a directional light source.

Sol_HSA
07-30-2007, 12:55 AM
..or if it's really just 2d stuff we're talking about, http://iki.fi/sol/gp/ch18.html

geon
07-30-2007, 01:13 AM
I remember seeing a nice 2D bumpmapping tutorial for TinyPTC, a long time ago, but I can't find it now...

gasto
07-30-2007, 06:26 PM
WOW Sol_HSA!
You are my hero.

To bad it is with SDL, but Iīve been doing some pygame hacking, wich is basically a wrapper on SDL.

So maybe I will switch to SDL or pygame for this project.

TheNut
07-30-2007, 08:29 PM
Bump mapping is all about mimicking 3D, so it only makes sense to work in 3D even if your final result is 2D. Here's a run of the mill 2D square, the basis for all rendered sprites. Just throw a normal map on it and run it down a fragment shader for processing and you're done. Very fast and efficient.

http://www.nutty.ca/tmp/bump.jpg

The best part of utilizing the GPU is that the special effects don't end here. You can emit lights, render ripple effects on your 2D surfaces, blur images, cast a glowing/halo effect, etc... Anything you can do in Gimp or Photoshop is pretty much doable in real-time with the GPU.