--[[ Combined RTX 5090 Reflection & Lighting Controller (Luau) - Mirrors nearby Players & NPCs via ViewportFrame with occlusion fade - Applies dynamic surface reflections to nearby world objects (extra-strong dark/black specular) - Strong sun rays + crisp bloom/contrast scaling with game ClockTime (no GUI, no forced sky) ]] if getgenv().RTX5090CombinedLoaded then return end getgenv().RTX5090CombinedLoaded = true local function getServiceSafe(name) if typeof(cloneref) == "function" then local ok, ref = pcall(cloneref, game:GetService(name)) if ok and ref then return ref end end return game:GetService(name) end local Players = getServiceSafe("Players") local Workspace = getServiceSafe("Workspace") local Lighting = getServiceSafe("Lighting") local RunService = getServiceSafe("RunService") local LocalPlayer = Players.LocalPlayer -- Clean up any leftovers from previous runs local function cleanLeftovers() local namesToRemove = { "RoShade_Base", "RoShade_Glass", "Physical_Mirror_Folder", "Global_SSR_Mirror_Plane", "ReflectionSurface", "CombinedReflectionGui", "CombinedReflectionControls", } for _, item in ipairs(Workspace:GetChildren()) do if table.find(namesToRemove, item.Name) then pcall(function() item:Destroy() end) end end for _, desc in ipairs(Workspace:GetDescendants()) do if desc.Name == "SSR_Reflective_Layer" or desc.Name == "RTX_Surface_Layer" then pcall(function() desc:Destroy() end) end end end cleanLeftovers() -- RTX 5090 Tuning Config local CULL_DIST = 105 local BLK_DIST = 48 local STEP2_DIST = 72 local VPF_RES_SCALE = 0.85 local OBJ_WRAP_DIST = 45 local OBJ_CLEAN_DIST = 58 local MAX_WRAPPED_PARTS = 85 local MIN_PART_SIZE = 1.1 local NPC_MAX = 6 local NPC_RANGE = 58 local NPC_DESPAWN = 72 local SCAN_IV = 0.45 local SLOW_IV = 0.35 local DIRTY_DELAY = 0.12 local FADE_T = 0.1 local AIR = Enum.Material.Air local R6 = Enum.HumanoidRigType.R6 local AIR_STATE = { [Enum.HumanoidStateType.Jumping] = true, [Enum.HumanoidStateType.Freefall] = true, } local OWN_PARTS = { LeftFoot = true, RightFoot = true, ["Left Leg"] = true, ["Right Leg"] = true, LeftLowerLeg = true, RightLowerLeg = true, } local WATCH_CLASSES = { "BasePart", "Accessory", "Clothing", "ShirtGraphic", "BodyColors", "CharacterMesh", "SurfaceAppearance", "WrapLayer", "Humanoid", } local OFFS = { Vector3.zero, Vector3.new(0.35, 0, 0), Vector3.new(-0.35, 0, 0), Vector3.new(0, 0.35, 0), Vector3.new(0, -0.35, 0), Vector3.new(0, 0, 0.35), Vector3.new(0, 0, -0.35), } -- State local fr = 0 local slotN = 0 local lastDayFactor = -1 local refs = {} local trackedPlrs = {} local npcSet = {} local npcPending = {} local wrappedParts = {} local wrappedCount = 0 local mir = {} local bl = {} local pc = {} local conns = {} local pt, gui, vpf, vcam, grd local lVs, lFov, lIT, lVis local bloom, cc, sunRays, atmosphere local function getPartLuminance(color) return (0.2126 * color.R) + (0.7152 * color.G) + (0.0722 * color.B) end local function mirrorCFrame(oc, fy) local x, y, z, r00, r01, r02, r10, r11, r12, r20, r21, r22 = oc:GetComponents() return CFrame.new(x, (2 * fy) - y, z, -r00, r01, r02, r10, -r11, -r12, -r20, r21, r22) end local function pairTree(a, b, out) local pool = {} for _, ch in ipairs(b:GetChildren()) do pool[ch.Name] = pool[ch.Name] or {} table.insert(pool[ch.Name], ch) end local used = {} for _, ch in ipairs(a:GetChildren()) do local k = ch.Name used[k] = (used[k] or 0) + 1 local m = pool[k] and pool[k][used[k]] if m and m.ClassName == ch.ClassName then if ch:IsA("BasePart") then table.insert(out, { ch, m, f = 0, tg = 0, rOn = false, vis = true }) end pairTree(ch, m, out) end end end local function calcRadius(r) local m = 4 for _, p in ipairs(r.pairs) do if p[1].Parent then local x = (p[1].Position - r.hrp.Position).Magnitude + p.qr if x > m then m = x end end end r.mrad = m + 2 end local function calcHipHeight(r) local h = r.hum if not h then return end local v = h.HipHeight + r.hrp.Size.Y * 0.5 if h.RigType == R6 then local leg = r.char:FindFirstChild("Left Leg") if leg then v = v + leg.Size.Y end end r.hh = v end local function lowestY(r) local m = math.huge for _, p in ipairs(r.pairs) do if p[1].Parent then local y = p[1].Position.Y - p.hy if y < m then m = y end end end return m ~= math.huge and m or nil end local function detachClone(r) if r.clone and r.clone.Parent then r.clone.Parent = nil end end local function removeRef(key) local r = refs[key] if not r then return end refs[key] = nil if r.npc then trackedPlrs[key] = nil end for _, cn in ipairs(r.conns) do pcall(function() cn:Disconnect() end) end if r.clone then pcall(function() r.clone:Destroy() end) end end local function buildClone(r) if r.clone then r.clone:Destroy() r.clone = nil end r.pairs = {} if not r.char or not r.char.Parent then return end r.char.Archivable = true local cln = r.char:Clone() if not cln then return end local prs = {} pairTree(r.char, cln, prs) for _, v in ipairs(cln:GetDescendants()) do if v:IsA("LuaSourceContainer") or v:IsA("Sound") or v:IsA("BillboardGui") or v:IsA("ParticleEmitter") or v:IsA("Trail") or v:IsA("Beam") or v:IsA("Light") or v:IsA("Fire") or v:IsA("Smoke") or v:IsA("Sparkles") or v:IsA("ForceField") or v:IsA("Highlight") then v:Destroy() elseif v:IsA("Humanoid") then v.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None v.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOff end end for _, p in ipairs(prs) do p[2].Anchored = true p[2].CanCollide = false p[2].CastShadow = false p[2].Material = Enum.Material.SmoothPlastic p.sz = p[1].Size p.hx = p.sz.X * 0.5 p.hy = p.sz.Y * 0.5 p.hz = p.sz.Z * 0.5 p.qr = p.sz.Magnitude * 0.5 p.own = (r.isLocal and OWN_PARTS[p[1].Name]) and true or false if p[1] == r.hrp and r.hrp.Name == "HumanoidRootPart" then p.root = true p[2].Transparency = 1 end end r.clone = cln r.pairs = prs r.scale = r.char:GetScale() r.lfy = nil r.hum = r.char:FindFirstChildOfClass("Humanoid") calcHipHeight(r) calcRadius(r) end local function syncSizes(r) if not r.char or not r.char.Parent then return end if r.scale ~= r.char:GetScale() then buildClone(r) return end for _, p in ipairs(r.pairs) do if p[1].Parent and p[1].Size ~= p.sz then p.sz = p[1].Size p[2].Size = p.sz p.hx = p.sz.X * 0.5 p.hy = p.sz.Y * 0.5 p.hz = p.sz.Z * 0.5 p.qr = p.sz.Magnitude * 0.5 end end calcHipHeight(r) calcRadius(r) end local function addRef(key, c, isNpc) if not vpf then return end if refs[key] and refs[key].char == c then return end removeRef(key) local hrp = c:WaitForChild("HumanoidRootPart", isNpc and 2 or 4) if not hrp and isNpc then hrp = c.PrimaryPart or c:FindFirstChild("Torso") or c:FindFirstChild("UpperTorso") or c:FindFirstChild("Head") end if not hrp or not vpf then return end if isNpc then if not c.Parent then return end else if not key.Parent or key.Character ~= c then return end end if refs[key] then return end slotN += 1 local r = { char = c, hrp = hrp, pairs = {}, conns = {}, dirty = false, dirtyAt = 0, isLocal = (key == LocalPlayer), npc = isNpc and true or false, mrad = 6, slot = slotN, d = 0, slow = os.clock() + math.random() * SLOW_IV, cands = {}, blk = false, step = 1, upd = true, doOcc = false, hh = 3, fyT = 0, } refs[key] = r local function onDirty(v) for _, cls in ipairs(WATCH_CLASSES) do if v:IsA(cls) then r.dirty = true r.dirtyAt = os.clock() + DIRTY_DELAY return end end end table.insert(r.conns, c.DescendantAdded:Connect(onDirty)) table.insert(r.conns, c.DescendantRemoving:Connect(onDirty)) buildClone(r) end local function trackPlayer(plr) if trackedPlrs[plr] then return end trackedPlrs[plr] = true table.insert(conns, plr.CharacterAdded:Connect(function(c) task.wait(0.25) addRef(plr, c, false) end)) table.insert(conns, plr.CharacterRemoving:Connect(function() removeRef(plr) end)) if plr.Character then task.spawn(addRef, plr, plr.Character, false) end end local function trackNpc(m) if npcSet[m] or not m:IsA("Model") then return end if Players:GetPlayerFromCharacter(m) then return end npcSet[m] = true end local function scanNpcs() if not vpf then return end local cam = Workspace.CurrentCamera if not cam then return end local cPos = cam.CFrame.Position local have = 0 local near = {} for m in pairs(npcSet) do if not m.Parent or not m:IsDescendantOf(Workspace) then npcSet[m] = nil removeRef(m) elseif Players:GetPlayerFromCharacter(m) then npcSet[m] = nil else local root = m:FindFirstChild("HumanoidRootPart") or m.PrimaryPart if root then local dist = (root.Position - cPos).Magnitude if refs[m] then if dist > NPC_DESPAWN then removeRef(m) else have += 1 end elseif dist < NPC_RANGE and not npcPending[m] then table.insert(near, { m, dist }) end end end end for _ in pairs(npcPending) do have += 1 end table.sort(near, function(a, b) return a[2] < b[2] end) for i = 1, #near do if have >= NPC_MAX then break end have += 1 local model = near[i][1] npcPending[model] = true task.spawn(function() pcall(addRef, model, model, true) npcPending[model] = nil end) end end -- Object surface reflection helpers with strong dark/black specular highlights local function isCharacterPart(part) local parent = part.Parent while parent and parent ~= Workspace do if parent:IsA("Model") then if parent:FindFirstChildOfClass("Humanoid") or Players:GetPlayerFromCharacter(parent) then return true end end parent = parent.Parent end return false end local function applyOverlayTuning(clone, baseColor, dayFactor) local lum = getPartLuminance(baseColor) local isDark = lum < 0.18 if isDark then clone.Color = Color3.fromRGB(215, 228, 248) clone.Transparency = 0.78 - (dayFactor * 0.10) clone.Reflectance = 0.78 + (dayFactor * 0.22) else clone.Color = baseColor:Lerp(Color3.fromRGB(252, 254, 255), 0.38) clone.Transparency = 0.88 - (dayFactor * 0.06) clone.Reflectance = 0.45 + (dayFactor * 0.28) end end local function wrapObjectPart(part) if wrappedCount >= MAX_WRAPPED_PARTS then return end if not part:IsA("BasePart") or part.Transparency >= 0.95 then return end local sz = part.Size if sz.X < MIN_PART_SIZE and sz.Y < MIN_PART_SIZE and sz.Z < MIN_PART_SIZE then return end if part.Name == "RTX_Surface_Layer" or part.Name == "SSR_Reflective_Layer" or part.Name == "ReflectionSurface" or part.Name == "Terrain" then return end if wrappedParts[part] or part:FindFirstChild("RTX_Surface_Layer") then return end if isCharacterPart(part) then return end pcall(function() local oldArch = part.Archivable part.Archivable = true local clone = part:Clone() part.Archivable = oldArch if not clone then return end for _, child in ipairs(clone:GetChildren()) do child:Destroy() end clone.Name = "RTX_Surface_Layer" clone.Material = Enum.Material.SmoothPlastic clone.Anchored = true clone.CanCollide = false clone.CanTouch = false clone.CanQuery = false clone.CastShadow = false if clone:IsA("MeshPart") then clone.TextureID = "" end clone.Size = sz + Vector3.new(0.012, 0.012, 0.012) clone.CFrame = part.CFrame applyOverlayTuning(clone, part.Color, math.max(0, lastDayFactor)) clone.Parent = part wrappedParts[part] = { clone = clone, baseColor = part.Color } wrappedCount += 1 end) end -- Occlusion check local function segmentBlocks(q, s) local l = q.cf:PointToObjectSpace(s) local tmin, tmax = 0, 1 local d = l.X - q.o.X if math.abs(d) < 1e-8 then if math.abs(q.o.X) > q.hx then return false end else local t1, t2 = (-q.hx - q.o.X) / d, (q.hx - q.o.X) / d if t1 > t2 then t1, t2 = t2, t1 end if t1 > tmin then tmin = t1 end if t2 < tmax then tmax = t2 end if tmin > tmax then return false end end d = l.Y - q.o.Y if math.abs(d) < 1e-8 then if math.abs(q.o.Y) > q.hy then return false end else local t1, t2 = (-q.hy - q.o.Y) / d, (q.hy - q.o.Y) / d if t1 > t2 then t1, t2 = t2, t1 end if t1 > tmin then tmin = t1 end if t2 < tmax then tmax = t2 end if tmin > tmax then return false end end d = l.Z - q.o.Z if math.abs(d) < 1e-8 then if math.abs(q.o.Z) > q.hz then return false end else local t1, t2 = (-q.hz - q.o.Z) / d, (q.hz - q.o.Z) / d if t1 > t2 then t1, t2 = t2, t1 end if t1 > tmin then tmin = t1 end if t2 < tmax then tmax = t2 end if tmin > tmax then return false end end return tmin < 0.999 end local function collectRef(key, r, now, cPos, lk) r.blk = false local valid = r.npc and (r.char.Parent ~= nil) or (key.Parent and key.Character == r.char) if not valid or not r.char.Parent or not r.hrp.Parent then removeRef(key) return end if r.dirty and now >= r.dirtyAt then r.dirty = false buildClone(r) elseif now >= r.slow then r.slow = now + SLOW_IV syncSizes(r) end if not r.clone then return end local hp = r.hrp.Position local dist = (hp - cPos).Magnitude if dist > CULL_DIST then detachClone(r) return end local h = r.hum if h then if not r.fy or (h.FloorMaterial ~= AIR and not AIR_STATE[h:GetState()]) then r.fy = hp.Y - r.hh end elseif now >= r.fyT then r.fyT = now + 0.12 r.fy = lowestY(r) or r.fy end if not r.fy or cPos.Y <= r.fy then detachClone(r) return end if r.clone.Parent ~= vpf then r.clone.Parent = vpf end r.mc = Vector3.new(hp.X, 2 * r.fy - hp.Y, hp.Z) r.d = dist r.c = hp if (r.mc - cPos):Dot(lk) < -r.mrad then return end local cBlk = r.isLocal or dist <= BLK_DIST r.step = (cBlk or dist < STEP2_DIST) and 1 or 2 r.upd = (r.step == 1) or (r.lfy == nil) or ((fr + r.slot) % r.step == 0) r.doOcc = r.upd if r.upd then local fyC = (r.fy ~= r.lfy) for i = 1, #r.pairs do local p = r.pairs[i] if p[1].Parent then local acf = p[1].CFrame if fyC or acf ~= p.lc then p.lc = acf p.mcf = mirrorCFrame(acf, r.fy) p[2].CFrame = p.mcf end if not p.root then p.base = p[1].Transparency p.vis = true if cBlk and math.max(p.base, p[1].LocalTransparencyModifier) < 0.9 then p.cf = acf p.wp = acf.Position p.o = acf:PointToObjectSpace(cPos) p.rOn = true else p.rOn = false end end else p.vis = false p.rOn = false end end r.lfy = r.fy if cBlk then r.blk = true table.insert(bl, r) end end table.insert(mir, r) end local function updateOcclusion(r, cPos) local nc = 0 local v = r.mc - cPos local vv = v:Dot(v) for k = 1, #bl do local o = bl[k] local w = o.c - cPos local t = vv > 1e-6 and math.clamp(w:Dot(v) / vv, 0, 1) or 0 local dd = v * t - w local lm = o.mrad + r.mrad if dd:Dot(dd) < lm * lm then nc += 1 r.cands[nc] = o end end for i = 1, #r.pairs do local p = r.pairs[i] if not p.root and p.vis then local tg = 0 if nc > 0 then local v2 = p.mcf.Position - cPos local vv2 = v2:Dot(v2) local npcCount = 0 for k = 1, nc do local o = r.cands[k] if not (p.own and o.isLocal) then for m = 1, #o.pairs do local q = o.pairs[m] if q.rOn then local w = q.wp - cPos local t = vv2 > 1e-6 and math.clamp(w:Dot(v2) / vv2, 0, 1) or 0 local dd = v2 * t - w local lm = q.qr + p.qr if dd:Dot(dd) < lm * lm then npcCount += 1 pc[npcCount] = q end end end end end if npcCount > 0 then for si = 1, #OFFS do local s = p.mcf:PointToWorldSpace(OFFS[si] * p.sz) for m = 1, npcCount do if segmentBlocks(pc[m], s) then tg = p.own and 0.35 or 0.95 break end end if tg > 0 then break end end end end p.tg = tg end end end local function stepFade(r, now) for i = 1, #r.pairs do local p = r.pairs[i] if not p.root then local tr if p.vis then local f, tgt = p.f, p.tg local s = math.min((now - (p.ft or now)) / FADE_T, 1) p.ft = now if f < tgt then f = math.min(f + s, tgt) elseif f > tgt then f = math.max(f - s, tgt) end p.f = f tr = p.base + (1 - p.base) * f else tr = 1 end if tr ~= p.wt then p[2].Transparency = tr p.wt = tr end end end end -- Sharp Day/Night RTX lighting with strong sun rays & highlight bloom local function setupRTXEffects() local oldDof = Lighting:FindFirstChild("RTX_DepthOfField") if oldDof then oldDof:Destroy() end pcall(function() Lighting.GlobalShadows = true Lighting.EnvironmentSpecularScale = 1 Lighting.EnvironmentDiffuseScale = 1 end) bloom = Lighting:FindFirstChild("RTX_Bloom") or Instance.new("BloomEffect") bloom.Name = "RTX_Bloom" bloom.Parent = Lighting cc = Lighting:FindFirstChild("RTX_ColorCorrection") or Instance.new("ColorCorrectionEffect") cc.Name = "RTX_ColorCorrection" cc.Parent = Lighting sunRays = Lighting:FindFirstChild("RTX_SunRays") or Instance.new("SunRaysEffect") sunRays.Name = "RTX_SunRays" sunRays.Parent = Lighting atmosphere = Lighting:FindFirstChild("RTX_Atmosphere") or Instance.new("Atmosphere") atmosphere.Name = "RTX_Atmosphere" atmosphere.Offset = 0 atmosphere.Haze = 0 atmosphere.Parent = Lighting end local function updateDayNightRTX() local ct = Lighting.ClockTime local dayFactor if ct >= 6 and ct <= 18 then dayFactor = math.sin(((ct - 6) / 12) * math.pi) else dayFactor = 0 end if math.abs(dayFactor - lastDayFactor) < 0.01 then return end lastDayFactor = dayFactor for _, entry in pairs(wrappedParts) do if entry and entry.clone and entry.clone.Parent then applyOverlayTuning(entry.clone, entry.baseColor, dayFactor) end end if bloom then bloom.Intensity = 0.48 + ((1 - dayFactor) * 0.35) bloom.Size = 9 + ((1 - dayFactor) * 4) bloom.Threshold = 1.15 - (dayFactor * 0.10) end if cc then cc.Contrast = 0.30 + ((1 - dayFactor) * 0.08) cc.Saturation = 0.18 + (dayFactor * 0.12) cc.Brightness = -0.02 + (dayFactor * 0.03) cc.TintColor = Color3.fromRGB( math.floor(245 + (dayFactor * 10)), math.floor(246 + (dayFactor * 9)), math.floor(255 - ((1 - dayFactor) * 10)) ) end if sunRays then sunRays.Intensity = 0.30 + (dayFactor * 0.45) sunRays.Spread = 0.52 end if atmosphere then atmosphere.Density = 0.025 + ((1 - dayFactor) * 0.025) atmosphere.Haze = 0 atmosphere.Glare = 0.10 + (dayFactor * 0.18) atmosphere.Color = Color3.fromRGB( math.floor(150 + (dayFactor * 95)), math.floor(165 + (dayFactor * 85)), math.floor(200 + (dayFactor * 50)) ) atmosphere.Decay = Color3.fromRGB( math.floor(100 + (dayFactor * 70)), math.floor(115 + (dayFactor * 75)), math.floor(150 + (dayFactor * 85)) ) end end -- Per-frame step local function onRenderStep() if not vpf or not pt or not vcam then return end fr += 1 local now = os.clock() local cam = Workspace.CurrentCamera if not cam then return end if pt.Parent ~= cam then pt.Parent = cam end local vs = cam.ViewportSize local cCF = cam.CFrame local cPos = cCF.Position local fov = cam.FieldOfView if vs ~= lVs or fov ~= lFov then lVs, lFov = vs, fov local fRad = math.rad(fov) local h = 2 * math.tan(fRad * 0.5) * 1.05 pt.Size = Vector3.new(h * (vs.X / math.max(vs.Y, 1)), h, 0.05) gui.CanvasSize = Vector2.new(math.floor(vs.X * VPF_RES_SCALE), math.floor(vs.Y * VPF_RES_SCALE)) vcam.FieldOfView = math.min(120, math.deg(2 * math.atan(math.tan(fRad * 0.5) * 1.05))) end pt.CFrame = cCF * CFrame.new(0, 0, -(1 + 0.05 * 0.5)) vcam.CFrame = cCF if fr % 15 == 0 then pcall(updateDayNightRTX) end local lk = cCF.LookVector local it = 0.6 + (1 - 0.6) * math.clamp((-lk.Y - 0.35) / (0.75 - 0.35), 0, 1) if it ~= lIT then vpf.ImageTransparency = it lIT = it end local shouldHide = it >= 0.995 if shouldHide == lVis or lVis == nil then lVis = not shouldHide vpf.Visible = lVis end if shouldHide then return end table.clear(mir) table.clear(bl) for key, rf in pairs(refs) do collectRef(key, rf, now, cPos, lk) end local nm = #mir local j0 = nm > 0 and (fr % nm) or 0 for jj = 1, nm do local r = mir[(jj + j0 - 1) % nm + 1] if r.doOcc then updateOcclusion(r, cPos) end if r.upd then stepFade(r, now) end end end -- Build Viewport reflection layer local function setupViewportLayer() local cam = Workspace.CurrentCamera local vs = cam and cam.ViewportSize or Vector2.new(1280, 720) pt = Instance.new("Part") pt.Name = "ReflectionSurface" pt.Anchored = true pt.CanCollide = false pt.CanTouch = false pt.CanQuery = false pt.CastShadow = false pt.Transparency = 1 pt.Size = Vector3.new(1, 1, 0.05) pt.Parent = cam gui = Instance.new("SurfaceGui") gui.Name = "CombinedReflectionGui" gui.Adornee = pt gui.Face = Enum.NormalId.Back gui.AlwaysOnTop = true gui.LightInfluence = 0 gui.ResetOnSpawn = false gui.ClipsDescendants = true gui.SizingMode = Enum.SurfaceGuiSizingMode.FixedSize gui.CanvasSize = Vector2.new(math.floor(vs.X * VPF_RES_SCALE), math.floor(vs.Y * VPF_RES_SCALE)) local uiParent = LocalPlayer:WaitForChild("PlayerGui") if typeof(gethui) == "function" then pcall(function() uiParent = gethui() end) else pcall(function() uiParent = game:GetService("CoreGui") end) end gui.Parent = uiParent vpf = Instance.new("ViewportFrame") vpf.AnchorPoint = Vector2.new(0.5, 0.5) vpf.Position = UDim2.fromScale(0.5, 0.5) vpf.Size = UDim2.fromScale(1, 1) vpf.BackgroundTransparency = 1 vpf.BorderSizePixel = 0 vpf.Ambient = Color3.new(0.75, 0.75, 0.75) vpf.LightColor = Color3.new(1, 1, 1) vpf.LightDirection = Vector3.new(0, 1, 0) vpf.Parent = gui vcam = Instance.new("Camera") vcam.Name = "ReflectionCam" if cam then vcam.CFrame = cam.CFrame vcam.FieldOfView = cam.FieldOfView end vcam.Parent = vpf vpf.CurrentCamera = vcam grd = Instance.new("UIGradient") grd.Transparency = NumberSequence.new({ NumberSequenceKeypoint.new(0, 0.25), NumberSequenceKeypoint.new(0.6, 0.55), NumberSequenceKeypoint.new(1, 0.88), }) grd.Rotation = 90 grd.Parent = vpf end -- Initialize setupRTXEffects() updateDayNightRTX() setupViewportLayer() RunService:BindToRenderStep("RTX5090CombinedStep", Enum.RenderPriority.Last.Value, onRenderStep) for _, plr in ipairs(Players:GetPlayers()) do trackPlayer(plr) end table.insert(conns, Players.PlayerAdded:Connect(function(plr) trackPlayer(plr) end)) table.insert(conns, Players.PlayerRemoving:Connect(function(plr) removeRef(plr) trackedPlrs[plr] = nil end)) table.insert(conns, Workspace.DescendantAdded:Connect(function(desc) if desc:IsA("Humanoid") and desc.Parent then trackNpc(desc.Parent) elseif wrappedCount < MAX_WRAPPED_PARTS and desc:IsA("BasePart") then task.defer(function() if not desc.Parent then return end local char = LocalPlayer.Character local root = char and char:FindFirstChild("HumanoidRootPart") if root and (desc.Position - root.Position).Magnitude <= OBJ_WRAP_DIST then wrapObjectPart(desc) end end) end end)) -- Initial throttled NPC scan task.spawn(function() local n = 0 for _, desc in ipairs(Workspace:GetDescendants()) do if desc:IsA("Humanoid") and desc.Parent then trackNpc(desc.Parent) end n += 1 if n % 1200 == 0 then task.wait() end end end) -- Periodic NPC & nearby world-object reflection loop task.spawn(function() local overlapParams = OverlapParams.new() overlapParams.FilterType = Enum.RaycastFilterType.Exclude while task.wait(SCAN_IV) do pcall(scanNpcs) local char = LocalPlayer.Character local root = char and char:FindFirstChild("HumanoidRootPart") if root then local rPos = root.Position for part, entry in pairs(wrappedParts) do if not part or not part.Parent or (part.Position - rPos).Magnitude > OBJ_CLEAN_DIST then pcall(function() if entry and entry.clone then entry.clone:Destroy() end end) wrappedParts[part] = nil wrappedCount = math.max(0, wrappedCount - 1) end end if wrappedCount < MAX_WRAPPED_PARTS then overlapParams.FilterDescendantsInstances = { char } local nearbyParts = Workspace:GetPartBoundsInRadius(rPos, OBJ_WRAP_DIST, overlapParams) for i = 1, #nearbyParts do if wrappedCount >= MAX_WRAPPED_PARTS then break end wrapObjectPart(nearbyParts[i]) end end end end end)