Re: [Bf-committers] Blender tangent space calculation

2011-11-19 Thread Eugene Minov
Correct, this is how blender does it everywhere in its code-base. Ok. I've asked because after weldind I've gotten this problem with some quads. But today seems that I solve it by swapping the first vertex in the vert array with the first finded vertex that is not indexed to any of the 4'th

Re: [Bf-committers] Blender tangent space calculation

2011-11-19 Thread Eugene Minov
Be sure to submit a patch for review. I've submitted a patch today. This is my first patch and I hope I've did all right. I've checked it for warnings, added txt file with small description about api. I've added a simple test exporting script that writes a data to txt file. I've added a

Re: [Bf-committers] Blender tangent space calculation

2011-11-19 Thread Morten Mikkelsen
I am not 100% sure I understand you correctly but your fix doesn't sound correct but perhaps I am misunderstanding you. Anyway, the welder is going to generate a zero based index list unlike what is used within Blender. If you want to use the indexed result within a Blender context you'd have to

Re: [Bf-committers] Blender tangent space calculation

2011-11-19 Thread Morten Mikkelsen
If you want to use the indexed result within a Blender context you'd have to put a dummy vertex at the beginning of the vertex array such that all other vertices are offset by one entry I mean put a dummy vertex in front of the unique vertices of course (meaning after welding). And also +1 to

Re: [Bf-committers] Blender tangent space calculation

2011-11-19 Thread Eugene Minov
If you want to use the indexed result within a Blender context you'd have to put a dummy vertex at the beginning of the vertex array such that all other vertices are offset by one entry and then you'd add all the welder-generated indices by +1 to offset to after the dummy vertex. Yes you're

Re: [Bf-committers] Blender tangent space calculation

2011-11-18 Thread Eugene Minov
Hi! I think that I've finished this. Don't forget to look in do_multires_bake() in object_bake.c It shows you how to add the tangent layer: Yes, I've figured out how to create DerivedMesh object by Mesh object. And then I've created the tangent layer in this way. // get pointer to the

Re: [Bf-committers] Blender tangent space calculation

2011-11-18 Thread Eugene Minov
Sorry for extra line :) I wanted to ask about this line: const int iGetNrVerts= data-mface[face_num].v4!=0 ? 4 : 3; I think 'iGetNrVerts' may be incorrect with some cases when there is four vertices per face but the last one is points to first indexed vertex. Or there is no way that last index

Re: [Bf-committers] Blender tangent space calculation

2011-11-18 Thread Morten Mikkelsen
I wanted to ask about this line: const int iGetNrVerts= data-mface[face_num].v4!=0 ? 4 : 3; Or there is no way that last index points to zero? Correct, this is how blender does it everywhere in its code-base. Super glad to hear you're getting useful results! Be sure to submit a patch for

Re: [Bf-committers] Blender tangent space calculation

2011-11-17 Thread Eugene Minov
The proper way to get the tangent layer can be seen in: https://svn.blender.org/svnroot/bf-blender/trunk/blender/source/blender/editors/object/object_bake.c Okay, I've found a 'multiresbake_get_normal' function for correct normals calculation. I also looked into 'DM_add_tangent_layer'

Re: [Bf-committers] Blender tangent space calculation

2011-11-17 Thread Morten Mikkelsen
Don't forget to look in do_multires_bake() in object_bake.c It shows you how to add the tangent layer: float *pvtangent= NULL; // create tangent vectors if not already created if(CustomData_get_layer_index(dm-faceData, CD_TANGENT) == -1) DM_add_tangent_layer(dm); // get pointer to the

Re: [Bf-committers] Blender tangent space calculation

2011-11-17 Thread Morten Mikkelsen
And flush_pixel() shows you how to traverse the buffer. Essentially the way it works in blender is there's always 4 of them per face whether it's a triangle or a quad. On Thu, Nov 17, 2011 at 9:31 AM, Morten Mikkelsen mikkels...@gmail.comwrote: Don't forget to look in do_multires_bake() in

