Announcement

Collapse
No announcement yet.

Maya Paint FX constant screen-space line width (issue)

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

  • Maya Paint FX constant screen-space line width (issue)

    Hi guys,

    We are trying to get paint effects toon lines rendered with V-Ray to be a constant width/thickness in screen space from the camera, but have not found a way to do so.
    I resorted to a V-Ray Python Post Translate solution, but somehow it seems to be very unstable where it doesn't update correctly on frame changes... as if it gets processed before the actual changed Paint FX locations/widths are computed for the next frame?

    Here's the code snippet we created:

    Code:
    from vray.utils import *
    
    multiplier = 0.1
    
    # Get render camera position
    render_view = findByType("RenderView")[0]
    transform = render_view.get("transform")
    campos  = transform.offs
    
    # Get all GeoMayaHairs and multiply width by distance
    hairs = findByType("GeomMayaHair")
    for hair in hairs:
    
       widths = hair.get("widths")
       vertices = hair.get("hair_vertices")
    
       for i, (vtx, width) in enumerate(zip(vertices, widths)):
    
           dist = (campos - vtx).length()
           widths[i] = multiplier * width * dist
    
       hair.set("widths", widths)
    It seems to be somewhat more stable in viewport renders - but even then sometimes switching frame and rendering produced all mangled line setups in the render... then re-rendering the same frame, and voila.... fixed. Very odd.

    To be clear... we only found this issue really when the renders came out of Deadline (through mayabatch?) as we hadn't seen it pop up in viewport often (or at least not in a reproducable way). In Deadline only one seemingly random frame seemed to work correctly, which funnily enough was the frame the file was saved on. Any ideas on how to debug?
    Last edited by colorbleed; 28-04-2019, 12:12 AM.

  • #2
    Hello,
    V-Ray already supports hair widths in pixels, but it seems this isn't exposed in our pfx support. If you change your script to just:

    Code:
    [FONT=monospace]from vray.utils import *[/FONT]
    
    [FONT=monospace]# Get all GeomMayaHair nodes and set their widths_in_pixels[/FONT]
    [FONT=monospace]hairs = findByType("GeomMayaHair")[/FONT]
    [FONT=monospace]for hair in hairs:[/FONT]
    [FONT=monospace]   hair.set("widths_in_pixels", True)[/FONT]
    Does this fix your problem? You'll also have to edit your current widths to multiply them by 0.1. One limitation is that this isn't updated in IPR, i.e. if you start an interactive render and move the camera the lines will have widths appropriate for the camera's original position.

    Your issues are because the post-translate script is not run for every frame, but only once the scene and all frames are processed and exported. The python module doesn't have full access to animated params and you can only observe and modify their state at the initial frame. Settings widths_in_pixels should work, because it's not animated.
    V-Ray for Maya developer

    Comment


    • #3
      Thanks, ah - that's the argument. It needs a boolean! I tried setting the widths_in_pixels as an array of values or something, no luck. But this does seem to do the trick and is much easier too to set a screen-space width! Great stuff.

      That also makes sense as to why other frames would just have the lines disappearing, that must've been because the length of the array I was setting wasn't correct for other frames and it would be messed up completely.

      Also, somewhat unrelated maybe. But can I also apply a different shader for this rendertime geometry? Somehow assigning a surface shader for example to the "pfxToon" node didn't change much about the actual shader being assigned at rendertime.
      Last edited by colorbleed; 15-05-2019, 09:15 AM.

      Comment


      • #4
        Maya doesn't let you override the PfxToon stroke material, so we don't support exporting with a different material, but you can still edit it in post-translate. Let's say you've created a material named VRayMtl1 and want it assigned to all pfxToon nodes:
        Code:
        # if material is not assigned to any object it will not be exported, export it here
        vraymtl = exportMaterial('VRayMtl1')
        nodes = findByType('Node')
        for node in nodes:
            if node.name().startswith('pfxToonShape'):
                node.set('material', vraymtl)
        This relies on your pfxToon strokes being named pfxToonShape1, 2, etc., so if you've changed their name from the default, edit it accordingly. You can access the color, incandescence and transparency of the strokes using a VRayHairSampler node.
        V-Ray for Maya developer

        Comment


        • #5
          Thanks - exactly what I was thinking about - just didn't know how to assign shader in the V-Ray post translate. Both tricks above would be perfect in V-Ray Post Translate documentation for Maya, they are quite clever tricks. The same with this trick to disable motion blur on animated UVs. Perfect examples that would be nice in the V-Ray for Maya documentation. Maybe great additions for this page?

          Appreciate the help, thanks again!

          Comment


          • #6
            Hey colorbleed thanks for your suggestion! We included both of the scripts in the documentation. You can find them here:

            https://docs.chaosgroup.com/display/...ant+Line+Width
            https://docs.chaosgroup.com/display/...f+Animated+UVs
            Kristin Ivanova

            Technical Writer
            www.chaos.com
            https://docs.chaos.com/

            Comment

            Working...
            X