Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wait(1)
- local Tool = Instance.new("Tool", owner.Backpack)
- Tool.Name = "Renderer"
- local handle = Instance.new("Part", Tool)
- handle.Name = "Handle"
- handle.Size = Vector3.new(1, 1, 1)
- local base = 15
- local height = 15
- local distance = 200
- local r_gradient = .15
- local size = Vector3.new(.1, .1, .01)
- function Setvecmag(v, m)
- return v*(m/v.Magnitude)
- end
- function Reflect(pixel, ray, color, p, r)
- if ray.Instance.Reflectance ~= 0 then
- local dist = ray.Distance
- local vec = (ray.Position - pixel)
- local dir = vec - 2 * vec:Dot(ray.Normal) * ray.Normal
- local r_ray = Raycast(ray.Position, dir.Unit*(distance-dist), p)
- local r_ray_color
- local r_color
- if r_ray then
- --local d = Instance.new("SpawnLocation", script:FindFirstChildOfClass("WorldModel"))
- --d.Anchored = true
- --d.Position = r_ray.Position
- --d.Size = Vector3.new(1,1,1)
- r_ray_color = r_ray.Instance.Color
- r_color = ray.Instance.Color:Lerp(r_ray_color, ray.Instance.Reflectance)
- if (r_ray.Instance.Reflectance ~= 0) then
- task.wait(.01)
- return Reflect(r_ray.Position, r_ray, r_color, p, r+1)
- end
- return r_ray, r_color, r
- end
- if r_ray == nil then
- return ray, color, r
- end
- end
- return ray, ray.Instance.Color, r
- end
- function Shadow(ray, color, max)
- max = max or 0
- local sundir = game:GetService("Lighting"):GetSunDirection()
- local shadowtest = Raycast(ray.Position, sundir*903249)
- if shadowtest then
- if not (ray.Instance == shadowtest.Instance) then
- return Colormult(color, .5)
- end
- end
- return Colormult(color, math.max(1-getVectorAngles(game:GetService("Lighting"):GetSunDirection(), ray.Normal)/math.pi, max))
- end
- function clearRenders()
- script:FindFirstChild("WorldModel"):Destroy()
- end
- function getVectorAngles(v1, v2)
- return math.acos(v1:Dot(v2)/(v1.Magnitude * v2.Magnitude))
- end
- function Raycast(start, dir, p)
- local ray = workspace:Raycast(start, dir, p)
- if ray then
- return ray
- end
- end
- function ColorLerp(c1, c2, t)
- return c1:Lerp(c2, t)
- end
- function Colormult(color, m)
- return Color3.new(color.R*m, color.G*m, color.B*m)
- end
- function makeBlock(x, y, parent)
- local c_pixel = Instance.new("SpawnLocation", parent)
- local pos = handle.CFrame:ToWorldSpace(CFrame.new(Vector3.new(x - base/2, y - 3.7, -.51)))
- local params = RaycastParams.new()
- params.FilterDescendantsInstances = {script}
- params.FilterType = Enum.RaycastFilterType.Blacklist
- local ray = Raycast(pos.Position, pos.LookVector*distance, params)
- c_pixel.Size = size
- c_pixel.Locked = true
- c_pixel.CFrame = pos
- c_pixel.Anchored = true
- c_pixel.Enabled = false
- if ray ~= nil then
- local r_ray, r_color, reflections = Reflect(c_pixel.Position, ray, ray.Instance.Color, params, 1)
- if r_ray == ray then
- c_pixel.Color = Colormult(Shadow(ray, ray.Instance.Color:Lerp(Color3.new(.5, .5, 1), ray.Instance.Reflectance), .35), 1-reflections/20)
- c_pixel.Material = "SmoothPlastic"
- end
- if r_ray ~= ray then
- c_pixel.Color = Colormult(Shadow(r_ray, r_color, .35), 1-reflections/20)
- end
- else
- c_pixel.Color = Color3.new(.5, .5, 1)
- c_pixel.Material = "SmoothPlastic"
- end
- end
- function onClick()
- local wmodel = Instance.new("WorldModel", script)
- handle.Anchored = true
- for x = 0, base, size.X do
- for y = 0, height, size.Y do
- local s, e = pcall(function() makeBlock(x, y, wmodel) end)
- if e then
- wait(1)
- pcall(function() makeBlock(x, y, wmodel) end)
- end
- end
- task.wait(0.05)
- end
- handle.Anchored = false
- end
- Tool.Activated:Connect(onClick)
- owner.Chatted:Connect(function(msg)
- if string.lower(msg) == "%clr" then
- clearRenders()
- end
- end)
Add Comment
Please, Sign In to add comment