Re: [Bf-committers] Blender tangent space calculation

2011-11-16 Thread Morten Mikkelsen
Sorry for confusing you here but I think I found a better reference for you since you'll be needing the tangents too and you are not supposed to be building them yourself. The proper way to get the tangent layer can be seen in:

Re: [Bf-committers] Blender tangent space calculation

2011-11-15 Thread Eugene Minov
If it's not already available in the python API Hmm, I think not, as far as I can see in 'blender_python_reference_2_57' and by searching in 'blender-2.60a' sources. I've found only two files in sources with references to 'SMikkTSpaceContext' struct and to 'genTangSpaceDefault' function: -

Re: [Bf-committers] Blender tangent space calculation

2011-11-15 Thread Eugene Minov
Oh, I am sorry again, I'd thought that you mean soft/hard edges not faces, I stupid! :\ Yeah there is must me way to gen those normals too. On Tue, Nov 15, 2011 at 7:12 PM, Eugene Minov minov@gmail.com wrote: If it's not already available in the python API Hmm, I think not, as far as

Re: [Bf-committers] Blender tangent space calculation

2011-11-15 Thread Morten Mikkelsen
There is no point in doing this unless you export the correct tangents and normals. That is the ones that were used to bake the normal map. I realize it blows that there is no API function to get the render normal. So what you have to do is produce it yourself like is done in

Re: [Bf-committers] Blender tangent space calculation

2011-11-15 Thread Eugene Minov
Yes, I absolutely agree, hard faces obviously must be exported in the same way how they seen in render. I think they can welds along with tangents. On Tue, Nov 15, 2011 at 9:01 PM, Morten Mikkelsen mikkels...@gmail.comwrote: There is no point in doing this unless you export the correct tangents

Re: [Bf-committers] Blender tangent space calculation

2011-11-15 Thread f . paglia . 80
To: bf-blender developersbf-committers@blender.org Reply-To: bf-blender developers bf-committers@blender.org Subject: Re: [Bf-committers] Blender tangent space calculation Yes, I absolutely agree, hard faces obviously must be exported in the same way how they seen in render. I think they can welds

Re: [Bf-committers] Blender tangent space calculation

2011-11-15 Thread Morten Mikkelsen
I don't know anything about Python but if you can get hold of the dm (DerivedMesh) on the c side of things then I can show you how to get the correct normals and tangents and even help you get them welded should you want this. On Tue, Nov 15, 2011 at 10:43 AM, Eugene Minov minov@gmail.com

Re: [Bf-committers] Blender tangent space calculation

2011-11-15 Thread Alberto Torres
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

Re: [Bf-committers] Blender tangent space calculation

2011-11-14 Thread Eugene Minov
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

Re: [Bf-committers] Blender tangent space calculation

2011-11-14 Thread Alberto Torres
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

Re: [Bf-committers] Blender tangent space calculation

2011-11-14 Thread Morten Mikkelsen
So why not to simply adding possibility for generate/access a tangent normals into the python api? If it's not already available in the python API then I agree that it's a good idea. However, you'd need to supply support for normals as well since at this point the python API only gives

[Bf-committers] Blender tangent space calculation

2011-11-13 Thread Eugene Minov
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

Re: [Bf-committers] Blender tangent space calculation

2011-11-13 Thread Morten Mikkelsen
There you go buddy -- http://lmgtfy.com/?q=blender+tangent+space On Sun, Nov 13, 2011 at 8:46 AM, Eugene Minov minov@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

Re: [Bf-committers] Blender tangent space calculation

2011-11-13 Thread Eugene Minov
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

Re: [Bf-committers] Blender tangent space calculation

2011-11-13 Thread M.G. Kishalmi
Eugene, the link Morten pointed you tohttp://wiki.blender.org/index.php/Dev:Shading/Tangent_Space_Normal_Mapsexplains that the tangent space you created your normal maps in (in blender) is generated by the implementation in

Re: [Bf-committers] Blender tangent space calculation

2011-11-13 Thread Eugene Minov
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