Tangents generation and you. Is it important? (updated with some RESULTS! incudes new pictures)

So do you care about the direction of tangents? I mean from all the XSI ships I've seen all the tangents are facing generaly the same way with some variation but I can't really determine why they are like that.

I understand XSI's interface for creating tangents but I have no idea how they determine the inital direction in the first place. It certianly seems to work for ships in game.

 

Anyone have better insight into this, and ultimatly does it matter what direction they are as long as it looks okay?

 

I'll see if I can russle up a screen shot to illustrate what I mean...

 

This ship should be obvious, the red lines are the tangents.

 

 

 

The reason I ask is because I can't think of a useful way to get a result like that (and im not even sure what is 'best'). I can make them all face one way or get some horrible averageness or have them per vert (which dosn't seem like a good idea).

22,039 views 43 replies
Reply #1 Top

Dont know how you managed that feat, but tangents are "supposed" to be similar to 3dsmax smoothing. Tough they are UV mapped similar to texture mapping. In the mod docs it says to try to get the same or close to the same color throughout the mesh when viewed in constant mode.

Reply #2 Top

Great job  ,  do you texture? 

Reply #3 Top

Quoting Major, reply 1
Dont know how you managed that feat, but tangents are "supposed" to be similar to 3dsmax smoothing. Tough they are UV mapped similar to texture mapping. In the mod docs it says to try to get the same or close to the same color throughout the mesh when viewed in constant mode.

 

I've delt with vector smoothing already with the normal generation code, thats an easy concept - you have a bunch of faces, they are part of the same surface element and part of the same smoothing group, you find the mid point between them all and you have your per vertex smooth normal.

According to the interwebs generic 3D tangents are calculated by using the existing UV coordinates which basicly makes the tangents face the direction of the U part of the texture although its smoothed so its not always true. Anyway XSI makes tangents that all face generally the same direction (as you can see from the screen shot).

Using the 'internet' method they point all over the place. The equivlent XSI colour tangent map is going to have lots of sharp constrasting colours in it. Thats clearly not useful. (I could get a screen shot of these tangents too). The problem is I don't know how to replace that function of XSI, it dosn't seem that important to me, as long as the tangents are smooth - thus the question.

 

I guess I need to do more research on the effects of tangents in game...

 

 

That is the PSI BATTLESHIP (I forget the in game names...) from original sins btw, I din't make it - my ships are far less high tech.

Reply #4 Top

Okay...  I had a ship's tangents but they looked really bad so I'll do a bomber instead, nice curved body should help show it.

 

Notice how the tangents follow the U around the body. This method creates horrible tanget 'seams' though and thus isn't useable if they are at all important (which they are, but to what extent, lol).

 

 

 

Heres a screen shot with all the tangents facing the same direction (which is the best method I've got right now) for comparison.

 

Reply #5 Top

Hummm, I should point out that im talking about generating tangents for a mesh (along with everything else) and not actualy how I would use the XSI tangent interface. I might not have made that compltely clear in the original post...

 

Also if your wondering how I can see the tangents, my max tool creates line objects for each vert in the direction of the normal and tangent vectors. It has been very useful, probably the best thing I thought of. :)

Reply #6 Top

I'll be honest for the tangents I just create a new cube map in XSI (world space) and then smooth the crap out of it to eliminate the seams unless the ship is supposed to be angular. this seems to produce the proper effect (and all of the tangents are not facing the same direction, the tangent by definition should be orthoganal to the normal and the binormal.I'll have to admit I really haven't dug into iron clads normal map concept much other than noticing that instead of using a normal map it is computing the normal map off a height map (at least that is what I think they are actually doing) it saves the artists some excessive pain at the expense of some control and some shader processing time.

 

I've found the max to XSI conversion butchers the tangents in most cases so I just reapply them in XSI.

Reply #7 Top

Quoting EvilleJedi, reply 6
the tangent by definition should be orthoganal to the normal and the binormal

 

