Jump to content

normals unsmoothed after recompute


Recommended Posts

Hi there, 

After loading my mesh I apply a translation/rotation to the verts so I need to recompute the normals if I want the lighting to be accurate.

However it causes the normals to not be smoothed, am I doing it wrong?

BABYLON.Mesh.prototype.recomputeNormals = function ()
    var normals = [];
    var positions = this.getVerticesData(BABYLON.VertexBuffer.PositionKind);
    normals = this.getVerticesData(BABYLON.VertexBuffer.NormalKind);
    BABYLON.VertexData.ComputeNormals(positions, this.getIndices(), normals);
    this.setVerticesData(BABYLON.VertexBuffer.NormalKind, normals);

before recomputing the normals:






Link to comment
Share on other sites

Yes I think I do.

I move submeshes around in my application based on external data and it's all contingent on each submesh having its origin at the center of its bounding box. However when I load a model, all submeshes have their origin at the center of the model (0, 0, 0) so I move the verts so that the center of the bounding box is 0,0,0, then I translate the mesh back to where it was. I use object.bakeTransformIntoVertices();



Is there a better way to achieve that? :) 

I'm not sure why I would lose the smoothing after recalculating, I move the whole thing at once, verts have the same relative positions.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...