Game Development Community

Mirrored normal maps - Torque 3D

by Andres Bordeu · in Artist Corner · 08/18/2009 (1:55 pm) · 31 replies

Hi, we noticed that models that have mirrored UVs are not displaying normal maps correctly. The mirrored texture area displays an inverted normal map (shading is 'inwards'). Is there a workaround to this that doesn't require "unmirroring"? Other engines we've worked with solve this problem. Perhaps this will be fixed in future Torque 3D updates?

Thanks!
Page «Previous 1 2
#1
08/18/2009 (9:26 pm)
Is this for Collada or DTS files? If Collada, would you be able to send me an example of such a file?
#2
08/18/2009 (9:53 pm)
good catch Andres. plz followup on this thread.
#3
08/19/2009 (9:46 am)
It's happening with Collada. I haven't tested it with DTS. I'll post some sample info here briefly.
#4
08/19/2009 (10:01 am)
What program are u using to model in? Sometimes people mirror UVS and do not realize that they flip and therefore will not show correctly. If you are using Maya this is easy to see and correct. DL out.
#5
08/19/2009 (10:43 am)
I'm using 3d Studio Max. I don't see how mirroring UVs should affect it. I Reset XForms before exporting. Anyways, heres' a sample image:

aceteam.cl/Images/normal_test.jpg

Chris: I'm sending you the max file and resources by e-mail.
#6
08/19/2009 (11:01 am)
can you upload the max and the collada files plz ? ..or mail them to Chris.
- I can not reproduce this and I have tried half a dozen ways.

//edit: I see he is mailing them, great.
#7
08/19/2009 (11:04 am)
eb: Do you want me to send you the files as well? Are you getting correct results for mirrored models?
#8
08/19/2009 (11:11 am)
Chris, your e-mail bounced. Do you have a valid e-mail address you can provide me?
#9
08/19/2009 (6:05 pm)
Andres, email me the files too plz.

If you grab our emails from our profiles, the site adds the word "null" into the email...be sure to remove that word before sending. ;)
#10
08/19/2009 (10:01 pm)
Andres: The email in my profile is valid (make sure to remove the null as eb says), but I only need the collada file and textures. I'm not a max user so the max file is no use to me.
#11
08/20/2009 (4:27 am)
same problem here..

www.jamietelford.com/bintwo/normals.jpg
using maya for low poly.. mudbox for highpoly.. 2K normal baked in xNormal.. no mirroring in uv's..

our resident programmer thinks you are not considering the handedness of the tangent space basis.

three examples TGEA 1.8.1, T3D, and a no-name engine..

will TGEA and T3D be upgraded in the future? thx!

@andres I love your elephant punching simulator!
#12
08/20/2009 (10:14 am)
Thanks Chris & eb! I didn't notice the null when I sent the file before. I emailed the resources to you both. I kept the max file in the rar in case eb wants it. Keep me updated if you make any progress with this problem.

Jamie: Thanks! :) Glad you enjoyed it!
#13
08/20/2009 (11:20 am)
@Jamie: The exporter creates triangle strips, collada and Version26 cahced DTS models created from the collada models, do not appear to have this 'split-mesh' issue.

However, maybe there is more to this situation. Chris ?
www.ericrbarth.com/uploadpanel/view/lineissue.jpg
#14
08/21/2009 (2:13 am)
Andres: Were those shots (of the teapot) taken in T3D? Basic or Advanced Lighting?

In BL and AL, for both the DTS and DAE versions of the teapot you sent me, it looks like both sides of the normal map are facing inwards.

If you are able to rebuild the engine from source, could you try changing the end of TSMesh::createTangents to this (it just inverts the W component compared to stock T3D):

tangents[i].w = (mDot( cp, b ) < 0.0f) ? 1.0f : -1.0f;

This change makes the teapot display correctly on both sides in both BL and AL for me.
#15
08/21/2009 (10:03 am)
This is very strange... I checked my model again and you are right, the normals are facing inwards. I'm using T3D with Advanced Lighting.

The shots I took and that are posted above were taken with T3D Beta 4. Yesterday we updated to Beta 5 and now I'm getting both faces looking inwards. I'm not sure, but it seems like a code error to me. The process I used is the same I've always done for models we generated for the Source game engine. If I render the teapot in 3ds Max it looks ok. Can it be the exporter's fault? I'm using the COLLADA NextGen exporter (COLLADAMaxNew.dle).

About rebuilding the game engine, I'm not a programmer so I can't test your suggestion. Still, I think my asset pipeline should work since it renders correctly on other engines.



#16
08/21/2009 (10:19 am)
Quote:The shots I took and that are posted above were taken with T3D Beta 4. Yesterday we updated to Beta 5 and now I'm getting both faces looking inwards.

It's possible there were some changes to shadergen for beta5 that have changed the behaviour.

Quote:Still, I think my asset pipeline should work since it renders correctly on other engines.

I completely agree => and since I get the same results for both the DTS and DAE versions of your teapot, I think the error here is in the calculation of the tangents in T3D (rather than in the NextGen exporter or the T3D collada loader).

My fix solves the problem here for me so I will do some more investigating and see if I can get it into the next T3D build. Until then you could have a crack at rebuilding the engine with my fix (it's not that hard, and all the tools are free), or find some friendly programmer to generate a build for you....
#17
08/21/2009 (10:21 am)
Hi guys,

I've experienced problems with normal mirroring in previous engines.

Try this for a workaround it might work:

When you mirror the object attach it to the original half, but DO NOT weld the verts. Make sure the seem isn't welded and it should be ok. If you're a 3dsMax user you should be using the symmetry modifier in 3dsmax to do mirror rather than the mirror tool, and make sure you untick weld verts.

Oh and this is my first post, so hello guys :)


#18
08/21/2009 (10:57 am)
Here's a little more research from my side:

aceteam.cl/Images/normal_test2.jpg

I'm somewhat confused because I started looking at other models and some of them display correctly. It's like if the Red or Green channels are appearing inverted in some cases. I can't figure it out... :S

#19
08/21/2009 (11:00 am)
To backup my above claims, please read the below article.

Normal Mapping 101 - Common Misconceptions
#20
08/21/2009 (11:03 am)
Phil: If I don't weld the vertexes I won't get a smooth shading from one side of the model to the other. It would only work for geometric models like a vehicle for example. But what if I'm mirroring a horse model or a human model?

Edit: The sample that Nicholas uses in the document you linked is not very good, because the smiley is being rendered on a flat polygon, thus the shading is not affected by unwelded verts. But if the model was curve it would show.
Page «Previous 1 2