Hello, can I change the edge width scaling on the aiToon in Maya, depending on the distance between the camera and my model?
I have read that attaching a facing ratio shader to the width scaling could help, but I have tried that and found that it had no effect. I found that changing bias and gain had some effect on the line width in general, but not depending on the camera. Is there a particular way I should attach it?
The problem I am having is the a close up of my model shows barely any line width, while a wide shot shows very thick lines in comparison to my model.
You can use an aiStateFloat set to Rl. This gives you the distance from the camera to the shading point. Add one with aiAdd and take the reciprocal with aiReciprocal, thus taking the linear distance input and applying the function 1/(x+1). The result will vary taper from 1 when the point is close to 0 when it is far away. You can see what this looks like here. You can also scale the ray length with aiMultiply before passing it through the function to adjust how the effect falls off. Use this to drive the aiToon edge width scaling. If you're using Maya you can see an example here.
Same problem here, my current workaround is primitive and tedious, in post (AE in my case) i apply a "simple choker" and animate the choke matte in relative to the edge widh i want.
This requires different passes for the outlines of each object if they move independently on the "Z" axes in your scene.
Hope this helps
Hi ! I was also looking for that. Thank you Tim but I think i miss something when I tried it and I am not able to open your project it says "Error reading file". Here is what i tried. I new to maya so i'm pretty sur I did a mistake.
Thank you !
It's not empty. It's a Maya 2018 scene. Maybe you have an older verison?
Here's the shader tree:
createNode aiToon -n "aiToon1"; rename -uid "4FADED48-470B-E0B8-228E-A79FCC4266B6"; setAttr ".angle_threshold" 12.203390121459961; createNode aiReciprocal -n "aiReciprocal1"; rename -uid "EC988765-4429-C535-C4C3-798146F759E3"; createNode aiAdd -n "aiAdd1"; rename -uid "8EE04718-4C0C-2392-9DDF-F9B189A2180C"; setAttr ".input2" -type "float3" 1 1 1 ; createNode aiMultiply -n "aiMultiply1"; rename -uid "D738C301-43DD-46A2-1BEB-43A43B4F6BF4"; setAttr ".input2" -type "float3" 0.1 0.1 0.1 ; createNode aiStateFloat -n "aiStateFloat1"; rename -uid "CD8210B2-4064-5D10-3045-DCA3506982DE"; setAttr ".variable" 5; connectAttr "aiReciprocal1.outr" "aiToon1.edge_width_scale"; connectAttr "aiAdd1.out" "aiReciprocal1.input"; connectAttr "aiMultiply1.out" "aiAdd1.input1"; connectAttr "aiStateFloat1.out" "aiMultiply1.input1r"; connectAttr "aiStateFloat1.out" "aiMultiply1.input1g"; connectAttr "aiStateFloat1.out" "aiMultiply1.input1b"; connectAttr "aiToon1.msg" ":defaultShaderList1.s" -na; connectAttr "aiStateFloat1.msg" ":defaultRenderUtilityList1.u" -na; connectAttr "aiAdd1.msg" ":defaultRenderUtilityList1.u" -na; connectAttr "aiMultiply1.msg" ":defaultRenderUtilityList1.u" -na; connectAttr "aiReciprocal1.msg" ":defaultRenderUtilityList1.u" -na;
Thanks you Tim for the file! but i failed to render clear black line when the obj is really really far from the camera... does anyone know how to fix this? or is there any other way around this problem of width scaling depending on distance from camera?
@Tim Harding, is there a way to vary the thickness of different lines, while keeping the auto line thickness adjustment based off distance from camera? This technique works great, but I need a way to scale the overall thickness. Everything I've tried so far just seems to reduce the auto line thickness effect.
Thanks!
Has anyone come up with a solution for affecting line width with the folcal length and / or prescale of the camera? I'm toying around with piping a userDataFloat into an aiRange but that doesn't seem to be doing the job
Needed something like this for a little thing I was doing so I wrote down a quick linewidth_camerabased shader. Yep it supports camera FOV. Many things could be added but you can still expand it yourself with other arnold nodes like airange etc. First example is in the zip where noise is plugged into userfactor to further tweak line width. Oh, if lines starts to get 'grey' for far away objs it's because transparency is kicking in iirc .. there shold be an arnold option somewhere to avoid that.
Here some examples..
25mm
50mm
100mm
fixed linewidth
camerabased linewidth
https://www.rombo.tools/downloads/romboUtil_ToonLineWidth.zip
[edit: relinked with proper .ols file, previously I had upped the .oso]
simply drop .mtd and .osl files in a folder where you already have other arnold shaders.
@Max Tarpini Hi Max, I have just seen your attached file.
But the result didn't work like your pictures show.
I feel like toon1 shader is missing something? toon2 turns up equal line with all distance.
Could you explain how you make it in detailed?
Thank you in advanced.
I attach here the simple net you need to setup for the line width camera based osl shader to work.. user factor can be a plain number or anything you wanna add in as a special fx (here using a cell noise to give some variation to the line width)
Still here for those interested :
https://www.rombo.tools/downloads/romboUtil_ToonLineWidth.zip
Now the archive is corrected. Same link for download.