function RaycastRender()for z=1,renderResolution,1 do for c=1,renderResolution,1 do local I=Vector2.new(z*(viewportSize.X/renderResolution),c*(viewportSize.Y/renderResolution))local u=cam:ScreenPointToRay(I.X,I.Y)local F=workspace:Raycast(u.Origin,u.Direction*1000)if F then local z=Instance.new("\080\097\114\116",workspace)z.Anchored=true z.Size=Vector3.new(1,1,1)z.Position=F.Position game.Debris:AddItem(z,.095)end end end end function isPositionOnScreen(z)if(z-cam.CFrame.Position).Magnitude>3000 then local c,I=cam:WorldToViewportPoint(z)local u=I and c.Z>0 local F=cam:ViewportPointToRay(c.X,c.Y,0)local P=RaycastParams.new()P.FilterType=Enum.RaycastFilterType.Blacklist local S=workspace:Raycast(F.Origin,F.Direction*1000,P)local R=u and not S return R else return true end end
-- functions bruv

function RaycastRender()
	for x = 1, renderResolution do
		for y = 1, renderResolution do
			local currentScreenPos =
				Vector2.new(x * (viewportSize.X / renderResolution), y * (viewportSize.Y / renderResolution))
			local screenRay = cam:ScreenPointToRay(currentScreenPos.X, currentScreenPos.Y)
			local RayCast = workspace:Raycast(screenRay.Origin, screenRay.Direction * 1000)
			if RayCast then
				local Part = Instance.new("Part", workspace)
				Part.Anchored = true
				Part.Size = Vector3.new(1, 1, 1)
				Part.Position = RayCast.Position
				game.Debris:AddItem(Part, 0.095)
			end
		end
	end
end

function isPositionOnScreen(position)
	if (position - cam.CFrame.Position).Magnitude > 3000 then
		-- Check if on screen:
		local vector, inViewport = cam:WorldToViewportPoint(position)
		local onScreen = inViewport and vector.Z > 0

		-- Raycast outward:
		local ray = cam:ViewportPointToRay(vector.X, vector.Y, 0)
		local raycastParams = RaycastParams.new()
		raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
		--raycastParams.FilterDescendantsInstances = {game.Players.LocalPlayer.Character}
		local raycastResult = workspace:Raycast(ray.Origin, ray.Direction * 1000, raycastParams)

		-- Final check:
		local isVisible = onScreen and not raycastResult
		return isVisible
	else
		return true
	end
end
