Is there any way to edit the code for the node shaders?

I want to use the Bevel Shader with a sample of lets say 512, but the node is limited to 128, can I edit the source files to raise the limit or something? I know I can render bevel shader with more than 128 as I did so using a OSL shader, but since I can’t render OSL with GPU I’m looking for an alternative

It looks (to me who is not any sort of expert on Blender internals) like the 128 limit comes from here:

blender/makesrna/intern/rna_nodetree.c:5407 (line number may vary a bit by version)

static void def_sh_bevel(StructRNA *srna)
  PropertyRNA *prop;

  prop = RNA_def_property(srna, "samples", PROP_INT, PROP_UNSIGNED);
  RNA_def_property_int_sdna(prop, NULL, "custom1");
  RNA_def_property_range(prop, 2, 128);
  RNA_def_property_ui_range(prop, 2, 16, 1, 1);
  RNA_def_property_ui_text(prop, "Samples", "Number of rays to trace per shader evaluation");
  RNA_def_property_update(prop, 0, "rna_Node_update");

That 128 in the middle there is the upper limit on the “custom1” node attribute which is the “Samples” value.

To change it, you’ll need to set up to build Blender from source code on your platform, then edit this file, then do a build and try the resulting blender executable to see if it works or not. This is actually not too difficult to do and it’s rather fun to be able to build your own Blender at any moment with the up to the minute latest changes that have been committed.

For reasonably complete step by step instructions, see: Building Blender - Blender Developer Wiki

It’s mostly a matter of installing a bunch of prerequisite tools and stuff. See the link at the bottom of the page for additional components needed for CUDA and Optix support which you probably want.

Alternatively you could put in an enhancement request and try to convince the developers to make this change. You could also do this after you’ve built it yourself and demonstrated that this change has value.

1 Like

Thanks a lot for the help mate, it really points me in the right direction.

I think what you found is definitely where the limitation is coded.

But oh man, I didn’t expect to have to recompile the whole damn program, I was expecting to just change a file in the installation folder or something, I’m gonna take a look at the resources you sent me and see if I can do something about it.

I don’t consider development feedback a valid option because considering how slowly some things are done in Blender development I could make a request now and it only comes to fruition in 2 years as I can see that it’s not a priority.

1 Like

I’m curious why you need such a large value. Are you using a huge radius or very close-up shots, or what is it that makes say 128 insufficient. The documentation says basically “oh, 4 is usually plenty”.

P.S. if you can share a simple scene that demonstrates it, that would be even better.

This thread goes in depth about this issue

But a TLDR is: using a render sample above 1 introduces line artifacts in the bake, using a render sample of 1 fixes that but makes the bevel very pixelated, using higher bevel samples fixes that, 512 is around where it gets acceptable but the default blender shader goes only up to 128, hence my original post

1 Like

Also, I managed to compile my own version of blender following the resources you gave me (after a day of trying and 2 hours of compiling), the program itself work just fine, but the shader didnt work…

On CPU baking it worked fine, but for GPU baking anything about 128 either gave the same results as 128 or tottaly bugged out and failed to bake, so IDK what other files I have to modify to correctly change that

In the end I gave up and decided to just bake everything on CPU :frowning:

1 Like

A change to Blender got committed last night to change the segment limit from 100 to 1000. It ought to be in tonight’s daily 3.2 Alpha build (though there hasn’t been a new build since the 24th so it may be failing for some reason).

It looks identical to the change we discussed here, so maybe it will have similar issues on the GPU side.

1 Like