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

Override Material: Morph Targets #18062

Closed
4 of 15 tasks
vanruesc opened this issue Dec 4, 2019 · 4 comments · Fixed by #18072
Closed
4 of 15 tasks

Override Material: Morph Targets #18062

vanruesc opened this issue Dec 4, 2019 · 4 comments · Fixed by #18072

Comments

@vanruesc
Copy link
Contributor

vanruesc commented Dec 4, 2019

Description of the problem

I'm using MeshNormalMaterial and MeshDepthMaterial as override materials and I sometimes set morphTargets to true. Now in three@0.111.0, this setting prevents objects without morph targets from being rendered altogether.

I'm not sure if this behaviour is intentional but since this change hasn't been documented I thought I should let you know.

Sandbox

Uncomment line 23 in index.js:
https://codesandbox.io/s/override-material-morph-targets-06hjw

Three.js version
  • Dev
  • r111
  • r110
  • r109
  • ...
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS
@Mugen87
Copy link
Collaborator

Mugen87 commented Dec 4, 2019

I can confirm this worked with R110. The regression was probably introduced via #17649.

@Mugen87
Copy link
Collaborator

Mugen87 commented Dec 4, 2019

Simplified example:

R110: https://jsfiddle.net/aoLbzj1s/
R111: https://jsfiddle.net/aoLbzj1s/1/

The problem is that setting morphTargets to true does not render the mesh when the geometry contains no morph targets. With R110 the mesh is still rendered.

@zeux It seems the uniform morphTargetBaseInfluence still needs an update even if no morph targets are defined. Adding this code in WebGLRenderer.renderBufferDirect() seems to fix the fiddle:

if ( material.morphTargets === true && object.morphTargetInfluences === undefined ) {

    program.getUniforms().setValue( _gl, 'morphTargetBaseInfluence', 1 );

}

Can you think of a better way fixing this? Maybe we can refactor WebGLMorphtargets.update() so it is called when morphTargets is set to true (and not when morphTargetInfluences is defined).

@zeux
Copy link
Contributor

zeux commented Dec 4, 2019

Yeah we definitely need to always set the base influence if the material being used has the morph target shader variant. I will take a look...

@vanruesc
Copy link
Contributor Author

vanruesc commented Dec 4, 2019

FYI: the same problem occurs when morphNormals is set to true in MeshNormalMaterial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants