Jump to content

Reflections on Pyramid


Punn
 Share

Recommended Posts

mmmh.. the distorded reflection is typically the problem encountered with computeNormals() on vertices belonging to exacly 3 coplanar faces : http://www.babylonjs-playground.com/#TPE3U#4

 

However the new cylinder re-implementation doesn't use computeNormal() any longer but dedicated computed normals from the cylinder geometry itself.

I tested it, there were no artifact, even with many subdivisions (I didn't test tessellation = 4 ...) .

Link to comment
Share on other sites

Ok, got it : http://www.babylonjs-playground.com/#TPE3U#5

 

Well, it's rightly the same problem than encountered with computeNormals() about 2 coplanar facets having vertices with different normals due to their but ... without computeNormals() !

Because there is only a quad per face and many subdivisions, we create here this specific case : 2 coplanar triangles, but different normalson each, so the quad plane has no 4 similar normals => visual artifact.

 

I'm afraid, in this very case, the solutions are to set the subdivisions to 1 OR to set your normals afterwards with a computation dedicated to the specific geometry.

 

 

NOTE : this means computeNormals() is not magic, but dedicated computed computed are neither

Link to comment
Share on other sites

If you really need to keep many cylinder subdivisions (instead of 1 to avoid the artifact), you could convert your mesh to a flat shaded one : http://www.babylonjs-playground.com/#TPE3U#6

 

Each mesh face will then have its own normals not depending from the other side vertices. This is a really simple way to deal with artifacts on meshes which have edge angles lower than 120°

Link to comment
Share on other sites

gotcha : https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.mesh.vertexData.ts#L790

 

JS lazy evaluation :

diameterTop = diameterTop || options.diameterTop || 1;

if diameterTop is falsy then options.diameterTop else 1 ...

But 0 is falsy in JS !

I'm fixing this right now.

 

 

@DK : I think we've got the same problem on each sideOrientation evaluation :

sideOrientation = sideOrientation || options.sideOrientation || Mesh.DEFAULTSIDE;

This will work only as long as the constant DEFAULTSIDE is set to zero.

If we change it some day, the lazy evaluation might come to strange results.

ex : if DEFAULT is set to 1 and we call the method by requesting sideOrientation: FRONTSIDE, what is zero => we'll get DEFAULT (== 1) instead

 

Maybe something like this would be better :

            if (sideOrientation === 0 || options.sideOrientation === 0) {                sideOrientation = 0;            } else {                sideOrientation = sideOrientation || options.sideOrientation || Mesh.DEFAULTSIDE;            }
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.

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

Loading...
 Share

  • Recently Browsing   0 members

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