-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
Introduce MeshGouraudMaterial #24467
Conversation
Current limitations:
AFAIK, there are no other limitations. @Mugen87 I expect the getter/setter for |
Um, adding the getter should actually resolve the issue since the renderer can now access the common |
Oh, see #15187. FWIW, I think that pattern is no longer needed, because the code injection ( |
Good news! However, if you want automatic cube map conversion for |
Right. It's main purpose was to enable automatic uniform updates, because the renderer does not do that for custom materials. // BTW, this was really hard to get working... I'd hate to ask users to have to do this. That is why I created an actual material -- not just a shader. In any event, for whatever reason, automatic equirectangular conversion for (at least) this non-built-in material is not working, and I have no idea why... |
I'll download your branch and debug offline. Maybe I find something. |
The problem is that the shader of three.js/src/renderers/webgl/WebGLMaterials.js Lines 172 to 184 in 9e5512f
As you can see the code correctly configures the uniforms with the environment map from So adding the |
Thanks for your sleuthing, @Mugen87. :-)
So it's a sequencing thing... |
In order to get things going without breaking the equirect support, I suggest to evaluated if ( material.isMeshGouraudMaterial ) {
m_uniforms.envMap.value = envMap;
m_uniforms.flipEnvMap.value = ( envMap.isCubeTexture && envMap.isRenderTargetTexture === false ) ? - 1 : 1;
} We can refactor this later. |
@Mugen87 Ugh... You have to also test for I agree, it would be nice if the app does not have to set |
Sorry, the code block is executed too late. Can you please move it below this if block: three.js/src/renderers/WebGLRenderer.js Lines 1730 to 1735 in d80e640
|
PR looks good to me now! What do you think about using the new material in at least one example? Maybe |
OK, in a separate PR... Let me recover from this one first. :-) |
Thanks! |
This PR requires a new build. |
Done! |
* Introduce MeshGouraudMaterial * Remove unnecessary shader chunk * Support MeshGouraudMaterial envMap * Inline lights_lambert_vertex and remove it from core
* Introduce MeshGouraudMaterial * Remove unnecessary shader chunk * Support MeshGouraudMaterial envMap * Inline lights_lambert_vertex and remove it from core
Related issue: #24452.
This PR adds
MeshGouraudMaterial.js
to the the newly-created/examples/jsm/materials/
directory.MeshGouraudMaterial
implements a Lambert illumination model with Gouraud (per-vertex) shading.MeshGouraudMaterial
has the same feature set, and uses the same shaders, as the legacy version ofMeshLambertMaterial
.