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:
LightTypeRenderer<T>
,AutoCloseable
,org.lwjgl.system.NativeResource
- Direct Known Subclasses:
AreaLightRenderer
,InstancedPointLightRenderer
public abstract class InstancedLightRenderer<T extends LightData & InstancedLightData>
extends Object
implements LightTypeRenderer<T>
Draws lights as instanced quads in the scene.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionInstancedLightRenderer
(int lightSize) Creates a new instanced light renderer with a resizeable light buffer. -
Method Summary
Modifier and TypeMethodDescriptionAdds the specified light to the renderer.protected abstract com.mojang.blaze3d.vertex.MeshData
void
free()
List
<? extends LightRenderHandle<T>> protected abstract @Nullable net.minecraft.client.renderer.RenderType
getRenderType
(List<? extends LightRenderHandle<T>> lights) Calculates the render type to use for the specified lights.int
void
prepareLights
(LightRenderer lightRenderer, CullFrustum frustum) Prepares the light renderer.void
renderLights
(LightRenderer lightRenderer) Renders all prepared lights with this renderer.protected abstract void
setupBufferState
(VertexArrayBuilder builder) Sets up the instanced buffer state.steal
(LightRenderHandle<T> handle) Attempts to re-add the specified handle to this renderer if invalid.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.lwjgl.system.NativeResource
close
-
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
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
-
addLight
Description copied from interface:LightTypeRenderer
Adds the specified light to the renderer.- Specified by:
addLight
in interfaceLightTypeRenderer<T extends LightData & InstancedLightData>
- Parameters:
light
- The light to add- Returns:
- A handle to the light in the renderer
-
steal
Description copied from interface:LightTypeRenderer
Attempts to re-add the specified handle to this renderer if invalid.- Specified by:
steal
in interfaceLightTypeRenderer<T extends LightData & InstancedLightData>
- Parameters:
handle
- The handle to add- Returns:
- A valid handle to this renderer
-
prepareLights
Description copied from interface:LightTypeRenderer
Prepares the light renderer.- Specified by:
prepareLights
in interfaceLightTypeRenderer<T extends LightData & InstancedLightData>
- Parameters:
lightRenderer
- The light renderer instancefrustum
- The culling view frustum
-
renderLights
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 interfaceLightTypeRenderer<T extends LightData & InstancedLightData>
- Parameters:
lightRenderer
- The light renderer instance
-
getLights
- Specified by:
getLights
in interfaceLightTypeRenderer<T extends LightData & InstancedLightData>
- Returns:
- A view of all lights in this renderer
-
getVisibleLights
public int getVisibleLights()- Specified by:
getVisibleLights
in interfaceLightTypeRenderer<T extends LightData & InstancedLightData>
- Returns:
- The number of lights visible last frame
-
free
public void free()- Specified by:
free
in interfaceorg.lwjgl.system.NativeResource
-