Announcement

Collapse
No announcement yet.

Passing Attributes At Rendertime To VRay Shaders

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

  • Passing Attributes At Rendertime To VRay Shaders

    Is there a way to tell a VRay shader to dynamically read an attribute (string, float, triple float, etc.) for use at rendertime? For instance, if I attach a custom string attribute to an object (shape node) which has a path to a texture, and then tell the shader to obtain the texture for the color map from that attribute, or alternately to assign a triple float array as a custom attr to a shape with three values (0-1) and have, say, the diffuse color cue off of those at rendertime? This is a feature I use in RMan via an mattr command as tcl in the shader, and I would like to use the same functionality via VRay in Maya. Thanks!

  • #2
    You can add a V-Ray "User attributes" attribute to any shape or transform; it is a string that allows you to define other color, float or string values, f.e. something like:

    col1=0.6,0.5,0.4;number2=0.8;tex_path=/path/to/textures

    Once you have defined the user attributes, you can use them in the following ways:
    *) You can use them inside your shaders using the VRayUserColor and VRayUserScalar utility shading nodes;
    *) You can specify user attributes in the file name string for File textures by enclosing attribute in < and >

    Recent nightly builds allow you to split the single user attribute into multiple dynamic attributes that can be animated; they also support writing the user attributes into .vrmesh files.

    Let me know if you have other questions.

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

    Comment


    • #3
      Sounds great, I'll give it a try, thanks!

      Comment


      • #4
        Hi Vlado,
        I finally gave this a try, and am having a problem getting it to work. I added the user attribute to my shape node of my geometry, and set it to tex_path=[path to my tif texture]. I then create a VRayMtl, and in diffuse color, added a file node, and per your second option, in the image name attribute, I set it to <tex_path>, but this is not working. Can you please give a specific example of what I should put in that attribute so this will pick up the texture map? Thanks!

        -David

        Comment


        • #5
          Can you post your scene? Works fine for me generally.

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

          Comment


          • #6
            Maya file and texture map

            I have uploaded the Maya 2012 binary file as well as the texture map.
            Attached Files

            Comment


            • #7
              I got it working...it looks like when I have the <tex_path> set to the entire path for the texture file, it doesn't seem to like that, but if I just set it to the prefix of the texture, in this case "book_cover_075" and then I set the file node's image name attribute to: "/net/cgraid1/projects/ShineCreative_STEMUtahBooks/Development/IN_OUT/elements/book_covers/processed/<tex_path>.tif", then it works. Is there some reason the entire path in that attribute it not working? Is it eating the slashes perhaps and they need escaped? It would be good to just be able to provide the full path instead of having to do it this way, as in reality, these textures may live in different locations and be of different types, all of which I want to be able to embed in that variable.

              -David

              Comment


              • #8
                For the moment it works this way - we could make a feature-request to improve that functionality if needed.
                Svetlozar Draganov | Senior Manager 3D Support | contact us
                Chaos & Enscape & Cylindo are now one!

                Comment


                • #9
                  When the entire file name is a single tag, it seems that the current workspace path is automatically prepended to it, because then it is assumed that it is a relative path. It works if you include a '/' at the start or some other part of the path.

                  We can probably fix it so that the workspace path is prepended (if needed) only after all tags have been resolved - let me know how important this is and we can work on it.

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

                  Comment


                  • #10
                    It would be useful to add that as we are using this for rendering large numbers of similar items where the texture lookups are being dynamically generated in-scene looking at different paths based on the entity type, allowing us to use a small number of shaders to accomplish this. Thanks for looking into this.

                    -David

                    Comment

                    Working...
                    X