DrawPartialTexturedRect image stretching

I’m using an image of the map and DrawPartialTexturedRect (Code below) to create a minimap. The problem is when it tries to draw something that is out of the bounds of the image (In this case, outside of the map), it creates this artifacting/stretching

How can I fix this?

DrawPartialTexturedRect


function surface.DrawPartialTexturedRect( x, y, w, h, partx, party, partw, parth, texw, texh )
	--[[ 
		Arguments:
		x: Where is it drawn on the x-axis of your screen
		y: Where is it drawn on the y-axis of your screen
		w: How wide must the image be?
		h: How high must the image be?
		partx: Where on the given texture's x-axis can we find the image you want?
		party: Where on the given texture's y-axis can we find the image you want?
		partw: How wide is the partial image in the given texture?
		parth: How high is the partial image in the given texture?
		texw: How wide is the texture?
		texh: How high is the texture?
	]]--
	if not( x && y && w && h && partx && party && partw && parth && texw && texh ) then
		ErrorNoHalt("surface.DrawPartialTexturedRect: Missing argument!")
		return
	end
	local percX, percY = partx / texw, party / texh;
	local percW, percH = partw / texw, parth / texh;
	local vertexData = {
		{
			x = x,
			y = y,
			u = percX,
			v = percY
		},
		{
			x = x + w,
			y = y,
			u = percX + percW,
			v = percY
		},
		{
			x = x + w,
			y = y + h,
			u = percX + percW,
			v = percY + percH
		},
		{
			x = x,
			y = y + h,
			u = percX,
			v = percY + percH
		}
	}
	
	surface.DrawPoly( vertexData );
end

EDIT:

Turns out using the “noclamp” option in the Material function caused it to tile, like this:

Perhaps this could shed some light on a solution!

I don’t understand what you’re asking, but I’d love to help.
Where is the texture being created? Is it static (precached) or is it a RenderView?
Why are you trying to draw information that is out of the map?

Hi! sorry if information was a bit scarce. I am creating a minimap, and this is what happens when someone walks up to the corner of the map. The image is a precached image, which I define like so:
local CachedPic = Material(“data/mapimages/”…game.GetMap()…“600x600.jpg”, “noclamp nocull”)

Adding the last 2 parameters, noclamp nocull, seemed to make the image tile instead of stretch, which is a nicer result but not what I need

So, what I suggest is that you kind of rethink how you are approaching this.
In my approach, I’d go for something much simpler, something like a DPanel with some borders n’ stuff,
then draw a materialized rectangle ( with the map image on it ) that moves according the the player’s position.
This way, you can just simply draw a black rectangle behind it and that just shows that you’re at the edge of the map.

Alright, this would be the third time re-doing it, as I’ve learned from mistakes… (Never use Renderview for minimaps! - it causes weird skybox issues)

If you’d like, you can add me on steam and I’ll give you a hand.