PDA

View Full Version : unreal2 extreme toon shader and varying line thickness



mattratcliffe
10-16-2010, 10:37 AM
Hi all

I've been wrestling with the unreal toon shader and have hit a brick wall. Basically I want to control the edgetracer line width using the incidence angle of the light. However I've tweaked the nodes in the pixel filter toontracer and it just doesn't work.

http://screencast.com/t/SSKJ4D2Km

And a screenshot of what I have at the moment:

http://screencast.com/t/9wlROkOGuC

I'm a nodes noob and this combined with very little documentation out there is making it a difficult challenge.

Any help would be much appreciated as I'm pulling my hair out!

thanks

Matt

nickdigital
10-16-2010, 03:20 PM
I think you need to plug the light info into a gradiant node, not an incidence node...I think. I'm a noob with nodes too.

The only time I've had to change line thickness I've done it with a procedural to give a brush look to it.

MooseDog
10-16-2010, 05:45 PM
I think you need to plug the light info into a gradiant node, not an incidence node...I think. I'm a noob with nodes too.

good first step :thumbsup:

mattratcliffe
10-17-2010, 05:28 AM
Thanks for the replies guys. I've had a go with the gradient but still nothing.

When I add a texture straight into the size section of the toonshader (when I press the T )I can control the line thickness because the gradient gives me values I can put in. I can't add in incidence or light incidence, only normal angle (which is stupid):cursin:

http://screencast.com/t/41fvjdkjSTlO

The problem I think is how gradients work in nodes. When I add a gradient node it doesn't have these values any more, just colour and alpha. I think the edgetracer brush is looking for values and not colours to control it's line thickness. Does anyone know how to add values into a gradient in the node editor.

http://screencast.com/t/xPmsMKRRmI01

Are there any other techniques to getting varying edge size. I have tried the reverse light incidence gradient trick but doesn't work due to the low poly nature of the model.

Any help much appreciated


cheers

Matt

nickdigital
10-17-2010, 10:12 AM
Some with more nodes experience will hopefully chime in cuz anything I do with the gradient doesn't change the thickness.

Do you have to use Unreal? Maybe a different technique is the way to go?

http://www.newtek.com/forums/showthread.php?t=113243

mattratcliffe
10-17-2010, 10:54 AM
Thanks again nickdigital for the response. I've taken a look at that guys work and tutorials. Very useful with superb results but not all the techniques work with lowpoly objects. I'll keep plugging away at this till I get something half decent.

I'm also going to take a look at blender too, as the freestyle render looks incredible. If only Newtek would seriously look at NPR in Core. :(

