-
Notifications
You must be signed in to change notification settings - Fork 604
How to dynamically change normal, metallic and roughness with Textures? #412
Comments
Currently the only way to load a custom material is to compile it into a .sfb with a mesh (say a single triangle :) and to call getMaterial() after loading it. This should let you change the textures dynamically. |
Thank you @romainguy , we found that @michaelvogt is doing this in #390 and started to implement our material definition for Are you planning to expose custom material creation feature, sometime in the future? Also, is there any chance to have |
We are tracking the feature request to open up material creation at #393 |
@malik-at-work thanks, subscribed. Also, as @romainguy mentiond using the fake object, we've manage to get our custom material:
One more question, can we change the default value for created parameters? |
We've prepared a sample project that demonstrates how to change textures dynamically. Hope it will help others to answer questions that we got. |
Thank For great demo. But I want to change the color of the added object at runtime by selection of colors from a list of colors in alert dialog or elsewhere. So, is it possible to change only the color of the object at runtime? If possible then can we change the color of some perticular part of the object? Please help me. Thank you in advance. |
Hey @HEMAL-VES , yes it is possible to change only color texture, you can use only baseColorTexture from sample project. Or you can play with MaterialFactory. To change the color of a particular object part, you got few options:
|
You can also create a custom material that lets you change a color multiplier (this feature should be supported by gltf). |
Hello, I don't understand methods like what getUV0 does, do you needsome pre requisite knowledge to understand these? |
Hi @yakivmospan I checked your example which you have posted to change texture dynamically. But in that example, you have used texture image which you are using to change the texture of the object. That's a great one. But I did not want to this in my project. I just want to change the color of an object by selecting a color from color picker dialog. Which change color dynamically of the object. Is there any way to change the color of the object dynamically at runtime without using the texture image file Or Custom Material Reference? |
@HEMAL-VES Hey, as I wrote in previous post, take a look at Or as @romainguy mentioned, you can play with color multiplier. Cheers |
Hi Yakiv: In order to use metallic and roughness for FBX, with a focus on economy of resources (textures), I wonder if it's possible to have a unique map for both (as we have in glTF). The idea here would be to use the three channel in a more standard PBR way:
In the sfa file, for certain material we'll have:
The material fragment (extract) would be like this:
Does this will work? |
Hi guys Is it possible to change textures for 3d-model with animation ( Is there any working solution? Tnx, Andrey |
Hi @yakivmospan , |
I've a similar use case. Your help will be appreciated @yakivmospan . |
Hey guys,
In our case, we have pure
model.obj
mesh, without texture references in it. AndbaseColorMap.png
,normalMap.png
,metallicMap.png
,roughnessMap.png
files that we want to use asTexture
's for our mesh. The set of textures can vary for one mesh, so, for example, we can have one mesh and 8 png files (two flavors of one model).To load my
obj
file dynamically, I can first convert it tosfb
, no probs with that. But what can I do, to apply my textures to it dynamically? That is completely possible to do withSceneKit
&ArKit
on iOS (including mesh generation fromobj
file) and what we've already done there.We saw #41 , #197 and #112 issues. According to those, with texture, we can change only the base color of our mesh, using
MaterialFactory.makeOpaqueWithTexture(context, baseColorMapTexture)
. Thats becauseMaterialFactory
uses default.sfm
material definition?Can we somehow create
Material
for a custom compiled*.mat
definition, so we will be able to apply another textures toMaterial
withsetTexture("normalMapTexure")
method and then set it toRenderable
? At least that is possible to do with filament, in this sample you are loading material definition from file. Can we createMaterial
with filament and pass it to Sceneform ?Would be great to have something like this in API :
We also tried to convert our
obj
tofbx
, where default fbx*.sfm
material definition has already implementednormalMap
,metallicMap
androughnessMap
parameters. Unfortunatelly as per #41 , we were not able to change any of them usingrenderable.getMaterial().setTexture("normalMap", texture);
. Maybe thats because there are no mentions about textures in.fbx
model?Thanks in advice,
Yakiv.
The text was updated successfully, but these errors were encountered: