- This topic has 12 replies, 2 voices, and was last updated 2 years, 9 months ago by
kdv.
-
AuthorPosts
-
2023-01-17 at 11:05 am #59635
junglistCustomerHello everyone,
I’m having some trouble trying to apply custom texture to cloned object.
Does anyone come up with solution how to do that?Additionally, I have noticed that puzzle:
replace texture in material works globally, it changes texture in all materials with same naming.The idea I had was to assign different material and later on change its texture. But since it changes texture in all materials, I won’t manage to achieve desired result.
Attachments:
2023-01-17 at 11:19 am #59637kdv
ParticipantYou’re right. The problem exists
https://www.soft8soft.com/topic/verge3d-4-2-pre1-available/#post-55894I’m having some trouble trying to apply custom texture to cloned object.
you also need to clone the object’s material with a new name. then you can apply any texture to the cloned material.
Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
2023-01-17 at 11:35 am #59638
junglistCustomerCould you share example how to clone material and not an object?
Attachments:
2023-01-17 at 12:55 pm #59641kdv
Participant
But you’ll have to use a new texture image in
.ktx2format. Non-compressed texture image will be replaced in ALL materials using this image.For example, you have three material using the same texture
white.jpg. If you try to replacewhite.jpgwithblack.jpgin the second material you’ll replace textures in all materials. But if you replacewhite.jpgwithblack.ktx2then it will affect only the second material.Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
2023-01-17 at 1:13 pm #59643
junglistCustomerThank you very much.
Can I use original texture in ktx2 and after cloning use ktx2 as well or there has to be transfer from png to ktx2?
2023-01-17 at 1:17 pm #59644kdv
ParticipantEven if you use texture compression all textures will have names as original images. So in any case it will be
png/jpg => ktx2replace texture in material works globally, it changes texture in all materials with same naming
materials with the same names on different objects are not independent materials. It’s one material applied to several objects.
Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
2023-01-18 at 7:13 am #59658
junglistCustomerHello again,
I have tried your method but for some reason I’m getting an error.
Mainly because object.material – undefiendBut if I use getObjectMaterial puzzle it Finds the material.
Maybe you have clue what is causing this?
2023-01-18 at 7:24 am #59663kdv
Participant‘Bot’ is a Group of meshes (a multi-material mesh). Groups don’t have materials. If the material to clone is on the first place in the list of material then add this string
object = object.resolveMultiMaterial()[0];and replace
const objectbylet object
But if I use getObjectMaterial puzzle it Finds the material.
this puzzle returns the first sub-mesh material’s name.
Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
2023-01-18 at 8:01 am #59665
junglistCustomerFigured out that the reason I don’t get .material.
Because I have 2 materials in object:
Body and Edges.If I use single material per object, it works fine.
Is there any workaround that?
2023-01-18 at 8:03 am #59666
junglistCustomerThank you,
You are the best!!!
2023-01-18 at 8:03 am #59667kdv
Participantdeleted…
Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
2023-01-20 at 12:49 pm #59711
junglistCustomerHello again,
I have noticed that this method only works for glTF.2 materials.
Maybe you know if there is a work around it?I have noticed strange thing about *object.material.map.name*
It shows same name even after texture been changed.
Maybe that’s exactly why you told to use .ktx2?Attachments:
2023-01-20 at 1:10 pm #59713kdv
ParticipantI have noticed that this method only works for glTF.2 materials.
it should works with all materials. but it doesn’t ))) the script only clones a material and gives a new name to it. nothing else. all the rest is done by the standard
replaceTexturefunction.I have noticed strange thing about *object.material.map.name*
It shows same name even after texture been changed.the
replaceTexturefunction doesn’t change the texture’s name. It replaces the texture’s image only. The name always remains the same. And this function won’t allow you to replace a non-compressed texture by a non-compressed texture only in one material. It’s possible but it needs thereplaceTexturefunction to be re-worked significantly…Looks like node materials are more complicated that it was expected
Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
-
AuthorPosts
- You must be logged in to reply to this topic.






