Alexey Shmakov
Alexey Shmakov

Reputation: 13

Android ArCore Sceneform API. How to change textures in runtime?

The server has more than 3000 models and each of them has several colors of material. I need to load separately models and textures and set textures depending on the user's choice. How to change baseColorMap, normalMap, metallicMap, roughnessMap in runtime?

after modelRenderable.getMaterial().setTexture("normalMap", normalMap.get()); nothing happens I'm doing something wrong. There is no information in documentation for that.

Upvotes: 1

Views: 2184

Answers (2)

Rikesh Shrestha
Rikesh Shrestha

Reputation: 41

use this code`

CompletableFuture<Texture> futureTexture = Texture.builder()
          .setSource(this, R.drawable.shoes)
          .build();

and replace with

/*.thenAccept(renderable -> andyRenderable = renderable)*/
        .thenAcceptBoth(futureTexture, (renderable, texture) -> {
            andyRenderable = renderable;
            andyRenderable.getMaterial().setTexture("baseColor", texture);
        })

would work.

Upvotes: 1

Adrian Perez
Adrian Perez

Reputation: 36

thank you for posting this question.

  • setTexture() appears to not work: Unfortunately this part of our API is still a little rough; it works but is very easy to get wrong. We're working on a sample to illustrate how to modify material parameters (including textures) at runtime and will improve our error reporting in the next release.
  • Thousands of models w/ multiple permutations how?: The plan here has two parts:
    • The binaries used by the Android Studio plugin will be made available for use in build scripts on server platforms. This will allow you to do a server-side conversion of your assets to .sfb. We'll be releasing a blog post soon on how to do this.
    • The .sfa will get the ability to contain loose textures and materials not explicitly associated with geometry, and .sfa's will be able to declare data dependencies on other .sfa's. This will mean that you can author (and deliver) .sfb's that contain textures/materials (but no geometry) and .sfb's that contain geometry (but no textures/materials), and if they're both available at instantiation time it will just work.

Upvotes: 1

Related Questions