V-Ray for Maya
Paint FX Constant Line Width
This example using Post-Translate Python Script shows how to set a constant hair width in pixels, effectively applying it for Paint FX toon lines.
Last updated 19 September 2025
This example using Post-Translate Python Script shows how to set a constant hair width in pixels, effectively applying it for Paint FX toon lines.
Set Hairs Width In Pixels
<code><span class="line"><span style="color:#D73A49">from</span><span style="color:#24292E"> vray.utils </span><span style="color:#D73A49">import</span><span style="color:#D73A49"> *</span></span>
<span class="line"></span>
<span class="line"><span style="color:#6A737D"># Get all GeomMayaHair nodes and set their widths_in_pixels</span></span>
<span class="line"><span style="color:#24292E">hairs </span><span style="color:#D73A49">=</span><span style="color:#24292E"> findByType(</span><span style="color:#032F62">"GeomMayaHair"</span><span style="color:#24292E">)</span></span>
<span class="line"><span style="color:#D73A49">for</span><span style="color:#24292E"> hair </span><span style="color:#D73A49">in</span><span style="color:#24292E"> hairs:</span></span>
<span class="line"><span style="color:#24292E"> hair.set(</span><span style="color:#032F62">"widths_in_pixels"</span><span style="color:#24292E">, </span><span style="color:#005CC5">True</span><span style="color:#24292E">) </span></span></code>
The widths_in_pixels option will instruct V-Ray to treat the line widths (exported as hair strands) as screen-space width values in pixels, rather than the default world-space widths.
In addition, using the Post-Translate Python Script, you can override the material of the pfxToon nodes. This script relies on your pfxToon strokes being named pfxToonShape1, 2, etc., so if you've changed their name from the default, edit it accordingly.
Set VRayMtl to pfxToon nodes
<code><span class="line"><span style="color:#6A737D"># if material is not assigned to any object it will not be exported, export it here</span></span>
<span class="line"><span style="color:#24292E">vraymtl </span><span style="color:#D73A49">=</span><span style="color:#24292E"> exportMaterial(</span><span style="color:#032F62">'VRayMtl1'</span><span style="color:#24292E">)</span></span>
<span class="line"><span style="color:#24292E">nodes </span><span style="color:#D73A49">=</span><span style="color:#24292E"> findByType(</span><span style="color:#032F62">'Node'</span><span style="color:#24292E">)</span></span>
<span class="line"><span style="color:#D73A49">for</span><span style="color:#24292E"> node </span><span style="color:#D73A49">in</span><span style="color:#24292E"> nodes:</span></span>
<span class="line"><span style="color:#D73A49"> if</span><span style="color:#24292E"> node.name().startswith(</span><span style="color:#032F62">'pfxToonShape'</span><span style="color:#24292E">):</span></span>
<span class="line"><span style="color:#24292E"> node.set(</span><span style="color:#032F62">'material'</span><span style="color:#24292E">, vraymtl)</span></span></code>