roblox-lighting
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRoblox Lighting & Atmosphere
Roblox 灯光与氛围设置
Use this skill when configuring lighting, atmosphere, time of day, post-processing effects, or creating visual mood for a game.
当你需要为游戏配置灯光、氛围、时间、后期处理效果,或是营造视觉氛围时,可以使用本技能。
Lighting Service Properties
灯光服务属性
luau
local Lighting = game:GetService("Lighting")
-- Time of day (24-hour format as string)
Lighting.ClockTime = 14 -- 2 PM (numeric, 0-24)
Lighting.TimeOfDay = "14:00:00" -- same thing as string
-- Core lighting
Lighting.Brightness = 2 -- sun intensity (0-10, default 2)
Lighting.Ambient = Color3.fromRGB(70, 70, 70) -- shadow color
Lighting.OutdoorAmbient = Color3.fromRGB(128, 128, 128) -- outdoor shadow fill
Lighting.ColorShift_Top = Color3.fromRGB(0, 0, 0) -- sky color tint
Lighting.ColorShift_Bottom = Color3.fromRGB(0, 0, 0) -- ground bounce tint
-- Shadows
Lighting.GlobalShadows = true
Lighting.ShadowSoftness = 0.2 -- 0 = sharp, 1 = very soft
-- Environment
Lighting.EnvironmentDiffuseScale = 1 -- how much skybox colors affect surfaces
Lighting.EnvironmentSpecularScale = 1 -- skybox reflections on shiny surfaces
Lighting.Technology = Enum.Technology.Future -- or ShadowMap, Voxelluau
local Lighting = game:GetService("Lighting")
-- 时间(24小时制数值格式)
Lighting.ClockTime = 14 -- 下午2点(数值范围0-24)
Lighting.TimeOfDay = "14:00:00" -- 字符串格式的同一设置
-- 核心灯光参数
Lighting.Brightness = 2 -- 太阳强度(范围0-10,默认值2)
Lighting.Ambient = Color3.fromRGB(70, 70, 70) -- 阴影颜色
Lighting.OutdoorAmbient = Color3.fromRGB(128, 128, 128) -- 户外阴影填充色
Lighting.ColorShift_Top = Color3.fromRGB(0, 0, 0) -- 天空颜色色调
Lighting.ColorShift_Bottom = Color3.fromRGB(0, 0, 0) -- 地面反射色调
-- 阴影设置
Lighting.GlobalShadows = true
Lighting.ShadowSoftness = 0.2 -- 0=锐利,1=极柔和
-- 环境参数
Lighting.EnvironmentDiffuseScale = 1 -- 天空盒颜色对表面的影响程度
Lighting.EnvironmentSpecularScale = 1 -- 天空盒在光滑表面的反射程度
Lighting.Technology = Enum.Technology.Future -- 可选ShadowMap、VoxelAtmosphere
氛围设置
The object controls fog, haze, and sky color blending:
Atmosphereluau
local atmo = Instance.new("Atmosphere")
atmo.Density = 0.3 -- fog thickness (0 = clear, 1 = opaque)
atmo.Offset = 0.25 -- how high fog starts (0 = ground, 1 = sky)
atmo.Color = Color3.fromRGB(199, 199, 199) -- fog color (near)
atmo.Decay = Color3.fromRGB(92, 92, 92) -- fog color (far/horizon)
atmo.Glare = 0 -- sun glare intensity (0-10)
atmo.Haze = 0 -- atmospheric haze (0-10)
atmo.Parent = LightingAtmosphereluau
local atmo = Instance.new("Atmosphere")
atmo.Density = 0.3 -- 雾浓度(0=清晰,1=完全不透明)
atmo.Offset = 0.25 -- 雾起始高度(0=地面,1=天空)
atmo.Color = Color3.fromRGB(199, 199, 199) -- 近处雾色
atmo.Decay = Color3.fromRGB(92, 92, 92) -- 远处/地平线雾色
atmo.Glare = 0 -- 太阳眩光强度(0-10)
atmo.Haze = 0 -- 大气霾浓度(0-10)
atmo.Parent = LightingPost-Processing Effects
后期处理效果
All post-processing goes as children of Lighting:
所有后期处理效果都作为Lighting的子对象存在:
BloomEffect
BloomEffect(光晕效果)
luau
local bloom = Instance.new("BloomEffect")
bloom.Intensity = 0.5 -- glow strength (0-1)
bloom.Size = 24 -- glow spread (pixels)
bloom.Threshold = 0.8 -- brightness threshold to bloom (0-1)
bloom.Parent = Lightingluau
local bloom = Instance.new("BloomEffect")
bloom.Intensity = 0.5 -- 发光强度(0-1)
bloom.Size = 24 -- 发光扩散范围(像素)
bloom.Threshold = 0.8 -- 触发发光的亮度阈值(0-1)
bloom.Parent = LightingColorCorrectionEffect
ColorCorrectionEffect(色彩校正效果)
luau
local cc = Instance.new("ColorCorrectionEffect")
cc.Brightness = 0 -- -1 to 1
cc.Contrast = 0.1 -- -1 to 1
cc.Saturation = 0.1 -- -1 to 1 (negative = desaturated)
cc.TintColor = Color3.fromRGB(255, 255, 255) -- color overlay
cc.Parent = Lightingluau
local cc = Instance.new("ColorCorrectionEffect")
cc.Brightness = 0 -- 范围-1到1
cc.Contrast = 0.1 -- 范围-1到1
cc.Saturation = 0.1 -- 范围-1到1(负值为去饱和)
cc.TintColor = Color3.fromRGB(255, 255, 255) -- 颜色叠加层
cc.Parent = LightingDepthOfFieldEffect
DepthOfFieldEffect(景深效果)
luau
local dof = Instance.new("DepthOfFieldEffect")
dof.FarIntensity = 0.3 -- blur at far distance
dof.FocusDistance = 50 -- studs where focus is sharpest
dof.InFocusRadius = 30 -- studs of sharp focus range
dof.NearIntensity = 0 -- blur at near distance
dof.Parent = Lightingluau
local dof = Instance.new("DepthOfFieldEffect")
dof.FarIntensity = 0.3 -- 远处模糊强度
dof.FocusDistance = 50 -- 最清晰的对焦距离(studs单位)
dof.InFocusRadius = 30 -- 清晰对焦范围(studs单位)
dof.NearIntensity = 0 -- 近处模糊强度
dof.Parent = LightingSunRaysEffect
SunRaysEffect(太阳光效)
luau
local rays = Instance.new("SunRaysEffect")
rays.Intensity = 0.1 -- ray visibility (0-1)
rays.Spread = 0.5 -- ray spread angle (0-1)
rays.Parent = Lightingluau
local rays = Instance.new("SunRaysEffect")
rays.Intensity = 0.1 -- 光线可见度(0-1)
rays.Spread = 0.5 -- 光线扩散角度(0-1)
rays.Parent = LightingMood Presets
氛围预设
Bright Day (default/casual)
明亮白天(默认/休闲风格)
luau
Lighting.ClockTime = 14
Lighting.Brightness = 2
Lighting.Ambient = Color3.fromRGB(128, 128, 128)
Lighting.OutdoorAmbient = Color3.fromRGB(128, 128, 128)
-- Atmosphere: light haze
atmo.Density = 0.2
atmo.Offset = 0.5
atmo.Color = Color3.fromRGB(200, 220, 255)luau
Lighting.ClockTime = 14
Lighting.Brightness = 2
Lighting.Ambient = Color3.fromRGB(128, 128, 128)
Lighting.OutdoorAmbient = Color3.fromRGB(128, 128, 128)
-- 氛围:轻度薄雾
atmo.Density = 0.2
atmo.Offset = 0.5
atmo.Color = Color3.fromRGB(200, 220, 255)Golden Hour (warm, cinematic)
黄金时刻(温暖、电影感)
luau
Lighting.ClockTime = 17.5
Lighting.Brightness = 2
Lighting.Ambient = Color3.fromRGB(80, 60, 40)
Lighting.OutdoorAmbient = Color3.fromRGB(150, 120, 80)
Lighting.ColorShift_Top = Color3.fromRGB(255, 200, 100)
-- Atmosphere: warm fog
atmo.Density = 0.3
atmo.Offset = 0.3
atmo.Color = Color3.fromRGB(255, 200, 150)
atmo.Decay = Color3.fromRGB(200, 100, 50)
-- Post: warm tint
cc.TintColor = Color3.fromRGB(255, 240, 220)
cc.Contrast = 0.1
bloom.Intensity = 0.4
bloom.Threshold = 0.7luau
Lighting.ClockTime = 17.5
Lighting.Brightness = 2
Lighting.Ambient = Color3.fromRGB(80, 60, 40)
Lighting.OutdoorAmbient = Color3.fromRGB(150, 120, 80)
Lighting.ColorShift_Top = Color3.fromRGB(255, 200, 100)
-- 氛围:暖雾
atmo.Density = 0.3
atmo.Offset = 0.3
atmo.Color = Color3.fromRGB(255, 200, 150)
atmo.Decay = Color3.fromRGB(200, 100, 50)
-- 后期:暖色调
cc.TintColor = Color3.fromRGB(255, 240, 220)
cc.Contrast = 0.1
bloom.Intensity = 0.4
bloom.Threshold = 0.7Night (dark, moody)
夜晚(昏暗、氛围感)
luau
Lighting.ClockTime = 0
Lighting.Brightness = 0.5
Lighting.Ambient = Color3.fromRGB(30, 30, 50)
Lighting.OutdoorAmbient = Color3.fromRGB(20, 20, 40)
-- Atmosphere: dark blue fog
atmo.Density = 0.4
atmo.Offset = 0.1
atmo.Color = Color3.fromRGB(20, 20, 50)
-- Post: blue tint, low saturation
cc.TintColor = Color3.fromRGB(180, 190, 255)
cc.Saturation = -0.2
cc.Brightness = -0.05luau
Lighting.ClockTime = 0
Lighting.Brightness = 0.5
Lighting.Ambient = Color3.fromRGB(30, 30, 50)
Lighting.OutdoorAmbient = Color3.fromRGB(20, 20, 40)
-- 氛围:深蓝色雾
atmo.Density = 0.4
atmo.Offset = 0.1
atmo.Color = Color3.fromRGB(20, 20, 50)
-- 后期:蓝色调、低饱和度
cc.TintColor = Color3.fromRGB(180, 190, 255)
cc.Saturation = -0.2
cc.Brightness = -0.05Horror (oppressive, claustrophobic)
恐怖风格(压抑、幽闭)
luau
Lighting.ClockTime = 22
Lighting.Brightness = 0.3
Lighting.Ambient = Color3.fromRGB(10, 10, 15)
Lighting.OutdoorAmbient = Color3.fromRGB(5, 5, 10)
Lighting.GlobalShadows = true
Lighting.ShadowSoftness = 0.1 -- sharp shadows = scarier
-- Atmosphere: thick dark fog
atmo.Density = 0.5
atmo.Offset = 0
atmo.Color = Color3.fromRGB(10, 10, 10)
-- Post: desaturated, dark
cc.Saturation = -0.4
cc.Contrast = 0.2
cc.Brightness = -0.1
-- No bloom (bloom = cheerful)luau
Lighting.ClockTime = 22
Lighting.Brightness = 0.3
Lighting.Ambient = Color3.fromRGB(10, 10, 15)
Lighting.OutdoorAmbient = Color3.fromRGB(5, 5, 10)
Lighting.GlobalShadows = true
Lighting.ShadowSoftness = 0.1 -- 锐利阴影更恐怖
-- 氛围:浓重黑雾
atmo.Density = 0.5
atmo.Offset = 0
atmo.Color = Color3.fromRGB(10, 10, 10)
-- 后期:去饱和、昏暗
cc.Saturation = -0.4
cc.Contrast = 0.2
cc.Brightness = -0.1
-- 禁用光晕(光晕会显得欢快)Underwater
水下场景
luau
Lighting.ClockTime = 12
Lighting.Brightness = 1
Lighting.Ambient = Color3.fromRGB(20, 60, 80)
-- Atmosphere: heavy blue-green
atmo.Density = 0.7
atmo.Offset = 0
atmo.Color = Color3.fromRGB(30, 100, 120)
atmo.Decay = Color3.fromRGB(10, 40, 60)
-- Post: blue tint, blur
cc.TintColor = Color3.fromRGB(150, 200, 255)
cc.Saturation = -0.3
-- DepthOfField for murky distance
dof.FarIntensity = 0.5
dof.FocusDistance = 30
dof.InFocusRadius = 20luau
Lighting.ClockTime = 12
Lighting.Brightness = 1
Lighting.Ambient = Color3.fromRGB(20, 60, 80)
-- 氛围:浓重蓝绿色雾
atmo.Density = 0.7
atmo.Offset = 0
atmo.Color = Color3.fromRGB(30, 100, 120)
atmo.Decay = Color3.fromRGB(10, 40, 60)
-- 后期:蓝色调、模糊
cc.TintColor = Color3.fromRGB(150, 200, 255)
cc.Saturation = -0.3
-- 景深效果模拟浑浊的远景
dof.FarIntensity = 0.5
dof.FocusDistance = 30
dof.InFocusRadius = 20Sci-Fi (clean, high-tech)
科幻风格(简洁、高科技)
luau
Lighting.ClockTime = 12
Lighting.Brightness = 3
Lighting.Ambient = Color3.fromRGB(100, 100, 120)
-- Atmosphere: minimal, clean
atmo.Density = 0.1
atmo.Color = Color3.fromRGB(200, 210, 255)
-- Post: slight blue, high contrast
cc.TintColor = Color3.fromRGB(230, 240, 255)
cc.Contrast = 0.15
bloom.Intensity = 0.6
bloom.Threshold = 0.6
bloom.Size = 30luau
Lighting.ClockTime = 12
Lighting.Brightness = 3
Lighting.Ambient = Color3.fromRGB(100, 100, 120)
-- 氛围:极简、干净
atmo.Density = 0.1
atmo.Color = Color3.fromRGB(200, 210, 255)
-- 后期:轻微蓝色调、高对比度
cc.TintColor = Color3.fromRGB(230, 240, 255)
cc.Contrast = 0.15
bloom.Intensity = 0.6
bloom.Threshold = 0.6
bloom.Size = 30Dynamic Lighting
动态灯光
Day/Night Cycle
日夜循环
luau
local CYCLE_SPEED = 1 -- minutes per full day (1 = fast, 24 = real-time)
task.spawn(function()
while true do
Lighting.ClockTime += (task.wait() / 60) * (24 / CYCLE_SPEED)
if Lighting.ClockTime >= 24 then
Lighting.ClockTime -= 24
end
end
end)luau
local CYCLE_SPEED = 1 -- 完整一天的时长(分钟,1=快速,24=实时)
task.spawn(function()
while true do
Lighting.ClockTime += (task.wait() / 60) * (24 / CYCLE_SPEED)
if Lighting.ClockTime >= 24 then
Lighting.ClockTime -= 24
end
end
end)Zone-Based Lighting (indoor/outdoor)
区域灯光切换(室内/室外)
luau
-- Client: tween lighting when entering zones
local function transitionToIndoor()
TweenService:Create(Lighting, TweenInfo.new(1), {
Brightness = 1,
Ambient = Color3.fromRGB(100, 90, 70),
}):Play()
TweenService:Create(atmo, TweenInfo.new(1), {
Density = 0,
}):Play()
end
local function transitionToOutdoor()
TweenService:Create(Lighting, TweenInfo.new(1), {
Brightness = 2,
Ambient = Color3.fromRGB(128, 128, 128),
}):Play()
TweenService:Create(atmo, TweenInfo.new(1), {
Density = 0.3,
}):Play()
endluau
-- 客户端:进入区域时平滑过渡灯光
local function transitionToIndoor()
TweenService:Create(Lighting, TweenInfo.new(1), {
Brightness = 1,
Ambient = Color3.fromRGB(100, 90, 70),
}):Play()
TweenService:Create(atmo, TweenInfo.new(1), {
Density = 0,
}):Play()
end
local function transitionToOutdoor()
TweenService:Create(Lighting, TweenInfo.new(1), {
Brightness = 2,
Ambient = Color3.fromRGB(128, 128, 128),
}):Play()
TweenService:Create(atmo, TweenInfo.new(1), {
Density = 0.3,
}):Play()
endLocal Lights
局部灯光
Light Types
灯光类型
| Light | Use for | Key properties |
|---|---|---|
| Lamps, torches, orbs | Range, Brightness, Color |
| Flashlights, stage lights | Range, Angle, Face |
| Screens, panels, signs | Range, Angle, Face |
| 灯光类型 | 适用场景 | 关键属性 |
|---|---|---|
| 灯具、火把、光球 | Range(范围)、Brightness(亮度)、Color(颜色) |
| 手电筒、舞台灯光 | Range(范围)、Angle(角度)、Face(朝向) |
| 屏幕、面板、标识牌 | Range(范围)、Angle(角度)、Face(朝向) |
Practical Light Setup
实用灯光设置
luau
local function createTorch(part: BasePart)
-- Neon glow (visual only, no actual light)
part.Material = Enum.Material.Neon
part.Color = Color3.fromRGB(255, 150, 50)
-- Actual light emission
local light = Instance.new("PointLight")
light.Color = Color3.fromRGB(255, 170, 80)
light.Brightness = 2
light.Range = 20
light.Shadows = true -- expensive, use sparingly
light.Parent = part
endluau
local function createTorch(part: BasePart)
-- 霓虹发光(仅视觉效果,无实际光照)
part.Material = Enum.Material.Neon
part.Color = Color3.fromRGB(255, 150, 50)
-- 实际光照发射
local light = Instance.new("PointLight")
light.Color = Color3.fromRGB(255, 170, 80)
light.Brightness = 2
light.Range = 20
light.Shadows = true -- 性能开销大,谨慎使用
light.Parent = part
endPerformance Note
性能注意事项
- Shadows on lights are expensive. Limit to 4-6 shadow-casting lights visible at once.
- PointLight.Shadows = false is much cheaper than true.
- Use Neon material for visual glow without the performance cost of actual lights.
- On mobile, consider disabling light shadows entirely.
- 灯光阴影的性能开销大,同一时间最多保留4-6个可见的阴影投射灯光。
- 比
PointLight.Shadows = false性能开销小得多。true - 使用Neon材质实现视觉发光效果,无需实际灯光的性能开销。
- 在移动端,建议完全禁用灯光阴影。
Common Mistakes
常见错误
- Brightness too high: Values above 3 wash out everything. Start at 2.
- Atmosphere Density too high: Above 0.5 makes everything look like soup. Subtle is better.
- Too many post-processing effects: Each one costs frame time. Pick 2-3 max.
- Bloom on everything: High bloom + low threshold = everything glows. Use threshold > 0.7.
- No Ambient light: Setting Ambient to black makes shadows pitch black (unrealistic). Always have some fill.
- Forgetting Technology setting: looks best but costs more. Use
Enum.Technology.Futurefor mobile.ShadowMap - Stacking ColorCorrection: Multiple ColorCorrectionEffects multiply. Use one and tween its properties.
- Not testing on mobile: Lighting that looks great on desktop can be invisible or washed out on mobile screens.
- 亮度设置过高:数值超过3会导致画面过曝,建议从2开始调整。
- 氛围浓度设置过高:超过0.5会让画面像浓汤一样,建议保持微妙效果。
- 后期处理效果过多:每个效果都会占用帧率,最多保留2-3个。
- 全局光晕:高光晕+低阈值会让所有物体发光,建议阈值设置>0.7。
- 无环境光:将Ambient设为黑色会让阴影完全变黑(不符合现实),始终保留一定的填充光。
- 忘记设置Technology:视觉效果最佳但性能开销大,移动端建议使用
Enum.Technology.Future。ShadowMap - 叠加色彩校正:多个ColorCorrectionEffect会叠加效果,建议使用单个并通过补间调整属性。
- 未在移动端测试:在桌面端效果良好的灯光,在移动端屏幕可能会不可见或过曝。