Class InstancedLightRenderer<T extends LightData & InstancedLightData>

java.lang.Object
foundry.veil.api.client.render.light.renderer.InstancedLightRenderer<T>
Type Parameters:
T - The type of lights to render
All Implemented Interfaces:
InscatteringLightRenderer<T>, LightTypeRenderer<T>, AutoCloseable, org.lwjgl.system.NativeResource
Direct Known Subclasses:
AreaLightRenderer, InstancedPointLightRenderer, SpotLightRenderer

public abstract class InstancedLightRenderer<T extends LightData & InstancedLightData> extends Object implements InscatteringLightRenderer<T>
Draws lights as instanced quads in the scene.
  • Field Details

    • lightSize

      protected final int lightSize
    • maxLights

      protected int maxLights
  • Constructor Details

    • InstancedLightRenderer

      public InstancedLightRenderer(int lightSize)
      Creates a new instanced light renderer with a resizeable light buffer.
      Parameters:
      lightSize - The size of each light in bytes
  • Method Details

    • createMesh

      protected abstract com.mojang.blaze3d.vertex.MeshData createMesh()
      Returns:
      The mesh data each instanced light will be rendered with use
    • setupBufferState

      protected abstract void setupBufferState(VertexArrayBuilder builder)
      Sets up the instanced buffer state.
    • getRenderType

      @Nullable protected abstract @Nullable net.minecraft.client.renderer.RenderType getRenderType(List<? extends LightRenderHandle<T>> lights)
      Calculates the render type to use for the specified lights.
      Parameters:
      lights - All lights in the order they are in the instanced buffer
      Returns:
      The render type to use
    • getInscatteringRenderType

      @Nullable protected abstract @Nullable net.minecraft.client.renderer.RenderType getInscatteringRenderType(List<? extends LightRenderHandle<T>> lights)
      Calculates the render type to use for the specified lights' in-scattering.
      Parameters:
      lights - All lights in the order they are in the instanced buffer
      Returns:
      The render type to use for in-scattering
    • addLight

      public LightRenderHandle<T> addLight(T light)
      Description copied from interface: LightTypeRenderer
      Adds the specified light to the renderer.
      Specified by:
      addLight in interface LightTypeRenderer<T extends LightData & InstancedLightData>
      Parameters:
      light - The light to add
      Returns:
      A handle to the light in the renderer
    • steal

      public LightRenderHandle<T> steal(LightRenderHandle<T> handle)
      Description copied from interface: LightTypeRenderer
      Attempts to re-add the specified handle to this renderer if invalid.
      Specified by:
      steal in interface LightTypeRenderer<T extends LightData & InstancedLightData>
      Parameters:
      handle - The handle to add
      Returns:
      A valid handle to this renderer
    • prepareLights

      public void prepareLights(LightRenderer lightRenderer, CullFrustum frustum)
      Description copied from interface: LightTypeRenderer
      Prepares the light renderer.
      Specified by:
      prepareLights in interface LightTypeRenderer<T extends LightData & InstancedLightData>
      Parameters:
      lightRenderer - The light renderer instance
      frustum - The culling view frustum
    • renderLights

      public void renderLights(LightRenderer lightRenderer)
      Description copied from interface: LightTypeRenderer
      Renders all prepared lights with this renderer.
      Shaders, custom uniforms, and the way lights are rendered is up to the individual renderer.
      Specified by:
      renderLights in interface LightTypeRenderer<T extends LightData & InstancedLightData>
      Parameters:
      lightRenderer - The light renderer instance
    • renderLightInscattering

      public void renderLightInscattering(LightRenderer lightRenderer)
      Description copied from interface: InscatteringLightRenderer
      Renders inscattering of all prepared lights with this renderer.
      Shaders, custom uniforms, and the way lights are rendered is up to the individual renderer. This function is not called for the first-person perspective.
      Specified by:
      renderLightInscattering in interface InscatteringLightRenderer<T extends LightData & InstancedLightData>
      Parameters:
      lightRenderer - The light renderer instance
    • getLights

      public List<? extends LightRenderHandle<T>> getLights()
      Specified by:
      getLights in interface LightTypeRenderer<T extends LightData & InstancedLightData>
      Returns:
      A view of all lights in this renderer
    • getVisibleLights

      public int getVisibleLights()
      Specified by:
      getVisibleLights in interface LightTypeRenderer<T extends LightData & InstancedLightData>
      Returns:
      The number of lights visible last frame
    • free

      public void free()
      Specified by:
      free in interface org.lwjgl.system.NativeResource