Yeah in the first bomber screen shot above the tangents are usualy at right angles to the normal (and the binormal, but that isn't saved in the .mesh).

NO ship i've found that comes from XSI has anywhere near orthoganal tangents. I was kinda of suprised by it at first but it makes sense since Ironclads UVmapping is... tightly packed. I actualy tried per element smoothing and predictably diffrent elements had stupid lighting effects.

 

 

I wonder if triangle order has any importance in the mesh file?

Reply #8 Top

Okay I thought of something at least - I have no idea how this looks ingame btw, I can't seem to tell the diffrnce, I need to make a specific data map with low ambient light and lots of normal maps maybe.

 

Anyway this is useing a predtermined vector (1, 1, 1 in this case) as the 'fake' base vector (rather than the UV calculation and then I orthognalise it with the normal.

I call it "flow smoothing" since it results in the same basic flow of tangents but they seem to be orthagonal.

See what you think: (notice the yellow lines (texture seam) on the missile warhead, that usualy is a mess)

 

Heres a better example of the 'flow' thing (green lines are the normals)

 

Reply #9 Top

I for one use either a cubic texture projection from Cinema4D (yep, I bought that one) or the spherical texture projection from XSI for the tangents. Smoothing is dependant how you want the lightning to be seen on your surface. Tangents are absolutely important for the looks of the game.

Reply #10 Top

Quoting TobiWahn_Kenobi, reply 9
I for one use either a cubic texture projection from Cinema4D (yep, I bought that one) or the spherical texture projection from XSI for the tangents. Smoothing is dependant how you want the lightning to be seen on your surface. Tangents are absolutely important for the looks of the game.

Yeah, conflicting tangents also cause problems with skybox reflections for the same reason.

 

Have you authored any meshes that I could visualise the tangents with to see what effect it had?

Reply #11 Top

You can take a look at the tangents of the babylon 5 mod models

https://forums.sinsofasolarempire.com/361694/page/32/#2485663

Release 0.35 includes models with tangents made with XSI spherical projection (Hermes.mesh) and others made with cinema4D box projection

Reply #12 Top

The way I believe you should go about adjusting your tangent maps is not by using a separate spherical or box projection, but a copy of your UV set used for texturing the model (as mentioned in the modding documentation). That way you can simply rotate and mirror the specific UV projections of the parts of your model so that you get a more or less uniform color in constant view in XSI.

The image above shows the tangents of my latest model, and while they're not 100% perfect (I made a mistake and rotated some individual polygon UV's on the nose and from there it was like trying to set a Rubik's Cube) ingame it looks just fine, with zero artefacts and overall even lightning. When setting them in XSI, just try to get a more or less same shade of blue, green, red or whatever. As long as the model is approximately the same shade, your tangents are ok.

 

If you don't set this right, but just apply tangents and maybe smooth them quick with a tangent operator, without getting the shading (orientation) right, you will have lighting issues ingame. Nothing too obvious, but you will notice that the less perpendicular to the camera the area of your model is, the darker it gets, to the point of having really bad visibility of the most of your model. So yeah, tangent orientation is vital to the proper ingame look.

Reply #13 Top

to the OP do we know if the max importer correctly imports the tangents? I've tried many different versions of exporting them from XSI and having tangents that look like that (essentially planar projection) do not look right in game.

 

The actual lighting being 'correct' is if the ship has a light side and darkside when facing the star (the only real light source in the map), if that is being properly calculated then the lighting is 'correct.' and the problem is with the specular calculation. Exporting a sphere from XSI with a blended cubic map seems to work properly for base lighting, same with a cube with cubic mapping, however this doesn't properly do the specular highlighting.

 

that being said, with the uni directional tangents does the whole ship get lighter and darker when it rotates with respect to the central star? and does it properly highlight and dim surfaces based on the star lighting, especially on rounded surfaces? (do this with a ship that has zero specular and zero reflection and a material glossyness of 0 and ship highlight filter off) I'm curious how it is working because I found a method that seems to 'look  mostly right' and also makes sense with how the shader is written, but I really haven't dug into how they use the tangents and the _NM map on the stock ships because I still have an issue with not having low angle highlights from light sources.

Reply #14 Top

Nah, I'm not talking about no "shadows" at all, Im just saying that if you do the tangents wrong your ship will have dark areas where there shouldn't be any dark areas. That said, Sins engine has a very rudimentary light/shadow system (I suppose real shadows would bog down the system too much, so its pointless to go for anything higher than "ok, this side of the ship is slightly darker than the other side" - you will notice that the "dark side" of the ship doesn't really exist - as soon as the camera is perpendicular to the dark side the ship is lighted up, even though theoretically it should be pitch black. This is of course for gameplay reasons.

The method I am using is pretty much the one suggested in the modding manual, and it replicates the lighting of vanilla ships pretty well. The ligh/dark transition occurs smoothly as well, though the effect is not as obvious as it would have been if the engine did real self-shadowing.

However, if you do not adjust the tangents well, which shows in XSI as sharp color transitions across polygon lines, you get artefacts like this:

I will have to adjust the tangents in this section to get rid of that. Notice its not actually a texture problem, rather its a lighting problem, where the bumpmapping suddenly shifts the angle and this shows up as a pretty obvious and ugly seam. That's why I recommend not going over 60 in XSI tangent smoothing operator, because excessive smoothing seems to "mask" up what would otherwise be pretty obvious sharp color transitions.

Reply #15 Top

Oh yeah, about low angle highlights. That's something which is bugging me as well. I know of one sure fire way to combat that - add a really low level of reflection to the whole ship. Not enough so that you get a gloss, but enough so that the ship reflects some of the environment map. It makes the ship be somewhat lighter when viewed from a low angle. I am now not even sure that there something wrong with the way we do tangents and normal maps since vanilla ships seem to have a simmilar problem.

Reply #16 Top

OMG lol, I never really knew what the second UV numbers were for in a sins mesh file but I was working on getting a second UV working for tangents (I wanted to do this before but I didn't think I could - now I can :)) and had the thought that maybe they are the tangent UV? That would be cool.

Is this something I just totaly missed before that was obvious to everyone else lol?

 

Certainly if I use the second map for tagnents instead of some arbitary my new tangent colour viser has better results - all of the tangent conflicts I know of (using the psi battleship again) are gone.

My tangents still point in diffrent directions than the mesh files ones though.

 

Reply #17 Top

All I can advise is to base your tangent map off the original UV map, then manually arrange the tangent UV's so that your tangents all point in the same continuous direction - this translates in XSI as having the same shade of color throughout the model (when viewed in continuous or shaded modes). This ensures that you will not have visual artifacts such as weird shadows, or lighting problems (such as diagonal dark areas).

As you know, Sins absolutely requires tangents to be assigned to the model (or your model is pitch black or has massive lighting issues and artifacts), but you can base them on just your UV set without needing a second set just for tangents. This will work, but as mentioned before, you'll get visual problems. Usually subtle, but they'll be there.

Reply #18 Top

Im not sure you get where Im coming from. Im programming a 'replacement' Max Importer/Exporter in MAXScript. I didn't think I could do tangents off a second map (and didn't really understand what XSI did with them anyway before now) so was looking for an alterantive since you really can't use the primary map very well. After I actualy researched it, I can do it (its currently working atm).

Its not finshed yet but now I can copy the main UVs and fix them up as the tagnents in max. I even have a similar RGB colour vertex map to illustrate them but I prefer using arrow maps anyway. I don't like it much, the real tangent problems don't show up clear enough for me, im trying some new ideas with that.

Reply #19 Top

Ah, I see. Well, considering that the previously available Max exporters\importers were unable to import UV maps together with the actual geometry, I'd say you did a good job already. Doing the tangent maps manually is about a half an hour job, so its not nearly as big of a deal as not having an original UV set, especially since the original textures are useless without it.

Vertex colouring in my opinion works better than arrows simply because it can be used with high poly models as well as low poly ones. I imagine arrows would get quite cluttered in high poly density sections of a model, whereas vertex coloring remains precise and easily readible.

Reply #20 Top

yeah the second UV set is used for the tangent map (the XSI docs say to use the second map cluster to set the tangents) and the tangent UVs don't care about the scaling or positioning just the orientation

using the max map can be an issue if you rotate any of the UVs though, for example you cannot mirror geometry like you would in a standard UV map you need to make sure the faces are going to same way, these types of corrections are easy to do , but it would be great to be able to do it automatically (since the pos and scale aren't important for the tangent UV channel)

 

what XSI needs is maxes per face UV modifier, that would generate the proper tangent map every time (since each face would be always flattened independantly) I haven't found any set of options that does this though)

 

I also second mansh00ters comment on vertex coloring, it makes it a lot easier to see problems.

Reply #21 Top

I read the copy and paste to a diffrent map channel in XSI in the documentation but never put the fact the mesh file has two UV sets and that together before, heh. Some meshes don't have any second set (its all just zero) though.

 

Anyway, my tool now imports the second set and applys it to the second map channel (the one I use for the tagnents generation now).

 

Im not sure how good it is in XSI, but mine colour map dosn't easily show certain situations of bad tangent. I.e. If you have a mirrored section that joins itself, the join will have 90 degree tangents to the rest of the mesh. This will only show up as a slight diffrnce in colour atm, im trying to think of lower range of colour perhaps so it 'swings' faster? Need to experiment.

Reply #22 Top

The XSI colour shading has sharp transitions in symmetryzed model situations, which you need to fix by reorientating the tangent UV's on one side. But they show up pretty distinctly.

So if I understand correctly, you made a tool which allows import of .mesh files in Max with UV sets preserved? Nice, very nice. Could use that in the future...

Reply #23 Top

I think I might have gotten close. It was always very wishy-washy but I eventualy thought of spliting the faces based on the difference of angle bewteen a per vert tangent and the face its in (like a an autosmooth operation).

Some dot products later and it seems to work, it creates hard edges on bad seams. You really have to make sure your smoothing is good though (havn't hooked it up to importer yet so its using the my mesh processor data instead).

 

Angle variance version still hasn't got the new method implemented yet though, but Ill get some normal RGB screen shots up soon.

Reply #24 Top

The Psi Battleship with its 'good' tangents on, no problems (not that I can see anyway).

 

Now the same ship but this time using the main UV to generate the tangents, theres a buch of issues not seen here but the main one is clear (I hope :P).

 

Here is XSI mod tool with what I think are the same kind of thing (I don't use XSI much so who knows, lol)

 

Here is mr cylinder from the max tool foundation for learning.

Remember that has no seperate vertes along that edge, its not a seperate element. The code says "hey this vert is WAY OFF man!" and makes a new one that is the same as the face thus creaing a hard edge.

 

The biggest limitation with my tool is that it isn't instant, never mind constant. I.e. you have to process the model and let it vis it every time you want to check it. :(

 

Reply #25 Top

Okay, I think I got the variance map working now. This is similar to the RGB map shown before but it goes from blue (good) to red (bad). Its just an indicator of how far the verts are away from the face tangent. Curves will be a bit pink du to the averaged nature of vert tangents but big splotches of red mean there could be something wrong.


Here is the Psi Battleship again (the star of the thread I guess) with the variance map on using Default Tangents (i.e. the texture UV map, not the special tangent one) and flow smooth switched off.

 

EDIT: White background for better contrast