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

Remove extensions in shaders when upgrading to WebGL 2.0 #8969

Merged
merged 11 commits into from
Jun 19, 2020

Conversation

baothientran
Copy link
Contributor

Replace extension preprocessor that isn't required in WebGL 2.0 in shaders code with WEBGL_2 preprocessor. All the shaders will automatically have #define WEBGL_2 after #version 300 es to indicate the context version being used by Cesium

This should fix the issue where log depth doesn't work properly when zooming out from the earth in WebGL 2.0:

Screen Shot 2020-06-16 at 9 57 57 AM

The issue comes from czm_writeLogDepth function. It checks if GL_EXT_frag_depth extension is available, but the extension is only available in WebGL 1.0. So the code doesn't run.

@lilleyse Can you please take a look at the changes?

@baothientran baothientran requested a review from lilleyse June 17, 2020 03:40
@cesium-concierge
Copy link

Thanks for the pull request @baothientran!

  • ✔️ Signed CLA found.

Reviewers, don't forget to make sure that:

  • Cesium Viewer works.
  • Works in 2D/CV.
  • Works (or fails gracefully) in IE11.

@lilleyse
Copy link
Contributor

@baothientran thanks for the fix! I should be able to review tonight.

Copy link
Contributor

@lilleyse lilleyse left a comment

Choose a reason for hiding this comment

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

Great catch @baothientran. I can confirm this fixes the issue.

CHANGES.md Outdated Show resolved Hide resolved
Source/Renderer/modernizeShader.js Outdated Show resolved Hide resolved
var versionThree = "#version 300 es";
var foundVersion = false;
for (i = 0; i < splitSource.length; i++) {
if (/#version/.test(splitSource[i])) {
splitSource[i] = versionThree;
splitSource[i] = versionThree + "\n" + webgl2DefineMacro;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since #version is required to be on top, should I break the loop early?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that should be fine

@baothientran
Copy link
Contributor Author

baothientran commented Jun 18, 2020

@dennisadams 's comment is the solution for the last puzzle I have for depth texture. The new commit should fix the below issues:
Fixes #7952
Fixes the zooming issue
Fixes the issue where geometries disappear when moving mouse

@lilleyse Can you please take a look at it again? The new commit should convert the sampler's minification and magnification filter to have NEAREST for WebGL 2.0

Copy link
Contributor

@lilleyse lilleyse left a comment

Choose a reason for hiding this comment

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

Looks good, just a couple comments

Source/Renderer/Texture.js Outdated Show resolved Hide resolved
Comment on lines 536 to 538
minificationFilter = mipmap
? TextureMinificationFilter.NEAREST_MIPMAP_NEAREST
: TextureMinificationFilter.NEAREST;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can depth textures be mipmapped?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The spec doesn’t seem to mention if depth texture can be mipmapped. I will try it out to see if there are any error

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 hardcode the MinificationFiltering to be NEAREST_MIPMAP_NEAREST if pixelFormat is depth format. Chrome gives me error on it. So I think it can't have mipmap

@lilleyse
Copy link
Contributor

That latest changes look good to me 👍

@lilleyse lilleyse merged commit 5d4b8d0 into master Jun 19, 2020
@lilleyse lilleyse deleted the webgl2-remove-extension branch June 19, 2020 21:49
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.

3 participants