A clear cut line shader?...

Yes I know, there are a lot of very nice ao effects producing osls’ which can achieve in some degree such a thing but it is only in some degree. And the reason is that the ao effects producing osls’ create, always, a fading out too in the lines appearing in the edges of objects. You never have a clear cut line on the edges (as is in the image below –the result has been achieved by modelling and not shading-). So, is there a chance to produce a clear cut line producing osl shader? A good line shader with edge crease degrees and line thickness options?

Such a shader may be useful in many shading tasks, especially when used in various node combinations, for producing edge decay effects, transparent line renderings, npr descriptions of hard surfaced models (as an alternative to Freestyle) etc.

So, any good osl programmer here to consider a solution? : - )


You can clip any gradient to a sharp line just by checking if it’s greater/less than some threshold, and outputting 1 or 0 based on this. Which you can do with just a math node (“greater than” and “less than” modes). Since this evaluation is done per shading sample, it’s “infinite resolution” and will always be crisp regardless of how low resolution the input data was.

Hello J_the_Ninja! Can you put somewhere a very simple node arrangement so that may I download and inspect it?

Even a screenshot only of such an arrangement could be enough…

Here are some experiments with the ao shader of Gao (a member of the forum here), for finding a way to produce clear cut, crisp line shading. It is a very nice osl script but the effect it produces is an ao like effect. When someone keeps the ao distance very small it produces something very near to a line but it is not crisp enough so as to make a clear cut line… and when you increase the distance there begins the fading (as is illustrated in the second image below).

The second image is a sample of what can be done with a line shader. The lines do not have crispness -they are made with the mentioned script- but they do give an idea of what I mean.

The script is, however, very near to be able to produce a clear cut line, it has all the information of where the lines have to be put on an object… so I am putting below a very simple scene including it… maybe someone with good osl programming knowledge can turn it to a clear cut line shading script. Or even someone can think a node arrangement which will produce such a shading.

As I said before, a clear cut line shading would be very helpful on making decay effects on the edges of the objects (it can be used for many other purposes too of course). The ‘pointiness’ is good but it works mainly with cavities and not so much with sharp edges.



The link for downloading the scene:


I think that I did find a script that does, somehow, the work… if anyone is interested can look at my thread in the ‘sketchbook’ section of the forum…

Nice try BluePrintRandom… I will experiment with your nodes arrangement. I do suspect however that it does need a dense mesh for giving its results. The script I used gives quite nice results with even very simple meshes, however. I am putting below some experiments I did with it. My aim was achieving a clear cut line drawing in 3D space by means of shading. I think that the results are satisfying.

Having such a shading way, with all its options, in the trunk of Blender would be great because the osl scripts are too expensive as to the render times. As it is evident from the samples below it is a shading kind that can be used for various purposes… from ‘dirt and decay’ effects in the edges of objects to technical npr renderings. Even in the cases of objects which have a very simple mesh structure. It is as having a Freestyle which works having in its disposition all the abilities of a shader. : - )


why dont you link it here. people are involve here. even I am leaving for sketchbook section but its just idea

I am putting below a very simple scene using the script. Whoever finds a new idea as to its use let share it…

Btw, as I said before, the script is not mine… I did find it somewhere here in the forum but I do not remember where. If someone recognizes it as his-her own, he-her can inform us.


Brecht and Bao2 :wink:

there’s an updated version here: https://github.com/sambler/osl-shaders/tree/master/ramps/BaAmbientOcclusion

if you are a CGCookie member you can watch Clip Art lesson from Kent Trammel, might help…

Secrop thanks for reminding and the links… : - )

Burning, I have seen a video related to the technique you mention. It is good but it is about some other thing. My aim is not simply producing a cartoonish result but having a way to ‘draw’ -somehow, of course- in real 3D space.

Have you tried Freestyle + Mark Edges so that it always draws just the edges you mark?

Of course, I have tried it. It is not the same thing however. The thing that is achieved with this script is lines that are not just 2D lines, they are ‘actually’ lines. Something like wires. So they can be fading out according to their distances -in the cases that is used a semi transparent shading on the objects-, have glossiness and they may work in dof having scenes. And, no need to say, they can be used as a masking medium for achieving dirt and decay like effects, even in low poly objects’ sharp corners and edges (the already existing, in the shading nodes system of Cycles, ‘pointiness’ feature has a deficiency when comes to such objects).

Freestyle is great but it has the limitations that post image processing has. Whereas here, with this script, we have the advantages that actual shading offers. The only shortcoming of it is it is being costly in render times.

Below I am putting two renders showing the workings of glossiness and dof effect in this kind of shading: