[Interest] Qt3D: Mesh, buffer and tangent

Sean Harmer sean.harmer at kdab.com
Tue Apr 11 10:45:26 CEST 2017


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).

> 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.

> 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/

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.

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



More information about the Interest mailing list