Jump to content


Bump mapping 2D


7 replies to this topic

#1 gasto

    New Member

  • Members
  • PipPip
  • 11 posts

Posted 29 July 2007 - 07: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).


Posted Image


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

Thanks for your time.
Windows XP SP3, Ubuntu 9.10, Pentium Celeron D 2.6 GHz, 2 MB RAM, ACER LCD monitor, Nvidia GeForce 6200, Lambda Lexicon USB audio interface.

#2 Sol_HSA

    Senior Member

  • Members
  • PipPipPipPip
  • 482 posts
  • LocationNowhere whenever

Posted 29 July 2007 - 08: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.
http://iki.fi/sol - my schtuphh

#3 gasto

    New Member

  • Members
  • PipPip
  • 11 posts

Posted 30 July 2007 - 12:11 AM

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?
Windows XP SP3, Ubuntu 9.10, Pentium Celeron D 2.6 GHz, 2 MB RAM, ACER LCD monitor, Nvidia GeForce 6200, Lambda Lexicon USB audio interface.

#4 Reedbeta

    DevMaster Staff

  • Administrators
  • 4979 posts
  • LocationBellevue, WA

Posted 30 July 2007 - 02:10 AM

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.
reedbeta.com - developer blog, OpenGL demos, and other projects

#5 Sol_HSA

    Senior Member

  • Members
  • PipPipPipPip
  • 482 posts
  • LocationNowhere whenever

Posted 30 July 2007 - 07:55 AM

..or if it's really just 2d stuff we're talking about, http://iki.fi/sol/gp/ch18.html
http://iki.fi/sol - my schtuphh

#6 geon

    Senior Member

  • Members
  • PipPipPipPip
  • 893 posts

Posted 30 July 2007 - 08:13 AM

I remember seeing a nice 2D bumpmapping tutorial for TinyPTC, a long time ago, but I can't find it now...

#7 gasto

    New Member

  • Members
  • PipPip
  • 11 posts

Posted 31 July 2007 - 01:26 AM

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.
Windows XP SP3, Ubuntu 9.10, Pentium Celeron D 2.6 GHz, 2 MB RAM, ACER LCD monitor, Nvidia GeForce 6200, Lambda Lexicon USB audio interface.

#8 TheNut

    Senior Member

  • Moderators
  • 1473 posts
  • LocationThornhill, ON

Posted 31 July 2007 - 03:29 AM

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.

Posted Image

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.
http://www.nutty.ca - Being a nut has its advantages.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users