Lighting
How the 3D scene is lit and finished: the Lighting service, lights parented to parts, materials, and the post effects and atmosphere under Lighting. In a project, the Lighting folder's contents become children of the service, so effects can be saved as files there.
Lighting service
Lighting holds the settings for the sun, sky, ambient light, fog and exposure. A new game starts at 14:00 with shadows on.
| Property | Default | Meaning |
|---|---|---|
ClockTime | 14 | Hours after midnight, wrapped into [0, 24). Moves the sun and moon. |
GeographicLatitude | 41.7333 | Degrees. Tilts the sun's path across the sky. |
Brightness | 2 | How strong sunlight and moonlight are. |
Ambient | (70, 70, 70) | Light added everywhere, indoors and out. |
OutdoorAmbient | (70, 70, 70) | Light added to surfaces facing the open sky. |
EnvironmentDiffuseScale | 1 | How much the sky lights surfaces, from 0 to 1. |
EnvironmentSpecularScale | 1 | How much the sky shows in reflections, from 0 to 1. |
ExposureCompensation | 0 | Stops of exposure, from -5 to 5. Each stop doubles the image's brightness. |
AutoExposure | true | Whether the exposure adapts to how bright the picture is, as an eye does. See How the scene is drawn. |
FogColor | (192, 192, 192) | The colour distant surfaces fade to. |
FogStart, FogEnd | 0, 100000 | Studs from the camera where fog begins and where it hides everything. |
GlobalShadows | true | Whether the sun casts shadows. |
ShadowSoftness | 0.2 | From 0 for hard shadow edges to 1 for the softest. |
GetSunDirection() returns the unit vector towards the sun. The sun rises towards -X at 6:00, is highest at 12:00, tilted towards +Z by GeographicLatitude, and sets towards +X at 18:00. GetMoonDirection() is the opposite direction. GetMinutesAfterMidnight() and SetMinutesAfterMidnight(minutes) read and set ClockTime in minutes.
Lights
A light gives off light from its parent BasePart and gives none while it has no BasePart parent. Every light has Brightness (default 1), Color (white), Enabled (true) and Shadows (false).
While Shadows is true, opaque parts and meshes within the light's Range block its light, from a shadow map drawn for it each frame: one view for a SpotLight or SurfaceLight and six, one per side of a cube, for a PointLight. The part a light is inside, usually the one holding it, does not block it. Up to 16 shadow views fit each frame, given to the shadowed lights nearest the camera that light something in view; a light that does not fit shines without shadows. A light's shadow map is drawn again only when the light, the parts within its reach or the meshes move or change, so still lights over still scenes cost almost nothing. A cone wider than 150 degrees is shadowed only within 150 degrees of it. Lights cast no shadows while Lighting.GlobalShadows is false or the project's Shadows setting is None.
| Class | Shines | Extra properties |
|---|---|---|
PointLight | In every direction from the part's centre. | Range (8 studs) |
SpotLight | In a cone from the part's centre out of its Face. | Range (16), Angle (90 degrees), Face (Front) |
SurfaceLight | In a cone out of the whole of the part's Face. | Range (8), Angle (90), Face (Front) |
Range is clamped to [0, 60] studs and Angle, the cone's full width, to [0, 180] degrees.
Materials
BasePart.Material picks how a surface reflects light, from Enum.Material. The default is Plastic. Neon glows in its own colour, and Glass, Ice, Foil and the metals are shiny. BasePart.Reflectance, from 0 to 1, makes any material mirror more of the sky.
Post effects and atmosphere
These change the finished image while they are children of Lighting. Each PostEffect has Enabled (true).
BloomEffect: what is brighter thanThreshold(2) glows, spread overSize(24, at most 56) pixels and scaled byIntensity(1).SunRaysEffect: rays of light streaming from the sun past whatever stands in front of it, when the sun is on or near the screen.Intensity(0.25) is how bright they are andSpread(1) how far across the screen they reach, both from 0 to 1.MotionBlurEffect: smears the picture along how far each part of it moved across the screen since the last frame as the camera moved, as a camera's open shutter does.Intensity(0.5, from 0 to 1) is how much of that movement it smears along. A sudden jump of the camera is not smeared. Things that move on their own are not smeared yet.DepthOfFieldEffect: blurs what is out of focus, as a camera lens does. What is withinInFocusRadius(10, from 0 to 50) studs ofFocusDistance(0.05, from 0 to 200) studs from the camera stays sharp. Beyond that, what is nearer blurs by up toNearIntensity(0.75) and what is farther by up toFarIntensity(0.75), both from 0 to 1, more the farther outside the focus it is. A blurred thing in front spreads over what is sharp behind it.ColorCorrectionEffect:Brightness(0) adds to every colour,Contrast(0) andSaturation(0) scale from no change at 0 (-1 removes all saturation), andTintColor(white) multiplies the image.VolumetricFog: fog that light scatters in, so beams of sunlight and of lights glow through it and shadows cut through them.Density(0.01, from 0 to 1) is how much of the light crossing a stud of it is scattered or absorbed,Color(white) the colour it scatters, andAnisotropy(0.6, from -0.95 to 0.95) how much it scatters forwards, which makes beams glow most when looking towards their source. It is drawn out toDistance(300, from 10 to 2000) studs from the camera. AboveHeight(0) studs it thins byFalloff(0) per stud, so aFalloffabove 0 keeps it to the ground. It is lit by the sun through its shadows, by the sky, and by the lights near the camera through their shadows.Clouds: clouds drifting across the sky in a layer from 2,000 to 4,000 studs up, where Roblox keeps them underTerrain.Cover(0.5) is how much of the sky they cover andDensity(0.7) how thick they are, both from 0 to 1, andColor(white) tints them.Enabled(true) turns them off. They are lit by the sun, brightest looking towards it, and by the sky, shade the ground beneath them from the sun, and show in reflections and in the sky's light on surfaces, which is captured again every second as they drift.Atmosphere: haze that fades the distance into the sky.Density(0.395) is how much of the distance it hides andOffset(0) how much of it sits in front of the horizon rather than over the sky, both from 0 to 1.Colortints the haze andDecaythe light passing through it far from the sun.Glare(0) brightens the haze around the sun andHaze(0) thickens it towards the horizon, both from 0 to 10.
How the scene is drawn
Surfaces are lit in linear colour with physically based shading: Lambert diffuse and GGX specular, from each material's roughness and metalness. Everything lighting a surface adds up:
- The sun or moon. The sun's light reddens as it nears the horizon. Once it sets, the moon takes over with dim blue light, and stars come out. It casts soft shadows from cascaded shadow maps by default, or exact ray-traced ones, as projects.md describes. With shadow maps, small contact shadows where things meet, too fine for the maps, are found by marching a short way towards the light through the depth of the scene, out to 200 studs.
- Up to 1024 lights: of the enabled
PointLight,SpotLightandSurfaceLights underScene, the 1024 whose reach comes closest to the camera. The view is split into a grid of clusters, 16 across, 9 down and 24 deep, and each pixel is lit only by the lights that reach its cluster, so many small lights cost little. Each fades smoothly to nothing at itsRange, measured from its middle, and casts its shadow from there. ASurfaceLightgives off light from the whole rectangle of its face, so glossy surfaces show a highlight of its shape and surfaces near it are lit as if by a panel. APointLightorSpotLightis a small sphere as wide as its part's smallest side, up to a stud, which softens its highlights. - The sky. The sky is captured into an environment map whenever it changes, such as when
ClockTimemoves. It lights surfaces as image-based lighting: diffuse light from every direction of the sky and ground (scaled byEnvironmentDiffuseScale), and reflections of it, blurred to match each surface's roughness (scaled byEnvironmentSpecularScale). Surfaces in shadow reflect less of it. A map of the opaque scene seen from straight above, 512 studs across around the camera, tells what has something over it: roofed and enclosed places get little of the sky's light,OutdoorAmbientor the sky's reflection, fading in over a few studs through doorways and under eaves. The project'sSkyOcclusionsetting turns that off. Screen-space ambient occlusion darkens the sky's light, andAmbientandOutdoorAmbient, in creases, in corners and under things, within about 2.5 studs: it finds how high the scene rises around each pixel in a few directions and how much of the sky that leaves open around the surface's normal, weighted as light falls on it. It leaves the sun and the lights alone, and partly transparent surfaces take none. The same pass gathers light bounced off the scene around each opaque surface, within about 8 studs, from what the frame before showed there, so a sunlit floor brightens the wall beside it and a red wall tints what faces it. - Reflections of the scene. Smooth opaque surfaces reflect the opaque scene around them where it is on the screen, traced through the depth of the scene and read from the frame before, fading to the sky's reflection towards the edges of the screen and on rougher surfaces. The project's
ScreenSpaceReflectionssetting turns them off. AmbientandOutdoorAmbient.OutdoorAmbientis strongest on surfaces facing up and fades to none on surfaces facing down.- Emission:
Neonglows in its own colour andForceFieldfaintly.
A partly transparent surface lets light from behind through in proportion to its Transparency, but reflects the sky and highlights at full strength, so clear glass still shines where it catches the light.
Materials other than the plastics, metals, ice and glass draw a pattern across part surfaces, in studs, so it keeps its scale on parts of any size and moves with the part: grain on concrete, sand, grass, fabric, slate and the corroded metal, mottling on marble, granite, pebble and cobblestone, wood grain, planks, bricks and diamond plate. Patterns have relief, such as recessed mortar and raised diamonds, which catches the light up close and fades out by 150 studs away. MeshParts use their own textures, with no pattern, and a Part whose Shape is not Block has no pattern either.
Part shapes
A Part is drawn in its Shape. A Ball is a sphere as wide as the part's smallest side, as raycasts take it. A Cylinder runs along the part's X axis and is as wide as the smaller of its other two sides. A Wedge is full height at the back (+Z) and slopes down to the front edge of its bottom. A CornerWedge is a pyramid on its bottom face with its peak over the right front corner, which is Gamma's choice. Shaped parts cast shadows from shadow maps but not ray-traced ones, which treat every part as its box.
The sky is drawn behind everything. By day it is the light of the sun scattered by Earth-like air, molecules and aerosols, with ozone, which turns it blue overhead and orange and red near the horizon at sunrise and sunset, and it glows around the sun; its disk, a moon and stars at night are drawn over it. Where the GPU cannot draw into floating point textures, it is a gradient from the horizon to the zenith that follows the time of day instead. Distant surfaces fade into an Atmosphere's haze, thickest along the horizon, and then into Lighting's fog. Fog that ends beyond 10,000 studs is left off.
The scene is drawn into a floating point frame buffer, with 4x multisampling where the GPU supports it, or as many samples as the project's Multisampling setting asks for (projects.md). With the project's TemporalAntiAliasing setting, on by default, the camera moves by a different fraction of a pixel each frame, the noise that dithers soft shadows, fog, reflections and ambient occlusion moves with it, and each frame is blended with the frames before where the camera's movement carries them. That smooths edges and settles the noise into a smooth result. What the frames before showed is limited to the colours around each pixel now, and dropped where its depth matches none of the depths around the pixel now, as where something moved on its own, so things that move or come into view do not leave trails. Post effects then apply in order: temporal anti-aliasing, motion blur, depth of field, volumetric fog, bloom, tone mapping with an ACES curve after ExposureCompensation, then colour correction. The default exposure is set so a mid-grey surface in the midday sun keeps about its own colour. With AutoExposure, the exposure then follows the log average brightness of the picture, weighted towards its middle: it darkens by up to 2 stops in brighter scenes than that and brightens by up to 2 in darker ones, such as indoors or at night, easing over about a second, faster towards the light than the dark. Without a BloomEffect, nothing spreads a glow: Neon is still bright, but has no halo.