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

Fix issue with transparent diffuse texture setting the technique state #284

Merged
merged 3 commits into from
May 25, 2017

Conversation

lilleyse
Copy link
Contributor

In addDefaults.enabledDiffuseTransparency it checks if any materials have a transparent diffuse texture and if so sets the alpha render state for that technique. The problem occurs when multiple materials share the same technique and one transparent texture causes the whole model to be transparent.

The solution was to check if the technique has other users, and if so copy the technique before messing with the render state.

Sample models that show the problem are here: https://groups.google.com/forum/#!topic/cesium-dev/4cG1nDU_QwU

@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 93.831% when pulling 1a4b221 on diffuse-texture-alpha-fix into 98ab533 on master.

@@ -347,6 +347,42 @@ function addDefaultTechnique(gltf) {
}
}

function isTechniqueShared(gltf, techniqueId) {
var users = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick, but references or numberOfReferences would have better semantics.

if (materials.hasOwnProperty(materialId)) {
var material = materials[materialId];
if (material.technique === techniqueId) {
++users;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not return early, i.e., return true; when this is > 1, then just always return false; below.

@lilleyse
Copy link
Contributor Author

Updated

@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 93.822% when pulling 1a76402 on diffuse-texture-alpha-fix into 9684790 on master.

@pjcozzi pjcozzi merged commit 3449df8 into master May 25, 2017
@pjcozzi pjcozzi deleted the diffuse-texture-alpha-fix branch May 25, 2017 21:26
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