Announcement

Collapse
No announcement yet.

AppSDK: Export Material

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

  • AppSDK: Export Material

    Is it possible in the App SDK to export a material from a Houdini path similar to vray.utils.exportMaterial("") in VRay for Maya's Post Translate?
    Jacob Børsting
    Head of Pipeline @ Ghost VFX

  • #2
    AppSDK could export anything.
    https://docs.chaosgroup.com/vray_app...on27/vray.html
    There is an export() method which accepts "pluginExportList" argument to export only particular plugins.
    V-Ray For Houdini | V-Ray Hydra Delegate | VRayScene
    andrei.izrantcev@chaos.com
    Support Request

    Comment


    • #3
      But how would I export a material that isn't assigned to anything in Houdini for later doing the assignments in the App SDK?

      In Maya I would:
      import vray.utils as vr
      mat = vr.exportMaterial('myMaterial') ## export material from Maya to VRay, that isnt assigned to anything in the scene
      node.set('material', mat) ## assign that material to a Node in the VRay scene
      Jacob Børsting
      Head of Pipeline @ Ghost VFX

      Comment


      • #4
        Ah, so you don't need to export it to the vrscene file?

        > But how would I export a material that isn't assigned to anything in Houdini

        There is Object -> Force Materials list.
        Then you can get plugin by name, it's usually just the node path with / converted to | (like /mat/vrayMtl1 -> |mat|vrayMtl1).

        We could add such API at some point...
        V-Ray For Houdini | V-Ray Hydra Delegate | VRayScene
        andrei.izrantcev@chaos.com
        Support Request

        Comment


        • #5
          But unfortunately this:
          Code:
          node.set('material', mat) ## assign that material to a Node in the VRay scene
          wont work in Houdini...
          We heavily use Instancer2 plugin and material is set via Instancer2 "instances" list item...
          V-Ray For Houdini | V-Ray Hydra Delegate | VRayScene
          andrei.izrantcev@chaos.com
          Support Request

          Comment


          • #6
            I've added exportMaterial() API to the next nightly build...
            The only difference will be material assignment (regarding the info the in previous post):
            Code:
            import vray
            
            r = vray.VRayRenderer()
            
            matPluginName = self.exportMaterial("/mat/vrayMaterialBuilder")
            
            objNode = r.plugins["|obj|box1|node"]
            objNode.geometry.instances_material_override = r.plugins[matPluginName]
            "self" syntax may be a bit misleading, but in this context it'll mean current ROP so that:
            Code:
            self.exportMaterial("/path/to/mat")
            will be internally replaced with:
            Code:
            _vfh_ipr.exportMaterial(rop="/path/to/this/rop", mat="/path/to/mat")
            Last edited by bdancer; 17-08-2020, 07:27 AM.
            V-Ray For Houdini | V-Ray Hydra Delegate | VRayScene
            andrei.izrantcev@chaos.com
            Support Request

            Comment


            • #7
              Great. Thanks.

              That's exactly what I was looking for.
              Jacob Børsting
              Head of Pipeline @ Ghost VFX

              Comment


              • #8
                A quick followup question.

                How do you duplicate a Plugin node in the App SDK? Similar to node.duplicate(name) in Post Translate (Maya)
                Jacob Børsting
                Head of Pipeline @ Ghost VFX

                Comment


                • #9
                  @bdancer: Did you get chance to look at this?
                  Is it possible to duplicate a Plugin, creating a new instance with the same properties?
                  Jacob Børsting
                  Head of Pipeline @ Ghost VFX

                  Comment


                  • #10
                    > How do you duplicate a Plugin node in the App SDK?

                    If there is no such method here https://docs.chaosgroup.com/vray_app...n27/index.html then probably no....
                    V-Ray For Houdini | V-Ray Hydra Delegate | VRayScene
                    andrei.izrantcev@chaos.com
                    Support Request

                    Comment


                    • #11
                      Hi jbvfx,

                      We have plans to add utility functions to copy/clone/duplicate plugin instances from one renderer instance to another but that would work in the same renderer too. But we haven't done it so far. So currently the solution would be to write a helper method yourself. it's pretty straightforward if you don't use animated/interpolated params but it's not very hard even if you do. Here is a sample function which duplicates a plugin in the simples case when there are no animated params:

                      Code:
                      def duplicatePlugin(plugin, newPluginName):
                        newPlugin = plugin.getClass()(newPluginName)
                        for propName in newPlugin:
                          if plugin.getMeta(propName)['runtimeType'] != 'Unspecified': # skip unset properties
                            propValue = plugin[propName]
                            if propValue != plugin.getReference(propName): # alternative plugin outputs are read as referencing themselves; skip them
                              newPlugin[propName] = propValue
                      return newPlugin
                      You can add exception handling if needed.

                      Best regards,
                      Stan and the AppSDK team

                      Comment


                      • #12
                        Great, thanks Stan.
                        Jacob Børsting
                        Head of Pipeline @ Ghost VFX

                        Comment

                        Working...
                        X