Run it
Copy the script and paste it into your executor.
RunService = :()
Players = :()
Lighting = :()
Workspace = :()
Lighting.Brightness =
Lighting.Ambient = .(, , )
Lighting.OutdoorAmbient = .(, , )
Lighting.GlobalShadows =
Lighting.EnvironmentDiffuseScale =
Lighting.EnvironmentSpecularScale =
localPlayer = Players.LocalPlayer
camera = Workspace.CurrentCamera
character = localPlayer.Character localPlayer.CharacterAdded:()
sunDirection = .(, -, ).Unit
sunColor = .(, , )
sunIntensity =
skyColor = .(, , )
skyIntensity =
maxDistance =
gammaCorrection =
maxRays =
minRays =
lodDistance =
(part, position)
part:() part:()
normal = (position - part.Position).Unit
normal
relativePosition = part.CFrame:(position)
halfSize = part.Size /
normals = {
.(, , ),
.(-, , ),
.(, , ),
.(, -, ),
.(, , ),
.(, , -),
}
distances = {
.(halfSize.X - relativePosition.X),
.(-halfSize.X - relativePosition.X),
.(halfSize.Y - relativePosition.Y),
.(-halfSize.Y - relativePosition.Y),
.(halfSize.Z - relativePosition.Z),
.(-halfSize.Z - relativePosition.Z),
}
minDistance = .huge
normal = .(, , )
i = ,
distances[i] < minDistance
minDistance = distances[i]
normal = normals[i]
part.CFrame:(normal)
(part, position)
accumulatedColor = .(, , )
surfaceNormal = (part, position)
offsetPosition = position + surfaceNormal *
distanceFromCamera = (camera.CFrame.Position - position).Magnitude
numRays = maxRays
distanceFromCamera > lodDistance
numRays = .(minRays, .(maxRays * (lodDistance / distanceFromCamera)))
skySamples =
skyLight = .(, , )
i = , numRays
u = .()
v = .()
theta = .(.( - u))
phi = * .pi * v
x = .(theta) * .(phi)
y = .(theta)
z = .(theta) * .(phi)
randomDirection = .(x, y, z)
randomDirection = randomDirection.Unit
up = .(, , )
rotation = .(up:(surfaceNormal), .(up:(surfaceNormal)))
randomDirection = rotation:(randomDirection)
rayParams = RaycastParams.()
rayParams.FilterDescendantsInstances = {part, character}
rayParams.FilterType = .RaycastFilterType.Blacklist
rayParams.IgnoreWater =
result = Workspace:(offsetPosition, randomDirection * maxDistance, rayParams)
result
skyLight += skyColor
skySamples = skySamples +
skySamples >
skyLight = (skyLight / skySamples) * skyIntensity
accumulatedColor += skyLight
normalDotLight = .(, surfaceNormal:(-sunDirection))
rayParams = RaycastParams.()
rayParams.FilterDescendantsInstances = {part, character}
rayParams.FilterType = .RaycastFilterType.Blacklist
rayParams.IgnoreWater =
sunOccluded = Workspace:(offsetPosition, -sunDirection * maxDistance, rayParams)
shadowFactor =
sunOccluded
shadowFactor =
materialReflectance = part.Reflectance
materialColor = part.Color
sunIntensityFactor = normalDotLight * sunIntensity * ( - materialReflectance) * shadowFactor
sunLight = sunColor * sunIntensityFactor
sunLight = .(
sunLight.R * materialColor.R,
sunLight.G * materialColor.G,
sunLight.B * materialColor.B
)
accumulatedColor += sunLight
accumulatedColor = .(
accumulatedColor.R ^ ( / gammaCorrection),
accumulatedColor.G ^ ( / gammaCorrection),
accumulatedColor.B ^ ( / gammaCorrection)
)
accumulatedColor = .(
.(accumulatedColor.R, , ),
.(accumulatedColor.G, , ),
.(accumulatedColor.B, , )
)
accumulatedColor
parts = {}
()
parts = {}
_, obj (Workspace:())
obj:() obj.Transparency <
obj.Material = .Material.SmoothPlastic
.(parts, obj)
obj.CastShadow =
()
()
_, part (parts)
partPosition = part.Position
color = (part, partPosition)
color
part.Color = color
RunService.RenderStepped:(()
()
)
Workspace.DescendantAdded:((descendant)
descendant:() descendant.Transparency <
descendant.Material = .Material.SmoothPlastic
.(parts, descendant)
descendant.CastShadow =
)
Workspace.DescendantRemoving:((descendant)
descendant:()
i, part (parts)
part == descendant
.(parts, i)
)
(character)
_, part (character:())
part:() part.Transparency <
.(parts, part)
part.CastShadow =
(character)
localPlayer.CharacterAdded:((newCharacter)
character = newCharacter
(character)
)shaders