We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
You can continue the conversation there. Go to discussion →
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
Please let us know how to change texture of 3d model at runtime, in sceneform we use this code to change texture at runtime :
` public void LoadTexture(Context context, Bitmap colorImageBitmap) { Log.d("LoadTexture", "LoadTexture : @@@@@@@1 renderableInstance.size() : " + renderableInstances.size()); for (RenderableInstance renderableInstance : renderableInstances) { Texture.builder() .setSource(colorImageBitmap) .setSampler( Texture.Sampler.builder() .setWrapMode(Texture.Sampler.WrapMode.REPEAT) .build() ) .build() .thenAccept(texture -> { MaterialFactory.makeOpaqueWithTexture(context, texture) .thenAccept(material -> { material.setFloat("roughness", 0.5f); // Set roughness material.setFloat("ao", 1.0f); // Set AO Log.d("LoadTexture", "LoadTexture :@@@@@@2 renderableInstance.getMaterialsCount() : " + renderableInstance.getMaterialsCount());
renderableInstance.setMaterial(0, material); }); }); Log.d("LoadTexture", "LoadTexture @@@@@@@3 : renderableInstance.getEntity() : " + renderableInstance.getEntity()); } }`
The text was updated successfully, but these errors were encountered:
I solved it as follows
private fun createTextureFromBitmap(engine: Engine, bitmap: Bitmap): Texture { val texture = Texture.Builder() .width(bitmap.width) .height(bitmap.height) .levels(1) .sampler(Texture.Sampler.SAMPLER_2D) .format(Texture.InternalFormat.SRGB8_A8) .build(engine) val buffer = ByteBuffer.allocateDirect(bitmap.byteCount) bitmap.copyPixelsToBuffer(buffer) buffer.flip() texture.setImage( engine, 0, Texture.PixelBufferDescriptor( buffer, Texture.Format.RGBA, Texture.Type.UBYTE ) ) buffer.clear() return texture } texture = createTextureFromBitmap(engine, bitmap) (modelNodes[0] as ModelNode).materialInstances[0][0] = setBaseColorMap(texture)
Sorry, something went wrong.
No branches or pull requests
Please let us know how to change texture of 3d model at runtime, in sceneform we use this code to change texture at runtime :
` public void LoadTexture(Context context, Bitmap colorImageBitmap) {
Log.d("LoadTexture", "LoadTexture : @@@@@@@1 renderableInstance.size() : " + renderableInstances.size());
for (RenderableInstance renderableInstance : renderableInstances) {
Texture.builder()
.setSource(colorImageBitmap)
.setSampler(
Texture.Sampler.builder()
.setWrapMode(Texture.Sampler.WrapMode.REPEAT)
.build()
)
.build()
.thenAccept(texture -> {
MaterialFactory.makeOpaqueWithTexture(context, texture)
.thenAccept(material -> {
material.setFloat("roughness", 0.5f); // Set roughness
material.setFloat("ao", 1.0f); // Set AO
Log.d("LoadTexture", "LoadTexture :@@@@@@2 renderableInstance.getMaterialsCount() : " + renderableInstance.getMaterialsCount());
The text was updated successfully, but these errors were encountered: