Announcement

Collapse
No announcement yet.

Round Edges Scene Node

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

  • Round Edges Scene Node

    Hi,

    The Round Edges attribute does a really nice job of adding detail to meshes with hard edges that can not be edited. Likeways the Round Edges material does the same great job at shader level.

    Would it be possible to assign a round edges attribute to a selection of objects in the scene that may not share material assignments? I imagine a Round Edges scene node / set would be useful, or the ability to add a round edges attribute to a group node.

    Thanks

  • #2
    You could use the Scene Override Snippet to create to add rounded edges to your VRayScene geometry.
    It's going to be a bit tricky, since you should recreate the materials to be wrapped inside a MtlRoundedEdges and apply them to the geometry either in the Snippet directly, or use a new Maya material to apply it.
    In either case, it's not going to be a straightforward process, but in case you're interested, I can describe the steps in detail.
    Alex Yolov
    Product Manager
    V-Ray for Maya, Chaos Player
    www.chaos.com

    Comment


    • #3
      Originally posted by yolov View Post
      In either case, it's not going to be a straightforward process, but in case you're interested, I can describe the steps in detail.
      This would be really helpful if you don't mind. Thank you.

      Comment


      • #4
        Here's a previous thread discussing more options
        __
        https://surfaceimperfections.com/

        Comment


        • #5
          No problem, just a heads-up that it's a hacky workaround for the moment.
          First off, you'll need to know how V-Ray understands certain things, because some things are represented in one way in Maya, but in another way in V-Ray.
          V-Ray represents geometry, material, transformations and the binding of geometry and materials in its own way:
          - there geomMesh (among other types) plugins that hold the faces and vertices
          - there are node plugins that hold the transformations of geomMeshes, but also bind the geomMesh to a material
          - there are material plugins that define certain properties like 2-sided, double-sided, etc, incl. rounded edges
          - there are BRDF plugins that define the brdf

          In this sense, a cube with a lambert material and rounded edges in Maya will be represented like this in V-Ray:
          Code:
          Node pCubeShape1 {
            transform=<transform>; // we won't be dealing with this
            material=lambert;
            geometry=<geometry>; // we won't be dealing with this
          }
          
          MtlSingleBRDF lambert {
            brdf=diffuse_brdf;
          }
          
          BRDFDiffuse diffuse_brdf {
            color=Color(0.5, 0.5, 0.5);
          }
          When there's rounded edges applied, the only difference is that there is a MtlRoundedEdges exported, that uses the MtlSingleBRDF as base_mtl. Then the Node's material equals this MtlRoundedEdges.

          We can do a snippet override on our imported vrscene node where we override our node's material, but then we'll need to create this material. We can use the above as an override, and we'll simply need to add the MtlRoundedEdges in between the Node and the MtlSingleBRDF.
          Here's an example of what the snippet would look like, I've only included the lines that we'll need:
          Code:
          BRDFVRayMtl VRayMtl1@vraymtl {
          diffuse=AColor(0.5, 0.5, 0.5, 1);
          }
          
          MtlSingleBRDF VRayMtl1@material {
          brdf=VRayMtl1@vraymtl;
          }
          
          MtlRoundEdges roundedEdges {
          base_mtl=VRayMtl1@material;
          radius=0.5;
          raytraced_consider_same_object_only=1;
          raytraced_mode=0;
          }
          
          Node pCubeShape1@node {
          material=roundedEdges;
          }
          Then there's yet another way, that might be even simpler, but still hacky. I just gave the above as an example that might help understand the following:
          We can add roundedEdges to our scene and use it to replace the vrscene's objects' materials at render time with a few simple steps + two lines of scripting.
          Now, adding the attributes to another mesh will require this other mesh living somewhere in the scene. But once we know that the rounded edges attribute is actually a material, we can create a MtlRoundedEdges from Create > V-Ray > Create from V-Ray plugin > Material.
          Then we can create a new material in Maya, for example a new VRayMtl and plug it into the RoundedEdges Material that we just created.
          Then we can use the V-Ray Post-translate Python API to export this new material to V-Ray, then use only that as a snippet override.
          This way you can still tweak the settings from what's in the scene, without adding or changing more code.

          1. create a MtlRoundedEdges from Create > V-Ray > Create from V-Ray plugin > Material. Give it any name, in my example I've called it roundedEdges_2
          2. add a VRayMtl to its base.
          3. add this into Render Settings > common tab > mel/python callbacks > post-translate python
          Code:
          from vray.utils import *
          
          exportMaterial('roundedEdges_2')
          4. add this as a snippet override:
          Code:
          Node pCubeShape1@node {
            material=roundedEdges_2;
          }
          I'm adding example files. vrscene_node_rounded_edges.zip
          Alex Yolov
          Product Manager
          V-Ray for Maya, Chaos Player
          www.chaos.com

          Comment


          • #6
            Originally posted by yolov View Post
            Then there's yet another way, that might be even simpler, but still hacky. I just gave the above as an example that might help understand the following:
            We can add roundedEdges to our scene and use it to replace the vrscene's objects' materials at render time with a few simple steps + two lines of scripting.
            Now, adding the attributes to another mesh will require this other mesh living somewhere in the scene. But once we know that the rounded edges attribute is actually a material, we can create a MtlRoundedEdges from Create > V-Ray > Create from V-Ray plugin > Material.
            Then we can create a new material in Maya, for example a new VRayMtl and plug it into the RoundedEdges Material that we just created.
            Then we can use the V-Ray Post-translate Python API to export this new material to V-Ray, then use only that as a snippet override.
            This way you can still tweak the settings from what's in the scene, without adding or changing more code.

            1. create a MtlRoundedEdges from Create > V-Ray > Create from V-Ray plugin > Material. Give it any name, in my example I've called it roundedEdges_2
            2. add a VRayMtl to its base.
            3. add this into Render Settings > common tab > mel/python callbacks > post-translate python
            Code:
            from vray.utils import *
            
            exportMaterial('roundedEdges_2')
            4. add this as a snippet override:
            Code:
            Node pCubeShape1@node {
            material=roundedEdges_2;
            }
            I'm adding example files. [ATTACH]n1020427[/ATTACH]

            Ah thanks so much. This would work really well.

            The only thing I would like to know / change about this is if it would be possible to assign the new roundedEdges_2 material to only the objects in the vrscene file that have the 'VRayMtl1' assigned. Is this possible in the snippet?

            Thanks
            Last edited by brobins; 13-12-2018, 09:05 AM.

            Comment


            • #7
              My tests show that you just insert the rounded edges and keep the old materials from the vrscene file, unfortunately.
              This is because the vrscene overrides, to my knowledge, work for overriding 'node' parameters, but with materials it's a 'replace'.
              We'll do some work in the future to improve the workflow, but this limitation might stick.

              As a workaround: you can do Create > V-Ray > Import material from file > load your vrscene - this will list all materials from the vrscene file > you can locate your material and do 'import' , which will recreate the material in maya. Then use this imported material as the base of the new rounded edges material and apply it with the post-translate method.
              An alternative that might be worth trying is to use a vrmat material and load the vrscene into it. Then use the vrmat as the base of the new rounded edges material and again apply it with post-translate.
              Alex Yolov
              Product Manager
              V-Ray for Maya, Chaos Player
              www.chaos.com

              Comment


              • #8
                I cant seem to get the post-translate python / snippet override working as you described it. Is something here not set correctly?

                Thanks

                Attached Files

                Comment


                • #9
                  That setup should mean that a VRayLightMtl1 from the Maya scene will be assigned to every object of the vrscene file. Is that correct?
                  Alex Yolov
                  Product Manager
                  V-Ray for Maya, Chaos Player
                  www.chaos.com

                  Comment


                  • #10
                    See if there's any errors/warnings in the script editor when you render.
                    Alex Yolov
                    Product Manager
                    V-Ray for Maya, Chaos Player
                    www.chaos.com

                    Comment


                    • #11
                      Hi, yes that is correct.

                      I have since found that this only works when the shader is a VRayPluginNodeMtl. Using a regular VRayMtl (or VRayLightMtl) doesnt seem to work for me.

                      A workaround I have found is to use a pluginNodeMtl 'Wrapper' and use any material as the base, this also seems to work fine.

                      Comment


                      • #12
                        It should work nonetheless. Can you get me a scene and point me to what the goal is and I'll try to figure out a setup. I just hope it's not too urgent, because I won't be able to look into it until Monday.

                        P.S. we really need to improve the workflow.
                        Alex Yolov
                        Product Manager
                        V-Ray for Maya, Chaos Player
                        www.chaos.com

                        Comment


                        • #13
                          Originally posted by yolov View Post
                          It should work nonetheless. Can you get me a scene and point me to what the goal is and I'll try to figure out a setup. I just hope it's not too urgent, because I won't be able to look into it until Monday.

                          P.S. we really need to improve the workflow.
                          Sure, I will upload a scene tomorrow.

                          The ultimate goal above is to utilize vrscene files as the format in which our shaded assets are published, and to have the ability to use the material select render element as it in integral to our compositing pipeline. I understand that the material select RE will not work with materials that are stored inside the vrscene files and your suggested workaround above would be a good solution to this. The only missing piece of the puzzle would be a good way of targeting the specific objects inside the vrscene file in which to apply the override material to. There are a large volume of meshes and materials in the vrscene asset and we would only want to apply the override material to a selection of those. I thought the simplest way would be to do it by which material is assigned to the meshes in the vrscene file but this does not seem to be the case.

                          Comment


                          • #14
                            Here is a a couple of test scenes that hopefully illustrate the workflow. I have managed to achieve a similar result to what I wanted by prefixing the node names with 'paint_' and using a wildcard selection in the snippet to override the material of only those nodes. This does mean a slight change to our current asset preparation workflow stage but it does seem to work.

                            'carpaint_vrscene_build_01.ma' is the original file that is setup in maya how we expect to work with 2 material select elements isolating the shaders we require for compositing.

                            'carpaint_vrscene_build_01.vrscene' is a vrscene file of the above maya scene.

                            'carpaint_vrscene_build_02.ma' is the final resulting maya scene with the vrscene file loaded, the shaders loaded via 'load from vrscene file' connected to the same material select elements and then overriden onto all nodes in the vrscene file with the <* paint *> wildcard. Also using the post translate python script.

                            One thing to note is that I can only get the override to work if I use a VrayPluginNodeMtl, in this instance I have used a pluginNodeWrapper and connected my shader to the base.

                            Thanks
                            Attached Files

                            Comment


                            • #15
                              OK, I think I just realized that I may have missed one crucial bit of information: you need a MtlSingleBRDF in between the Node {material=<material>;} and the BRDF.
                              The way V-Ray thinks of materials is slightly different than the way we think of them. For example, a blend material in Maya is a BRDF for V-Ray. V-Ray needs a 'material' that is assigned to the Node, and the material has a brdf plugin that points to the BRDF (for example a blendMtl is a BRDFLayered in V-Ray).

                              So what you need to do is simply add a MtlSingleBRDF. You can either do that in the post-translate python or otherwise you need to create it from plugin. The reason why it's working with a wrapperMtl from plugin in your case, is simply because this plugin is a 'material' plugin from V-Ray's perspective.

                              I'm attaching two examples.

                              In the first one, I have created a MtlSingleBRDF in my post-translate script with a create() function from the vray.utils api. Then I've set it's brdf parameter to whatever material we're exporting with the exportMaterial() function. I've actually discarded your wrapperMtl completely and I'm directly calling exportMaterial() to the blendMtl. Then I'm wrapping this blendMtl into a newly created MtlSingleBRDF and lastly, in the vrscene snippet override - I'm overriding the Node {material} to the MtlSingleBRDF.
                              You can read more about this here: https://docs.chaosgroup.com/display/...ed+V-Ray+Scene

                              In the second example, I've just created a MtlSingleBRDF from plugin and I'm only doing an exportMaterial() call to that shading node. Instead of MtlSingleBRDF you can use any other 'material' type plugin (2Sided material, wrapper material, rounded edges material are all 'materials' for V-Ray).

                              Sorry for all the hastle, it's a hacky workaround, unfortunately.

                              Also one additional note - for the mtlSelects to work - I've reassigned the new vrayMtl materials that I've created. I've not used pluginNodes in either of the examples above.

                              carpaint_vrscene_workflow_02.zip
                              Alex Yolov
                              Product Manager
                              V-Ray for Maya, Chaos Player
                              www.chaos.com

                              Comment

                              Working...
                              X