-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
MobileStandardMaterial #557
Conversation
src/components/gltf-model-plus.js
Outdated
@@ -76,7 +77,7 @@ function cloneGltf(gltf) { | |||
|
|||
cloneSkinnedMesh.bind(new THREE.Skeleton(orderedCloneBones, skeleton.boneInverses), cloneSkinnedMesh.matrixWorld); | |||
|
|||
cloneSkinnedMesh.material = skinnedMesh.material.clone(); | |||
// cloneSkinnedMesh.material = skinnedMesh.material.clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed to comment this line out to get the ShaderMaterial to work. This means that models from the same url will share a material and changing the uniforms of one material will affect the other. Because we are no longer using the audio feedback for making the avatar's head brighter, I think this is safe? Maybe we are modifying materials somewhere else?
@@ -256,8 +257,12 @@ async function loadGLTF(src, contentType, preferredTechnique, onProgress) { | |||
|
|||
gltf.scene.traverse(object => { | |||
if (object.material && object.material.type === "MeshStandardMaterial") { | |||
object.material.envMap = envMap; | |||
object.material.needsUpdate = true; | |||
if (preferredTechnique === "KHR_materials_unlit") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see this wasn't so hacky! :)
(thanks for the PR when you are technically on vacation!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will have to be careful to watch StandardShader for changes upstream to make sure we include them here, but otherwise LGTM
|
Replaces any StandardMaterials with the MobileStandardMaterial when on low quality mode (mobile and standalone). This improves performance of glTF models loaded via the media tools that do not use
MOZ_alt_materials
andKHR_materials_unlit
.The MobileStandardMaterial currently uses an unlit shading model. It uses the
color
,map
,aoMap
,aoMapIntensity
,emissive
,emissiveMap
, andopacity
fields from the StandardMaterial. The result is visually similar to the output ofgltf-unlit-generator
.We could also use this material instead of using
gltf-unlit-generator
andMOZ_alt_materials
in our art pipeline. It would result in downloading more textures and a slightly more expensive shader, but can be used in all situations without export-time generation of an unlit map.Future versions of MobileStandardMaterial could also use the metallic, roughness, and normal maps in a more efficient manner than the StandardMaterial. Disabling dynamic lighting and using a cheaper approximate BRDF will improve the performance while still looking physically correct.