3
$\begingroup$

I made this flood fill/breadth-first search style voxel lighting system using geometry nodes. However, due to the wonky set-up I have in the repeat zone, it lags quite a lot when the light is moved. I have used the new bake node to reduce lag, but I would much prefer a solution to the node setup itself, since the bake node doesn't really help when making adjustments to the searching itself (which comes before the bake node)

enter image description here

Blend file is included at the bottom.

Here's the initial set-up.

  • Use a 32 x 32 point cloud to represent the voxels in a chunk, and store the inputted mesh as point attributes in that 32 x 32 point cloud (also store the light as another attribute) enter image description here enter image description here
  • The occupied voxels node group is as follows enter image description here
  • And then the voxels to points node group: enter image description here

Here's the repeat zone set-up. The idea is as follows:

  • use a geometry proximity node to find the points in the point cloud that are 1m from the light
  • subtract the occupied voxels (so the propagation doesn't go through them)
  • subtract all the previous iterations (so you're only left with all points x meters away from the light in manhattan/taxicab distance)
  • each iteration, a new point cloud is created from the current loop to feed into the next loop
  • this is a hacky solution since the geometry proximity node uses euclidean distance. using a distance value of 1m and resetting the sample position to be points from the previous iteration creates a taxicab-like algorithm but it means a lot of unnecessary calculation is being done
  • each iteration, the light level is stored starting from 15 (for the center) and decreasing by 1 each iteration
  • then I transfer the light level onto the original mesh and store that as an attribute per face

In shader nodes I use the attributes and some math to sample the appropriate color from a lightmap texture (Y values are sunlight, X is time of day), but multiplying the attribute directly also works.

Repeat zone set-up

Example iterations (the light level 1-15 is previewed here):

Iteration 1

enter image description here

Iteration 2

enter image description here

Iteration 6

enter image description here

Iteration 4, with 1m cubes instanced on each point and the "current distance" point cloud being previewed

enter image description here

$\endgroup$
6
  • 1
    $\begingroup$ Could you illustrate the starting configuration (before the Repeat Zone) then successively the results of the first two iterations ? For those of us not familiar with Minecraft-style... $\endgroup$ Commented May 16 at 5:51
  • $\begingroup$ @StefLAncien more pictures have been added $\endgroup$
    – LuigiTKO
    Commented May 16 at 20:34
  • $\begingroup$ Am I correct in understanding that, in the case where there are no occupied voxels, the "pattern" around the light source remains the same as long as the light source does not move to an adjacent voxel ? By pattern, I mean the point cloud with decreasing intensity (white points in your pictures at successive iterations). $\endgroup$ Commented May 17 at 8:34
  • $\begingroup$ @StefLAncien if there are no occupied voxels, the pattern around the light source will expand. if there are occupied voxels, the light will not expand through those voxels $\endgroup$
    – LuigiTKO
    Commented May 17 at 19:04
  • $\begingroup$ There are interior faces, particularly inside the tree. Is it OK to remove these, or do you want a process robust enough to deal with that ? $\endgroup$ Commented May 20 at 20:37

0

You must log in to answer this question.

Browse other questions tagged .