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


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, .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
