Announcement

Collapse
No announcement yet.

shave and render passes

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

  • shave and render passes

    What would be the recommended way to work with Shave and a Haircut and Vray's render passes system?
    Is there a way to put the hair into a render element of some sort?

    Here are some specific difficulties I bumped up against:

    occlusion:
    I do know that the passes themselves work with shave. For example you can generate a spec pass that will work on the shave hair along with everything else. Occlusion is a big problem though because it takes (understandably) a really long time to render occlusion on hair. So simply having render passes on a scene with shave hair is problematic since it will take a huge hit on render times. So it there a way to exclude the hair from the occlusion calculation in the extra-tex pass?

    mattes:
    Last time I checked there was not a way to get the hair into multi-matte because there was no way to assign the shave hair and object ID. Has this changed in 2.0? Would there be a way to set it up with a material ID? That would not work with the native Shave shader, but maybe we could assign a vray hair shader to it?

    Any insights appreciated.

  • #2
    Originally posted by sharktacos View Post
    I do know that the passes themselves work with shave. For example you can generate a spec pass that will work on the shave hair along with everything else. Occlusion is a big problem though because it takes (understandably) a really long time to render occlusion on hair. So simply having render passes on a scene with shave hair is problematic since it will take a huge hit on render times. So it there a way to exclude the hair from the occlusion calculation in the extra-tex pass?
    Hm, while you can exclude objects from occlusion in the V-Ray dirt texture, the shave geometry is created at render time, so there is no way to link it to the dirt texture. You might be able to do this from the post-translate Python callback. However I'm somewhat doubtful that it will speed things up - the hair would be still in the scene, and it will still need to be processed for any rays that pass through it. I'm afraid in that case it would be best to compute the occlusion in a separate render without the hair.

    Last time I checked there was not a way to get the hair into multi-matte because there was no way to assign the shave hair and object ID. Has this changed in 2.0? Would there be a way to set it up with a material ID? That would not work with the native Shave shader, but maybe we could assign a vray hair shader to it?
    You could be able to do it from said post-translate Python callback - you will need to set the "objectID" of the shave Node object in the V-Ray scene.

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

    Comment


    • #3
      Originally posted by vlado View Post
      Hm, while you can exclude objects from occlusion in the V-Ray dirt texture, the shave geometry is created at render time, so there is no way to link it to the dirt texture. You might be able to do this from the post-translate Python callback. However I'm somewhat doubtful that it will speed things up - the hair would be still in the scene, and it will still need to be processed for any rays that pass through it. I'm afraid in that case it would be best to compute the occlusion in a separate render without the hair.
      One solution would be to make a render layer for the occlusion (instead of a render pass), and have everything but the hair in that render layer. The only problem with this is that Shave seems to be automatically included into render layers. I know there was a way to exclude it from a render layer with mental ray. Is there a way to do that with v-ray?

      EDIT: The above does seem to work with a layer override applied to the shave globals "hide hair" toggle. So that seems like a viable solution. Oddly, the same does not work with the shave "active" toggle in the shave node attributes. This works in Maya Software and Mental Ray, but with Vray it causes Maya to hang.
      Last edited by sharktacos; 12-10-2011, 10:49 AM.

      Comment


      • #4
        Originally posted by vlado View Post
        You could be able to do it from said post-translate Python callback - you will need to set the "objectID" of the shave Node object in the V-Ray scene.
        I think I understand what you mean, but being a non-programmer, I can't imagine what the python code in the post-translate Python callback would need to be to connect the shave hair node object ID to a multi-matte. Do you know off-hand what the code would be, or can you point me to a recipe?

        Comment


        • #5
          Hi there,

          Sorry for re-opening an old post, and for the following code ... just testing things around

          According to Vlado's advices I tried to set up a basic post-translate process to get shave masks, here is the current function :

          Code:
          import maya.cmds as cmds
          import maya.mel	as mel
          
          def postTranslate():
              with open("/tmp/vrpost.log", "w") as f:
                  base_id = 1
          	nodes = cmds.ls("shaveVrayShader*")
                  nodes.sort()
                  for n in nodes:
                      mel.eval("vrayAddAttr " + n + " vrayColorId")
                      mel.eval("vrayAddAttr " + n + " vrayMaterialId")
                      cmds.setAttr(n + "." + "vrayMaterialId", base_id)
                      col_id = float(base_id) / float(len(nodes))
                      cmds.setAttr(n + "." + "vrayColorId", col_id, col_id, col_id, type="double3")
                      f.write(n + " -> matte " + str(base_id) + ", color " + str(col_id) + "\n")
                      base_id += 1
          
          	base_id = 1
          	nodes = cmds.ls("pSolidShape*")
          	nodes.sort()
          	for n in nodes:
                      mel.eval("vrayAddAttr " + n + " vrayObjectID")
                      cmds.setAttr(n + ".vrayObjectID", base_id)
                      f.write(n + " -> object " + str(base_id) + "\n")
                      base_id += 1
          
          	nodes = cmds.ls("shaveHair*")
          	nodes.sort()
          	for n in nodes:
                      mel.eval("vrayAddAttr " + n + " vrayObjectID")
                      cmds.setAttr(n + ".vrayObjectID", base_id)
                      f.write(n + " -> object " + str(base_id) + "\n")
                      base_id += 1
          With two hairy balls, here's the resulting debug log, so everything seem workin as intended :
          Code:
          shaveVrayShader1 -> matte 1, color 0.5
          shaveVrayShader2 -> matte 2, color 1.0
          pSolidShape1 -> object 1
          pSolidShape2 -> object 2
          shaveHair1 -> object 1
          shaveHair2 -> object 2
          shaveHairShape1 -> object 3
          shaveHairShape1_growth -> object 4
          shaveHairShape2 -> object 5
          shaveHairShape2_growth -> object 6
          We are still stuck, the object, matte and material ids remain desperately black. The only working way (but not production ready) is to assign a standard material to shaveHair* nodes and uncheck "Override Geom Shader" so we can extract some material masks.

          Any tip or trick would be greatly appreciated !

          Tonio

          Comment


          • #6
            From what I see, in the post-translate function you are changing the Maya scene, which is no use; you should be modifying the V-Ray scene instead. I'm attaching an example here: http://www.spot3d.com/vray/scenes/shave_matte.zip

            If you export a .vrscene file for the scene, you will see two plugins in it with type "hairVRayShader" - one has name "pSolidShape2@mesh4" and the other - "pSolidShape1@mesh3"; look for the respective "Node" plugins which reference those hair shaders as geometry. In this particular scene, they are "pSolidShape1@node" and "pSolidShape2@node" (you could walk the V-Ray scene to find the Node plugin that corresponds to a particular hairVRayShader plugin). Then you need to set the "objectID" parameter of the respective Node plugins, and voila - you get your mattes.

            This is my post-translate callback:
            Code:
            from vray.utils import *
            
            p=findByName("pSolidShape2@node")
            p[0].set("objectID", 1)
            
            q=findByName("pSolidShape1@node")
            q[0].set("objectID", 2)
            It might be a bit of a hassle to figure out the correct names though - the nodes just get some default names which are not immediately related to the Shave objects.

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

            Comment


            • #7
              Thanks a lot Vlado !

              Sorry I didn't read the documentation before spreading code ... basically it works, here is my "pseudo" smart version, should be sufficient for our purpose (only four shave nodes, always on screen) :

              Code:
              rom vray.utils import findByName
              import re
              
              def postTranslate():
                  nodes = findByName("pSolidShape*@*")
                  nodes.sort()
                  for n in nodes:
                      if n.has("objectID"):
                          match = re.match("pSolidShape([0-9]+)@.*", n.name())
                          if match:
                              object_id = int(match.groups()[0])
                              n.set("objectID", object_id)
              I'll study your scene since I only get unmultipled objectid output rather than a clean multimatte result like yours (my matte aov remains black), should be trivial from now.

              Thanks again, have a good weekend !

              Tonio
              Attached Files

              Comment


              • #8
                Originally posted by thekraken View Post
                I'll study your scene since I only get unmultipled objectid output rather than a clean multimatte result like yours (my matte aov remains black), should be trivial from now.
                For this you need one (or more) multimatte element with the correct object IDs set for the red/green/blue components, like I have set it up in my scene.

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

                Comment


                • #9
                  Really nice, it's now working like a charm.

                  I tried to find an "artist compliant" workflow, not sure it's the best way to control things but here's our method now : assign a material to a shave display group (fortunately it's the only way to get shave and render layers happy together), set a material id, create a matte RE and set ids accordingly.

                  The post-translate code will then transfer the material id to the associated shaveHairShader objectid, and we've come full cycle :

                  Code:
                  from vray.utils import findByName
                  
                  def postTranslate():
                      nodes = findByName("pSolidShape*@node")
                      for node in nodes:
                          if node.has("material") and node.has("objectID"):
                              mat = node.get("material")
                              if mat.has("material_id_number"):
                                  node.set("objectID", int(mat.get("material_id_number")))
                  Thanks again for your kind help Vlado !

                  Tonio

                  Comment


                  • #10
                    Glad that you got it working

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

                    Comment

                    Working...
                    X