Class InstancedLightRenderer<T extends Light & InstancedLight>

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

public abstract class InstancedLightRenderer<T extends Light & InstancedLight> extends Object implements LightTypeRenderer<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()
      Sets up the instanced buffer state.
    • setupRenderState

      protected abstract void setupRenderState(LightRenderer lightRenderer, List<T> lights)
      Sets up the render state for drawing all lights.
      Parameters:
      lightRenderer - The renderer instance
      lights - All lights in the order they are in the instanced buffer
    • clearRenderState

      protected abstract void clearRenderState(LightRenderer lightRenderer, List<T> lights)
      Clears the render state after drawing all lights.
      Parameters:
      lightRenderer - The renderer instance
      lights - All lights in the order they are in the instanced buffer
    • isVisible

      protected abstract boolean isVisible(T light, CullFrustum frustum)
      Checks whether the specified light can be seen in the specified frustum.
      Parameters:
      light - The light to check
      frustum - The frustum to check visibility with
      Returns:
      Whether that light is visible
    • prepareLights

      public void prepareLights(LightRenderer lightRenderer, List<T> lights, Set<T> removedLights, CullFrustum frustum)
      Description copied from interface: LightTypeRenderer
      Prepares the specified lights to be rendered.
      Specified by:
      prepareLights in interface LightTypeRenderer<T extends Light & InstancedLight>
      Parameters:
      lightRenderer - The light renderer instance
      lights - The lights to render
      removedLights - The lights that will be removed this frame
      frustum - The culling view frustum
    • renderLights

      public void renderLights(LightRenderer lightRenderer, List<T> lights)
      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 Light & InstancedLight>
      Parameters:
      lightRenderer - The light renderer instance
      lights - The lights to render
    • getVisibleLights

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

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