Skip to content
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

Support batch table binary section for pnts #4112

Merged
merged 5 commits into from
Jul 14, 2016
Merged

Conversation

lilleyse
Copy link
Contributor

@lilleyse lilleyse commented Jul 13, 2016

For CesiumGS/3d-tiles#32 (comment)

The pnts format now loads colors through the batch table JSON/binary, or uses a default color if there is no batch table or no TILES3D_RGB property. I'm not creating a batchTableResources for Points3DTileContent since that will probably require some more thought it we even want per-point properties.

One question: do we want to allow the pnts format to specify a default color? If it's in the batch table it could look like:

{
    "TILES3D_COLOR" : [1.0, 0.0, 0.0]
}

colors = new Uint8Array(length);
for (var i = 0; i < length; ++i) {
colors[i] = 64;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm I think I'm going to fix this so the attribute is just a single value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this won't work easily with GeometryAttribute.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we provide a uniform using an appearance?

Otherwise put a TODO here (not PERFORMANCE_IDEA) so we optimize this before merging into master.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try that.

@pjcozzi pjcozzi mentioned this pull request Jul 13, 2016
2 tasks
@pjcozzi
Copy link
Contributor

pjcozzi commented Jul 13, 2016

if we even want per-point properties

It doesn't need to be part of this PR and it might be a new class in Cesium, but we will want per-point properties that can be used for dynamic styling and vertex shader generation, see CesiumGS/3d-tiles#22 (comment)

@pjcozzi
Copy link
Contributor

pjcozzi commented Jul 13, 2016

One question: do we want to allow the pnts format to specify a default color?

OK...it should include alpha and be the same range as the per-point color, e.g., [0, 255] or whatever it ends up being without compression. No need to finalize now, but it will need to be consistent.

@lilleyse
Copy link
Contributor Author

That reminds me I should also include a TILES3D_RGBA semantic.

@pjcozzi
Copy link
Contributor

pjcozzi commented Jul 13, 2016

That reminds me I should also include a TILES3D_RGBA semantic.

+1

@pjcozzi
Copy link
Contributor

pjcozzi commented Jul 13, 2016

Just those comments.

@lilleyse
Copy link
Contributor Author

Updated to support RGBA. What is the best way to render PointGeometry with alpha blending?

@lilleyse
Copy link
Contributor Author

Ah I messed up the merge. Fixing that now.

@lilleyse lilleyse force-pushed the batch-table-binary branch from 1393820 to 45e6a94 Compare July 13, 2016 21:53
@lilleyse
Copy link
Contributor Author

Updated to support RGBA. What is the best way to render PointGeometry with alpha blending?

Never mind, I have an idea. It will require modifying the PointApperance shaders though, which we'll end up doing anyways.

// Get the point colors
var tiles3DRGB = batchTableJSON.TILES3D_RGB;
var tiles3DRGBA = batchTableJSON.TILES3D_RGBA;
if (defined(tiles3DRGB)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about CesiumGS/3d-tiles#22 (comment)

Should the tile be invalid (in practice if someone wants multiple per-point colors, they would use their own semantics)? Or give should RGBA win over RGB?

@lilleyse
Copy link
Contributor Author

Updated. I'm building the shaders based on whether it's RGB, RGBA, or constant color, but still using PointGeometry and PointAppearance. I also added TILES3D_COLOR option from here: CesiumGS/3d-tiles#22 (comment).

@pjcozzi
Copy link
Contributor

pjcozzi commented Jul 14, 2016

Very nice, thanks @lilleyse!

@pjcozzi pjcozzi merged commit 5d3f792 into 3d-tiles Jul 14, 2016
@pjcozzi pjcozzi deleted the batch-table-binary branch July 14, 2016 17:07
var batchTableBinaryByteLength = view.getUint32(byteOffset, true);
byteOffset += sizeOfUint32;

var positions = new Float32Array(arrayBuffer, byteOffset, pointsLength * 3);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, in b3dm and i3dm, the batch table comes before glTF. We should be consistent here for now and move the positions payload after the batch table; however, we might want to switch them all later if there is a benefit, e.g., to avoid parsing it in some cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that's true, I'll make the change in a new PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised we haven't run into this before, but TypedArray constructors expect their byte offset to be aligned to the type. For two of the points tilesets, the byte length of the batch table is odd and this causes problems when creating a Float32Array of the positions. Do we want to require byte alignment in the spec?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, definitely need to say this in the spec. @tfili and I have ran into this before and I know some of the work we did included the padding

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants