[Bf-committers] Blender tangent space calculation

Alberto Torres kungfoobar at gmail.com
Tue Nov 15 23:16:24 CET 2011


I've said "compilant" as in "I've tested with several meshes with
automatic unwrapping (lots of seams) and baking from multires data and
the result is perfect". I don't really know if it's really 100%
compatible. I guess I must test with weird quads to be sure.

In any case, I can tab - ctrl+t whenever I see a problem there. I'm
just commenting that if you use ogre this shouldn't be an issue, but I
completely agree that it should be a way to get exactly the same
normals blender generates.

2011/11/15 Morten Mikkelsen <mikkelsen7 at gmail.com>:
> You should be careful referring to them as "compliant". I understand what
> you mean that they are compliant in "format".
> But as is explained here -->
> http://wiki.blender.org/index.php/Dev:Shading/Tangent_Space_Normal_Maps
> the only way to be fully compliant is to use the exact same spaces that
> were used to generate the bake.
> This can also be achieved by using the referenced implementation (which is
> used in Blender) because it's designed to be order-independent
> and also independent of how the geometry is indexed or even indexed at all.
>
> Being fully compliant is what allows the renderer to achieve smooth
> transitions of normal fields going from one island to the next.
> This is important for characters especially.
>
>
>
>
> On Mon, Nov 14, 2011 at 8:34 AM, Alberto Torres <kungfoobar at gmail.com>wrote:
>
>> In the last days I've been doing a blender->ogre material converter
>> and after learning how each engine calculates the normals from tangent
>> normal maps, I've found that Ogre::Mesh::buildTangentVectors builds
>> the necessary vectors compatible with blender ones. It has a couple of
>> options for splitting mirrored UVs and saving the polarity in the 4th
>> component, just like blender's generated GLSL code expects.
>>
>> 2011/11/14 Eugene Minov <minov.eug at gmail.com>:
>> > Hi!
>> > One more question, if I may.
>> > I've seen that there is a couple of the exporter programs which can
>> > generate tangents to export for specific 3D engines only, like
>> OgreExporter.
>> >
>> > So why not to simply adding possibility for generate/access a tangent
>> > normals into the python api?
>> > I am not saying that it very hard to generate those tangents using
>> Morten's
>> > implementation directly in program, but think it'll be more a..
>> consistence
>> > and ease way for people who building their games to properly export their
>> > meshes :)
>> >
>> > Maybe if nobody wants, then I'd like to try implement this by some time.
>> > What you guys think about this?
>> >
>> > Eugene
>> >
>> > On Mon, Nov 14, 2011 at 2:41 AM, Eugene Minov <minov.eug at gmail.com>
>> wrote:
>> >
>> >> Oh, my bad :) I've seen that page but I'd thought this page is explains
>> >> different baking modes in blender's render.
>> >>
>> >> Morten Mikkelsen - thank you for your great implementation! I'will learn
>> >> it!
>> >> M.G. Kishalmi - thanks for explanation )
>> >>
>> >>
>> >> On Mon, Nov 14, 2011 at 1:55 AM, M.G. Kishalmi <lmg at kishalmi.net>
>> wrote:
>> >>
>> >>> Eugene,
>> >>>
>> >>> the link Morten pointed you
>> >>> to<
>> >>>
>> http://wiki.blender.org/index.php/Dev:Shading/Tangent_Space_Normal_Maps
>> >>> >explains
>> >>> that
>> >>>  the tangent space you created your normal maps in (in blender)
>> >>>  is generated by the implementation in
>> >>> mikktspace.h<
>> >>>
>> https://svn.blender.org/svnroot/bf-blender/trunk/blender/intern/mikktspace/mikktspace.h
>> >>> >and
>> >>> mikktspace.c<
>> >>>
>> https://svn.blender.org/svnroot/bf-blender/trunk/blender/intern/mikktspace/mikktspace.c
>> >>> >
>> >>> .
>> >>>
>> >>> you might want to use those in your app (check the licence inside).
>> >>>
>> >>> cheers,
>> >>>  lmg
>> >>>
>> >>>
>> >>> On Sun, Nov 13, 2011 at 10:51 PM, Eugene Minov <minov.eug at gmail.com>
>> >>> wrote:
>> >>>
>> >>> > Wow!! Thanks a lot, for pointing me to the google ;)
>> >>> >
>> >>> > But I afraid that maybe I've not correctly describe my problem. If
>> so,
>> >>> > sorry for that, because my english is still kinda weak.
>> >>> > My problem not in generating a normal maps (a textures) in blender.
>> Not
>> >>> at
>> >>> > all.
>> >>> >
>> >>> > My problem is that I cannot fully correct render my already generated
>> >>> > normal maps in my app. Because, how I mentioned in the last mail, the
>> >>> usual
>> >>> > methods for this purpose (by UV coords) is not gives me desired
>> results.
>> >>> >
>> >>> > So I wanted to ask for help with information about methods blender
>> uses
>> >>> for
>> >>> > generating tangents.
>> >>> >
>> >>> > And yes, I had searched in google but unfortunately have't found
>> >>> something
>> >>> > helpful yet.
>> >>> > If someone can point me to that kind of info, I will be very
>> grateful!
>> >>> >
>> >>> > On Mon, Nov 14, 2011 at 12:08 AM, Morten Mikkelsen <
>> >>> mikkelsen7 at gmail.com
>> >>> > >wrote:
>> >>> >
>> >>> > > There you go buddy --> http://lmgtfy.com/?q=blender+tangent+space
>> >>> > >
>> >>> > >
>> >>> > >
>> >>> > > On Sun, Nov 13, 2011 at 8:46 AM, Eugene Minov <minov.eug at gmail.com
>> >
>> >>> > wrote:
>> >>> > >
>> >>> > > > Hi.
>> >>> > > > I am sorry if I subscribe into a wrong place, I am new and I've
>> not
>> >>> > > > actually planned to change or to debug the blender sources yet.
>> >>> > > > But I trying to write app that'll be render models with normal
>> >>> mapping
>> >>> > > > exported from blender, and I have a question about how exactly is
>> >>> > blender
>> >>> > > > calculates a tangent vectors when Unwrap operation in the editing
>> >>> mode
>> >>> > > > performs?
>> >>> > > >
>> >>> > > > Calculating tangents in my app in usual manner (using UV coords
>> and
>> >>> > verts
>> >>> > > > positions) gives me different tangents for each face of the same
>> >>> vertex
>> >>> > > > indexed from, and thus crumpled normal map looking.
>> >>> > > > Then by looking into blender sources (searching  by 'tangent'
>> >>> keyword)
>> >>> > > I've
>> >>> > > > found a couple of functions with tangents calculations, like:
>> >>> > > >    float axis[3] = {0.0f, 0.0f, 1.0f};
>> >>> > > >    cross_v3_v3v3(tangent, normal, up);
>> >>> > > >    normalize_v3(tangent);
>> >>> > > >
>> >>> > > > After I tried same method in my program I've gotten almost
>> perfect
>> >>> > > looking
>> >>> > > > model, depending on what initial axis I've used.
>> >>> > > > To choose, which axis to use (0, 0, 1), (0, 1, 0) or (1, 0, 0)
>> for
>> >>> each
>> >>> > > > normal, I calculate max dot product of tangent calculated by each
>> >>> axis
>> >>> > > with
>> >>> > > > tangent calculated from UV coords.
>> >>> > > > But still it seems that in some rare vertices tangent is
>> calculates
>> >>> > > wrong,
>> >>> > > > maybe because of wrong initial axis.
>> >>> > > >
>> >>> > > > So, can anyone please give me any information about tangents
>> >>> > calculation
>> >>> > > > formula that blender uses while generates UV coords or some
>> advice
>> >>> > about
>> >>> > > > choosing initial axis.
>> >>> > > > Thanks for help.
>> >>> > > >
>> >>> > > > Eugene
>> >>> > > > _______________________________________________
>> >>> > > > Bf-committers mailing list
>> >>> > > > Bf-committers at blender.org
>> >>> > > > http://lists.blender.org/mailman/listinfo/bf-committers
>> >>> > > >
>> >>> > > _______________________________________________
>> >>> > > Bf-committers mailing list
>> >>> > > Bf-committers at blender.org
>> >>> > > http://lists.blender.org/mailman/listinfo/bf-committers
>> >>> > >
>> >>> > _______________________________________________
>> >>> > Bf-committers mailing list
>> >>> > Bf-committers at blender.org
>> >>> > http://lists.blender.org/mailman/listinfo/bf-committers
>> >>> >
>> >>> _______________________________________________
>> >>> Bf-committers mailing list
>> >>> Bf-committers at blender.org
>> >>> http://lists.blender.org/mailman/listinfo/bf-committers
>> >>>
>> >>
>> >>
>> > _______________________________________________
>> > Bf-committers mailing list
>> > Bf-committers at blender.org
>> > http://lists.blender.org/mailman/listinfo/bf-committers
>> >
>> _______________________________________________
>> Bf-committers mailing list
>> Bf-committers at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-committers
>>
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
>


More information about the Bf-committers mailing list