Y axis of the normal map inverted

I’ve noticed that light direction is inverted on the Y axis when using normal map textures with the built-in shader.

My model is just a simple quad.

Here I used a normal map from the Wikipedia, but it happens with the most of the textures from external sources.

The normal maps that come with Panda3D bump-mapping sample work correctly, because they have their green channel inverted.

I understand that I can “fix” all the normal maps I’ve downloaded with Gimp: Colors->Decompose, invert green channel image, then Colors-> Compose.

But is there a faster method, something I can set in the code and don’t process all the normal maps manually?

It would be interesting to know from the Panda3d users what is your workflow with normal maps and which way is generally prefered.

Do you convert each texture you have manually with graphics software?
Or do you use only your own normal maps with already correct Y-coordinate?
Or maybe there’s a way to tell Panda3D programmatically to use flipped coordinate?

Sorry if this question is stupid, though I’ve been programming for some time, I am new to computer graphics.

I tend to use my own normal-maps, and my own shaders, so it’s seldom an issue for me, I’m afraid.

I did encounter it once, when using a normal-map baked by Blender from a high-poly model. Since that was a singular case, I just converted the image manually to work as expected.

I’m afraid that I don’t know whether there’s a way to modify Panda’s handling of normal maps; hopefully someone else will know!

Does the quad have correct binormals and tangents generated?

Are the normal vectors of the mesh pointing the right way?

@Thaumaturge, thanks for your reply. Your games indeed don’t seem to have third-party assets. I have to use other people’s work.

@rdb I believe they are, I generate them with recomputeTangentBinormal function.
There’s only 1 polygon and 1 normal pointing up.

Here’s the quad source:

<CoordinateSystem> { Z-Up }

<Group> Plane {
  <Transform> {
    <Matrix4> {
      1 0 0 0
      0 1 0 0
      0 0 1 0
      0 0 0 1
    }
  }
  <VertexPool> Plane {
    <Vertex> 0 {
      -1 -1 0
      <UV> {
        0 0
        <Tangent> { 1 0 0 }
        <Binormal> { 0 1 0 }
      }
    }
    <Vertex> 1 {
      -1 1 0
      <UV> {
        0 1
        <Tangent> { 1 0 0 }
        <Binormal> { 0 1 0 }
      }
    }
    <Vertex> 2 {
      1 -1 0
      <UV> {
        1 0
        <Tangent> { 1 0 0 }
        <Binormal> { 0 1 0 }
      }
    }
    <Vertex> 3 {
      1 1 0
      <UV> {
        1 1
        <Tangent> { 1 0 0 }
        <Binormal> { 0 1 0 }
      }
    }
  }
  <Polygon> {
    <Normal> { 0 0 1 }
    <VertexRef> { 0 2 3 1 <Ref> { Plane } }
  }
}