OpenB3D Normal Mapping with Directional Light?

BlitzMax Forums/MiniB3D Module/OpenB3D Normal Mapping with Directional Light?

RustyKristi(Posted 2016) [#1]
Did someone already figured out how to use Normal Maps with Directional Light? I have asked munch about this before but forgot to provide an example.

It seems even if I use directional light and got too far away with camera, the whole object seems to darken. That's not how normal map behaves in directional lighting.


Krischan(Posted 2016) [#2]
I'm not sure if this is what you're looking for but some time ago I've made some tests with DOT3 lighting and normal maps in miniB3D. I only switched the framework to OpenB3D in this example. Here, the asteroid is displayed nearly fullbright (or completely dark, depending on the rotation angle) while using the vanilla minib3d framework everything is ok (tested with the latest wrapper/build).

Download Source+Media: dot3test.zip (3.1MB ZIP)

Use arrow keys and mouse to rotate the asteroid, other key functions see demo. Oh, it could be that I've made a mistake in my source and it needs to be adjusted to work with OpenB3D. But I never found out why the scene looks so different and so I didn't start serious coding in OpenB3D yet.

But perhaps it is an good example for you to start to play with.




RustyKristi(Posted 2016) [#3]
Thanks Krischan, appreciate this demo that you posted and it's really well done!

While vanilla minib3d does not support shaders, this looks like it can be done in Blitz3d as well and this is the right one though I think it is more costly in performance. Don't you agree.

OpenB3d has already taken advantage of normal mapping + specular shader and this is the one that I have been talking about. Too bad the examples are only using pivot lights with just a little emphasis on normal map+outdoor directional lighting.

btw, still interested in your non-shader work. So how do I change the ambient light aside from 127,127,127 on the dark shaded part?

I see this is where it makes the calculations

Local r:Int=(EntityX(piv2)+1.0)*127.5
Local g:Int=(EntityZ(piv2)+1.0)*127.5
Local b:Int=Normalize(dist,0,StarLight,128+8,128-8)
EntityColor ASTEROID,r,g,b



This is openb3d's normal + specular mapping using example GLSL shaders. point light looks right only, no example on directional lighting or it's not done right.



switching to Directional light (all bump map modes, place looks dark far away)




Krischan(Posted 2016) [#4]
I found the light calculations in a source here in the forum (don't exactly know where) and experimented with it. But it works in vanilla miniB3D. There exists another example in my O.R.C.S. example, see the last post there for an example showing working "DOT3 lights". There is a advanced demo of it available, too:

ORCS_MiniB3D_Demo.zip (8.9MB ZIP)



And sure, using shaders is more advanced but I never advanced to shaders yet. I never really got into shader programming but would love to use them on my planet creation algorithms and my game.


RustyKristi(Posted 2016) [#5]
thanks Krischan. Looks good, will check it out.

Yes, shaders powers modern game engines. Strip them out of unreal engine, cryengine and unity, and you get graphics that looks or goes back to DX7.


RemiD(Posted 2016) [#6]
I don't understand your problem...
Maybe you could use an omni light with a great range instead of a direct light ?


RustyKristi(Posted 2016) [#7]
I don't understand your problem...
Maybe you could use an omni light with a great range instead of a direct light ?


I think the problem is with the shader implementation and example as directional light works ok with normal mapping.


RustyKristi(Posted 2016) [#8]
Update: this is how normal mapping should look with directional light.



it's funny but just by coincidence when I'm checking DBPro by chance I stumbled on this demo pic on their forum.