Import crate model with multiple uv maps not working

I read this: Major material fail - #18 by nehon and still can’t setup my file to work in JME imorter. I have good looking Diffuse map OR good looking Normal map. Can someone look into my blend file and say what is wrong? I spend 2 hours trying different metods but its still not working. I of course activated SeparateTexCoord option in material.


Did you generate tangents on the geometry? Right-click on the geometry in the SceneExplorer, select Tools->Generate Tangents.

:+1: Yes I did… check… yes, I did it (before model was black).

Are they UV mapped? Or do you use some other form of projection-mapping in blender? Did you try creating a j3m material file (in the Properties window under “Material” when you select the geometry) and tweaking that?

  1. Yes, 2 uv maps 2.Yes I try.

Wait, separate tex coord… Where did you enable that? In blender? Normally the two maps have the same texture coords…

In SDK material. I want first uv for color and specular, second uv for normal map. So I need SepTexCo… I think.

Not really. I can’t say if your model actually has separate texture coords but its not the norm.

My friend (@FrozenShade) say that second tex coord is for lightmap only. Probably this is the cause.

In .vert file I found:

attribute vec2 inTexCoord2;

But everything is about LightMap there.

Should I add next input attribute inTexCoordX, manage everything with conditional compilation in proper places in .vert and .frag files?
If so, is there any constant number for normal uv map, like inTexCoord5?

Lighting.j3md assumes that it’s the same texture coordinates for normal, bump, and diffuse… because it’s very strange for them to be different. So they all use inTexCoord1. inTexCoord2 is only used for light maps in Lighting.j3md.

If you need different (stranger) behavior then you will need to write a custom shader.

1 Like

It is not a problem atm :wink:
I want to modify current one, but I’m not sure if I understand everything… TexCoord2 is ‘reserved’ for lightmap, so, to be clean, I should use next index, TexCoord3. It means that in Blender I need to make 3 uv maps: first one a basic uv for color, specular etc, second one should be empty (we don’t need lightmap there) and the third one with separate normal map. Do I understand it right?

Or you just use texcoord 1 for all, like most people do.

1 Like

May not help.

But I had an issue with a model, that unless you imported the UV map with the originally file. The texture coords will be on.

So when you import having the UV map itself does make a difference when changing to the .j3o

Please expalin @BigBob

After modifying the shader program I found that inTexCoord3 have the same value as inTexCoord. I can’t explain that…

Well, what did you set it to? If you didn’t set the TexCoord3 vertex buffer then you might just get random crap in there.

Your life will be 10000000000000000000000000000000000000000000000000000000000000x easier if you can just use normal maps that align with your diffuse maps. It’s really strange that you can’t for some reason.

My team member asked me to add this function. He told me that he need it do do something more nice.
Yes yes yes, I know that I need to modify .vert file too.

  varying vec2 texCoord3;
  attribute vec2 inTexCoord3;


   texCoord3 = inTexCoord3;

And the .frag :

        //TODO: calc newTexCoord3 when we need it with parallax
        vec4 normalHeight = texture2D(m_NormalMap, texCoord3);
        vec4 normalHeight = texture2D(m_NormalMap, newTexCoord);

The main question is: what else I need to do?

Well, something actually needs to add that mesh data. Not sure what magic incantations or dead-cat-swinging are necessary to make that happen from Blender through the importer. (The importer stopped working on most of my models a long time ago so I haven’t even used it in a while…)

Importing second UV map works well. Tested it with LightMap. The third one makes problem…

What I was saying (I wrote that way too early in the morning)

Was when I would import the model it would say something like “This has a texture of xxx.png that can’t be found would you like to search for it?”

If I said no, and just added the texture to the material. The map would be off as well as all others.

If I imported the model and browsed for the texture and imported it with it. Then applying different textures still stayed on the UV coords.

So there is something going on at the point of import that sets a models UV coordinates somehow.

Why this is the case, don’t know