Interface VolumeGenerator

All Known Implementing Classes:
CPUGalaxyVolumeGenerator, GalaxyVolumeGenerator

public interface VolumeGenerator
A backend that turns a slot's fields into a voxel texture: one that dispatches the compute shader (GalaxyVolumeGenerator) and one that evaluates the same field in Java (CPUGalaxyVolumeGenerator), for hardware without compute shaders.

The two differ in how they produce the voxels and in how precisely they reproduce the noise, not in what they store: both write the same RGBA8 layout, both calibrate against VolumeCalibration, and both hand back a VolumeTexture the material can bind. What the volume looks like is therefore a property of the fields, not of the backend.

  • Method Details

    • forRuntime

      static VolumeGenerator forRuntime()
      Returns:
      The backend this runtime will use: the compute one when it is available, the CPU one otherwise. Null is not possible - the CPU voxeliser needs nothing but a GL context.
    • name

      String name()
      Returns:
      Short name of the backend, for the logs.
    • isAvailable

      boolean isAvailable()
      Returns:
      Whether this backend can run in the current runtime.
    • generate

      VolumeTexture generate(List<? extends GalaxyAttributes> fields, VoxelGrid grid, VolumeTexture existing)
      Generates the volume texture of one slot, refilling existing when it fits the grid.
      Parameters:
      fields - The fields that go into the slot, in slot order.
      grid - Grid dimensions.
      existing - The slot's current texture, or null to always allocate a new one.
      Returns:
      The volume, which may wrap existing, or null if generation is not possible.
    • readStats

      float[] readStats(VoxelGrid grid)
      Reads back the statistics of the last generation, for logging and calibration checks. See GalaxyVolumeGenerator.readStats(VoxelGrid) for the meaning of each entry.
      Parameters:
      grid - The grid that was generated.
      Returns:
      The statistics, or null if there is nothing to read.
    • constrainGrid

      default VoxelGrid constrainGrid(VoxelGrid grid)
      Reduces a grid to what this backend can afford. The compute path fills any grid the quality settings ask for; the CPU one evaluates the field on the processor, so it is given a smaller one.
      Parameters:
      grid - The grid the quality settings derive.
      Returns:
      The grid to generate.