Game Development Community

Material normals get reversed - RESOLVED

by Martin Banks · in Torque 3D Professional · 12/16/2009 (1:56 pm) · 15 replies

I have a model with a diffuse and normal map material for its face.

When I load up the model in 1.0.1, it looks fine. When I load up the model in 1.0.1 alpha, the normals expressed in the normal maps come out reversed.... except when the following conditions are met:

--New material is just assigned to the face.

So, I can load the model, assign a new material, define the textures to go into the diffuse and normal maps...everything is fine.

I save, then close the scene and reopen....normals are reversed.

If I then select the model, start the material editor, create a new material, assign textures, etc. ....everything is fine again.

wash-rinse-repeat.

Does not happen in 1.0.1. only in alpha.

Thanks in advance.

#1
12/16/2009 (3:17 pm)
Here is the model after I initially assign a material.

i620.photobucket.com/albums/tt287/softydevel/normalsgood.jpg
#2
12/16/2009 (3:18 pm)
And after I save, close and then reopen:

i620.photobucket.com/albums/tt287/softydevel/normalsbad.jpg
#3
12/21/2009 (7:38 pm)
That is strange. Is this with a collada (DAE) model?
#4
12/22/2009 (11:38 am)
@Chris

yup.
#5
12/22/2009 (3:01 pm)
One theory I had was that the material "mapTo" name is already assigned to another Material, and what you see in-game just depends on which one is assigned last. So when you create and assign a new Material (with the right settings) everything looks ok, but on restart, the other Material (with the wrong settings) is assigned last so the normals look wrong again.

If that is the case, I think there should be a warning/error message in the console about overwriting a material. Do you see any errors/warnings in the console (either when you assign the new material, or when you restart the game)?
#6
12/22/2009 (3:29 pm)
@Chris - I see no errors or warnings loading or changing materials.
#7
12/22/2009 (7:25 pm)
And there's no chance the material "mapTo" name is already in use? (I might be wrong about the console warning/error if this happens).

What does the model look like in both cases with toggleNormalsViz enabled? Does the materials.cs file look sensible?
#8
12/23/2009 (2:17 pm)
In togglenormalsviz the model's contours match what is implied in the pictures above, and the material.cs file is normal.
#9
01/08/2010 (1:32 pm)
There must be a difference in the way materials are interpreted for display on assingment, versus on load.

Anyone have any ideas as to what changes in the rendering code between last version and 1.0.1 Alpha have caused this?
#10
01/08/2010 (1:37 pm)
There was a tangent bug that we fixed, but I'm not sure when it was. I think the bug was fixed after 1.0, so you should flip the green channel in your map (that is probably what is wrong, I could be incorrect in that guess though).
#11
01/08/2010 (1:53 pm)
@Pat

I thought about taking issue with my normal map (swapping, or inverting channels), but if this is the problem, then why does it show up correct initially?
#12
01/08/2010 (6:22 pm)
..that's precisely what I find interesting, it initially renders correctly and then upon reload, incorrectly.

Would you care to share the model Martin ..(source file too plz) ?
#13
01/12/2010 (6:22 pm)
Quote:that's precisely what I find interesting, it initially renders correctly and then upon reload, incorrectly.

That's what made me think there is a material name clash. Which material you see would depend on what order the Material objects were parsed.

@Martin: Can you confirm that there is only one Material defined that uses this "mapTo" name?
#14
06/06/2010 (3:15 pm)
Logged as TQA-288.
#15
08/02/2010 (5:00 pm)
Fixed in 1.1 Beta 2