Page MenuHome

Add Line material node
Needs ReviewPublic

Authored by Miguel Pozo (pragma37) on Mar 28 2020, 7:20 PM.
Tokens
"100" token, awarded by Xperto."Love" token, awarded by aaronfang."Love" token, awarded by Dangry."Love" token, awarded by Emre_Can_Oezcan."Like" token, awarded by hitrpr."Love" token, awarded by HEYPictures."Love" token, awarded by miyashh."Love" token, awarded by dlfon99."100" token, awarded by hoie."Love" token, awarded by sdkfile."Love" token, awarded by lone_noel."Love" token, awarded by alexmarkley."Love" token, awarded by renderedone."Love" token, awarded by xorrito."Love" token, awarded by gintszilbalodis."Love" token, awarded by Stig."Love" token, awarded by kyraneth."Love" token, awarded by TimBrown."Love" token, awarded by 1D_Inc."Like" token, awarded by IPv6."Like" token, awarded by Fracture128."Love" token, awarded by RoYou."Burninate" token, awarded by HF."Yellow Medal" token, awarded by Lingfox."Love" token, awarded by tonpix."Love" token, awarded by mindinsomnia."Love" token, awarded by elekmark."Love" token, awarded by Xlindvain."Grey Medal" token, awarded by duarteframos."Love" token, awarded by TheFlow."Love" token, awarded by jeacom256."Love" token, awarded by kenziemac130."Burninate" token, awarded by AnityEx."Love" token, awarded by TheAngerSpecialist."Love" token, awarded by juliocargnin."Burninate" token, awarded by blackviking."Love" token, awarded by weasel."Love" token, awarded by Yuro."Love" token, awarded by AndyCuccaro."Love" token, awarded by silenceimpaired."100" token, awarded by yassir_a_p."Love" token, awarded by chukx007."Love" token, awarded by Yegor."Love" token, awarded by corpse."Love" token, awarded by jaaypeso24."Love" token, awarded by SHEIKH."Like" token, awarded by dupoxy."Like" token, awarded by belich."Love" token, awarded by Pipeliner."Love" token, awarded by Syntex3D."Love" token, awarded by asmitty."Like" token, awarded by odil24."Love" token, awarded by dulrich."Love" token, awarded by lightbwk."Love" token, awarded by wo262."Burninate" token, awarded by tintwotin."Mountain of Wealth" token, awarded by higgsas."Love" token, awarded by ogierm."Like" token, awarded by crantisz."Love" token, awarded by a.monti."Love" token, awarded by amonpaike."Love" token, awarded by bunny.

Details

Summary

This patch adds a new line node for material node graphs. It aims to support both Cycles and EEVEE.

