We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Custom texture on cloned object

Home Forums Puzzles Custom texture on cloned object

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #59635
    junglist
    Customer

    Hello 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:
    You must be logged in to view attached files.
    #59637
    kdv
    Participant

    You’re right. The problem exists
    https://www.soft8soft.com/topic/verge3d-4-2-pre1-available/#post-55894

    I’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. 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 meaning at all.

    #59638
    junglist
    Customer

    Could you share example how to clone material and not an object?

    Attachments:
    You must be logged in to view attached files.
    #59641
    kdv
    Participant

    https://v3d.net/dqv

    But you’ll have to use a new texture image in .ktx2 format. 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 replace white.jpg with black.jpg in the second material you’ll replace textures in all materials. But if you replace white.jpg with black.ktx2 then it will affect only the second material.

    Puzzles and JS. 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 meaning at all.

    #59643
    junglist
    Customer

    Thank 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?

    #59644
    kdv
    Participant

    Even if you use texture compression all textures will have names as original images. So in any case it will be png/jpg => ktx2

    replace 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. 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 meaning at all.

    #59658
    junglist
    Customer

    Hello again,
    I have tried your method but for some reason I’m getting an error.
    Mainly because object.material – undefiend

    But if I use getObjectMaterial puzzle it Finds the material.

    Maybe you have clue what is causing this?

    Attachments:
    You must be logged in to view attached files.
    #59663
    kdv
    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 object by let object

    But if I use getObjectMaterial puzzle it Finds the material.

    this puzzle returns the first sub-mesh material’s name.

    Puzzles and JS. 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 meaning at all.

    #59665
    junglist
    Customer

    Figured 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?

    #59666
    junglist
    Customer

    Thank you,

    You are the best!!! :good:

    #59667
    kdv
    Participant

    deleted…

    Puzzles and JS. 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 meaning at all.

    #59711
    junglist
    Customer

    Hello 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:
    You must be logged in to view attached files.
    #59713
    kdv
    Participant

    I 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 replaceTexture function.

    I have noticed strange thing about *object.material.map.name*
    It shows same name even after texture been changed.

    the replaceTexture function 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 the replaceTexture function to be re-worked significantly…

    Looks like node materials are more complicated that it was expected :scratch:

    Puzzles and JS. 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 meaning at all.

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.