Class Environment
Environment management class for 3D rendering.
An environment class that manages and sends information about the current rendering settings (such as ambient color, fog, light sources, camera transformation matrices) to shaders. Extends UniformList to provide automatic uniform management and light source handling.
Fields
environment.camera | Camera object associated with the current Environment. |
environment.uniform_list | Inherited UniformList functionality. |
environment.lights | Collection of light sources organized by uniform name. |
Methods
environment:init (camera) | The public constructor. |
environment:add_light (uniform_name, light) | Adds a light source to the environment. |
environment:send_uniforms_to (shader) | Sends all environment uniforms to the specified shader. |
environment:apply_shader (shader) | Applies the shader and sends all environment uniforms to it. |
environment:send_light_sources_to (shader) | Sends light source uniforms to the shader. |
Fields
- environment.camera
-
Camera object associated with the current Environment.
- camera menori.Camera or menori.PerspectiveCamera
- environment.uniform_list
-
Inherited UniformList functionality.
Uniforms in the list are automatically sent to the shader when rendering
objects with this environment.
- uniform_list menori.UniformList
- environment.lights
-
Collection of light sources organized by uniform name.
Each key maps to an array of light objects that implement UniformList.
- lights table
Methods
- environment:init (camera)
-
The public constructor.
Initializes the environment with a camera.
Parameters:
- camera menori.Camera or menori.PerspectiveCamera Camera that will be associated with this environment
- environment:add_light (uniform_name, light)
-
Adds a light source to the environment.
Light sources are grouped by uniform name and sent to shaders as arrays.
Parameters:
- uniform_name string Name of uniform used in the shader (e.g., "directionallights", "pointlights")
- light menori.UniformList Light source object that implements UniformList
- environment:send_uniforms_to (shader)
-
Sends all environment uniforms to the specified shader.
This function can be used when creating custom display objects or shading techniques.
This method is called automatically when the environment is used in scene:render_nodes().
Parameters:
- shader love.Shader LOVE Shader object to send uniforms to
- environment:apply_shader (shader)
-
Applies the shader and sends all environment uniforms to it.
Sets the shader as current and ensures all uniforms are transmitted.
This method is called automatically when the environment is used in scene:render_nodes().
Parameters:
- shader love.Shader LOVE Shader object to apply and configure
- environment:send_light_sources_to (shader)
-
Sends light source uniforms to the shader.
Transmits all registered light sources as shader uniform arrays with count variables.
For each light group, sends a "count" uniform and individual light data.
This function can be used when creating custom display objects or shading techniques.
This method is called automatically when the environment is used in scene:rendernodes().
Parameters:
- shader love.Shader LOVE Shader object to send light uniforms to