Skip to content

Commit 8d67e9e

Browse files
authored
Merge pull request #12933 from CesiumGS/voxel-rte
Use eye coordinates for voxel raymarching
2 parents 0e35728 + 64e17d3 commit 8d67e9e

33 files changed

+2284
-1162
lines changed

Apps/Sandcastle/gallery/Voxel Picking.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,17 @@
8080
this.names = ["color"];
8181
this.types = [Cesium.MetadataType.VEC4];
8282
this.componentTypes = [Cesium.MetadataComponentType.FLOAT32];
83-
this._levelCount = 3;
83+
this.availableLevels = 3;
8484
this.globalTransform = globalTransform;
8585
}
8686

8787
ProceduralMultiTileVoxelProvider.prototype.requestData = function (options) {
8888
const { tileLevel, tileX, tileY, tileZ } = options;
8989

90-
if (tileLevel >= this._levelCount) {
91-
return Promise.reject(`No tiles available beyond level ${this._levelCount}`);
90+
if (tileLevel >= this.availableLevels) {
91+
return Promise.reject(
92+
`No tiles available beyond level ${this.availableLevels - 1}`,
93+
);
9294
}
9395

9496
const dimensions = this.dimensions;
@@ -174,6 +176,7 @@
174176
customShader: customShader,
175177
});
176178
voxelPrimitive.nearestSampling = true;
179+
voxelPrimitive.stepSize = 0.7;
177180

178181
viewer.scene.primitives.add(voxelPrimitive);
179182
camera.flyToBoundingSphere(voxelPrimitive.boundingSphere, {

Apps/Sandcastle/gallery/Voxels.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,14 @@
123123
this.componentTypes = [Cesium.MetadataComponentType.FLOAT32];
124124
this.globalTransform = globalTransform;
125125

126-
this._levelCount = 2;
127-
this._allVoxelData = new Array(this._levelCount);
126+
this.availableLevels = 2;
127+
this._allVoxelData = new Array(this.availableLevels);
128128

129129
const allVoxelData = this._allVoxelData;
130130
const channelCount = Cesium.MetadataType.getComponentCount(this.types[0]);
131131
const { dimensions } = this;
132132

133-
for (let level = 0; level < this._levelCount; level++) {
133+
for (let level = 0; level < this.availableLevels; level++) {
134134
const dimAtLevel = Math.pow(2, level);
135135
const voxelCountX = dimensions.x * dimAtLevel;
136136
const voxelCountY = dimensions.y * dimAtLevel;
@@ -158,9 +158,9 @@
158158
ProceduralMultiTileVoxelProvider.prototype.requestData = function (options) {
159159
const { tileLevel, tileX, tileY, tileZ } = options;
160160

161-
if (tileLevel >= this._levelCount) {
161+
if (tileLevel >= this.availableLevels) {
162162
return Promise.reject(
163-
`No tiles available beyond level ${this._levelCount - 1}`,
163+
`No tiles available beyond level ${this.availableLevels - 1}`,
164164
);
165165
}
166166

CHANGES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
### @cesium/engine
88

9+
#### Breaking Changes :mega:
10+
11+
- Voxel rendering now requires a WebGL2 context, which is [enabled by default since 1.101](https://github.com/CesiumGS/cesium/pull/10894). For voxel rendering, make sure the `requestWebGl1` flag in `contextOptions` is NOT set to true.
12+
913
#### Fixes :wrench:
1014

1115
- Materials loaded from type now respect submaterials present in the referenced material type. [#10566](https://github.com/CesiumGS/cesium/issues/10566)
@@ -17,6 +21,7 @@
1721
- Prevent runtime errors for certain forms of invalid PNTS files [#12872](https://github.com/CesiumGS/cesium/issues/12872)
1822
- Improved performance of clamped labels. [#12905](https://github.com/CesiumGS/cesium/pull/12905)
1923
- Fixes issue where multiple instances of a Gaussian splat tileset would transform tile positions incorrectly and render out of position. [#12795](https://github.com/CesiumGS/cesium/issues/12795)
24+
- Converted voxel raymarching to eye coordinates to fix precision issues in large datasets. [#12061](https://github.com/CesiumGS/cesium/issues/12061)
2025

2126
#### Additions :tada:
2227

packages/engine/Source/Scene/ClippingPlaneCollection.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ function ClippingPlaneCollection(options) {
106106
* An event triggered when a new clipping plane is added to the collection. Event handlers
107107
* are passed the new plane and the index at which it was added.
108108
* @type {Event}
109-
* @default Event()
109+
* @readonly
110110
*/
111111
this.planeAdded = new Event();
112112

113113
/**
114114
* An event triggered when a new clipping plane is removed from the collection. Event handlers
115115
* are passed the new plane and the index from which it was removed.
116116
* @type {Event}
117-
* @default Event()
117+
* @readonly
118118
*/
119119
this.planeRemoved = new Event();
120120

@@ -472,7 +472,7 @@ ClippingPlaneCollection.prototype.update = function (frameState) {
472472
// Compute texture requirements for current planes
473473
// In RGBA FLOAT, A plane is 4 floats packed to a RGBA.
474474
// In RGBA UNSIGNED_BYTE, A plane is a float in [0, 1) packed to RGBA and an Oct32 quantized normal,
475-
// so 8 bits or 2 pixels in RGBA.
475+
// so 8 bytes or 2 pixels in RGBA.
476476
const pixelsNeeded = useFloatTexture ? this.length : this.length * 2;
477477

478478
if (defined(clippingPlanesTexture)) {

0 commit comments

Comments
 (0)