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

The override material of scene that support both Mesh and InstanceMesh meanwhile #20878

Closed
dayinji opened this issue Dec 11, 2020 · 1 comment

Comments

@dayinji
Copy link

dayinji commented Dec 11, 2020

Is your feature request related to a problem? Please describe.

Yes, as document describes, material cannot be shared by Mesh and InstanceMesh. So when I set override material of scene, it would no work on one of Mesh and InstanceMesh.
I guess this is because the material will be compiled before rendering. Once a Mesh object is rendered first, the vertexShader of the material will not contain the code blocks required by InstanceMesh.
So, for example, when I render a scene contains Mesh and InstanceMesh, and use a BokehPass which required a override material to render a depth buffer, it will trigger a visual bug.

Describe the solution you'd like

  1. Add an overriedMaterialForInstance property to Scene, and once the overrideMaterial is set, we clone it to overriedMaterialForInstance.
  2. Inside the renderObjects function of WebGLRenderer. we override object's material based on whether it is instanceof Mesh or InstanceMesh.

If you think the solution I proposed is feasible, I am willing to submit a PR.

Describe alternatives you've considered

None.

Additional context

None.

@Mugen87
Copy link
Collaborator

Mugen87 commented Dec 11, 2020

Duplicate of #17701.

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

2 participants