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

WebGL 2 and WebGL Extensions Roadmap #797

Closed
7 of 22 tasks
pjcozzi opened this issue May 26, 2013 · 48 comments
Closed
7 of 22 tasks

WebGL 2 and WebGL Extensions Roadmap #797

pjcozzi opened this issue May 26, 2013 · 48 comments

Comments

@pjcozzi
Copy link
Contributor

pjcozzi commented May 26, 2013

Extensions in Canary

Draft WebGL Extensions

Proposed WebGL Extensions

OpenGL ES 3.0 Features

  • Multisampled Renderbuffers - AA without using FXAA.
  • Half-float vertex attributes, i.e., GL_OES_vertex_half_float.
  • Uniform buffer objects - for backing uniforms with buffers based on update frequency. Also see Optimize setting uniforms #649.
  • Sampler objects - the Cesium abstractions already look like this to some extent.
  • Immutable textures - reduce driver validation (EXT_texture_storage).
  • Instancing, i.e., ANGLE_instanced_arrays, for batching geometry and models.
  • Primitive restart - batch render line strips instead of individual lines.
  • Transform feedback - perhaps for particle systems.
  • [ ] Program binaries - to reduce shader compile times. (Not in WebGL 2.0)

More on ES 3.0

More on WebGL 2.0

WebGL 2 Demos

Done

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Apr 29, 2014

Uniform buffer objects

The renderer could always expose UBOs and emulate them with traditional uniforms or uniform arrays if they are not supported. This will require some GLSL macros or shader patching for the uniform/uniform-buffer declarations.

Automatic uniforms can be grouped into uniform buffers based on update frequency: per frame and per object (model-matrix).

Each command can provide two uniform buffer: one for uniforms that don't change often and one for uniforms that do. This maps to technique (don't change) and material (do change) parameters. Or one uniform buffer might be fine since the command creator won't have to figure out how to organize them.

@pjcozzi pjcozzi mentioned this issue Apr 29, 2014
72 tasks
@pjcozzi pjcozzi mentioned this issue Oct 6, 2014
30 tasks
@pjcozzi pjcozzi self-assigned this Oct 6, 2014
@pjcozzi pjcozzi changed the title WebGL Extensions Roadmap WebGL 2 and WebGL Extensions Roadmap Feb 16, 2015
@lilleyse lilleyse mentioned this issue Sep 8, 2015
24 tasks
@lilleyse lilleyse mentioned this issue Oct 14, 2015
@pjcozzi
Copy link
Contributor Author

pjcozzi commented Oct 14, 2015

Cesium Implementation Status (after #3094)

  • OES_standard_derivatives is disabled. dFdx, dFdy and fwidth are not recognized when compiling the shader.
    • There should be one test failure for materials because the PolylineArrowMaterial uses standard derivatives.
  • EXT_frag_depth is disabled. gl_FragDepth is not recognized when compiling the shader (neither is gl_FragDepthEXT).
  • OES_texture_float is disabled. Could not create a texture with PixelDatatype.FLOAT.
  • WEBGL_depth_texture is disabled. Could not attach a depth-stencil texture to a FBO.

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Nov 10, 2015

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Feb 12, 2016

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Oct 18, 2016

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Dec 13, 2016

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Dec 30, 2016

WebGL 2 articles on the RTR blog:

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Jan 24, 2017

Texture Array: we could use TEXTURE_2D_ARRAY in some cases where texture atlases are used. It will be simpler and great for dynamic updates when the size doesn't change, #2319

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Jan 24, 2017

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Jan 24, 2017

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Jan 25, 2017

@lilleyse
Copy link
Contributor

@mramato 👍

That'll be on me an @YoussefV once we start the WebGL 2 / MSAA work.

@lilleyse
Copy link
Contributor

In WebGL 2 the camera zooms towards the globe instead of towards the geometry that the mouse is hovering over. This seems like a bug in either ScreenSpaceCameraController or scene.pickPosition.

Sandcastle

WebGL 1
zoom-webgl1

WebGL 2
zoom-webgl2

@dennisadams
Copy link
Contributor

@lilleyse
When ScreenSpaceCameraController needs a pickPosition, it calls both scene.pickPositionWorldCoordinates and globe.pickWorldCoordinates and chooses the closer of the two, assuming both are defined.
In our case, scene.pickPositionWorldCoordinates returns undefined and so ScreenSpaceCameraController uses the globe pick instead.
I played around a little and the problem seems to be that the depth texture is empty.
With the help of this error, I tried hard-coding a NEAREST filtering and it worked alright (even the error was gone). So I guess it's some problem with linear minification/magnification filtering.
I tried it with the changes from 8969, so that can also be a factor.

@lilleyse
Copy link
Contributor

@dennisadams awesome, that fixes it for me as well. Just to confirm you added nearest filtering to the depth-stencil texture?

  globeDepth._depthStencilTexture = new Texture({
    context: context,
    width: width,
    height: height,
    pixelFormat: PixelFormat.DEPTH_STENCIL,
    pixelDatatype: PixelDatatype.UNSIGNED_INT_24_8,
    sampler: Sampler.NEAREST // Fixes the zoom
  });

@baothientran
Copy link
Contributor

@dennisadams @lilleyse That also fixes the Silhouette post processing as well. Also I look it up, and in WebGL 2, it seems depth texture cannot have linear filtering. That may be a potential problem with other depth textures used by Cesium as well

@dennisadams
Copy link
Contributor

Just to confirm you added nearest filtering to the depth-stencil texture?

I went on a safe bet - hard-coded the Texture constructor.

@lilleyse
Copy link
Contributor

Labels look a bit different in WebGL 2. Click the images to see the difference.

WebGL 2
wegbl2

WebGL 1
wegbl2-off

Sandcastle

@lilleyse
Copy link
Contributor

The AO post process has artifacts: Local sandcastle.

ao

@lilleyse
Copy link
Contributor

Polyline arrows start to get squashed. Local sandcastle

arrow

@lilleyse
Copy link
Contributor

Cesium Inspector is extremely show when "Show Frustums" is checked. Local sandcastle

cesium-inspector

@lilleyse
Copy link
Contributor

Contour lines are much thinner in WebGL 2. Local sandcastle.

First thing I would look into is GL_OES_standard_derivatives which is another built-in define that's part of WebGL 1 but maybe not WebGL 2 (I haven't checked). GL_EXT_frag_depth is another one we should investigate.

contour1
contour2

@lilleyse
Copy link
Contributor

Alright that's all I've uncovered so far by going through each sandcastle example with WebGL2 enabled. @baothientran I recomend starting with #797 (comment) and seeing what other bugs are fixed in the process.

@lilleyse
Copy link
Contributor

@baothientran since the number of bugs fixes was starting to grow too much I consolidated them into a single CHANGES.md entry: 65757f8

@lilleyse
Copy link
Contributor

Also I updated the checklist above: #797 (comment)

@lilleyse
Copy link
Contributor

lilleyse commented Oct 15, 2020

@ebogo1
Copy link
Contributor

ebogo1 commented Aug 26, 2021

Suggestions to improve modernizeShader from @genosage in #9743:

A better way [than using replaceInSourceString/Regex] may be assigning an identifier and use it as the keyword to avoid calling replace functions each draw call.

// ShaderCache.js
  var vertexShaderText = vertexShaderSource.createCombinedVertexShader(
    this._context
  );
  var fragmentShaderText = fragmentShaderSource.createCombinedFragmentShader(
    this._context
  );

  var keyword =
    vertexShaderText + fragmentShaderText + JSON.stringify(attributeLocations);

@ptrgags
Copy link
Contributor

ptrgags commented Jan 19, 2022

When implementing EXT_mesh_features in CesiumJS, one WebGL 1 hurdle that impacts performance is the lack of gl_VertexID.

Implicit feature ID attributes can be computed by offset + floor(gl_VertexID / repeat). However, in WebGL 1, we have no choice but to do this computation on the CPU and then upload an extra attribute

@ptrgags
Copy link
Contributor

ptrgags commented Feb 8, 2022

Another WebGL 1 limitation that limits our implementation of EXT_mesh_features: In this table in the MDN docs, it seems that even a highp int is only required to have 17 bits. So for feature IDs, I'll have to use a highp float to squeeze out a couple more bits. Also there's no uint type. In a shader,uint32 would be more ideal, but only guaranteed in WebGL 2

@ggetz ggetz added the webgl 2 label Sep 20, 2022
@lilleyse
Copy link
Contributor

CloudCollection and voxels would benefit from 3D textures

@lilleyse
Copy link
Contributor

Point cloud properties (e.g. classification) may have precision artifacts in WebGL 1 if accessed in the frag shader. WebGL 2 may fix this with the flat qualifier. See CesiumGS/3d-tiles-samples#55 (comment) for more details.

@ggetz ggetz removed the webgl 2 label Feb 2, 2023
@ggetz
Copy link
Contributor

ggetz commented Feb 7, 2023

Given the work done in #10894, that should cover most of the actionable items in this issue. I'm going to close this and any specific items should be listed in their won issue, such as #649 and #630.

@ggetz ggetz closed this as completed Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants