Millions of facets with three.js?

I’ve heard terms like “polygon soup” thrown around quite often in recent years. That a “game” or, really just a “scene” is considered as a large collection of polygons and nothing more. You forget about objects and hierarchies for the most part, because it simplifies the concept drastically. If you do that - you only have to think about “how do I make my soup run at interactive frame rate”, admittedly, this approach is not all-encompassing as it is not as well suited for dynamic elements in the scene and may run counter to some memory optimization techniques such as instancing.

This is mostly a tangent, in the same direction as what @EliasHasle was talking about.

2 Likes

It is also hardware, shader and other factors related, if people only talk about how many million bare triangles they can render this mostly doesn’t reflect any real world scenario or the average hardware specs of the target audience, especially the gap between desktop and mobile.

1 Like

967 x 12 x 12 x 12 = 1,653,696 triangles

1 Like

@looeee
Are we gonna have instancedMesh with r109 ? :star_struck:

1 Like

http://dusanbosnjak.com/test/webGL/three-instanced-mesh/webgl_instanced_mesh_v4.html

Here’s an example of this. It too renders a lot of triangles. The sphere in particular renders over 32 million triangles (i think) since the shadows are turned on. The box is 1.2 million, times two. The demo itself is from:

Yes, but if you want to use something similar to this in <r109 you can check these out:

4 Likes

Looks like it!!

3 Likes

http://dusanbosnjak.com/test/webGL/three-instanced-mesh/webgl_instanced_mesh_v4.html
Ok so it hasn’t changed a lot: that scene, with 100 000 boxes (tha’ts half a million facets) renders at 32 FPS on my laptop.
And those facets are plain colored, they don’t have textures.
Now if you add textures, you’ll see that it can’t even reach half a million.

Phong doesn’t count much: the GPU is good at that kind of computings, it does them in parallel moreover. The problem is that you have to choose between lights (basic shading is fast but when you add lot of relexion and refraction it becomes slow), fog (really intense volumetric computations), facets (read lots of memory) or textures (read lots of memory). You can’t have all of them and a decent FPS.

The particular way I indexed facets make it possible to skip facets much faster than enumerating them so the number of facets is not a problem anymore.

The other example is a particular case: it doesn’'t have to read lots of memory, it is based on repeating facets.

As for objects and hierarchy, the way I indexed facets have nothing to do with object management. You can have any hierarchy you want, and you can have multiple indexes and merge them together fastly. There can be a decorelation between raw facets in the index and objets. At the end of the frame time, when you have moved all your objects, you update the index. And if objects use that kind of index, they can themselves know quickly if there move places them in the camera view or not.

Example: you have 1000 object of 1 million facets. You ask each object: give me the facets that are in view. There you have your billion facets. You won’t be able to draw more than millions of facets without halving the FPS: 1 million facets and 1 million pixels that’s twice the time spent.

1 Like

As for instanced mesh, it is neat for repeating geometry. It doesn’t cope with lots different objects.

Though there are solutions for certain types of objects. For example trees can be rendered with 5 kind of instanced mesh, but in the shader you move the vertice randomly. Then you’ll have all different trees. But you have to write your own shader, and it doesn’t work so well with all kind of objets. Cars for example.

Ok if I have some time to spent, I’ll make another demo. Because you just don’t get the point: when you REALLY give 1 million facets to the GPU it is as much as the number of pixels to render, and then the GPU spends twice as much time as if it had to render only a few facets and 1 million pixels.

How did you come up with this number? A box has 6 sides with 2 triangles each, making it 1.2 million “facets”. I’m not even sure how much these facets matter since it’s 24 vertices being transformed. Keep in mind that shadows are being rendered so, double the number of facets…

3 Likes

Ok, so how many WebGL programmers does it take to change 1.2 mil faucets?

5 Likes

At least 10 instances and a spatial index

btw When I first looked at this topic I thought it was about instancing 10k bathroom faucets models or something. Is that actually a common synonym for a face or just something lost in translation? :face_with_monocle:

4 Likes

faces

7 Likes

https://www.amentsoc.org/insects/glossary/terms/facet

In the parabolic superposition compound eye type, seen in arthropods such as mayflies, the parabolic surfaces of the inside of each facet focus light from a reflector to a sensor array.

2 Likes

Probably a fairer definition :stuck_out_tongue:

In three-dimensional geometry a facet of a polyhedron is any polygon whose corners are vertices of the polyhedron, and is not a face.[1][2]

@Nicoco I think the term you should be taking here is ‘face’.

Agreed, a facet can mean an arbitrary number of triangles, i think the more common term is Ngon.

This definition from mathworld doesn’t have the stipulation that a facet is not a face though, I wonder if the wiki definition is non-standard?

An (n-1)-dimensional face of an n-dimensional polytope.

According to this, in 3 dimensions the terms facets and faces are synonymous.

In any case, ‘face’ is certainly the standard term across all CG and geometry literature that I’ve read.

5 Likes

Usually don’t hear the term facet in a professional context, rather in old fashioned explanations teachers still love to use.

1 Like

Ah, and the references are unavailable online…

Here is the mathworld definition for Face. “A zero-dimensional face is a vertex” etc… I think in general it is best to lean on mathematicians for definitions, as they tend to have a good eye for generalization, which both orders the existing knowledge and expands the horizons.

Completely agree - however it’s important to stick with the conventions of our field as well, and remember that mathematical terms tend to be tweaked to suit each sub-field. So, for a mathematician discussing an n-dimensional polytope, a vertex is a face, an edge is a face, a polygon is a face. But as computer graphics engineers, we’d never refer to edges or vertices (or facets) as faces. Doing so might be technically correct, but it will still lead to confusion.

1 Like

GPUs deal with triangles though, neither faces nor facets are applicable? No matter what you do, a triangle has to be rasterized.