Bevel shader

Awesome- Both your modelling Speed and the Bevel-Shader!

Nice stuff Floatvoid. Interesting results regarding the baking, I wouldn’t have a clue where to start :confused:

I use modo’s smooth edge shader all the time, its extremely good for baking out normal maps for game assets. Seeing this particular shader approach pop up in Blender is a good thing.

Oh, cool, they added a proper per face-vertex tangent node. Must have missed that. Yep - with that thing it’s possible to bake to tangent space.

Had a go myself using Secrop’s node setup.

Kind of works however I am getting really noisy results, not quite sure what I am doing to be honest but promising results. Might have made an error with the node setup.

Played a little with this shader on some seriously messed-up geometry coming from rhino nurbs (it was a cut-in-half wc with all its inside, siphon, outlet, sink etc…). The result is amazing! The effect, even if subtly set, is so pleasing that i would even make it a material global property! Yeah, like a checkmark “Bevel shader” and a slider to set the amount. Well also in nodetree would cool anyway… if only it was available on GPU. Too bad this is OSL only.

Any coder wishing to dive in this lovely feature? :yes: (…everybody say YEEEAHH…)

@DefaultSound: You just need more samples. Set them in the shader node settings, not in the baking settings - the baker will only do one sample of diffuse color anyway, which is why the node has its own sample setting in the first place.

@lsscpp: This shader is extremely expensive in terms of computations since it does additional raytracing at the shading stage. I’m not quite sure the Cycles SVM on GPU is set up to allow that. If Brecht was still with us I’d have said we’ll get it sooner or later, but without him I’m not so sure. The shader could also benefit from a nicer sampler.

I was able to get the normals to bake, sweet! Baking worldspace (or object space), since transferring to a game engine needs proper tangent basis. In this case, object space to external tool like Handplane or Xnormal is best.

Unfortunately I’m also getting super noisy bakes. I even set the shader to 1500 samples and it didn’t make a difference.

I attempted to use the bevel shader in a scene the other day and results were…disappointing. Basically, cpu rendering sucks :\ (at least on my computer). I thought the results are interesting, at least helps add to the discussion a bit!


you cant compare GPU with CPU …

think having a scene that you can’t render with gpu becasue insufficente memory or other reasons, so at least this osl help you to save time in modeling/UV/loading time/render time.

Also the shader works on messy geometry with planes/faces/edges that can’t be joined, so that you can’t use bevel modifier

Hi Piotr, your script doesnot work anymore;(

Any updates, Piotr?

@tungee, I think you actually always looking for an update, and other people like me will find this thread, so to answer you, I tested the script, and it’s still running properly. Are you sure to activate the “open shading language” in the render panel ? It can take sometimes, for me one render to activate properly.

I am unable to get this working, it doesn’t seem to do anything. I followed Piotr’s node setup but nothing…at best I get lots of specular noise around the edges, but none of the nice effects the others got.

Can someone make an up to date guide for setting this up?

Here’s a blend file with the shader built in for you to try out. Just verified it works on 2.74

BevelTest.blend (2.19 MB)

this shader should be in trunk… it’s so useful.

So I’ve got quite a bit of free time now and decided to tackle the baking issue again. I’ve found some new stuff possibly.

So I tried baking the normals again and managed to convert the tangent normals to a diffuse texture, using the method J_the_Ninja suggested.

Now I’m still getting noisy results, and adjusting the samples didn’t make a difference. One thing however, is I noticed that the viewport render wasn’t noisy.



Upon looking into it a bit more it maybe because of these bugs/errors:

https://developer.blender.org/T40369
https://developer.blender.org/D1254

So the bake is noisy possibly because of the OSL issue. It makes sense since the render is fine.

Here is the blend file if anyone wants to test/ see the node setup

BevelShaderTest.blend (5.58 MB)

Also the normal in the render will differ based on the lighting. I’m not sure what would be the ideal lighting to get a view of tangent normals. Also I’m using a HDR for lighting.

The bake is noisy because it’s not designed with baking in mind - it’s meant to let cycles accumulate the samples in the final image. But baking only samples a given texel once for most passes, so it doesn’t work (at least as long as there’s no antialiasing).

To fix it, you want to have one or both of these two lines (can’t quite remember):

f = fmod(cellnoise(P*123456.0), 1.0);
rng_seed(rng, int(f * 21374647));

inside the for(samples) loop for baking. And then you want to get rid of the whole ‘let’s fire rays until we hit something’ thing and do proper accumulation in the shader.

Ah okay. Thanks. Again this is where it all goes above my head :spin: I tried