Community
Arnold for 3ds Max
Rendering with Arnold in 3ds Max using the MaxtoA plug-in.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

aiToon width scaling depending on distance from camera?

14 REPLIES 14
Reply
Message 1 of 15
ejk.row
6824 Views, 14 Replies

aiToon width scaling depending on distance from camera?

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.

Tags (3)
Labels (3)
14 REPLIES 14
Message 2 of 15
timh5D75Z
in reply to: ejk.row

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.

2876-far.png

2877-mid.png

2878-close.png

Message 3 of 15
peturS6ZFU
in reply to: ejk.row

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

Message 4 of 15
loic.arcy
in reply to: ejk.row

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.

3074-nodes.png

Thank you !

Message 5 of 15
gary.crane
in reply to: ejk.row

Hey Tim, I downloaded your example, and it is an empty scene

Message 6 of 15
Stephen.Blair
in reply to: ejk.row

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;


// Stephen Blair
// Arnold Renderer Support
Message 7 of 15
gary.crane
in reply to: ejk.row

yes, I am using 2017 atm. Thanks for the tree

Message 8 of 15
jooheon
in reply to: ejk.row

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?

6890-screenshot-2.png6889-screenshot-5.png

Message 9 of 15
Anonymous
in reply to: ejk.row

@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!

Message 10 of 15
forrest.brent
in reply to: ejk.row

Try this on for size homeboys

toonies.jpg

Message 11 of 15
forrest.brent
in reply to: ejk.row

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

Message 12 of 15
maxtarpini
in reply to: ejk.row

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..

25mmlinewidth-25mm.png

50mm

linewidth-50mm.png

100mm

linewidth-100mm.png


fixed linewidth

linewidth-constant.png

camerabased linewidth

linewidth-cambased.png

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.

Message 13 of 15
collapse5858
in reply to: ejk.row

@Max Tarpini Hi Max, I have just seen your attached file.

But the result didn't work like your pictures show.


擷取3.png

擷取4.png

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.

Message 14 of 15
maxtarpini
in reply to: ejk.row

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)

toonlinewidthmaya.png

Still here for those interested :
https://www.rombo.tools/downloads/romboUtil_ToonLineWidth.zip



Message 15 of 15
maxtarpini
in reply to: collapse5858

Sorry I have attached the .oso and not the proper .osl !

Now the archive is corrected. Same link for download.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report