Announcement

Collapse
No announcement yet.

Vray User Scalar tutorial

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

  • Vray User Scalar tutorial

    Hey everyone,

    Often people wonder how to add specific textures to specific objects without use of separate materials. Or how to get specific textures all in one render pass, i.e. extra texture pass that contains multiple various textures. Here is a basic tutorial on how to set this up. I my self just recently came across the need of this, and coming from max where they have multi sub object/multi sub texture which pretty much does this kind of thing, in maya we have nothing like that.

    Now there is an attribute in vray which allows user to specify where to apply which texture.

    Lets say we create a simple scene, 3 spheres and one plane. Each sphere should get its own texture color, but we will only use one vray material and assign it to everything.

    For each object that you wish to have custom texture assigned you must add a specific vray attribute called vray user scalar to the shape node. Here is mel command below:

    addAttr -ln "vrayUserScalar_typeSwitch" -at double |pSphere3|pSphereShape3;

    Note that "vrayUserScalar" must be named exactly like that, after one underscore, the custom name can be used, I used "typeSwitch", you can use whatever, but you must not use any underscores in your name otherwise it will not work.



    At each custom texture you must enter a vray user scalar value, for my case its:

    - 1 ramp (sphere1)
    - 2 checker (sphere2)
    - 3 noise (sphere3)
    - 4 red ramp (plane)

    The most complicated part is to set up the shader. Now we connect the texture to a condition node. We create a vrayUserScalar texture. Set the name of the attribute to your custom name (in my case typeSwitch). Set the default value to 0.0 (returns black in areas where there is no texture)

    Connect the vray user scalar texture to the condition's first term. Set the second term to be the same number as you specified in your object's shape node. For sphere 1, ramp, user scalar is 1, so in the condition node we will set operation as "equal", and connect the ramp to color if true. Set the color if false to 0,0,0, otherwise it will render grey in areas where this map is not true.



    Repeat the operation for as many textures/objects you wish to have.

    Now I create layered texture and add all the condition nodes into it. I am ready to connect it to the diffuse channel of my shader as well as my vray extra texture.



    Thats it.

    A small wish. Vlado it would be awesome to have this kind of setup as a single vray attribute which user can assign to any maya texture, much like the gamma/filter option right now. Just a user scalar value, to remove the need for condition node.

    And a scene file.

    vr_usr_scalar.zip
    Dmitry Vinnik
    Silhouette Images Inc.
    ShowReel:
    https://www.youtube.com/watch?v=qxSJlvSwAhA
    https://www.linkedin.com/in/dmitry-v...-identity-name

  • #2
    Yes, we are looking into the possibility to connect textures to extra V-Ray color attributes.

    For your example above, wouldn't it be simpler to use a Switch node?

    Best regards,
    Vlado
    I only act like I know everything, Rogers.

    Comment


    • #3
      Originally posted by vlado View Post
      Yes, we are looking into the possibility to connect textures to extra V-Ray color attributes.

      For your example above, wouldn't it be simpler to use a Switch node?

      Best regards,
      Vlado
      I use the same technique.
      The switch node is bad because with have a connection between shaders and shapes. If you export shaders, your connection with the swtich node will be broken.
      www.deex.info

      Comment


      • #4
        Originally posted by bigbossfr View Post
        I use the same technique.
        The switch node is bad because with have a connection between shaders and shapes. If you export shaders, your connection with the swtich node will be broken.
        Correct. The way we work with shaders is we export separate shader libraries and re-assign them in shots to sustain updating. If you do that, then the shapes must be reconnected, something not easily done with a switch.
        Dmitry Vinnik
        Silhouette Images Inc.
        ShowReel:
        https://www.youtube.com/watch?v=qxSJlvSwAhA
        https://www.linkedin.com/in/dmitry-v...-identity-name

        Comment


        • #5
          Hey guys,

          thanks for the inspiration but am I the only one struggling to get this to work?

          Even the maya file download scene doesn't work for me, in that it won't display the result shown in the image examples in the tutorial.

          It seems to be the connection to the custom attribute that's not working because if I manually set an integer of 1 - 4 in the default value of the VrayUserScalar, I get the relevan texture displaying, albeit on all of the objects.

          Maybe it's a naming issue... in the mesh shape attribute, of each object, the custom attribute is labelled "Vray User Scalar Type Switch", complete with gaps as shown, whereas in the actual VRayUserScalar node, the attribute is labelled"typeSwitch".

          I tried putting the gaps in and capitalizing in various ways but had no luck. I hope I'm missing something simple because I think this is a very useful technique.

          Cheers

          Nigel

          Comment


          • #6
            its a maya nice name displaying. The actual attribute when you add it has to be called vrayUserScalar_typeSwitch, this has to be matched case by case. Also make sure you got new vray, it may not be supported in older builds.
            Dmitry Vinnik
            Silhouette Images Inc.
            ShowReel:
            https://www.youtube.com/watch?v=qxSJlvSwAhA
            https://www.linkedin.com/in/dmitry-v...-identity-name

            Comment


            • #7
              Hey Morbid Angel,

              We're on Vray 2.20 official. I guess, by newer builds, you refer to the nightly builds. As new users, we haven't ventured to trying those just yet but will take a look once next week's deadline is over.

              New features are great but stability is crucial right now.

              Thanks heaps anyway

              Nigel

              Comment


              • #8
                well you'd be surprised, but their nightly builds are very stable. They have a stable branch, those can be easily used in production, we use them no prob, and get new features that way. I understand the deadline, but do explore that afterward.
                Dmitry Vinnik
                Silhouette Images Inc.
                ShowReel:
                https://www.youtube.com/watch?v=qxSJlvSwAhA
                https://www.linkedin.com/in/dmitry-v...-identity-name

                Comment


                • #9
                  Hi everyone,
                  I just need to do exactly the same thing on a current production, but with faces, not object.

                  Is there a way to randomize each face of an object with one shader ? (in reflections for example)

                  Comment


                  • #10
                    I think it would be possible with a script but not with the method described in this tutorial. This user value is strictly shape based. For the faces You would probably have to create a few different shaders and randomly assign them with the script.
                    Dmitry Vinnik
                    Silhouette Images Inc.
                    ShowReel:
                    https://www.youtube.com/watch?v=qxSJlvSwAhA
                    https://www.linkedin.com/in/dmitry-v...-identity-name

                    Comment

                    Working...
                    X