Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Compiled Objects

Mac Beach
Linux/OS X User
Join date: 22 Mar 2002
Posts: 458
07-18-2003 17:05
I just finished reading another thread that mentioned a chair with 70 primitives. Not the first time I have heard of detailed creations that were responsible for one sort of resource consumption or another. The discussion, with it's emphasis on "prims" caused an idea to reappear in my sieve-like brain and I figured I'd better write it down before I forget it again.

A bit of background...

The notion of "primitive" in SL refers to the set of 10 or so basics objects that can be created and then tinkered with to build all our stuff. In most 3D work that I've experienced the REAL primitive element is the triangle, and its is a one sided triangle at that. Invisible and non-solid from one side, solid, textured or colored from the other side. Mathematically, everything else can be built up from this true prim of all prims. Not only popular 3D object creation programs, but the video hardware itself is geared toward optimizing the rendering of these most atomic of building blocks. It is therefor not uncommon when working with these tools to take an object that is approaching done-ness and convert it from a collection of higher level building blocks such as spheres, cubes, conic sections etc into a single large collection of triangles. In the process a wonderful thing happens (well sometimes)... As all the interior components of the object are rendered into individual triangles and the interface determines (I have no idea how) that the vast majority of those triangles are invisible and can be discarded. The results is an object that looks exactly the same, but renders much faster. Of course once you do this you can't go back, as the original primitives you used have been forgotten. There may be an official name for this process, but as far as I know, 3DSMAX, Truespace and some others all use different terms, so I settled on "compiling" because shares the properties of taking high level language constructs and converting them into a simpler assembler, or machine language. It also shares the property that once this conversion has been done, further optimizations can take place yielding tighter and tighter code.

So, my suggested feature is to allow for objects, particularly complex ones to be compiled in some way so that the sims could handle many more of them without bogging down. I'm not sure if this could be done "live" by individual users or perhaps it would have to be done offline in some way by a separate process, but seems to me it would solve some performance problems and allow for more detailed builds without the enormous overhead we are seeing in a couple of cases.

