-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Geometry and Appearances #766
Comments
@bagnell for per-instance
var instance = new GeometryInstance({
geometry : geometry,
color : color,
show : false,
id : 'my instance id' // also used for picking
});
var primitive = new Primitive({
instances : [instance, anotherInstance, …],
mutableShow : true,
mutableColor : true
});
primitive.getMutableInstance('my instance id').show = true;
primitive.getMutableInstance('my instance id').color = new Color(); The mutable instance uses property getter/setters (performance will not be significant here), and maps the instance to the vertex buffer range that needs to be updated. Like the |
@bagnell for Columbus view / 2D above, let's
|
@bagnell here's a new plan for per-instance
var instance = new GeometryInstance({
geometry : geometry,
attributes : {
color : new GeometryInstanceAttribute({
componentDatatype : ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute : 4,
normalize : true,
value : color.toTypedArray() // function doesn't exist but you get it
}),
show : new GeometryInstanceAttribute({
componentDatatype : ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute : 1,
normalize : true,
value : 0
}),
}
}); Specific var instance = new GeometryInstance({
geometry : geometry,
attributes : {
color : new ColorGeometryInstanceAttribute(color),
show : new ShowGeometryInstanceAttribute(false)
}
}); Show should be a single component unsigned byte unless it hits a driver slow path, in which case, it should be a single component float (0.0 or 1.0).
var instance = new GeometryInstance({
geometry : geometry,
attributes : {
color : new ColorGeometryInstanceAttribute(color),
show : new ShowGeometryInstanceAttribute(false)
},
id : 'my instance id' // also used for picking
});
var primitive = new Primitive({
instances : [instance, anotherInstance, …]
});
var attributes = primitive.getGeometryInstanceAttribues('my instance id');
attributes.color = ColorGeometryInstanceAttribute.toValue(new Color());
attributes.show = ShowGeometryInstanceAttribute.toValue(true); The attributes use property getter/setters (performance will not be significant here), and map the instance to the vertex buffer range that needs to be updated. Like the |
@bagnell if you didn't already notice, to map per-instance attributes to a buffer range, we should optimize for the vertex caches before combing instances; otherwise, maintaining the mapping will be a pain. This will lead to a slightly less optimal ordering since there will be a compulsory miss at the start of each instance, but it will not matter at all in practice. In addition, this should improve the overall performance of the geometry pipeline. |
@bagnell are we already doing this? Or do we always introduce new vertices? |
We always introduce new vertices. |
Closing this. Having this roadmap is no longer very useful for tracking issues or enhancements with Geometry and Appearances. Thanks! |
Also see the discussion on the forum.
This will introduce a new generic
Primitive
(name TBA) that is higher-level than Renderer, but lower-level than the current primitives. It is meant for batching of heterogeneous static geometry. Static means changing the geometry, i.e., the vertex data, is expensive, but changing themodelMatrix
, is, of course, still cheap. Dynamic geometry batching is a separate topic, and will require direct, or near direct, access to vertex buffers.This decouples primitives into geometry and appearance, making it easy to add new geometry types, e.g., boxes, cylinders, etc., and new appearances, e.g., full GLSL shader + render state + material. The design is nothing new; it is what is done in pretty much every 3D engine and book out there, and similar to - but more general than - what I did in Insight3D years ago.
We'll use this to add features for KML, and may rewrite existing primitives - most likely
Polygon
andEllipsoidPrimitive
- to use it. The Geometric Algorithms Google Summer of Code proposal is a subset of this effort.Example code
Today we write:
In the future, we would write:
It's more code. Don't worry.
(1) it allows for batching:
(2) it is easy to draw new geometry or with new appearances
(3) we can write nice (slow) wrappers on top of it:
Now it's less code. Magic.
The new Primitive allows for individual geometry picking, and high-precision rendering with GPU RTE. In theory, I think I can make it work for Columbus view too.
Details
@bagnell
Primitives
VertexFormat
.Primitive
needs to use generic algorithms.Appearance
/Material
changes (which can change theVertexFormat
), we would have to keep the geometry in system memory. Ugh. This could be an "auto" option I suppose.Geometry
would need a function to add texture coordinates.Geometries
onComplete
(for primitives built on geometries too) so, for example, we can destroy a primitive once the new one is ready.WallGeometry
just be an extrusion object forSimplePolylineGeometry
?PolylineVolumeGeometry
and friends so the polygon can roll, i.e., it is not always oriented north.Appearances
Scripting
Performance
pickColor
attribute in a separate buffer and have a separate vertex array for the pick pass; this will reduce memory bandwidth and cache pollution for the color pass.fitToUnsignedShortIndices
to use tighter bounding spheres per-geometry.Done
@bagnell
binormal
andtangent
attributes to BoxGeometry.ExtentGeometry
.PolygonGeometry
that works with and without holes. It will not use the full pipeline used in the current Polygon primitive because some of that is in the generic Primitive.CircleGeometry
andEllipseGeometry
.WallGeometry
. Meet the needs of KML and Sky.Float64Array
, which will also require some WebGL-related changes.show
per geometry, i.e., how to change vertex data? We should be able to changecolor
too. (notes below)GeometryPipeline.combine
.@hpinkos
binormal
andtangent
attributes given a geometry with texture coordinates. See Computing Tangent Space Basis Vectors for an Arbitrary Mesh. @tfili has a C++ implementation.normal
attributes given a geometry with positions. I can dig up a C++ implementation.ExtrudedExtentGeometry
(with bottom/top) - or make this part of theExtentGeometry
. Meet the needs of KML.ExtrudedPolygonGeometry
(with bottom/top) - or make this part of thePolygonGeometry
. Meet the needs of KML.SphereGeometry
based onEllipsoidGeometry
.EllipseGeometry
andCircleGeometry
.CylinderGeometry
. @pjcozzi has C++ code.WallGeometry
subsample so it matches the curvature of the ellipsoid.PolygonGeometry
,ExtentGeometry
,EllipseGeometry
,CircleGeometry
,WallGeometry
,BoxGeometry
, andEllipsoidGeometry
. Go over the design with @pjcozzi beforehand.CorridorGeometry
. Option to miter or bevel corners.CorridorOutlineGeometry
.@pjcozzi
color
toVertexFormat
.Surface
(procedurally compute normal/binormal/tangent) appearance.modelMatrix
,color
, andpickData
, perhaps call itNodeGeometry
orSpatial
. This will allow us to "instance" the geometry, but we need to be careful because many pipeline operations modify the geometry in place.mesh
/meshes
togeometry
/geometries
throughout.Geometry
format. In particular: do we need more than oneindexList
and modifycombine
to work without indices.VertexFormat
andAppearance
, e.g., add normals if needed.SimplePolyline
geometry and appearance.Polygon
based on geometry and appearance.Extent
primitive.The text was updated successfully, but these errors were encountered: