Jump to content

  • Log In with Google      Sign In   
  • Create Account

Eric Lengyel

Member Since 25 Nov 2003
Offline Last Active Jul 21 2016 08:37 PM

#5179210 Depth bias clamping in opengl

Posted by Eric Lengyel on 09 September 2014 - 07:55 PM

Nvidia has released the 340.76 beta driver with support for EXT_polygon_offset_clamp:



#5177149 COLLADA vs FBX... Are They Worthwhile for Generic Model Formats?

Posted by Eric Lengyel on 30 August 2014 - 10:34 PM

These are just some of the reasons we created the Open Game Engine Exchange format (OpenGEX):



#5159967 Shadow Volumes - Edge finding

Posted by Eric Lengyel on 12 June 2014 - 01:19 AM

The description of the edgeArray parameter appears to be out of date in the book and should actually be different. Sorry about that. An updated version of the code can be found here:




This version explains that the edgeArray parameter should point to a preallocated buffer large enough to hold the maximum number of edges possible, which is three times the number of triangles in the mesh.

#5148261 Writing model 3D Model data to a new file as a new format

Posted by Eric Lengyel on 19 April 2014 - 07:01 PM

What I really miss from all this exchange formats, especially when using them to export stuff for a game engine, is the lacking support of custom attributes. You can add custom attributes in modelling tools, but you never got them exported to Collada/FBX. It is possible with OpenGex ?


It depends on exactly what kind of custom attributes you're talking about. OpenGEX supports custom per-vertex data and custom material attributes, but intentionally does not allow for general custom data all over the place. The reason for this is to avoid the creation of software-specific standards like you see in the Collada format through the use of the <technique> elements, making it necessary for importers to understand information whose format is specified over multiple poorly-maintained documents. Now if you're just talking about custom user-defined key-value properties like those supported in 3DS Max, then I can tell you that support for these is being considered for the next version of OpenGEX, and it's something that can easily be added to the existing exporters.

#5148021 Writing model 3D Model data to a new file as a new format

Posted by Eric Lengyel on 18 April 2014 - 06:18 PM

There is also the new OpenGEX format:



#5127125 About 3dMax export Skeleton

Posted by Eric Lengyel on 28 January 2014 - 10:34 PM

I use IGame to export the skeleton, but have some questions. I want to calculate the binding position with the skeleton. The function with


IGameSkin->GetInitBoneTM(IGameNode * boneNode, GMatrix &intMat)


can get the bone TM when skin was added. But it will return false the the param is root bone. There is another function 


GetInitSkinTM(GMatrix & intMat)


in IGameSkin. But it always return a Identity matrix. So how can I get the binding position with root bone?


If GetInitBoneTM() returns false, then it suggests that the bone is not actually used by the skinned mesh.


The GetInitSkinTM() function returns the transform that was applied to the skin geometry at the time that it was bound to the skeleton, and not the transform of any particular bone.


If you'd like to see an example of skin/skeleton exporting from Max (but without using the IGame interface), take a look at the source for the OpenGEX exporter:




The skin and bone bind transforms are exported at the top of the OpenGexExport::ExportSkin() function.

#5091113 Collision of plane and sphere

Posted by Eric Lengyel on 02 September 2013 - 03:18 PM

Not sure what L*P is supposed to mean.


It means the dot product between the four-dimensional plane L = (Nx, Ny, Nz, D) and the homogeneous point P = (Px, Py, Pz, 1). The plus sign in the book is correct. If you're familiar with my more recent talks on Grassmann Algebra, then this is more accurately stated as the wedge product between the antivector (Nx, Ny, Nz, D) and the vector (Px, Py, Pz, 1).

#5059353 normals in tangent space question

Posted by Eric Lengyel on 04 May 2013 - 11:32 PM

The tangent and bitangent are derived using a calculation like this:



#5055934 A C++ code to smooth (and fix cracks in) meshes generated by the standard, or...

Posted by Eric Lengyel on 22 April 2013 - 11:51 PM

another alternative is the transvoxel algorithm by E. Lengyel, though I am not sure if it's patented, it is iirc


The Transvoxel algorithm is not patented. More information here:




In general, a correctly implemented Marching Cubes algorithm generating a mesh with a single LOD will only produce cracks if it doesn't have a consistent way of choosing polarity for the so-called "ambiguous cases". This can be solved by using a fixed polarity based on corner states or some face-level choice function as used in the MC33 algorithm. See Section 3.1.2 of my dissertation at the above link for some discussion of these. Using fixed polarity is easy, and it never generates any holes in the resulting mesh.


A good MC implementation will generate a smooth mesh to begin with if the data at each voxel location has a range of values instead of just a binary in or out state. The ugly stair-stepping only shows up if you're forced to put each vertex right in middle of each isosurface-crossing edge because you don't have enough information to do anything more intelligent.

#5026889 C++ how to avoid calling destructor

Posted by Eric Lengyel on 29 January 2013 - 01:44 PM

You could do this, but I don't recommend it:

void pushback_function()
    char storage[sizeof(some_class)];
    some_class *temp = new(storage) some_class;

#5023723 Texture coordinate scaling + TBN calculation

Posted by Eric Lengyel on 20 January 2013 - 08:00 PM

Are you scaling after the rotation, so as to cause a skew? This would cause the tangent and bitangent to no longer be perpendicular, so calculating the bitangent as the cross product between the normal and tangent won't quite work. Instead, if you calculate the bitangent in terms of tan1 just like you calculated the tangent in terms of tan0, you'll get the right vector. But then you can no longer assume that the inverse of the TBN matrix is just its transpose when you do your shading.

#5021634 Game engine slection for a game programming course

Posted by Eric Lengyel on 14 January 2013 - 07:48 PM

If you're looking for an engine that teaches the proper techniques and general theory of game programming, then you'll probably want an engine that includes source code, and that eliminates Unity and UDK.


Please check out the C4 Engine, which has been used in game programming classes at many universities for several years. Here is an example of a specific course that uses the C4 Engine:





You can see the feature list here:




If you have any questions, please feel free to post in the C4 Engine forums:



#5016191 How do I create a vector tangent to each point in a non-function defined surf...

Posted by Eric Lengyel on 31 December 2012 - 04:59 PM

The answer to the thread title can be found here:



#5007293 Question about glGenTextures

Posted by Eric Lengyel on 04 December 2012 - 09:33 PM

The GL driver also keeps a copy of the texture image in RAM. The contents of the VRAM accessible to the GPU can be dumped at any time (for example, if the screen resolution is changed), and the driver needs to be able to restore your textures from its copy in RAM without you having to do anything.

#4941663 Intersection of two line segment in 3 dimensions

Posted by Eric Lengyel on 20 May 2012 - 10:19 AM

Aren't those both line-line tests and not line segment-line segment tests?

Yes, you're right. I must have been to sleepy to see the word "segment".