Announcement

Collapse
No announcement yet.

switch texture

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • switch texture

    Hi All!
    I was wondering if it would be possible to implement a switch texture node similar to the switch material node? this would be really useful in complex materials where we have multiple color variations of a product and want to use an input switch to choose the right for the object or scene file.
    The closes thing i could fin was the multi-subtext node with an option for Use ID generator texture. But i couldn't make it work. i used a custom user data field on the object called "matswitch" and connected a user scalar node ( with the same attribute) to the id generator texture input. but it didn't work.
    What's the right setup that would make texture switching work?

  • #2
    Hey akos_kiss , the MultiSubTex is the switch texture, so your approach is the right one. Simply switching textures on objects is most easily achieved by using the "Object ID" mode of the MultiSubTex. But if you need to switch on User Data field, it should also be possible.

    It would be best if you can share your setup so we can troubleshoot it, but I'll give a few possible pitfalls when using this approach:
    1. For the ID generator texture, you need to use User Integer node or shader. Using the User Scalar should also work, but you may have problems with rounding there.
    2. You should double-check that the name of the User Data field and the value in the "User Attribute" parameter (in the User Integer node) match perfectly (case sensitive).
    3. The "Data Type" and "Data Interface" of the User Data field should both be Integer.
    4. Make sure you have the same "ID"s for the textures in the texture list of MultiSubTex.
    5. (if using node materials) Make sure that you have connected the "Switch ID Texture" port (it is usually hidden in MultiSubTex, so you need to show it explicitly) to the User Integer node.

    I hope this helps you find your problem, or please share your setup so we may help further.
    Last edited by deyan.hadzhiev; 20-08-2024, 04:53 AM.
    Deyan Hadzhiev
    Developer
    chaos.com

    Comment


    • #3
      Hi deyan.hadzhiev

      Thanks for the help! I've must have done something wrong during my testing, but i recreated a new test scene with the multisub texture node.

      The ID generator texture is our prefered method of working as it gives better control over the scene and we can directly interface with more of c4d-s feature and connect them to vray materials.
      From your answer i suspect there are other ways to create "ID Generator Textures" for the multisubtex shader. Could you pleas elaborate on these methods? What am i missing? How could i generate ids inside of c4d in a different way?

      We mostly use the object id tag for different setups but this is mostly render element and gui driven decisions
      here are my findings

      4. Make sure you have the same "ID"s for the textures in the texture list of MultiSubTex.
      I think you meant different ID's because if i set the texture ids the same it doesn't work

      I've discovered that unfortunately v-ray's user integer or user scalar nodes don't read the c4d user data tag. This is a bit of a bummer ( or a bug?) because the user data tag is a way better and more versatile way of adding custom attributes to the obejects. Moving the user data tag around in a scene or copying it to other objects is way easier than adding custom tabs to an object.
      I've tested that the vray Cryptomatte (in Node user attribute mode) also ignores the user data tag.
      I've attached a test scene file. PBV_VR_SWITCH_SHADER_01.c4d


      Comment


      • #4
        Hey akos_kiss, thanks for your reply.

        I think you meant different ID's because if i set the texture ids the same it doesn't work
        I actually meant to have the IDs used in the texture list to match the values of the desired objects' user data, but now when I read what I wrote it really can be misunderstood what I mean. So sorry for the confusion.

        I've discovered that unfortunately v-ray's user integer or user scalar nodes don't read the c4d user data tag.
        Yes, unfortunately, V-Ray currently ignores those tags. Adding the user-attribute support was not a small effort, and we somehow missed that these tags may be used for this purpose. So I have already logged an internal improvement request [VC4D-2405] to add support for them. Thanks for bringing this up to us.

        From your answer i suspect there are other ways to create "ID Generator Textures" for the multisubtex shader. Could you pleas elaborate on these methods? What am i missing? How could i generate ids inside of c4d in a different way?
        Well, this is quite a huge topic. Technically speaking, you can input anything that has a single value output (both floating or integer) and you can have intermediate "Float Arithmetic" node to modify the values (e.g. scale up or down, or add offset).
        So the possible ID sources are basically countless, here are just a few examples of a more niche possible usages:
        1. You can use some of the outputs from the Sampler Info or Particle Info nodes. One such example is what I wrote in this forum post (even though the effect can be achieved without the ID generator).
        2. Using the User Scalar and User Integer nodes, allows you to easily sample object properties, for example:
        2.1. User Data members, as your original question and example scene.
        2.2. Some of the MoGraph data, like the Cloner (instance) Index.
        2.3. A value from a scalar vertex map (you just need to input the name of the vertex map tag as the "User Attribute" name in the User Scalar node). Just note here, that usually the vertex map has values in the range [0..1], so you would probably need an additional Float Arithmetic node to scale those values.
        3. You can use any other node that produces a scalar (float or color, after float conversion), like Distance, Dirt, Noise or many others.

        I hope this answers your question, but don't hesitate to ask if you had something more specific in mind.

        Edit:
        I forgot to mention something regarding the User Data convenience:
        Moving the user data tag around in a scene or copying it to other objects is way easier than adding custom tabs to an object.
        Although I agree that using the tag would be most convenient, you can currently use a Null parent object with the same purpose (and copy / move it around easily), because thelogic for reading the User Data, also reads values from parent objects in the hierarchy. It really is a bit cumbersome to move a Null around, but it might be better than copying the User Data field to all objects you need to have it.
        Last edited by deyan.hadzhiev; 22-08-2024, 05:41 AM.
        Deyan Hadzhiev
        Developer
        chaos.com

        Comment

        Working...
        X