Docs

SkyBox

Inherits: EntityHandle
C++ type: SkyBox

Cubemap sky rendering and the source environment for image-based lighting (IBL).

When a Sky entity has a valid cubemap texture, the engine generates irradiance and prefiltered specular environment maps from it. Meshes with Receive IBL enabled on their Mesh component use those maps for reflections and indirect diffuse lighting.

Editor-only component fields

These are edited on the Sky component in the Properties window and serialized with the scene (not yet exposed on the SkyBox script class):

Field Default Purpose
visible true Draw the sky background. When false, the sky is hidden but IBL maps are still built from the texture.
texture — Cubemap source (six faces or single file).
color white Linear RGBA tint.
rotation 0 Y-axis rotation in degrees.

Use Visible = false for invisible HDR environments that only drive reflections.

Properties

Name Languages
color C++ | Lua
alpha C++ | Lua
rotation C++ | Lua
customShader C++ | Lua

Methods

Name Languages
setTextures C++ | Lua
setTexture C++ | Lua
setTexturePositiveX C++ | Lua
setTextureNegativeX C++ | Lua
setTexturePositiveY C++ | Lua
setTextureNegativeY C++ | Lua
setTexturePositiveZ C++ | Lua
setTextureNegativeZ C++ | Lua
setColor C++ | Lua
setShaderUniform C++ | Lua
getShaderUniform C++ | Lua
removeShaderUniform C++ | Lua

Example

SkyBox sky(&scene);
// faces in +X, -X, +Y, -Y, +Z, -Z order
sky.setTextures(
    "sky/px.png", "sky/nx.png",
    "sky/py.png", "sky/ny.png",
    "sky/pz.png", "sky/nz.png");
sky.setRotation(15.0f);
local sky = SkyBox(scene)
-- faces in +X, -X, +Y, -Y, +Z, -Z order
sky:setTextures(
    "sky/px.png", "sky/nx.png",
    "sky/py.png", "sky/ny.png",
    "sky/pz.png", "sky/nz.png")
sky.rotation = 15

Enable Receive IBL on meshes that should reflect this environment. See Rendering Pipeline — IBL.

Method details


customShader

  • Setter: void setCustomShader(const std::string& path)
  • Getter: std::string getCustomShader() const

Project-relative base path of a forked shader ("shaders/dayNight" resolves to shaders/dayNight.vert and shaders/dayNight.frag, or "a.vert|b.frag" names the files separately). Empty (default) uses the scene default shader for this type, or the engine built-in. Changing it reloads the component. Same semantics as Mesh.customShader; see Custom Shaders.


setShaderUniform

  • void setShaderUniform(const std::string& name, const Vector4& value)
  • void setShaderUniform(const std::string& name, const Vector3& value)
  • void setShaderUniform(const std::string& name, const Vector2& value)
  • void setShaderUniform(const std::string& name, float value)
  • Vector4 getShaderUniform(const std::string& name) const
  • bool removeShaderUniform(const std::string& name)

Values for the members of the custom shader's u_vs_customParams / u_fs_customParams blocks, by member name. Setting a value only rewrites the uploaded block, so it can run every frame; a member with no value reads zero, or the scene's value under a scene default shader, and time (seconds since startup) and resolution (render target size) are reserved for the engine. Same semantics as Mesh.setShaderUniform; see Custom Shaders — Shader uniforms.

sky.setCustomShader("shaders/dayNight");
sky.setShaderUniform("strength", 0.8f);
sky.setShaderUniform("glowColor", Vector4(1.0f, 0.8f, 0.2f, 1.0f));
sky.customShader = "shaders/dayNight"
sky:setShaderUniform("strength", 0.8)
sky:setShaderUniform("glowColor", Vector4(1, 0.8, 0.2, 1))

See also