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

Enables WebGL 2 by default #10894

Merged
merged 42 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
b2229c9
Shader ugprade to GLSL 300
sanjeetsuhag Nov 8, 2022
d1f4570
JS Shader upgrade to GLSL 300
sanjeetsuhag Nov 8, 2022
48452e4
WIP ShaderSource mods
sanjeetsuhag Nov 8, 2022
a9e6aed
WIP demodernizeShader
sanjeetsuhag Nov 14, 2022
f052a02
Merge branch 'watched-files-fix' of https://github.com/CesiumGS/cesiu…
sanjeetsuhag Nov 14, 2022
4bb5854
Gets globe rendering with WebGL1 with demodernizeShader
sanjeetsuhag Nov 14, 2022
b2b5870
Fixes OIT.js shaders
sanjeetsuhag Nov 15, 2022
273b019
More JS fixes for OIT and MRT
sanjeetsuhag Nov 16, 2022
9cd404a
WebGL 1 spec fixes
Nov 16, 2022
e635196
More WebGL 2 shader migration
sanjeetsuhag Nov 16, 2022
1dd66d0
Gets WebGL 1 tests passing
sanjeetsuhag Nov 17, 2022
24ec5a5
WebGL2 Spec migration
sanjeetsuhag Nov 17, 2022
11c0970
Fixes CloudCollection shaders for WebGL2
sanjeetsuhag Nov 17, 2022
b38d3bd
More WebGL 2 spec fixes
sanjeetsuhag Nov 17, 2022
354ef3f
Shader spec compilation fixes
Nov 17, 2022
fd57848
More spec fixes
Nov 17, 2022
d474433
Spec cleanup
Nov 18, 2022
86ac727
Fix pickColorQualifier in ShadowVolumeAppearance.js
sanjeetsuhag Nov 18, 2022
51fcaa4
Fix accidental substitutions in I3SNodeSpec
sanjeetsuhag Nov 18, 2022
ce953c3
Merge branch 'main' of https://github.com/CesiumGS/cesium into webgl2…
sanjeetsuhag Dec 5, 2022
ee4fa0e
Removes WebGL 1 specs
sanjeetsuhag Dec 6, 2022
a5dc2ed
Merge branch 'main' of https://github.com/CesiumGS/cesium into webgl2…
sanjeetsuhag Dec 7, 2022
86bebe1
More Spec changes for WebGL2 specific specs
sanjeetsuhag Dec 7, 2022
566a0ee
More spec fixes
sanjeetsuhag Dec 8, 2022
6679cd7
Fixes ShaderSource functions
sanjeetsuhag Dec 8, 2022
33607ae
Fixes Sandcastles for WebGL2
sanjeetsuhag Dec 8, 2022
6e7cf1a
Fix spec failures for WebGL stub
sanjeetsuhag Dec 8, 2022
4a7a9b6
Feedback pass
sanjeetsuhag Dec 15, 2022
318283c
Merge branch 'main' of https://github.com/CesiumGS/cesium into webgl2…
sanjeetsuhag Jan 3, 2023
38de151
Upgrade voxel code to GLSL 300
sanjeetsuhag Jan 4, 2023
c5c4123
Merge branch 'main' of https://github.com/CesiumGS/cesium into webgl2…
sanjeetsuhag Jan 4, 2023
9001fdf
Removes modernizeShader
sanjeetsuhag Jan 5, 2023
1cec0d0
Spec fixes
sanjeetsuhag Jan 5, 2023
b8bddb3
Fix WebGL1 fallbacks for gl_FragDepth
Jan 10, 2023
ea0dda6
Add comments and clean up in OIT.js
Jan 11, 2023
48872d2
Fix out_FragData references in DebugInspector
Jan 12, 2023
04a6be0
Assume standard derivatives are supported
Jan 12, 2023
7a1b729
Restore fallbacks for no standard derivatives
Jan 13, 2023
ef1c287
Fix ElevationBandMaterial in WebGL2
Jan 13, 2023
350b017
Update error message in PostProcessStage
Jan 13, 2023
246631c
Fix pixelFormat in Megatexture.js
Jan 13, 2023
2302c48
Merge branch 'main' into webgl2-default
Jan 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions packages/engine/Source/Core/PixelFormat.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@ const PixelFormat = {
*/
ALPHA: WebGLConstants.ALPHA,

/**
* A pixel format containing a red channel
*
* @type {Number}
* @constant
*/
RED: WebGLConstants.RED,

/**
* A pixel format containing red and green channels.
*
* @type {Number}
* @constant
*/
RG: WebGLConstants.RG,

/**
* A pixel format containing red, green, and blue channels.
*
Expand Down Expand Up @@ -178,8 +194,10 @@ PixelFormat.componentsLength = function (pixelFormat) {
case PixelFormat.RGBA:
return 4;
case PixelFormat.LUMINANCE_ALPHA:
case PixelFormat.RG:
return 2;
case PixelFormat.ALPHA:
case PixelFormat.RED:
case PixelFormat.LUMINANCE:
return 1;
default:
Expand All @@ -195,6 +213,8 @@ PixelFormat.validate = function (pixelFormat) {
pixelFormat === PixelFormat.DEPTH_COMPONENT ||
pixelFormat === PixelFormat.DEPTH_STENCIL ||
pixelFormat === PixelFormat.ALPHA ||
pixelFormat === PixelFormat.RED ||
pixelFormat === PixelFormat.RG ||
pixelFormat === PixelFormat.RGB ||
pixelFormat === PixelFormat.RGBA ||
pixelFormat === PixelFormat.LUMINANCE ||
Expand Down Expand Up @@ -469,7 +489,7 @@ PixelFormat.toInternalFormat = function (pixelFormat, pixelDatatype, context) {
return WebGLConstants.RGB32F;
case PixelFormat.RG:
return WebGLConstants.RG32F;
case PixelFormat.R:
case PixelFormat.RED:
return WebGLConstants.R32F;
}
}
Expand All @@ -482,7 +502,7 @@ PixelFormat.toInternalFormat = function (pixelFormat, pixelDatatype, context) {
return WebGLConstants.RGB16F;
case PixelFormat.RG:
return WebGLConstants.RG16F;
case PixelFormat.R:
case PixelFormat.RED:
return WebGLConstants.R16F;
}
}
Expand Down
25 changes: 10 additions & 15 deletions packages/engine/Source/Scene/createElevationBandMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,46 +462,42 @@ function createLayeredEntries(layers) {
* });
*/
function createElevationBandMaterial(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
const scene = options.scene;
const layers = options.layers;
const { scene, layers } = defaultValue(options, defaultValue.EMPTY_OBJECT);

//>>includeStart('debug', pragmas.debug);
Check.typeOf.object("options.scene", scene);
Check.defined("options.layers", layers);
Check.typeOf.number.greaterThan("options.layers.length", layers.length, 0);
//>>includeEnd('debug');

const { context } = scene;
const entries = createLayeredEntries(layers);
const entriesLength = entries.length;
let i;

let heightTexBuffer;
let heightTexDatatype;
let heightTexFormat;

const isPackedHeight = !createElevationBandMaterial._useFloatTexture(
scene.context
);
const isPackedHeight = !createElevationBandMaterial._useFloatTexture(context);
if (isPackedHeight) {
heightTexDatatype = PixelDatatype.UNSIGNED_BYTE;
heightTexFormat = PixelFormat.RGBA;
heightTexBuffer = new Uint8Array(entriesLength * 4);
for (i = 0; i < entriesLength; i++) {
for (let i = 0; i < entriesLength; i++) {
Cartesian4.packFloat(entries[i].height, scratchPackedFloat);
Cartesian4.pack(scratchPackedFloat, heightTexBuffer, i * 4);
}
} else {
heightTexDatatype = PixelDatatype.FLOAT;
heightTexFormat = PixelFormat.LUMINANCE;
heightTexFormat = context.webgl2 ? PixelFormat.RED : PixelFormat.LUMINANCE;
Copy link
Contributor

Choose a reason for hiding this comment

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

Does Megatexture.js need similar treatment here? It's the only other place I noticed where LUMINANCE and LUMINANCE_ALPHA are being used with FLOAT datatype.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @lilleyse! Yes, it did need a similar fix:

  if (channelCount === 1) {
    pixelFormat = context.webgl2 ? PixelFormat.RED : PixelFormat.LUMINANCE;
  } else if (channelCount === 2) {
    pixelFormat = context.webgl2 ? PixelFormat.RG : PixelFormat.LUMINANCE_ALPHA;

heightTexBuffer = new Float32Array(entriesLength);
for (i = 0; i < entriesLength; i++) {
for (let i = 0; i < entriesLength; i++) {
heightTexBuffer[i] = entries[i].height;
}
}

const heightsTex = Texture.create({
context: scene.context,
context: context,
pixelFormat: heightTexFormat,
pixelDatatype: heightTexDatatype,
source: {
Expand All @@ -518,7 +514,7 @@ function createElevationBandMaterial(options) {
});

const colorsArray = new Uint8Array(entriesLength * 4);
for (i = 0; i < entriesLength; i++) {
for (let i = 0; i < entriesLength; i++) {
const color = entries[i].color;
color.toBytes(scratchColorBytes);
colorsArray[i * 4 + 0] = scratchColorBytes[0];
Expand All @@ -528,7 +524,7 @@ function createElevationBandMaterial(options) {
}

const colorsTex = Texture.create({
context: scene.context,
context: context,
pixelFormat: PixelFormat.RGBA,
pixelDatatype: PixelDatatype.UNSIGNED_BYTE,
source: {
Expand All @@ -544,11 +540,10 @@ function createElevationBandMaterial(options) {
}),
});

const material = Material.fromType("ElevationBand", {
return Material.fromType("ElevationBand", {
heights: heightsTex,
colors: colorsTex,
});
return material;
}

/**
Expand Down