Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local config = {
- size = 50, -- video size (size x size)
- pixel_size = {10, 10}, -- how big will each pixel be?
- dist = 300, -- view distance
- clear_color = Color3.new(0, 0.5, 1),-- what color will a nil pixel be?
- fov = {70, 70}, -- field of view per axis
- fog_color = Color3.new(1, 1, 1), -- obvious...
- interlacing = .1, -- level of interlacing (how many rows of pixels will be skipped per frame + 1)
- fps_target = 60, -- target fps for auto_quality (auto_quality MUST be true for this to work)
- error_margin = 5, -- how far off the FPS until the interlacing level is adjusted? (auto_quality MUST be true)
- auto_quality = true, -- automatically adjust interlacing level for optimum performance
- max_interlacing = 40, -- interlacing limit,
- ignore_characters = false, -- should the camera not show characters?
- lazy_mode = false -- only updates pixels when the camera rotates or moves (may or may not improve performance)
- }
- local player = game:GetService("Players").LocalPlayer
- local camera = workspace.CurrentCamera
- local time = tick()
- local f = 0
- local fps = 99
- local pixels = {}
- local fps_counter = Instance.new("TextLabel")
- local interlace_i = Instance.new("TextLabel")
- local ignore = {}
- local colors = {}
- local endpoints = {}
- local rad, min, max, abs, floor = math.rad, math.min, math.max, math.abs, math.floor
- function Color(r, g, b)
- r = r * 255
- g = g * 255
- b = b * 255
- r = floor(r+0.5)
- g = floor(g+0.5)
- b = floor(b+0.5)
- local i = r + (g * (255^2)) + (b * (255^3))
- local color = colors[i]
- if color == nil then
- color = Color3.new(r / 255, g / 255, b / 255)
- colors[i] = color
- end
- return color
- end
- function OnUpdate()
- local start = camera.CoordinateFrame.p
- local delta = tick() - time
- time = tick()
- local t = tick() % 84000
- if t % 5 == 0 then
- if config.ignore_characters then
- ignore = {}
- for i, v in ipairs(game.Players:GetChildren()) do
- table.insert(ignore, v.Character)
- end
- else
- ignore = {}
- end
- end
- -- fps counter
- local new_fps = floor(0.5 + (1 / delta))
- if new_fps ~= fps then
- fps = new_fps
- fps_counter.Text = "FPS: " .. fps
- end
- -- auto quality
- local needs_update = config.auto_quality and abs(config.fps_target - fps) > config.error_margin
- if needs_update then
- if fps < config.fps_target then
- if config.interlacing < config.max_interlacing then
- config.interlacing = config.interlacing + 1
- end
- else
- if config.interlacing > 1 then
- config.interlacing = config.interlacing - 1
- end
- end
- interlace_i.Text = "Interlacing Level: " .. config.interlacing
- end
- -- begin capture
- for x = f, config.size - 1, config.interlacing do
- for y = 0, config.size - 1 do
- local i = y + (x * config.size)
- local direction = (camera.CoordinateFrame * CFrame.Angles(rad(-((x / config.size) - 0.5) * config.fov[1]), rad(-((y / config.size) - 0.5) * config.fov[2]), 0)).lookVector
- local do_update = endpoints[i] == nil or (endpoints[i][1] ~= direction or endpoints[i][2] ~= camera.CoordinateFrame.p)
- if not config.lazy_mode or do_update then
- if endpoints[i] == nil then
- endpoints[i] = {}
- end
- endpoints[i][1] = direction
- endpoints[i][2] = camera.CoordinateFrame.p
- local ray = Ray.new(start, direction * config.dist)
- local object, hit = workspace:FindPartOnRayWithIgnoreList(ray, ignore)
- if object ~= nil and object:IsA("Part") and pixels[i] ~= nil then
- local t = object.Transparency
- local brightness = 1 - max(0, min(1, ((start - hit).magnitude / config.dist)))
- local r, g, b = object.Color.r * (1-t), object.Color.g * (1-t), object.Color.b * (1-t)
- local fog = {
- (1 - brightness) * config.fog_color.r,
- (1 - brightness) * config.fog_color.g,
- (1 - brightness) * config.fog_color.b
- }
- pixels[i].BackgroundColor3 = Color(
- fog[1] + ((r + (config.clear_color.r * t)) * brightness),
- fog[2] + ((g + (config.clear_color.g * t)) * brightness),
- fog[3] + ((b + (config.clear_color.b * t)) * brightness)
- )
- elseif pixels[i] ~= nil then
- pixels[i].BackgroundColor3 = config.clear_color
- end
- end
- end
- end
- f = f + 1
- if f > config.interlacing then
- f = 0
- end
- end
- function Load()
- local ui = Instance.new("ScreenGui", player:WaitForChild("PlayerGui"))
- for x = 0, config.size - 1 do
- for y = 0, config.size - 1 do
- local pixel = Instance.new("Frame")
- pixel.Size = UDim2.new(0, config.pixel_size[1], 0, config.pixel_size[2])
- pixel.Position = UDim2.new(0, x * config.pixel_size[1], 0, y * config.pixel_size[2])
- pixel.BorderSizePixel = 0
- pixel.Parent = ui
- pixels[x + (y * config.size)] = pixel
- end
- end
- if config.ignore_characters then
- ignore = {}
- for i, v in ipairs(game.Players:GetChildren()) do
- table.insert(ignore, v.Character)
- end
- end
- fps_counter.Parent = ui
- fps_counter.Size = UDim2.new(0, max(64, (config.size * config.pixel_size[1])), 0, 32)
- fps_counter.Position = UDim2.new(0, 0, 0, (config.size * config.pixel_size[2]) + 0)
- fps_counter.BorderSizePixel = 0
- interlace_i.Parent = ui
- interlace_i.Size = UDim2.new(0, max(64, (config.size * config.pixel_size[1])), 0, 32)
- interlace_i.Position = UDim2.new(0, 0, 0, (config.size * config.pixel_size[2]) + 32)
- interlace_i.BorderSizePixel = 0
- interlace_i.Text = "Interlacing Level: " .. config.interlacing
- game:GetService("RunService").RenderStepped:connect(OnUpdate)
- end
- Load()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement