Chris Oliver's Weblog
- All
- F3
- JavaFX
- Programming
- Research
Instancing
To conserve memory and minimize processor cache misses and GPU state changes, we need reasonable ways of "instancing" scene graph elements, meaning reusing the same objects in cases where the same element conceptually appears multiple times in the same scene.
It's possible to implement a transform and bounding volume hierarchy which supports instancing, however the overhead is significant, both in terms of its impact on processing costs and memory-use, as well as on ease-of-use for many use cases. If you introduce instancing at this level, every node potentially has many parents (and further ancestors) - which implies a node also has as many world space transforms and world space bounding volumes as the product of all its ancestors.
To avoid these costs but still retain some of the benefits of instancing, one approach is to make the instancing purely visual. In this case, a Node which appears multiple times in the same scene still may have at most one actual parent, and thus only a single world transform and bounding volume. A special auxiliary node type is provided which itself is part of the transform hierarchy and bounding volume hierarchy of the scene, however any nodes it contains remain disconnected from that, i.e it is not their parent. When this auxiliary node is rendered, it cancels the world transform of the actual parent (if any) of its child nodes and substitutes its own in place of that. In addition, it arranges for its children to derive their render states from its own rather than those of their parents.
In our system, this auxiliary node is called a "Lens" and has the following partial definition:
public class Lens extends Node {
public var view: Node;
...
}
Example - Bubblemark
It's not a very interesting example, but it is (hopefully) somewhat familiar. In "Bubblemark" the same vector "bubble" graphic appears N times, each with a different translation. It would be extraordinarily wasteful to actually create N duplicate Bubble objects (which are quite heavyweight). Instead, we can use N Lens objects (which are lightweight by comparison) each viewing a single Bubble, and translate the lenses instead of the bubble. Here's the relevant code:
Stage {
scene: Scene {
def bubble = Bubble {}
content:
Group {
content: bind lazy
for (ball in model.balls)
Lens {
x: bind lazy ball.x;
y: bind lazy ball.y;
view: bubble;
}
}
}
}
With this formulation of instancing I no longer have transform and bounding volume information about the "instanced" bubbles, however in this case I didn't need that since it's already present in the Bubblemark application's "model".
Performance of "Bubblemark" in our system seems good compared to others:
By comparison, the vector Flex example on bubblemark.com has roughly half the frame-rate, and more than double the CPU usage, even while rendering far fewer pixels. Of course, these discrepancies aren't just about instancing, but more so about using the GPU rather than the CPU for rasterization.
As a second example, here's a quickly thrown together example of a 3D chart, which was produced using one cylinder instance and one rectangle instance:
Posted at 03:49PM Jul 23, 2009 by Christopher Oliver in Research | Comments[18]
Thanks Chris, this is going to be helpful. Its beginning to look like complex scenegraphs (for instance music scores) are now going to be doable in JavaFX after all.
Posted by Thomas on July 23, 2009 at 09:42 PM PDT #
It's too bad this project is being abandoned. For my part, JavaFX lacks a "wow" factor (performance still being a big issue in the current release) and at least from what you're describing, this project could put the Oh! in wow! Maybe some clear-headed person at Sun/Oracle will see the light of day. Thanks for continuing to detail your work, in any case.
Oh, and I love that screenshot of the bubblemark, very cool.
Patrick
Posted by Patrick Wright on July 24, 2009 at 04:49 AM PDT #
What CPU/GPU/temperature monitoring software are you using in the first screenshot? :)
Posted by Anonymous on July 24, 2009 at 03:37 PM PDT #
To answer my own question: it seems to be atMonitor for Mac
Posted by Anonymous on July 25, 2009 at 05:32 AM PDT #
Chris,
Hopefully all your good work done for JavaFX 3D will have some nice outcome.... eventually.
In the meantime I really miss your "old style F3 power-demos" ... so I hope you'll be back with something more interesting ...
10x again for you hard work on FX.
PS1: Just hit this one, O3D from Google, you may take a look
http://blog.largeanimal.com/
PS2: Where are those nice JavaOne 2008/2009 nice demos/games - Tank Moon (or something like this)... & co.
Are these just marketing "vaporware" ?
Posted by El Cy on July 27, 2009 at 12:51 PM PDT #
Not sure whether your post is about Slim Shady or JavaFX.
All the ideas posted sound good ideas - which one are you prioritizing in terms of an actual shipping feature in JavaFX that people are able to use? Which ones are the lowest risk - biggest bang for buck?
Posted by Mr X on September 07, 2009 at 03:04 AM PDT #
This is a great description.
Posted by links of london on December 13, 2009 at 09:44 PM PST #
jean style jean style jeans stylejeans style mens jean style mens jean style skinny jean style skinny jean style blue jeans style blue jeans style seven jeans style seven jeans style new jean style new jean style latest jean style latest jean style jeans styles jeans styles boy style jeans boy style jeans men jean style men jean style jean style
Posted by jean style on December 17, 2009 at 10:07 PM PST #
Thank you very successful and useful site I have received the necessary information ...
Posted by Bilgisayar on December 26, 2009 at 07:50 AM PST #
Thank you very successful and useful site I have received the necessary information ...
Posted by toner arşivi on December 26, 2009 at 07:50 AM PST #
Thank you very successful and useful site I have received the necessary information ...
Posted by xerox on December 26, 2009 at 07:51 AM PST #
we only require 2d, 3d, and 4d vectors and 2x2, 3x3, and 4x4 matrices. These types are provided in a new package called javafx.math, http://www.watchgy.com/ namely Vec2, Vec3, Vec4, Mat2, Mat3, Mat4. Since rotations may be represented as a pair of angle/axis, or quaternion form, in addition to matrix form, we also provide the types AngleAxis, and Quat. http://www.watchgy.com/tag-heuer-c-24.html
http://www.watchgy.com/rolex-submariner-c-8.html
http://www.watchgy.com/rolex-daytona-c-6.html
Posted by rolex replica on December 29, 2009 at 05:33 AM PST #
thanks so much
Posted by rize on January 05, 2010 at 08:50 AM PST #
Thanks for continuing to detail your work, in any case.
Tavla indir
http://www.tavla-indir.org
Posted by Online tavla oyunu on January 05, 2010 at 12:43 PM PST #
thanks
http://emlakx.net
http://emlakx.net/haberler
http://emlaksay.com
http://parcakontor1.com
http://saays.com
http://arslantekniksogutma.com
http://cerkezkoyemlakofisi.com
Posted by emlak ilanları on January 30, 2010 at 05:07 AM PST #
Paylaşımiçin teşekkürler
Posted by medyum on January 30, 2010 at 02:18 PM PST #
http://www.cappadocia-balloon-tours.com
http://balloon-tours.net
http://www.incappadocia.com
http://www.balonturu.net
http://kapadokyabalon.gen.tr
http://www.durmaizle.net
http://www.cappadociacave.net
http://www.yataktasevisme.com
http://www.onlinesexizle.net
http://www.sinemaizle.web.tr
http://www.tandirkebap.net
http://www.zamanne.com
Posted by dsdsaddsadsa on February 02, 2010 at 04:51 AM PST #
Nice work thanks
Posted by medyum on February 08, 2010 at 03:16 PM PST #