Legacy Lighting/Technology Recreated | Feedback?

This is a script that increases the brightness of the outdoor highlights, similar to the Legacy outdoor highlights. This is something that I’ve been working on.

If you would like to test, please add a ColorGradingEffect in Lighting with TonemapperPreset set to Retro.

local power = 2
local colorKeepVal = 1.13
local deltaMin = 0.15

local lighting = game:GetService("Lighting")

function specialArith(i,o,e)
	if typeof(i) == "Color3" then
		if o == "/" then
			return Color3.new(i.R / e, i.G / e, i.B / e)
		elseif o == "*" then
			return Color3.new(i.R * e, i.G * e, i.B * e)
		end
	end
end

function specialDelta(a,b)
	if typeof(a) == "Color3" then
		return math.abs(((a.R + a.G + a.B) / 3) - ((b.R + b.G + b.B) / 3))
	elseif typeof(a) == "Vector3" then
		return math.abs(((a.X + a.Y + a.Z) / 3) - ((b.X + b.Y + b.Z) / 3))
	end
end

game.DescendantAdded:Connect(function(v)
	task.spawn(function()
		task.wait(0.15)
		if v:IsA("Terrain") then
			local mats = Enum.Material:GetEnumItems()
			for i,b in pairs(mats) do
				local s,E = pcall(function()
					local color = v:GetMaterialColor(b)
					local e = specialArith(color, "/", (power / colorKeepVal))
					v:SetMaterialColor(b,e)
					v:SetAttribute(b.Name, e)
				end)
				if not s then warn(E) end
			end
		end
		if v:IsA("BasePart") and (v.Material ~= Enum.Material.Neon) then
			v.Color = specialArith(v["Color"], "/", (power / colorKeepVal))
			v:SetAttribute("Color", v.Color)
			pcall(function() v.UsePartColor = true end)
		end
		if v:IsA("SpecialMesh") then
			local value = v.VertexColor / (power / colorKeepVal)
			v.VertexColor = value
			v:SetAttribute("VertexColor", v.VertexColor)
		end
		if v:IsA("MeshPart") then
			if not ((v.Parent:FindFirstChildOfClass("Humanoid"))) then
				if v:FindFirstChildOfClass("SurfaceAppearance") then
					local new = v:FindFirstChildOfClass("SurfaceAppearance")
					new.ColorMap = v.TextureID
					new.Color = specialArith(new.Color, "/", (power / colorKeepVal))
					new:SetAttribute("Color", new.Color)
					v = new
				else
					local new = Instance.new('SurfaceAppearance')
					new.ColorMap = v.TextureID
					new.Parent = v
				end
			end
		end
		if v:IsA("SurfaceAppearance") then
			v.Color = specialArith(v.Color, "/", (power / colorKeepVal))
			v:SetAttribute("Color", v.Color)
		end
		if v:IsA("Decal") then
			v.Color3 = specialArith(v.Color3, "/", (power / colorKeepVal))
			v:SetAttribute("Color3", v.Color3)
		end
		if v:IsA("Texture") then
			v.Color3 = specialArith(v.Color3, "/", (power / colorKeepVal))
			v:SetAttribute("Color3", v.Color3)
		end
		if v:IsA("Clothing") then
			v.Color3 = specialArith(v.Color3, "/", (power / colorKeepVal))
			v:SetAttribute("Color3", v.Color3)
		end
		local debounce = false
		v.Changed:Connect(function(p)
			if not debounce then
				debounce = true
				if v:IsA("Terrain") then
					local mats = Enum.Material:GetEnumItems()
					for i,b in pairs(mats) do
						local s, E = pcall(function()
							local color = v:GetMaterialColor(b)
							local e = specialArith(color, "/", (power / colorKeepVal))
							if specialDelta(v:GetAttribute(b.Name), color) > deltaMin then
								v:SetMaterialColor(b,e)
							end
							v:SetAttribute(b.Name, e)
						end)
						if not s then warn(E) end
					end
				end
				if v:IsA("BasePart") and (v.Material ~= Enum.Material.Neon) then
					if p == "Color" then
						local value = specialArith(v.Color, "/", (power / colorKeepVal))
						if specialDelta(v:GetAttribute("Color"), v.Color) > deltaMin then
							v.Color = value
						end
						v:SetAttribute("Color", v.Color)
                        debounce = false
					    return
					end
				end
				if v:IsA("SpecialMesh") then
					if p == "VertexColor" then
						local value = v.VertexColor / (power / colorKeepVal)
						if specialDelta(v:GetAttribute("VertexColor"), v.VertexColor) > deltaMin then
							v.VertexColor = value
						end
						v:SetAttribute("VertexColor", v.VertexColor)
					end
				end
				if v:IsA("SurfaceAppearance") then
					if p == "Color" then
						local value = specialArith(v["Color"], "/", (power / colorKeepVal))
						if specialDelta(v:GetAttribute("Color"), v.Color) > deltaMin then
							v.Color = value
						end
						v:SetAttribute("Color", v.Color)
					end
				end
				if v:IsA("Decal") then
					if p == "Color3" then
						local value = specialArith(v["Color3"], "/", (power / colorKeepVal))
						if specialDelta(v:GetAttribute("Color3"), v.Color3) > deltaMin then
							v.Color3 = value
						end
						v:SetAttribute("Color3", v.Color3)
					end
				end
				if v:IsA("Texture") then
					if p == "Color3" then
						local value = specialArith(v["Color3"], "/", (power / colorKeepVal))
						if specialDelta(v:GetAttribute("Color3"), v.Color3) > deltaMin then
							v.Color3 = value
						end
						v:SetAttribute("Color3", v.Color3)
					end
				end
				if v:IsA("Clothing") then
					if p == "Color3" then
						local value = specialArith(v["Color3"], "/", (power / colorKeepVal))
						if specialDelta(v:GetAttribute("Color3"), v.Color3) > deltaMin then
							v.Color3 = value
						end
						v:SetAttribute("Color3", v.Color3)
					end
				end
				debounce = false
			end
		end)
	end)
end)

