-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Improve voxel memory usage via Texture3D
#13084
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
Open
jjhembd
wants to merge
16
commits into
main
Choose a base branch
from
voxel-texture3d
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+675
−597
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b470f85
Update ContextLimits for webgl2, fix Texture3D size limit
9ecb55a
WIP: Add 3d texture size calculations in Megatexture
0b63a41
Add spec, clean up unused WebGL1 voxel code
034dee1
Add Texture3D.prototype.copyFrom
c576dce
Use 3D textures for voxel rendering
99a6be5
Fix ContextLimits.maximum3DTextureSize
5717661
Fix voxel rendering with nearest sampling
918b52c
Use VoxelProvider.availableLevels to estimate number of tiles
51aa022
Clean up Voxels sandcastle
3523120
Fix MegatextureSpec
d9d394e
Clean up dimension handling in VoxelTraversal
b626d96
Fix failing specs
a326430
Merge branch 'main' into voxel-texture3d
b61e6c6
Add MAX_3D_TEXTURE_SIZE to WebGL stub for specs
becb359
Stub more 3D3D texture methods for specs
c576e21
Update CHANGES.md
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,14 +153,11 @@ function getBuiltinsAndAutomaticUniforms(shaderSource) { | |
| } | ||
|
|
||
| function combineShader(shaderSource, isFragmentShader, context) { | ||
| let i; | ||
| let length; | ||
|
|
||
| // Combine shader sources, generally for pseudo-polymorphism, e.g., czm_getMaterial. | ||
| let combinedSources = ""; | ||
| const sources = shaderSource.sources; | ||
| if (defined(sources)) { | ||
| for (i = 0, length = sources.length; i < length; ++i) { | ||
| for (let i = 0; i < sources.length; ++i) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the cleanup here! Fond memories of being bitten by function-scoped 'var i' loop iterators in the bad old days. :) |
||
| // #line needs to be on its own line. | ||
| combinedSources += `\n#line 0\n${sources[i]}`; | ||
| } | ||
|
|
@@ -225,30 +222,34 @@ function combineShader(shaderSource, isFragmentShader, context) { | |
| let result = ""; | ||
|
|
||
| const extensionsLength = extensions.length; | ||
| for (i = 0; i < extensionsLength; i++) { | ||
| for (let i = 0; i < extensionsLength; i++) { | ||
| result += extensions[i]; | ||
| } | ||
|
|
||
| if (isFragmentShader) { | ||
| // If high precision isn't support replace occurrences of highp with mediump | ||
| // The highp keyword is not always available on older mobile devices | ||
| // If high precision isn't supported, replace occurrences of highp with mediump. | ||
| // The highp keyword is not always available on older mobile devices. | ||
| // See https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL_best_practices#In_WebGL_1_highp_float_support_is_optional_in_fragment_shaders | ||
| result += | ||
| "\ | ||
| #ifdef GL_FRAGMENT_PRECISION_HIGH\n\ | ||
| precision highp float;\n\ | ||
| precision highp int;\n\ | ||
| #else\n\ | ||
| precision mediump float;\n\ | ||
| precision mediump int;\n\ | ||
| #define highp mediump\n\ | ||
| #endif\n\n"; | ||
| result += ` | ||
| #ifdef GL_FRAGMENT_PRECISION_HIGH | ||
| precision highp float; | ||
| precision highp int; | ||
| #else | ||
| precision mediump float; | ||
| precision mediump int; | ||
| #define highp mediump | ||
| #endif | ||
| `; | ||
| } | ||
|
|
||
| if (context.webgl2) { | ||
| result += `precision highp sampler3D;\n\n`; | ||
| } | ||
|
|
||
| // Prepend #defines for uber-shaders | ||
| const defines = shaderSource.defines; | ||
| if (defined(defines)) { | ||
| for (i = 0, length = defines.length; i < length; ++i) { | ||
| for (let i = 0, length = defines.length; i < length; ++i) { | ||
| const define = defines[i]; | ||
| if (define.length !== 0) { | ||
| result += `#define ${define}\n`; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these comments have been updated to the WebGL2 minimums, since we now default to a WebGL2 context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When defaulting to a WebGL2 context, is there still a fallback path for devices that only support WebGL 1? I understand voxel rendering will require WebGL 2, but other CesiumJS APIs can run with just WebGL 1?
If not, just wondering if the comments should reflect the minimums for browsers and hardware that CesiumJS supports, rather than the minimums for the preferred/default WebGL 2.
(or if deprecating WebGL 1 support more broadly is on the roadmap, maybe that changes things!)