Ambient Occlusion "spread" parameter

Hi, dear developers team, hi dear community!

I am not good at programming, at algorithms, and I am not a developer in common sense… anyway!

I put my dirty hands on the source code and made this little change to the Ambient Occlusion node.
Now there is an option for shifting a sampling spread.

Why it might be needed:

  1. more flexible mask with AO
  2. when you need a sharper mask

I have diff-file ready to commit, but I doubt it’ll work under CUDA and Optix, course I build my custom branch with CPU support only. I hope images will be more oratory than my cumbersome explanation.


What do you think?

path_branched_rng_2D(
    kg, state->rng_hash, state, sample, num_samples, PRNG_BEVEL_U, &disk_u, &disk_v);
float2 d;
float phi, r;
disk_v = 1.0f-disk_v*(1-max(-1.0f,-min(0.0f,spread)));    
phi = M_2PI_F*disk_u;
r = sqrtf(disk_v)*min(1.0f,1.0f-spread);
d.x = r*cosf(phi);
d.y = r*sinf(phi);
float3 D = make_float3(d.x, d.y, safe_sqrtf(max(0.0f,1.0f - dot(d, d))));
Ray ray;
ray.P = ray_offset(sd->P, N);
ray.D = D.x * T + D.y * B + D.z * N;
ray.t = max_dist;
ray.time = sd->time;
ray.dP = sd->dP;
ray.dD = differential3_zero();
9 Likes

In Blender Today, Pablo asked, “why not to use traditional AO+color ramp”. The answer is that you will “lose” many extra rays in vain when you need sharper AO.

Also, it is nearly impossible to get that crisp AO as on the last screenshot. At least, it is nearly impossible with just a few samples.

1 Like

I think this would be good functionality to add. If you have a complete patch with UI integration you can submit it on developer.blender.org.

7 Likes

oooh If/when you make a patch, link it here so I can see! This looks good for NPR.

Will do it in the morning, but I will need help from developers to look carefully at my changes, I might mess around a little :upside_down_face:. Also, due to my limited understanding, I couldn’t build with CUDA/Optix support.

1 Like

Here is the patch:

5 Likes