An alternative (for which I haven't come up with a catchy name) would be to actually have a one-sided triangle as part of the SL "prim" set. While you can make a triangular object from the current set, it actually consists of 4 triangles (I think). A true one-sided triangular primitive along with a couple of extra building tools to allow edges and vertices to be snapped together would allow for the construction of very efficient complex objects, although the compiling approach would be a lot easier, if its possible.

It would be interesting to know how many triangles are in that 70 prim chair, and how many of them are visible.
Grim Lupis
Dark Wolf
Join date: 11 Jul 2003
Posts: 762
07-18-2003 18:19
I definitely want to second this motion. Anything that speeds up rendering by removing triangles is a good thing.

The big catch that I can think of (especially if it isn't resident-activated) is determining which objects get "compiled" and which ones are left alone.

i.e. If I'm working on a project, log off (or get kicked) and then come back tomorrow to find that it's been auto-compiled and I can no longer manipulate the individual components, I'm going to be upset.

--
Grim
_____________________
Grim

"God only made a few perfect heads, the rest of them he put hair on." -- Unknown
Ama Omega
Lost Wanderer
Join date: 11 Dec 2002
Posts: 1,770
07-18-2003 19:36
That is a nice idea.

But here is something..... 'primitive' polygons don't have to be triangles. There is no law that says they must and in fact some graphics engines have used 4 sided polygons as the most primitive shape. And I'm not entirely sure that isn't what SL is doing in many cases.

I wrote for one class a software modeling and rendering program that used both 4 sided and 3 sided polygons, and in fact even supported custom n sided polygons.

You are right though that 3 is pretty standard because generally that is how graphics cards do it. However it is also my understanding that the primitives available are the ones available because of some performance value. If I recall correctly they are the primitives supported directly by OpenGL, in such a way that they can tell an OpenGL compliant card "Draw a cube with X dimensions, at Y location with Z properties" and the card goes and does it in the best, most efficient way it can.

I'm not saying your idea isn't a good one, just that the performance gain may not be as clear cut and it may be a lot of work too.
Mac Beach
Linux/OS X User
Join date: 22 Mar 2002
Posts: 458
07-18-2003 21:52
Well, I've used programs that used 4 vertex primitives too, I think because it is easier to visualize and deal with texturing that way. But someone showed me once that even those programs at some point divide each "quad" along one of the diagonals to make two triangles. In some programs I think this goes along with "fixing" geometry, in that you can define a quad that does not lie on a plane (as it should) but you can't define a triangle in which the vertices are not coplanar, so an object defined by triangles can't have some of the problems caused by quads.

But my point, using whatever the lowest level of detail that SL deals with, was to eliminate the mostly unseen parts of an object when you (for example) lump several odd shaped pieces together to form a rock shape etc.
kohne Kato
Woo. Yay.
Join date: 4 May 2003
Posts: 109
07-18-2003 22:32
I'm sure that both of you know exactly what you're talking about, and I'm open to the idea that there are ways to speed up rendering of objects... but I think there is a reason why the SL 'primitives' aren't quite as 'primitive' as they could be.

Many SL-ers enjoy the SL world precisely because it is so easy to wade in and learn new skills. Even if it came at an advantage in speed, new players would be very frightened by an edit menu with a single, menacing triangle as the only tool. The idea that anybody with little background in 3D modeling has so much control over what they create is a strength of SL I would not like to see lost. It seems analogous to replacing LSL with assembly. You could do it... but then only the experienced could have any fun.
_____________________
May your prims not flash or sparkle,
might your heaps stack without collision,
let your inventory be clutter-free,
and high fps be with you.

- An SL blessing ^_^
Mac Beach
Linux/OS X User
Join date: 22 Mar 2002
Posts: 458
07-19-2003 00:18
Nooooooooo

I wasn't suggesting replacing anything. Just adding the triangle as an additional tool. To be honest I have NO desire to work with objects at that level of detail either...but then I wouldn't build a chair out of 70 prims.

I'm much more interested in having the SL interface "optimize" objects in some way simply so we can have more of them. I know that even in my simple building I have ended up with primitives overlapping and intersecting each other a lot and if all those otherwise invisible parts could be done away with it would seem to be a benefit to all.

As was pointed out, once this was done it might be the case that the objects would no longer be editable. This could actually be an advantage for objects you wanted to sell...sort of like a super-lock. To take care of this you would have to keep a "working" copy in your inventory I suppose.

I have no idea whether the inner workings of SL would allow this to be done either, so the whole thing may be moot. But considering that someone in another thread is claiming they have to move to a new sim because someone else has a few chairs in their basement... I figured maybe some technical approach might be worth talking about.
si Money
The nice demon.
Join date: 21 May 2003
Posts: 477
07-19-2003 03:26
From: someone
Originally posted by Mac Beach
Nooooooooo

I wasn't suggesting replacing anything. Just adding the triangle as an additional tool. To be honest I have NO desire to work with objects at that level of detail either...but then I wouldn't build a chair out of 70 prims.

I'm much more interested in having the SL interface "optimize" objects in some way simply so we can have more of them. I know that even in my simple building I have ended up with primitives overlapping and intersecting each other a lot and if all those otherwise invisible parts could be done away with it would seem to be a benefit to all.

As was pointed out, once this was done it might be the case that the objects would no longer be editable. This could actually be an advantage for objects you wanted to sell...sort of like a super-lock. To take care of this you would have to keep a "working" copy in your inventory I suppose.

I have no idea whether the inner workings of SL would allow this to be done either, so the whole thing may be moot. But considering that someone in another thread is claiming they have to move to a new sim because someone else has a few chairs in their basement... I figured maybe some technical approach might be worth talking about.


What you're talking about is really more a matter of compression of server<>client data, which is already done very heavily. If you consider the fact SL is basically sending the full amount of data which is sent from the CPU to the GPU which is GB+ of bus bandwidth across your net stream, you take into account it's already highly, highly compressed.

There's no real way to speed up the transfer of the data through the GPU in a manner of "pre-rendering" objects, they just don't work that way.
Tcoz Bach
Tyrell Victim
Join date: 10 Dec 2002
Posts: 973
07-19-2003 12:08
I wonder how your suggestion would effect physics. I know a while back a patch altered how the system processes collisions so that when a certain threshhold is reached, objects are approximated as rectangles. This seems to be the optimal shape for this system. Reading the Havok site gives a lot of interesting stuff related to this.

I havea feeling though that if you could see it all in wireframe, a big rectangle might actually be two triangles or so. I don't think the prims are single units; you can see this when putting a texture on something like a cylinder, then drastically altering the shape of that cylinder with top size or whatever. The texture will "break", as if the object is made up of smaller ones that no longer quite "fit".
_____________________
** ...you want to do WHAT with that cube? **