HUD Layers/Cuts/Masks.

Hey.

Basically, I’ve seen many people “cutting” the HUD, or making layers, I don’t really know how it works, and wonder if you could help.
I’ll describe what I mean with a picture:

You can see in the picture, that the rectangle is cutting out after the edge of the circle, How would I do it in LUA? And is it possible to do so with surface/draw libraries?

Thanks for your time.

Im not sure if you can use circular masks in gmod.

You can try surface.DrawPoly or render.SetScissorRect

EDIT: Maybe stencils can help, but i’m not sure how to use them at all or even if they’re relevant to your question.

Yeah, you should use stencils to accomplish what you’ve drawn.
http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexd0aa.html

Stencils ? Why ? You can just use UV texture.

Care to explain what a UV texture is? I’m interested. :slight_smile:

-snip-

UVs are texture mapping coordinates, most commonly used in modeling, but it can also used in 2D to rotate. texture without rotating the rectangle for example. They are used in surface.DrawPoly and surface.DrawTexturedRectUV. You can Google for more info.

Basically when you draw a textured polygon on the screen, each point has UV coordinates attributed to it. UV coordinates basically determine which part of the texture will be “attached” to that point. When you use a function like surface.DrawTexturedRect, the top left corner of the rectangle has (0,0) as its UV coordinates, and the bottom right corner has (1,1), which correspond respectively to the top left and bottom right corners of a texture. That results in the whole texture fitting inside the rectangle.

Now if you use surface.DrawPoly, you can input your own points with their respective UV coordinates, so basically you have full control over which region of the texture is going to appear within your polygon.

It’s not a good solution for the rectangle-in-circle image he posted though. Normally, Source supports a special blend mode on textures which allows you to use them as texture masks (it’s not specific to Garry’s Mod) and TF2 notably uses it on control point progress bars. However Valve seems to have broken this feature a long time ago for all Source games and never fixed it.

There are other ways to achieve such an effect though, but first maybe you should explain what you’re trying to do exactly.