for i,v in pairs(workspace:GetDescendants()) do
	task.spawn(function()
		task.wait()
		if v:IsA("Terrain") then
			local mats = Enum.Material:GetEnumItems()
			for i,b in pairs(mats) do
				local s,E = pcall(function()
					local color = v:GetMaterialColor(b)
					local e = specialArith(color, "/", (power / colorKeepVal))
					v:SetMaterialColor(b,e)
					v:SetAttribute(b.Name, e)
				end)
				if not s then warn(E) end
			end
		end
		if v:IsA("BasePart") and (v.Material ~= Enum.Material.Neon) then
			v.Color = specialArith(v.Color, "/", (power / colorKeepVal))
			v:SetAttribute("Color", v.Color)
			pcall(function() v.UsePartColor = true end)
		end
		if v:IsA("SpecialMesh") then
			local value = v.VertexColor / (power / colorKeepVal)
			v.VertexColor = value
			v:SetAttribute("VertexColor", v.VertexColor)
		end
		if v:IsA("MeshPart") then
			if not ((v.Parent:FindFirstChildOfClass("Humanoid"))) then
				if v:FindFirstChildOfClass("SurfaceAppearance") then
					local new = v:FindFirstChildOfClass("SurfaceAppearance")
					new.Color = specialArith(new.Color, "/", (power / colorKeepVal))
					new:SetAttribute("Color", new.Color)
					new.Parent = v
					v = new
				else
					local new = Instance.new('SurfaceAppearance')
					new.ColorMap = v.TextureID
					new.Parent = v
				end
			end
		end
		if v:IsA("Decal") then
			v.Color3 = specialArith(v.Color3, "/", (power / colorKeepVal))
			v:SetAttribute("Color3", v.Color3)
		end
		if v:IsA("Texture") then
			v.Color3 = specialArith(v.Color3, "/", (power / colorKeepVal))
			v:SetAttribute("Color3", v.Color3)
		end
		if v:IsA("Clothing") then
			v.Color3 = specialArith(v.Color3, "/", (power / colorKeepVal))
			v:SetAttribute("Color3", v.Color3)
		end
		local debounce = false
		v.Changed:Connect(function(p)
			if not debounce then
				debounce = true
				if v:IsA("Terrain") then
					local mats = Enum.Material:GetEnumItems()
					for i,b in pairs(mats) do
						local s, E = pcall(function()
							local color = v:GetMaterialColor(b)
							local e = specialArith(color, "/", (power / colorKeepVal))
							if specialDelta(v:GetAttribute(b.Name), color) > deltaMin then
								v:SetMaterialColor(b,e)
							end
							v:SetAttribute(b.Name, e)
						end)
						if not s then warn(E) end
					end
				end
				if v:IsA("BasePart") and (v.Material ~= Enum.Material.Neon) then
					if p == "Color" then
						local value = specialArith(v.Color, "/", (power / colorKeepVal))
						if specialDelta(v:GetAttribute("Color"), v.Color) > deltaMin then
							v.Color = value
						end
						v:SetAttribute("Color", v.Color)
                        debounce = false
					    return
					end
				end
				if v:IsA("SpecialMesh") then
					if p == "VertexColor" then
						local value = v.VertexColor / (power / colorKeepVal)
						if specialDelta(v:GetAttribute("VertexColor"), v.VertexColor) > deltaMin then
							v.VertexColor = value
						end
						v:SetAttribute("VertexColor", v.VertexColor)
					end
				end
				if v:IsA("SurfaceAppearance") then
					if p == "Color" then
						local value = specialArith(v["Color"], "/", (power / colorKeepVal))
						if specialDelta(v:GetAttribute("Color"), v.Color) > deltaMin then
							v.Color = value
						end
						v:SetAttribute("Color", v.Color)
					end
				end
				if v:IsA("Decal") then
					if p == "Color3" then
						local value = specialArith(v["Color3"], "/", (power / colorKeepVal))
						if specialDelta(v:GetAttribute("Color3"), v.Color3) > deltaMin then
							v.Color3 = value
						end
						v:SetAttribute("Color3", v.Color3)
					end
				end
				if v:IsA("Texture") then
					if p == "Color3" then
						local value = specialArith(v["Color3"], "/", (power / colorKeepVal))
						if specialDelta(v:GetAttribute("Color3"), v.Color3) > deltaMin then
							v.Color3 = value
						end
						v:SetAttribute("Color3", v.Color3)
					end
				end
				if v:IsA("Clothing") then
					if p == "Color3" then
						local value = specialArith(v["Color3"], "/", (power / colorKeepVal))
						if specialDelta(v:GetAttribute("Color3"), v.Color3) > deltaMin then
							v.Color3 = value
						end
						v:SetAttribute("Color3", v.Color3)
					end
				end
				debounce = false
			end
		end)
	end)
