[Interest] Qt3D: Mesh, buffer and tangent

Ch'Gans chgans at gna.org
Wed Apr 12 03:52:15 CEST 2017


On 11 April 2017 at 20:45, Sean Harmer <sean.harmer at kdab.com> wrote:
> Hi,
>
> On Tuesday 11 April 2017 10:46:24 Ch'Gans wrote:
>> Hi there,
>>
>> I'm writing some code to display 2D polygons as 3D polygonal plates,
>> my input being a 2D triangulated polygon.
>> As i'm pretty new to 3D/OpenGL, I had a look first at how the plane,
>> cylinder, cuboid, cone, and torus are doing this (from Qt3DExtra). I
>> can successfully display my polygonal plates and I think i got it
>> right.
>
> You only need tangent vectors if you wish to use normal-mapped materials with
> your geometry (or you have some other use for them in your own custom
> materials).

So I think that i do not need them, my application is CAD/CAM. I did
already get rid of the texture coordinates, and i've just removed the
tangents and have switched from Phong to Gooch material.
The only vertex data left are position and normal.

>
>> But I have a question concerning the tangent attributes in the
>> Qt3DExtra geometry source code:
>> Could someone briefly explain (or points to online resources) why the
>> plane, the cuboid,  the sphere and the torus geometries use 4 floats
>> for the tangents (x, y, z, w),  but the cylinder and cone use none?
>
> The cylinder and cone don't have tangents simply because it hasn't been
> implemented yet. The reason we use a vec4 is that the w component is used to
> indicate handedness of the tangent vector. The tangent, bitangent (calculated
> in the shaders), and normal vectors should form a right handed orthonormal
> basis for the normal mapping to work well so we need this extra bit of
> information.

Ok. So if you make sure in your code to generate a right handed
orthonormal basis, then you can remove this extra w data, is that
correct? (Actually you've answered this below)

>
>> I have read some online tutorial on OpenGL (helpful to understand
>> where these QBuffer and QAttribute come from), and quite often they
>> refer to tangent and bitangent, both of them being Vector3D.
>> Again why the difference with Qt3D? Are they different use-cases where
>> i should use one or the other?
>
> For more information on normal mapping have a read of:
>
> https://learnopengl.com/#!Advanced-Lighting/Normal-Mapping
>
> and
>
> http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-13-normal-mapping/

That the main one i've used, but the above is even better, very very
comprehensive, thanks for sharing!

>
> If you know for sure that your TBN matrices will be right handed you could use
> just vec3s for the tangents. OpenGL will expand this out to the vec4 in the
> shader interface anyway taking 1 as the 4th component.

OK, got it. Thanks for all the explanations!

Chris

>
> Cheers,
>
> Sean
>
>>
>> Thanks,
>> Chris
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>
> --
> Dr Sean Harmer | sean.harmer at kdab.com | Managing Director UK
> KDAB (UK) Ltd, a KDAB Group company
> Tel. +44 (0)1625 809908; Sweden (HQ) +46-563-540090
> Mobile: +44 (0)7545 140604
> KDAB - Qt Experts
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest



More information about the Interest mailing list