Normal Map From Mesh

Blitz3D Forums/Blitz3D Programming/Normal Map From Mesh

Morbius(Posted 2005) [#1]
Here's a simple method to render a normal map from a mesh.

www.worldmatrix.net/files/normal.zip



It's not terribly sophisticated, just point the proper lights at the mesh and take a screenshot. That's all it does, but it is quite effective. Try the screenshot in one of the normal mapping demos posted on this forum.

This is my first post, incidentally, so it took me a while to figure out how to link a picture to the post.

I hope I'm not getting into Blitz programming too late. It looks like Blitz may not have a future, which would be a shame because it is remarkably well organized, and stable compared to some other things I've tried. I may try to copy the class model in Managed DirectX if there's no future support.


Mustang(Posted 2005) [#2]
Screenshots and somekind of explanation would be good... :)


Alienforce(Posted 2005) [#3]
Great work!

I am trying to translate the render to a texture map based on the models UV cords... But i dont get it to work..
Mobius have you any little more code snippet to help ?

/Alienforce


Morbius(Posted 2005) [#4]
By the way...

Which normal mapping code on this forum is the "definitive" method? Or, is there one?

Alienforce:

If I understand you correctly...

To accomplish this mathematically, I imagine you'd have to determine the color of each triangle in the mesh based on which way it is pointing, which amounts to writing something like a rayshader, then unwrap it onto a texture and apply it to a lower polygon mesh.

The method above is only good for making textures for billboards and flat surfaces really.


Morbius(Posted 2005) [#5]
Alienforce:

Here's what I was talking about. Hope it helps.

www.worldmatrix.net/files/normalshader.zip

Here's a screenshot of the same guy with the vertex colors calculated in code.




Morbius(Posted 2005) [#6]
If you plot the vertex colors to a UV map, you get this:



The conversion to jpeg messes up the colors


Shifty Geezer(Posted 2005) [#7]
Anyone got an example of normal maps used in blitz? I'm guessing it's a complicated and intensive (read slow) process.


puki(Posted 2005) [#8]
"Rob Cummings" did code and a sort of explanation. However, due to him being banned, you can't search back through his forum posts - which is one of the problems of banning someone (plus, you lose their Code Archive list too).