Jump to content


Photo

Per-pixel Normal/bump Mapping. Updated!


  • Please log in to reply
43 replies to this topic

#1 Adventus

Adventus

    GMC Member

  • New Member
  • 516 posts

Posted 04 May 2007 - 01:21 AM

Accurate Perpixel Bumpmapping


"Dont Believe Imitations"



Posted Image


Download: L3S_bm2.gm6[GM6][1.8mb][Host-a.net]

Previous versions:
L3S_BM [GM6][1.7mb][64digits]

Since im probably ending my GM career fairly soon (Ogre3d & c++ look tantalising) and ill probably never make an L4S, i thought i would release the only example of real perpixel bumpmapping i've ever seen. I managed to get it fairly fast (I get a drop of about 10% compared to emboss bumpmapping), it requires no extra surfaces in my L3S engine and only requires two more sprite renders than the old emboss bumpmapping. Unlike other examples the accuracy of the bumpmap render does not depend on how many objects you use.... this isnt quite as obvious in the engine since i cant be bothered uploading my 4.5mb version with 512x512 textures.

EDIT _linenums:0'><strong class='bbc'>EDIT:</strong> Since not many people are actually aware of how the Dot3 bumpmapping formula works, just how it should look....*cough cough*.... i've decided to write a little speal arguing why this is an accurate approximation as opposed to the other examples i see lieing around.The normal dot3 bumpmapping formula is (n = normal,l = light):result = n.x*(x-l.x) + n.y*(y-l.y) + n.z*(z-l.z)Doing the usual GM workaround i split it into 3 renders:result = 0;result += n.x*(x-l.x)result += n.y*(y-l.y)result += n.z*(z-l.z)To deal with negative x-l.x components we have to create an inverse n.x so the equation becomes:if (x>l.x){result += n.x*abs(x-l.x)}else{result += -n.x*abs(x-l.x)}......Thats pretty easy and all, But tell me this, how do you get the x - l.x component on a perpixel basis? You see.... this is where my example differs from others. Others usually just approximated it based on the centre of the sprite or something. But, If you paid close attention in mathematics, you would realise that the dx component changes linearly with 0 at the light and extends out to infinity (Actually 255 because were dealing with 8bit per channel textures) on either side. This means that we could easily represent it like this:Posted ImageUsing this information, we see that by shifting the colours from black to white on each vertex of the n.x sprite based on the dx <strong class='bbc'>of that vertex</strong> we can make it automatically render the internal x - l.x components. This methods works 100% until you get the case where the light is above the sprite, however i've fixed this in the example by making it render 2 halfs with correct vertex colours when this special case occurs.Theres still more to the algorithm than i posted above, for instance how do you get the dz on a perpixel basis? This is where the only approximation (i know of) comes in.... Ill leave you guys to figure it out.
Cheers,

PS:
No i did not make the textures/normal maps, they are from FilterForge. This example will work with mulitple lights, but its not 100% integrated into the engine so it might be a bit hard to set up.

Update: Added some better Bumpmaps to show how versitile the engine is.

Update v2: Added some new Bumpmaps which have 'exhaggerated bumpiness'... also slightly modified the rendering procedure (normalised light vector).

Edited by Adventus, 27 September 2007 - 09:57 AM.

  • 0

#2 slayer_jojo

slayer_jojo

    GMC Member

  • New Member
  • 181 posts

Posted 04 May 2007 - 01:31 AM

Wow, this is some advanced stuff! Great job! My stupid crud graphics card doesn't really seem to work with this though. I get these funny shapes. I think it involves surfaces.
  • 0

#3 Adventus

Adventus

    GMC Member

  • New Member
  • 516 posts

Posted 04 May 2007 - 02:47 AM

My stupid crud graphics card doesn't really seem to work with this though.

Yea, its uses 3 screen size surfaces. But you can scale them down if you want (like the new example scales 2x).... go to the 'obj_L3S_system' object's 'create' event and change the 4th argument in l3s_system_create() and change it to 2 or 4.

Cheers,
  • 0

#4 bendodge

bendodge

    File Host

  • GMC Member
  • 1237 posts

Posted 04 May 2007 - 05:05 AM

That's great!
  • 0

#5 grandhighgamer

grandhighgamer

    Village Idiot

  • GMC Member
  • 3117 posts

Posted 04 May 2007 - 07:39 PM

I think I speak for all of us when I say: TEHH LLLEEEETTTZOZRZZZZ1111
Joking aside, it is awesome.

Edit: Oh, you b**tard. The link is just to a screenshot. *sobs uncontrollably*

Edited by grandhighgamer, 04 May 2007 - 07:41 PM.

  • 0

#6 Adventus

Adventus

    GMC Member

  • New Member
  • 516 posts

Posted 05 May 2007 - 01:05 AM

Edit: Oh, you b**tard. The link is just to a screenshot. *sobs uncontrollably*

Hehe woops, i screwed up the link when i updated it. It should be fine now.

Cheers,
  • 0

#7 Spider exo

Spider exo

    GMC Member

  • New Member
  • 36 posts

Posted 05 May 2007 - 01:21 AM

Wow.


Wow.

It's really good...
  • 0

#8 GML-PUNK

