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

glTF: Handle alpha mask and blend #945

Merged
merged 1 commit into from Mar 3, 2019

Conversation

Projects
None yet
4 participants
@georgios-uber
Copy link
Contributor

georgios-uber commented Mar 3, 2019

No description provided.

@georgios-uber georgios-uber self-assigned this Mar 3, 2019

@georgios-uber georgios-uber requested review from Pessimistress and ibgreen Mar 3, 2019

@georgios-uber

This comment has been minimized.

Copy link
Contributor Author

georgios-uber commented Mar 3, 2019

aaaa

@georgios-uber georgios-uber force-pushed the gltf-fix-alpha branch from 30467ed to 52b711b Mar 3, 2019

@georgios-uber georgios-uber merged commit cafd0df into master Mar 3, 2019

3 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
license/cla Contributor License Agreement is signed.
Details

@georgios-uber georgios-uber deleted the gltf-fix-alpha branch Mar 3, 2019

@@ -252,6 +254,18 @@ class GLTFMaterialParser {
this.parseTexture(material.emissiveTexture, 'u_EmissiveSampler', 'HAS_EMISSIVEMAP');
this.uniforms.u_EmissiveFactor = material.emissiveFactor || [0, 0, 0];
}
if (material.alphaMode === 'MASK') {

This comment has been minimized.

Copy link
@ibgreen

ibgreen Mar 3, 2019

Contributor
  • use switch statement (case 'MASK': case 'BLEND)
  • Break out a helper function to handle the blend setup?
  • Changing to MASK does not reset parameters?
webgl2: true
webgl2: true,
// alpha causes issues with some glTF demos
alpha: false

This comment has been minimized.

Copy link
@ibgreen

ibgreen Mar 3, 2019

Contributor

We might want to add some information about this in the glTF or PBRMaterial docs?

@@ -41,6 +41,10 @@ uniform sampler2D u_OcclusionSampler;
uniform float u_OcclusionStrength;
#endif
#ifdef ALPHA_CUTOFF

This comment has been minimized.

Copy link
@ibgreen

ibgreen Mar 3, 2019

Contributor

Nit: This feature just adds a single if statement, looks rather cheap, is it really justified to require a shader recompile to change it?

@tsherif

This comment has been minimized.

Copy link
Member

tsherif commented Mar 4, 2019

If we're doing alpha masking you might want to consider supporting alpha to coverage: https://en.wikipedia.org/wiki/Alpha_to_coverage
More detailed explanation: https://medium.com/@bgolus/anti-aliased-alpha-test-the-esoteric-alpha-to-coverage-8b177335ae4f

Enabling in WebGL is just gl.enable(gl.ALPHA_TO_COVERAGE)

@georgios-uber

This comment has been minimized.

Copy link
Contributor Author

georgios-uber commented Mar 4, 2019

Thanks @tsherif I'll look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.