Normal mapping

Blitz3D Forums/Blitz3D Programming/Normal mapping

Is possible use normal mapping and color texture in a model with Blitz3D?

I see normal demo, but use normal mapping without another texture (color) and ambient light is very short, is possible use with good light and 2 textures?

Thanks,
Is there a example?

It is possible, at least kind of. Fredborg released a demo sometime ago, use the search tools.

Ah, it's in his sig:
http://home1.stofanet.dk/mfredborg/DotMyBot.zip

BTW the head mesh in the demo sometimes makes problems on some systems, in that case simply import it somewhere and then export it again to make it work.

Pseudo-tutorial-in-a-codebox

;; STEP 1 :: Load normal map
NM = LoadTexture("normalmap.png")

;; STEP 2 :: Make it combine with the previous texture through a dot product
TextureBlend NM,4

;; STEP 3 :: Apply it to an entity
EntityTexture Entity,NM,0,0

;; STEP 4 :: Inside the main loop, update the entity's lighting either through vertex coloring or the EntityColor instruction.  EntityColor is faster but will be inaccurate, while VertexColor is slower but going to provide a lot more accuracy in the normal map.  Here I'll use EntityColor
EntityColor Entity, 127 -0, 127 +64, 127 +127  ;; The light is in front of and above the entity in this case (at least if I'm not mistaken, I'm a bit clueless right now so bear with me)


Only did this once on my own, so whatever.

You can download a normal mapping example with textures from my sig.
The code is short but not fully useful without modifications to meet your project settings, but may be you can use it as a reference.

Paolo.

And in my sig :)