GML-PUNK

    DC Productions

  • New Member
  • 460 posts

Posted 05 May 2007 - 02:25 AM

umm, wow, nice, nice, nice. :GM6:

Edited by GML-PUNK, 30 May 2007 - 12:23 AM.

  • 0

#9 foslock

foslock

    Do you concurr?

  • New Member
  • 716 posts

Posted 05 May 2007 - 03:36 AM

Very nice, ran at 200 fps the whole time on my 3 year old computer.

Very nice indeed.

If you have the choice, do not see the new Spider-Man movie. It is pitiful.
  • 0

#10 OpticalLiam

OpticalLiam

    GMC Member

  • New Member
  • 782 posts

Posted 05 May 2007 - 01:09 PM

Great work. Nice implementation and explanation of its workings.
  • 0

#11 twisted_games

twisted_games

    GMC Member

  • New Member
  • 697 posts

Posted 05 May 2007 - 05:01 PM

Its amazing. But one question:
would you please explain each of the subimages in the sprites. Thanks.
~Twisted
  • 0

#12 grandhighgamer

grandhighgamer

    Village Idiot

  • GMC Member
  • 3117 posts

Posted 05 May 2007 - 06:26 PM

A picture of what the texture looks with a light from left,up,right,down and above. Done via The Gimp or Photoshop or anything with 3d Bumpmapping capabilitys.
  • 0

#13 Adventus

Adventus

    GMC Member

  • New Member
  • 516 posts

Posted 06 May 2007 - 12:43 AM

If you have the choice, do not see the new Spider-Man movie. It is pitiful.

Hehe, thats gotta be the most random GMC comment i've come across.

A picture of what the texture looks with a light from left,up,right,down and above. Done via The Gimp or Photoshop or anything with 3d Bumpmapping capabilit

The order of these maps can be changed using the LS_bm_* variables but this is what i used in the example.:

Subimage 0: Diffuse map.
Subimage 1: Positive x component of the normal map
Subimage 2: Negative x component of the normal map.
Subimage 3: Positive y component of the normal map
Subimage 4: Negative y component of the normal map.
Subimage 5: Positive z component of the normal map.

You dont need a negative z component because if the light is underneath the object there wouldnt be a map being rendered anyway. Normally subimage 1,3,5 would be stored in the Red(x) Green(y) Blue(z) components of a single subimage, unfortunately GM doesnt support the Dot3 blend mode so this configuration isnt possible.

Great work. Nice implementation and explanation of its workings.

Whats the chances i see something very similar to this in your new lighting engine..... XD.

Cheers,
  • 0

#14 Clarkyboy

Clarkyboy

    GMC Member

  • New Member
  • 898 posts

Posted 06 May 2007 - 09:35 AM

VERY GOOD JOB!!!!!
DUDE!!! this is great! this will let allot of people make very pro games in gm!
9/2 for this! thats right 45/5 GG!
  • 0

#15 kickboxer89

kickboxer89

    GMC Member

  • New Member
  • 110 posts

Posted 06 May 2007 - 03:35 PM

you are fantastic =)

i had 140 fps...
[AMD athlon 64x2 | 3800+ | 2Ghz 1Gb RAM]
  • 0

#16 OpticalLiam

OpticalLiam

    GMC Member

  • New Member
  • 782 posts

Posted 06 May 2007 - 06:43 PM

Great work. Nice implementation and explanation of its workings.

Whats the chances i see something very similar to this in your new lighting engine..... XD.


Not very likely, as I'm not sure if I will be continuing with it. I'm trying to get into C++ now, Ogre.
  • 0

#17 Adventus

Adventus

    GMC Member

  • New Member
  • 516 posts

Posted 10 May 2007 - 07:42 AM

Not very likely, as I'm not sure if I will be continuing with it. I'm trying to get into C++ now, Ogre.

hehe its like i've got a shadow or something.... XD.

Also i've recently changed my username at 64digits, so if you havent been able to download for a few days.... its fixed now.
  • 0

#18 gamemakeriv

gamemakeriv

    GMC Member

  • Banned Users
  • 262 posts

Posted 11 May 2007 - 07:07 AM

Pretty nice,I like this.

Very Sad you won't be making L4S.

#19 fogger

fogger

    Clockwerk Studios

  • GMC Member
  • 430 posts
  • Version:GM6

Posted 12 May 2007 - 01:02 AM

Once again a excellent light-related engine, sadly this might be the last.
Adventus shows what is a prime example of what GM can do(if you're
not too keen on your VRAM usage). sadly this might be the last:(

~Pr0n

Edited by fogger, 12 May 2007 - 01:17 AM.

  • 0

#20 Adventus

Adventus

    GMC Member

  • New Member
  • 516 posts

Posted 22 May 2007 - 08:56 AM

Pretty nice,I like this.

Very Sad you won't be making L4S.

Once again a excellent light-related engine, sadly this might be the last.
Adventus shows what is a prime example of what GM can do(if you're
not too keen on your VRAM usage). sadly this might be the last:(

~Pr0n

Dont be so sure about this being my last. I do still intend on finishing my current huge project (I predict 1-2 years), Tribal. Its basically my transition to c++, ie 100% GM rendering, 75% C++ Logic.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users