Page MenuHome

Shading: Add More Features To The Voronoi Node.
ClosedPublic

Authored by Omar Ahmad (OmarSquircleArt) on Tue, Sep 10, 4:21 PM.

Details

Summary

This patch allows the Voronoi node to operate in 1D, 2D, and 4D space.
It also adds a Randomness input to control the randomness of the texture.
Additionally, it adds three new modes of operation:

  • Smooth F1: A smooth version of F1 Voronoi with no discontinuities.
  • Distance To Edge: Returns the distance to the edges of the cells.
  • N-Sphere Radius: Returns the radius of the n-sphere inscribed in the cells. In other words, it is half the distance between the closest point and the point closest to it.

And it removes the following three modes of operation:

  • F3.
  • F4.
  • Cracks.

This breaks backward compatibility in many ways, including the base case.
The versioning code will be added shortly after.

Diff Detail

Repository
rB Blender

Event Timeline

Not sure if this related to the missing versioning, but these test failures probably indicate a bug in the texture code itself:

@Brecht Van Lommel (brecht) Pretty sure this is due to missing versioning, probably due to the fact that the dimensions property is set to zero, so the appropriate function is not called and what ever in memory is displayed.

I though I would upload the patch for review while I do the versioning to conserve time. Is this fine?

It's fine. I guess it can indeed be caused by versioning if the enum values are wrong.

intern/cycles/kernel/svm/svm_voronoi.h
610

code style, missing braces.

632

more missing braces

  • Add versioning code. Versioning for coloring is still missing.
  • Follow coding style.
Omar Ahmad (OmarSquircleArt) marked 2 inline comments as done.Tue, Sep 10, 9:20 PM
  • Clean up. Remove unused functions.
  • Add versioning code for coloring.

A file to test versioning code:

These are the current test failures:

Ideally only the pattern changes, but for many of these the overall color or intensity is also different. Is it possible to get closer?

@Brecht Van Lommel (brecht) It appears the distance output should be the squared distance, not the actual distance, will add versioning code for that.

  • Add versioning code for squared euclidean distance.

The tests looks like this now.

The color of the last test changed because the Voronoi scale is very small and the output is connected to a color ramp whose last color ramp element is yellow.

When switching features, it seems to somehow keep using the disabled link in Cycles and produces broken output.

For example in this test file, switch to "Distance to Edge", set viewport to Rendered and rotate around to see artifacts.
https://developer.blender.org/diffusion/BL/browse/trunk/lib/tests/render/reports/T53600.blend

@Brecht Van Lommel (brecht) That's because Cycles doesn't take into account unavailable sockets while generating the shader graph from the BL nodetree. In my branch, I fixed that in this commit 228edc58. But this is not really related to Voronoi.

Should I create a patch for this?

@Brecht Van Lommel (brecht) That's because Cycles doesn't take into account unavailable sockets while generating the shader graph from the BL nodetree. In my branch, I fixed that in this commit 228edc58. But this is not really related to Voronoi.
Should I create a patch for this?

You can commit that directly to master, 228edc58 seems fine.

intern/cycles/util/util_math_float4.h
468–480

Move these two functions right after the fabs() implementation, otherwise they are not implemented for CUDA.

Omar Ahmad (OmarSquircleArt) marked an inline comment as done.Thu, Sep 12, 12:03 PM
Omar Ahmad (OmarSquircleArt) updated this revision to Diff 18149.
  • Define the floor and mix functions in CUDA.

I am getting about 2% performance regression on benchmark scenes with CUDA, while CPU is unaffected. I think this acceptable for now and we can try to gain that back later.

This revision is now accepted and ready to land.Thu, Sep 12, 12:38 PM