In Cycles works similarly to the AO node, by raytracing towards contiguous pixels and in EEVEE by reading the depth buffer.
In both cases it outputs the distance between the expected point it should encounter (assuming it's coplanar to the currently shaded pixel) and the actual point on the mesh/scene.
Right now outputs the max and min (as max negative) distance from surrounding pixels.
In Cycles it also outputs an outline based on object ID.

For further documentation and a build check https://blender-outline-node-docs.netlify.com/.

Know limitations/Current issues

  • In Eevee, it doesn't work for alpha blended objects, I don't think there's a simple solution for that and will likely stay that way.
  • In Eevee, distant objects tend to output slightly off results due to numerical precision. In practice, it's solved by dividing the node output by Width WorldSpace Size.
  • In Eevee, subpixel line widths are supported by rounding up or down the width based on probability. Ideally it should be rounded based on the camera jitter offset.
  • In Cycles, object outline works in viewport but not in render. (???)
  • In Cycles, rays should ignore fully transparent pixels. (This problem is also present in the AO node)

Diff Detail

Repository
rB Blender

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

Absolutely love this, would love to see it added. I concur with the earlier comment:

Honestly, as long as performance is not affected when a feature is not used I don't see how that can be a concern at all. Especially when it comes to NPR, where render times are usually pretty low anyways.

And the other comments that make the point that the advantage of having a feature like this operating within a shader is that it allows NPR rendering to interact with lighting, reflections, refractions, etc.

As always, I admire and appreciate how you see the bigger picture Brecht, and are always responsibly keeping an eye on all potential impacts of new features, on everything from UX to performance. I think this feature would be absolutely adored by artists (including myself), especially if it also made it into Cycles.

After seeing info that LANPR would be used as backend only, while frontend would be GreasePencil, I have some doubts - would really production ready LANPR compete visually with solution there? No offense, but I don't feel that GreasePencil has intricate visuals like custom material node there. (it's just vector curves that are very opaque and vary in thickness, not much more? I'd be happy to be corrected though)

Lingfox (Lingfox) rescinded a token.
Lingfox (Lingfox) awarded a token.

This won't be accepted will it? Pretty much a year went by, i guess is time for blender foundation to hire people that have more enthusiasm to the field, overworking a dev that does not care for npr to review npr stuff is not productive at all.
Lanpr still not implemented if this was at least acceptec we would have something.
@Miguel Pozo (pragma37) can you tag a dev to see this? They seem to forgot as npr is not a primary objective.

Is there any chance this gets updated to at least 2.91 or a way to manually update.

@juko (Juko_The10Tails) I updated the patch for 2.92 and uploaded a Windows build to Gumroad too.

@Miguel Pozo (pragma37) cool, thanks. It was one of the main reasons why I didn't update cause this is really useful. Personally I think this should be part of the base blender engine, for both eevee and cycles.

Thanks for working on this @Miguel Pozo (pragma37)! I've really been struggling to find an reasonable toon edge / toon line rendering method for a long time, and this honestly looks like the holy grail for me. (I'm working on building blender with this patch now, so I'll report back when I have some hands-on experience to confirm if this approach meets my needs.)

Now that Line Art Modifier has landed in master, I'd like to cast my vote for some attention to go to this shader-based approach. The reason is simple: for users like me, a baked solution will not offer real time feedback to my performance capture artists.

@Brecht Van Lommel (brecht) and @Clément Foucault (fclem) Is there any chance this patch could get some attention before the next LTS release? I've been a big fan of Blender adopting an LTS plan, but the idea of going another 12+ months without a "real" solution for toon lines in LTS would be pretty disappointing.

I'm just posting an update to confirm, yes I was able to build this for Linux on the latest blender master, and at least in initial testing it is working exactly as expected:

@Miguel Pozo (pragma37) As expected, the patch does not apply cleanly to the latest master as-is; I had to jiggle things around to get the patch applied. That said, what compiler are you testing against when you build for Windows? You may wish to try a Linux build because I got some compiler errors on my first try:

/home/alex/Build/blender/blender-git/blender/intern/cycles/kernel/osl/../../kernel/svm/svm_outline.h: In function ‘ccl::OutlineResult ccl::svm_outline(ccl::KernelGlobals*, ccl::ShaderData*, ccl::PathState*, ccl::float3, float)’:
/home/alex/Build/blender/blender-git/blender/intern/cycles/kernel/osl/../../kernel/svm/svm_outline.h:104:13: error: conversion from ‘double’ to ‘float’ changes value from ‘1.0e+11’ to ‘9.9999998e+10f’ [-Werror=float-conversion]
  104 |     ray.t = 100000000000.0;  // TODO
      |             ^~~~~~~~~~~~~~
/home/alex/Build/blender/blender-git/blender/intern/cycles/kernel/osl/../../kernel/svm/svm_outline.h:136:19: error: conversion from ‘double’ to ‘float’ changes value from ‘1.0e+11’ to ‘9.9999998e+10f’ [-Werror=float-conversion]
  136 |       max_depth = 100000000000.0;
      |                   ^~~~~~~~~~~~~~

Rough edges aside, (yes that was a joke) I'm very seriously considering migrating my character models to using this technique and using it in my next animated production. My biggest concern would be if this node never ended up getting merged and was eventually abandoned.

Miguel Pozo (pragma37) edited the summary of this revision. (Show Details)

Thanks for your feedback @Alex Markley (alexmarkley).

I've updated the diff to work on the latest master (the work was already done, but I forgot to submit it) and also made sure to use float literals to avoid compiler errors (hopefully, I can't test it on Linux right now).
I use the visual studio compiler on Windows, btw.

I've been maintaining this patch for over a year. It has over 1600 unique users on Gumroad and has made over 400$ in donations.
It has been used in production for commercial projects and as far as I know, it's still in use.
So unless it requires a full rewrite, I plan to keep maintaining it.

That said, I still hope it gets merged.
The only two "conflictive" needs it had (full resolution depth buffer in EEVEE and shader ray tracing in OptiX) are no longer an issue, so the patch is quite harmless and self-contained.
@Brecht Van Lommel (brecht) , @Clément Foucault (fclem) ?

Thanks for updating the patch @Miguel Pozo (pragma37)! I rebuilt blender master and (as of this evening) the patch applied cleanly with no issues. I am also happy to report that the GCC compilation error on Linux I observed has been resolved, so everything compiled with no changes.

I spent a couple hours updating my Toon node groups and fiddling with a couple of my hero models. I'm very pleased with the initial results, and I am definitely going to keep tinkering. Barring some showstopping issue I am thinking I will use this in my upcoming production.

Hope I don't come off as pushy or ungrateful, but will this be updated to 2.93.3, this is the only thing keeping me from updating. Wish this was an add-on, but I understand that it would be difficult to do so.

Hope I don't come off as pushy or ungrateful, but will this be updated to 2.93.3, this is the only thing keeping me from updating. Wish this was an add-on, but I understand that it would be difficult to do so.

Hey! Just wanted to mention I am using this patch with 2.93.3 with no issues whatsoever. The patch applies with just a few hunk offsets and compiling/using blender works as expected.