http://www.youtube.com/watch?v=79v-GXg3LqU
(http://www.youtube.com/watch?v=79v-GXg3LqU)

cheers

Matt

nickdigital
10-17-2010, 10:59 AM
I assume you've tried the flip poly technique too? Dupe your object, make it a little larger and flip the polys. We use that when we need to make instances as instances don't render Unreal or LW lines. That technique probably won't give you the look you're after but it's an option.

paulhart
10-17-2010, 11:06 AM
Take a look on the Freestyle Blender thread (HERE (http://blenderartists.org/forum/showthread.php?t=89986&page=60)) towards the bottom, where Blendman has posted his most recent renders with this branch. Thick and thin line, beautiful quality. I have been "beating" the drum for NPR for awhile, and have been making "builds" of the Freestyle branch over on Graphicall.org, for Win32 and Linux64.
I too have used UnrealExtreme2, and I went so far as to send a PM to customer service to try to get Rob Powers to visit the developers in Japan for UnrealExtreme to foster development and integration. Lightwave has lagged in this area, and given how big arch/viz, illustration, and animation can be with good line drawings, this needs to be more of a priority. "Other" programs have devoted modules and integrated solutions. Take a look at the Blender for an idea of what is needed.....
Paul

mattratcliffe
10-17-2010, 12:42 PM
@nickdigital I haven't tried that technique yet but it's on my list! My worry with that is animating and deforming a mesh, but I'll do a quick test to see how that works, thanks for reminding me ! :)

@paulhart Cheers for the link. Absolutely awesome stuff happening with blender at the moment. I think it's about time I dive in and have a go!

It's a real shame Newtek don't take advantage of the unreal shader, but I guess it's not on their priority list. Although I think NPR is slowly gaining momentum in the industry, it's still very niche at the moment but blender certainly looks like it's leading the pack.

Anyway, thanks guys. Will post something up if it's any good.

cheers

Matt

paulhart
10-17-2010, 12:48 PM
I had gotten the incidence angle to work before, so I will look around at some of my "node" efforts. The current Blender builds (2.54) don't have the incidence angle node activated, so we may have to wait for 2.6 to get it to work properly without a lot of work arounds, but those trials by Blendman as just delicious, glad you enjoyed the taste as much as I do.

mattratcliffe
10-17-2010, 01:20 PM
If you have any node examples that would be awesome. I may just hold fire then with Blender if there are a lot of work arounds, my poor brain is struggling with Lightwave as it is!

cheers

Matt

Dodgy
10-17-2010, 05:33 PM
Have a look at this setup. This is where having a maths degree helps.
The dot tells you how in line a surface normal is to the light direction, and then the add shifts it from -1 to 1 range into positive numbers, then this value is scaled using the multiply.

You can do the adding and scaling in the shader node setup or the pixel filter node panel, depending on how much control you want of your object's lines.

nickdigital
10-17-2010, 08:00 PM
Oh wow, nice one Dodgy!
:thumbsup:

paulhart
10-17-2010, 10:33 PM
Oh Dodgy, Hello.. to all.
I spent the better part of the afternoon, trying once again to generate the thick/thin line of my dreams, one which Blender Freestyle (see prior thread) generates with greater ease, but doesn't yet have the direction/incidence node implemented in 2.54. I put many combination of nodes together to no effect. You appear to have cracked it with you math smarts... however, the incompleteness of the diagram image made it impossible for me to duplicate your fine results. I found in odd that the Add Node only has one input, as does the Multiply (are they Scalar or Vector Add/Multiply Nodes?). I am still struggling, thinking that this should be easier. I have been using UnrealExtreme2 for several development generations, yet a quality, thick/thin, hand drawn line has eluded me. So, math guru, please expand your description and images to help me and others. Thank you in advance, your help is always appreciated.
Paul

Dodgy
10-18-2010, 12:22 AM
Okay, some things to note with nodes :)

Connections are colour coded. Green links are scalar (just normal one dimensional numbers, like 1, 1.4, 7 etc). Blue are 3d vectors. Red are colours (which are basically also vectors, as the have 3 dimensions so you can use them in a lot of the same situations as vectors). Magenta are integers. Cyan are materials. Also, the add node (as with other nodes) if you use it with just one input, the other input is a value which can be adjusted by the user.

From this you can tell the add and multiply nodes are scalar nodes.
The Dot node takes two vectors and (if they are unit vectors, which I think the Surface Normal and Light Direction vectors are) it returns the Cosine of the angle between them. As we all know, if the normal's direction matches that of the light direction, this is 1, of the normal is at 90 degrees to the light direction that's 0, and the normal is facing the opposite way, this is value is -1.

So we shift the range -1 to 1 up by say 2 (by adding 2) then this range becomes 1 to 3 (1 facing the light, 3 facing away) as a base for the width of the line. The multiply vector scales this range to get the final line width we want.
Alternatively, you could just pipe the Dot result into a gradient, with range -1 to 1, and use the alpha of keys in the gradient to control the thickness. This is very adjustable.

This is all done in the Unreal Edge tracer node, and piped into its custom 1 Input so the pixel filter can get at it.

In the Unreal Pixel filter Toon Tracer node panel, you add an Unreal Buffer node to get the custom buffers and pipe that into the Size input to get the line drawn the size you want.

Finally if you want a hand drawn line effect, you can use weight maps on your object to control the line width as well, or use a texture to randomly widen the line width, or both together.

nickdigital
10-18-2010, 12:34 AM
Great write up.

Dodgy
10-18-2010, 12:46 AM
It all makes sense?

nickdigital
10-18-2010, 12:56 AM
Yeah, it helps that you walk through it. I would be hard pressed to re-create this from scratch so I'm bookmarking this thread. :D

I know I'm still a noob with nodes. Nodes are definitely powerful but I feel they require a lot more in-depth thinking of how to put a specific network together. It's almost like programming. You know what you want your program to do...it's down to knowing the exact syntax to use.

The weight map technique is definitely interesting. It seems like that would be the way to go to get the old school Warner Bros/Disney line work.

mattratcliffe
10-18-2010, 03:14 AM
Thanks Dodgy for stepping through the process, however I still can't get it to work, which is probably due to my lack of nodes knowledge.

Here is what I have set up here:
http://screencast.com/t/eh7ack29

In the add node Ive added a value of 2.0 in B. The multiply has a value of 3.0. Not sure if I need to add anything else?


Also, I have noticed a line being scored right through the render. This seems to happen where the render buckets move on the screen and only happens when the image resolution is higher than 500, anyone else had this bizarre bug.

Thanks for the all the help guys, I'm slowly getting there!


cheers

Matt

mattratcliffe
10-18-2010, 03:40 AM
Hmm, I just solved that line through the middle. Seems to either be a nasty bug with the unreal shader or my machine going nuts. Anyway, it seems to be caused by the amount of segments the render is split into, so I had to up the segment memory limit to drop the segments per render to 1 and that did the trick. But, once I start rendering up very large stills, this will become useless :bangwall:

Dodgy
10-18-2010, 03:46 AM
No, you set up the nodes in the wrong place.

Add the Unreal Edgetracer node shader to your surfaces and set the nodes up there.

Then add the pixel filter Toontracer and add the Buffer node in the node panel there to get the results.

mattratcliffe
10-18-2010, 04:34 AM
Hi Dodgy. Thanks again for the help but it's still not working (apologies for being a total noob).

I've added in the edgetracer node into the surface shader and hooked it up to the custom 1 buffer.

http://screencast.com/t/0oAJlZV8ih

And in the toon shader pixel filter, I've added in the unreal buffer node and hooked it up to the brush size.

http://screencast.com/t/0haDq5c2R7N

This is all correct right? I've made sure the light is used in the light item info node and played with the other values but still no joy.

cheers

Matt

paulhart
10-18-2010, 04:17 PM
Dodgy, NickDigital, A little example would help pooooor me and mattratcliffe. Just a couple of balls or cylinders on a plane, with the Node setup, so we can take it apart and see how it works. I have created all kinds of variations based on this thread, none of which generates a variable line. It sounds so clear to you, and NickDigital seems to get it, so if one of you can post an example file, with simple objects, maybe the rest of us can also join the party. Thank you in advance for your assistance already and anything else you choose to toss this way...
Paul

Dodgy
10-18-2010, 06:52 PM
There you go.

paulhart
10-18-2010, 08:46 PM
Dodgy, Hello and thank you again... Well, I think I have found the problem. I am running Lightwave 9.61, with unrealx2_150_test2.zip for compatibility with FPrime 3.51, and Lightwave 9.6 according to the website, and have been doing so since it came out. I am attaching the error output, as it is looking for aspects of the plugin that I don't have, even with this latest plugin and Lightwave version. I truly appreciate your posting, as it quickly allowed me to see that I was not able to do what you are doing. I have tried adding the unreal2.p again, it loads fine, just doesn't have your pieces.
I enjoyed your web site, wandered around, took in the sights, enjoyed your videos and drawings.
Maybe someone else has a solution, it really shouldn't be so hard... ;>)
Paul
http://www.hartworks.net/lightwave/LineWidthErrors.png

nickdigital
10-18-2010, 08:55 PM
I'm running 1.06 and the scene loads up and works.

Maybe you need to use the latest version of Unreal?

paulhart
10-18-2010, 11:19 PM
See, that is the problem, unrealx2_106_lw9.zip is an earlier version, while unrealx2_150_test2.zip is the latest one for compatibility with Lightwave 9.6 and FPrime 3.51 according to the web site. But what do I know...???

nickdigital
10-18-2010, 11:41 PM
Version 1.5? Say whaaaa? You're on some new fancy version, lol.

Odd that it says support for 9.6 when I've been using 1.06 with 9.6 for awhile.

Of course it would help if I could read Japanese. :D

Dodgy
10-19-2010, 12:19 AM
Ah, that solves it.

However, having looked at the page, it says the node parts have been replaced by nodes2, so it should still be doable. I'll download it and have a fiddle.

Dodgy
10-19-2010, 12:35 AM
Okay, it appears there are new nodes, but the old nodes don't work, and there no method to retrieve the custom buffers, so this method won't work.

However, version 1.06 is still up on his plugin page, so you might want to download that till all the bugs are ironed out of this current version. I've been using it with 9.6 with few problems.

mattratcliffe
10-19-2010, 02:59 AM
Thanks Dodgey, I owe you a beer! It works!

http://screencast.com/t/cO6hnv0qhf

What I was doing wrong was plugging the multiplier node straight into the custom buffer. Using that gradient worked a treat.

I am using the old plugins though and that's a bummer that it doesn't work with the new ones (typical). I'll try sending the plugin author an email (although I have no idea where that is on his site) and see if he can get this back into the new plugins.

thanks again guys, great community you have here :)

cheers

Matt

Julez4001
08-10-2012, 06:59 AM
Did you ever find the correct email?