Announcement

Collapse
No announcement yet.

Vrscene global material override snippet

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

  • Vrscene global material override snippet

    Hello,

    I've been looking for a way to override all materials inside a vrscene with a new material but I couldn't find a solution. Specifically, I just need to render the vray scene with a gray shader(maintaining displacement and bump would be a plus). Has anyone got any tips for writing a snippet like that?

    On a side note, I think a global material override function like the one in Vray for Max would be useful in Maya as well. Unfortunately maya render layers/override can be quite slow when dealing with massive environments.

    Thanks!


  • #2
    The following snippet will create a new material within the snippet, which will be applied as a material to all nodes:
    Code:
    Node <*> {
    material=myMaterial;
    }
    
    BRDFDiffuse diffuse {
    color=Color(0.5,0.5,0.5);
    }
    
    MtlSingleBRDF myMaterial {
    brdf=diffuse;
    }
    Usually, you can use another BRDF, however, I presume a default one will suffice.
    Regarding the global override, yes, it would be useful, however, it depends on the host application and the way V-Ray is integrated. So for now layers are the current solution.
    Aleksandar Hadzhiev | chaos.com
    Chaos Support Representative | contact us

    Comment


    • #3
      Works great, thanks Aleksandar!

      Comment


      • #4
        Originally posted by aleksandar.hadzhiev View Post
        The following snippet will create a new material within the snippet, which will be applied as a material to all nodes:
        Code:
        Node <*> {
        material=myMaterial;
        }
        
        BRDFDiffuse diffuse {
        color=Color(0.5,0.5,0.5);
        }
        
        MtlSingleBRDF myMaterial {
        brdf=diffuse;
        }
        Usually, you can use another BRDF, however, I presume a default one will suffice.
        Regarding the global override, yes, it would be useful, however, it depends on the host application and the way V-Ray is integrated. So for now layers are the current solution.
        Hey Aleksandar,

        we are still experimenting with vrscene overrides and we encountered a problem:

        We are trying to override the whole scene with one of the material already present inside the vrscene but the render returns a black image. If we manually replace the 'material' string with a text editor for all the objects there is no problem. I've attached a simple vrscene with two materials and two objects and the code I'm using.

        Code:
        Node <*> {
        
        material=surfaceShader1@matte;
        
        }




        Attached Files

        Comment


        • #5
          Not as simple I'm afraid. however, another way to override the materials via the snippet is by creating the shader in Maya itself, export it via a post-translate python script and use it as an override through the scene overrides. Try the following:

          1. Create the desired override shader in Maya (i.e. VRayMtl1)
          2. In the Post-Translate Python Script (Common>MEL/Python callbacks) type the following code to export the fresh shader in the rendered .vrscene:
          Code:
          from vray.utils import *
          exportMaterial('VRayMtl1')
          3. In the snippet override, use the name of the recently exported shader:
          Code:
          Node <*> {
          material=VRayMtl1@material;
          }
          Aleksandar Hadzhiev | chaos.com
          Chaos Support Representative | contact us

          Comment


          • #6
            Thanks Aleksandar, I'll try this solution tonight

            Cheers

            Comment


            • #7
              Originally posted by aleksandar.hadzhiev View Post
              Not as simple I'm afraid. however, another way to override the materials via the snippet is by creating the shader in Maya itself, export it via a post-translate python script and use it as an override through the scene overrides. Try the following:

              1. Create the desired override shader in Maya (i.e. VRayMtl1)
              2. In the Post-Translate Python Script (Common>MEL/Python callbacks) type the following code to export the fresh shader in the rendered .vrscene:
              Code:
              from vray.utils import *
              exportMaterial('VRayMtl1')
              3. In the snippet override, use the name of the recently exported shader:
              Code:
              Node <*> {
              material=VRayMtl1@material;
              }
              I've tried this but the object does not render. Has anyone else had problem using this and managed to get it to work? I'm using v5.00.20.
              Also is there any more documentation or example snippets of this feature other then the this page?

              Thanks

              Comment


              • #8
                matthew_partridge Just tested this, it seems to work fine. Check your spelling and make sure you create the override material (step 1) for export.
                Aleksandar Hadzhiev | chaos.com
                Chaos Support Representative | contact us

                Comment

                Working...
                X