Hope I don't come off as pushy or ungrateful, but will this be updated to 2.93.3, this is the only thing keeping me from updating. Wish this was an add-on, but I understand that it would be difficult to do so.

Hey! Just wanted to mention I am using this patch with 2.93.3 with no issues whatsoever. The patch applies with just a few hunk offsets and compiling/using blender works as expected.

Stupid question, but how? Do you just update it over it or just copy certain files, which one, or something else?

Hope I don't come off as pushy or ungrateful, but will this be updated to 2.93.3, this is the only thing keeping me from updating. Wish this was an add-on, but I understand that it would be difficult to do so.

Hey! Just wanted to mention I am using this patch with 2.93.3 with no issues whatsoever. The patch applies with just a few hunk offsets and compiling/using blender works as expected.

I honestly dont get it, if it's that simple to implement, how come it hasn't been picked up by the devs for official release? It's the absolute best and most versatile solution for linework this far. I wish we didnt have to keep bugging Miguel for an update too :(

Hope I don't come off as pushy or ungrateful, but will this be updated to 2.93.3, this is the only thing keeping me from updating. Wish this was an add-on, but I understand that it would be difficult to do so.

No worries! I updated the Gumroad version to 2.93.4.
Implementing this as an addon is simply not possible, otherwise I would have followed that route from the beginning.
Although you can always use the OSL version in Cycles if you don't mind the lower performance.
https://developer.blender.org/differential/changeset/?ref=393152

Stupid question, but how? Do you just update it over it or just copy certain files, which one, or something else?

You would have to download Blender source code, apply this patch and compile Blender yourself.
What @Alex Markley (alexmarkley) means is that the patch itself works on the latest Blender 2.93.

Hope I don't come off as pushy or ungrateful, but will this be updated to 2.93.3, this is the only thing keeping me from updating. Wish this was an add-on, but I understand that it would be difficult to do so.

No worries! I updated the Gumroad version to 2.93.4.
Implementing this as an addon is simply not possible, otherwise I would have followed that route from the beginning.
Although you can always use the OSL version in Cycles if you don't mind the lower performance.
https://developer.blender.org/differential/changeset/?ref=393152

Stupid question, but how? Do you just update it over it or just copy certain files, which one, or something else?

You would have to download Blender source code, apply this patch and compile Blender yourself.
What @Alex Markley (alexmarkley) means is that the patch itself works on the latest Blender 2.93.

Thank you so much Miguel for the update! I was wondering if you could also reup the example shaders that were available in previous versions in gumroad. I ended up losing my copy.

@Allan (allanmrtn) They should still be on Gumrroad.

I'm attaching the example here too, just in case.

Good afternoon folks! I wanted to provide a quick update from my side.

I needed a reliable source of Blender 2.93 LTS builds with this patch applied, so I automated the build process. I am also providing Linux x86_64 builds for download here.

Along with Miguel's Windows builds, I am hoping this will help spread the word and allow more artists like myself to try out this Outline material node for themselves.

I continue to get stunning results from this Outline node, and I am definitely using it in my production. And since my latest production is based on Linux + Blender 2.93 LTS, my intention is to keep this build up to date for as long as 2.93 is receiving updates.

To the Cycles developers, please consider reviewing this patch and providing a path for it to be included in master! We need it desperately!

Thanks all,
--Alex M.

Good afternoon folks! I wanted to provide a quick update from my side.

I needed a reliable source of Blender 2.93 LTS builds with this patch applied, so I automated the build process. I am also providing Linux x86_64 builds for download here.

Along with Miguel's Windows builds, I am hoping this will help spread the word and allow more artists like myself to try out this Outline material node for themselves.

I continue to get stunning results from this Outline node, and I am definitely using it in my production. And since my latest production is based on Linux + Blender 2.93 LTS, my intention is to keep this build up to date for as long as 2.93 is receiving updates.

To the Cycles developers, please consider reviewing this patch and providing a path for it to be included in master! We need it desperately!

Thanks all,
--Alex M.

That's fantastic, I can see a lot of folks using that.

Hi @Miguel Pozo (pragma37)

Our team is planning to include this patch in our version of Blender. (https://github.com/acon3d/ABLER)
I just want to thank you for this patch cuz it solves a very crucial problem with what we are trying to do.
Please tell me if you want us to credit you in a certain way.
Here's my email: hoie@acon3d.com

Thanks!

Hello @Hoie Kim (hoie), you're welcome!

If you have a list of new features/modifications of your Blender version, something like "Outline Node by Miguel Pozo" would be nice, but not really required. :)

Hello @Hoie Kim (hoie), you're welcome!

If you have a list of new features/modifications of your Blender version, something like "Outline Node by Miguel Pozo" would be nice, but not really required. :)

Hey Miguel, any chance we are getting a stable 3.0 update for this patch? :)

@Allan (allanmrtn)
Yes, but it may have to wait for a little.
I tried to make the update, but the internal API has changed quite a bit and I wasn't able to get it working at all.
I need to take a deeper look at it whenever I have some time.