Sceneform-android-sdk: How can I change metallic or roughness factor in runtime?

Created on 18 Jun 2018  路  3Comments  路  Source: google-ar/sceneform-android-sdk

Hi, i'm already read issue #41, but it hasn't enough information.

How can I change metallic or roughness factor in runtime?

For example, in sample project hellosceneform, I want to change Andy's metallic factor "0" to "1" in runtime.

question

Most helpful comment

Get the material from a node and set properties defined in the MaterialFactory.
see:
https://developers.google.com/ar/reference/java/com/google/ar/sceneform/rendering/Material
https://developers.google.com/ar/reference/java/com/google/ar/sceneform/rendering/MaterialFactory
Material material = node.getRenderable().getMaterial(); material.setFloat(MaterialFactory.MATERIAL_METALLIC, /* 0 or 1 for metallic */ ); material.setFloat(MaterialFactory.MATERIAL_ROUGHNESS, /* 0 to 1 */);

All 3 comments

Get the material from a node and set properties defined in the MaterialFactory.
see:
https://developers.google.com/ar/reference/java/com/google/ar/sceneform/rendering/Material
https://developers.google.com/ar/reference/java/com/google/ar/sceneform/rendering/MaterialFactory
Material material = node.getRenderable().getMaterial(); material.setFloat(MaterialFactory.MATERIAL_METALLIC, /* 0 or 1 for metallic */ ); material.setFloat(MaterialFactory.MATERIAL_ROUGHNESS, /* 0 to 1 */);

You save my day! thanks a lot.

@malik-at-work I have imported my models but textures are not applied properly. I think the issue is with these metallic and roughness factors. Why we can't get these values from model?

Was this page helpful?
0 / 5 - 0 ratings