Normal Map causes rotation dependent Lightning


kind of hart to explain so I made a video of it. Sorry for bad quality, I never did screen capture before.

In the video you see a ball which first only has a diffuse map (works fine) and in the second part of the video also has a normal map (:S)
[video]Normal map causes rotation dependent lightning - YouTube

I made the model like it says here: [Creating assets in Blender3D] and imported it with the SDK blender importer. I tried to do TangentBinormalGenerator.generate() on the mesh. But it didn’t help, instead I kinda lost all my UV-Coords and it looked even worse.

This is the normal map:

And (for reference) the diffuse map:

Another Question: Is there any reference how jMonkey maps the RGB-Values to normal coordinates? The link from above advises to invert R and G from the blender normal map. According to blenders normal mapping color standard this would mean jMonkeyEngine maps as follows:

Red maps to X, mapping (0 – 255) to (positive 1.0 – negative 1.0)
Green maps to Y, mapping (0 – 255) to (positive 1.0 – negative 1.0)
Blue maps to Z, mapping (0 – 255) to (0.0 – positive 1.0)

This does look a bit weird to me? Every OpenGL shader implemention I have seen yet just mapps RGB to XYZ mapping (0 – 255) to (negative 1.0 – positive 1.0)

Thanks in advance!

(Aahrg why is there no possibility to edit the thread starting post? :facepalm: *kind of harD to explain)

What I forgot to say: The rotation/lightning issue also appears in the SDK model viewer. When I turn on camera light, the model is only lit from the front. The back is very dark although the camera light of course also is moving around the ball (I assume that). Of course there is no light source in the .blend, by the way.

You will need tangents or the normal map won’t work at all and you’ll get an effect similar to what you are seeing.

Normal maps and bump maps can’t work without tangents. So that’s the place you should be teasing out. The tangent generator shouldn’t be messing with your texture coordinates at all, though.

Okay my texture coordinates are fine with the generated tangents, it just looked like they were broken at first sight… but have your own look at it.


What I did:
or just
what made exactly the same result.

Here is the j30:

Still looks like a tangents problem. You could replace your model with just a Box just to validate that it’s mesh related.

While we’re here… what version of JME are you running?

That normal map looks really weird.

Your normal map has to be in tangent space (bleueish), this one looks like a classic bump map.

Are you guys looking at the same normal map I am? Because it doesn’t look like a bump map to me unless we are thinking two different kinds of bump maps.

I do start to wonder about y-flipping, too.

Edit: OP, do you just load the model from blender or have you exported/tweaked the material in some way? If you have modified that material can you show us that code? Perhaps the diffuse map is properly y-flipped but the normal map isn’t.

Actually, it does look a little too “pink” for a normal map, I guess.

OMG I just have baked the normals again with blender and left out the part of Creating assets in Blender3D: Fixing the normal colors in Blender and everything works :facepalm:

This is why I asked the second question, I had a feeling that it is obsolete stuff which is written there… I just didn’t try the regular blender normal baking output with TangentBinormalGenerator.generate() :facepalm:

So many thanks to all of you!

One last thing: Does anyone know the answer to my second question from above so I can ensure my blender normal baking output fully corresponds to jMonkeys idea of normal maps?

Edit @pspeed: I’m running jMonkeyEngine SDK 3.0 I recently downloaded from the website.

There was a time when we were flipping the normalmap’s Y (green) value which was incorrect. It has since been removed from the lighting shader. Should we remove that section from the blender wiki then?

When I’m sure I got the point right, it would be a pleasure to me to update the docs :wink:

This is blenders normal (maps) mapping:

Red maps from (0-255) to X (-1.0 - 1.0)
Green maps from (0-255) to Y (-1.0 - 1.0)
Blue maps from (0-255) to Z (0.0 - 1.0)

I assume jMonkey uses this mapping(?):

Red maps from (0-255) to X (-1.0 - 1.0)
Green maps from (0-255) to Y (-1.0 - 1.0)
Blue maps from (0-255) to Z (-1.0 - 1.0)

Is that right? This would mean you have to scale down the blue channel of blenders normal map and position it in the upper half. Mathematically it would be

Blue_jMonkey = 128 + Blue_blender/2

I did this with nodes in blender and got the best result till now. When one of you developers could review and confirm my thoughts then I would update the docs with a blender nodes setup that works 8)

1 Like

AFAIK you just have to invert the green channel in order for blender normal maps to work correctly in JME.

That would mean jMonkeys mapping is this:

Red maps from (0-255) to X (-1.0 – 1.0)
Green maps from (0-255) to Y (1.0 – -1.0)
Blue maps from (0-255) to Z (0.0 – 1.0)

It looks a bit weird, doesnt it?

Here is the normal map with the inverted green channel:

And just for completeness, I made one with just an inverted red channel:

They both look like my video I posted:
[video]Normal Map, Tangents generated - YouTube

And this is the normal map that has a scaled blue channel, like I suggested in my last post:

This is the best normal map I got so far, regarding to the result.