end

lighting.Brightness *= power + (power - 1)
lighting:SetAttribute("Brightness", lighting.Brightness)
lighting.Ambient = specialArith(lighting.Ambient, "*", (power))
lighting:SetAttribute("Ambient", lighting.Ambient)
lighting.OutdoorAmbient = specialArith(lighting.OutdoorAmbient, "*", (power))
lighting:SetAttribute("OutdoorAmbient", lighting.OutdoorAmbient)
local d = false
lighting.Changed:Connect(function(p)
	if not d then
		d = true
		if p == "Brightness" then
			local value = lighting.Brightness * (power + (power - 1))
			if math.abs(value - lighting:GetAttribute("Brightness")) > (deltaMin * 10) then
				lighting.Brightness = value
			end
			lighting:SetAttribute("Brightness", lighting.Brightness)
		end
		if p == "Ambient" then
			local value = specialArith(lighting.Ambient, "*", (power / 2))
			if specialDelta(lighting:GetAttribute("Ambient"), lighting.Ambient) > (deltaMin) then
				lighting.Ambient = value
			end
			lighting:SetAttribute("Ambient", lighting.Ambient)
		end
		if p == "OutdoorAmbient" then
			local value = specialArith(lighting.OutdoorAmbient, "*", (power / 2))
			if specialDelta(lighting:GetAttribute("OutdoorAmbient"), lighting.OutdoorAmbient) > (deltaMin) then
				lighting.OutdoorAmbient = value
			end
			lighting:SetAttribute("OutdoorAmbient", lighting.OutdoorAmbient)
		end
		d = false
	end
end)

Problems

  • Terrain will appear brighter due to the colors not being updated; I still haven’t found a way to do so. (SOLVED)
  • It won’t be easy to directly read the color of most objects.
  • Rapidly changing colors (like tweened colors) might cause the colors of the said object to go wrong.
  • Some math are wrong, which can cause problems, like the game being brighter/darker.
  • Nothing else; Help me find them?

How it works:
Highlights stand out more on darker parts. This script makes all parts darker, then increases Lighting.Brightness.

Comment what do you think, where do I improve, and how to fix the said problems. thanks!

2 Likes

Please how to test this in my game?

1 Like

It can be copy and pasted on a LocalScript.

Side note, please adjust the first values.

1 Like

Hi, have you tried it? I need feedback right now.

1 Like

Yes , but with diferent light Ambient and Outdoor ambient color it became pretty brightier

1 Like

Yeah, the game being brighter/darker is an issue that I’m aware of, but I still don’t have a proper solution to it. Can you show a screenshot too?

1 Like

No ,i had to edit multiple RBX files

1 Like