Announcement

Collapse
No announcement yet.

Mimicking Max's Material by Element Random Distribution in Maya.

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

  • Mimicking Max's Material by Element Random Distribution in Maya.

    Hello,

    I am trying to set up a shader that works the same was as material by element in Max. I see that Vray for Maya now has a multiSubTex. Could you recommend how I could use the 'get ID from' drop down to help randomize the input over a single object either on a per face or per shell basis?

    I have read the Vray Maya manual explaining the different options in the drop-down list but can't work out which one I should use. I'm guessing the best option would be for me to run a script to assign random ID's to the object faces and then for Vray to use that?


    Any help would be greatly appreciated.

    Nick.

  • #2
    MultiSubTex will work on separate objects using the same material and distributing different textures to them. A usual set-up would be to have all your objects use the same material which in turn has a multiSubTex. Then you can assign objectIDs to your objects and tell the MultiSubTex to distribute textures based on that. Alternatively, you can just use one of the other modes to get a random distribution - they don't require any additional attributes to be added to the objects - try random by ID or random by node name.
    As for per-element shaders - there's no such thing in Maya, except for assigning a new material to an object's face or set of faces.
    There is however one way to do this with VRay - using the vray additional attributes that can be added to a samplerInfo node. Then you can use the samplerInfo to drive a SwitchMtl and distribute different shaders either on different objects or on different elements of an objects (called shells in maya).
    I'm attaching a couple of simple examples. I've added a few different render layers to the SwitchMtl example showing how the different outputs are set up. Hope that helps.
    MultiSubTex_and_SwitchMtl.zip
    Alex Yolov
    Product Manager
    V-Ray for Maya, Chaos Player
    www.chaos.com

    Comment


    • #3
      Many thanks!! I will try them out and see what works best for me.

      Comment


      • #4
        Actually, if you add extra V-Ray attributes to a samplerInfo node, there is a "random by element" output that you can use in other textures to randomize them or to switch between different materials.

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

        Comment


        • #5
          Originally posted by yolov View Post
          MultiSubTex will work on separate objects using the same material and distributing different textures to them. A usual set-up would be to have all your objects use the same material which in turn has a multiSubTex. Then you can assign objectIDs to your objects and tell the MultiSubTex to distribute textures based on that. Alternatively, you can just use one of the other modes to get a random distribution - they don't require any additional attributes to be added to the objects - try random by ID or random by node name.
          As for per-element shaders - there's no such thing in Maya, except for assigning a new material to an object's face or set of faces.
          There is however one way to do this with VRay - using the vray additional attributes that can be added to a samplerInfo node. Then you can use the samplerInfo to drive a SwitchMtl and distribute different shaders either on different objects or on different elements of an objects (called shells in maya).
          I'm attaching a couple of simple examples. I've added a few different render layers to the SwitchMtl example showing how the different outputs are set up. Hope that helps.
          [ATTACH]31792[/ATTACH]
          Thanks for the scene!
          I just rendered your SwitchMtl.ma, but looks like that the third shader didn't work, it rendered only Red and Green shaders,
          am I missing something ?
          and....do yo know how random by ID could work on switchMtl ?


          Originally posted by vlado View Post
          Actually, if you add extra V-Ray attributes to a samplerInfo node, there is a "random by element" output that you can use in other textures to randomize them or to switch between different materials.

          Best regards,
          Vlado
          I couldn't to find the "random by element" is it the same as "random by polygon shell" ?

          Thanks guys!
          Last edited by henrique.dan; 22-08-2016, 12:23 PM.

          Comment


          • #6
            Yes, that's the one.

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

            Comment


            • #7
              I might have accidentally set up something incorrectly in the scene. Let me know if you still need help with this or the scene and I'll look into it.
              Alex Yolov
              Product Manager
              V-Ray for Maya, Chaos Player
              www.chaos.com

              Comment


              • #8
                Originally posted by yolov View Post
                I might have accidentally set up something incorrectly in the scene. Let me know if you still need help with this or the scene and I'll look into it.
                Yes please, I want to understand this node, could you send me some other examples ?
                Thanks!

                Comment


                • #9
                  Originally posted by vlado View Post
                  Yes, that's the one.

                  Best regards,
                  Vlado
                  Would it make sense to sneak this in as base functionality to the multi subtex map and have it automagically create this node in the background?

                  Comment


                  • #10
                    It's possible, yes...

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

                    Comment


                    • #11
                      Originally posted by henrique.dan View Post
                      Yes please, I want to understand this node, could you send me some other examples ?
                      Thanks!
                      Just tried the scene again (SwitchMtl.ma) - seems to work just fine. Have you tried the different render layers?
                      What Maya and VRay version are you trying to render this with?
                      Alex Yolov
                      Product Manager
                      V-Ray for Maya, Chaos Player
                      www.chaos.com

                      Comment


                      • #12
                        Let me know what other examples you need and I'll prepare some simple scenes.
                        Alex Yolov
                        Product Manager
                        V-Ray for Maya, Chaos Player
                        www.chaos.com

                        Comment


                        • #13
                          Originally posted by yolov View Post
                          Just tried the scene again (SwitchMtl.ma) - seems to work just fine. Have you tried the different render layers?
                          What Maya and VRay version are you trying to render this with?
                          working at Maya 2016 extension 1 / v-ray 3.4.

                          I'll attach the rendered images.

                          I wanted to make the switch by polyshell works like one shader for each objects.
                          Attached Files

                          Comment


                          • #14
                            I understand, but unfortunately that's not how it works. I'll put on a request, of course. Here's the details:
                            What I think you want to do is to get consecutive IDs, so that each shell ID is bigger than the previous and falls into the next material on the switch (for example) to replicate the way it renders on this example with objectID. However neither randomByPolyshell nor randomByID do that. They return a random float value between 0 and 1. The swicthMtl needs values up until 0.499 to fall into the first material (material 0), then 0.5-1.499 for the second (mtl 1) and so on. The switchMtl internally seams to add 0.5 to that value (example - the sphere gets 0.45, the cube is 0.8 and the cylinder is .3 but for the switchMtl they are respectively 0.95 (mtl 0), 1.3 (mtl1) and 0.8 (again mtl 0)). It just so happens that two of the objects get a random number that is within the swicthMtl's range for the first material on the list.
                            Now, it is possible to actually see the random number generated right in the VFB. Just connect the samplerInfo.randomByPolyShell to each component of a VRayMtl.illumColor (i.e. self illumination) and make the diffuse black. Render to the VFB and right-click each object to see the random float values that have been generated for them. From then on, you can try and add some math nodes to alter the resulting numbers, but it will quickly become very complex to handle.
                            If you want even distribution of random numbers, you can go with the objectID output from the sampler info, where you can script some objectID assignment to make things faster.

                            I'll make sure to notify you once we've implemented some more predictable random number generation method from the samplerInfo that will be useful for cases like yours.
                            Last edited by yolov; 24-08-2016, 09:22 AM.
                            Alex Yolov
                            Product Manager
                            V-Ray for Maya, Chaos Player
                            www.chaos.com

                            Comment


                            • #15
                              Originally posted by yolov View Post
                              I understand, but unfortunately that's not how it works. I'll put on a request, of course. Here's the details:
                              What I think you want to do is to get consecutive IDs, so that each shell ID is bigger than the previous and falls into the next material on the switch (for example) to replicate the way it renders on this example with objectID. However neither randomByPolyshell nor randomByID do that. They return a random float value between 0 and 1. The swicthMtl needs values up until 0.499 to fall into the first material (material 0), then 0.5-1.499 for the second (mtl 1) and so on. The switchMtl internally seams to add 0.5 to that value (example - the sphere gets 0.45, the cube is 0.8 and the cylinder is .3 but for the switchMtl they are respectively 0.95 (mtl 0), 1.3 (mtl1) and 0.8 (again mtl 0)). It just so happens that two of the objects get a random number that is within the swicthMtl's range for the first material on the list.
                              Now, it is possible to actually see the random number generated right in the VFB. Just connect the samplerInfo.randomByPolyShell to each component of a VRayMtl.illumColor (i.e. self illumination) and make the diffuse black. Render to the VFB and right-click each object to see the random float values that have been generated for them. From then on, you can try and add some math nodes to alter the resulting numbers, but it will quickly become very complex to handle.
                              If you want even distribution of random numbers, you can go with the objectID output from the sampler info, where you can script some objectID assignment to make things faster.

                              I'll make sure to notify you once we've implemented some more predictable random number generation method from the samplerInfo that will be useful for cases like yours.
                              oh! sorry about my misunderstood...
                              Thank you yolov!

                              Comment

                              Working...
                              X