Stencils to cut holes in things

How do I get this, basically?


No, _Killburn posted that photo in WAYWO.

I was being sarcastic. Also, you would use the render library for this.

(User was banned for this post ("Not helpful" - Gran PC))

Sarcasm doesn’t help OP. Nor does a reference to a library. If you can’t supply the information he’s looking for, you shouldn’t make such awful posts.

I think this is related. I don’t think it is possible to do a clip plane on the world though. Or a stencil test for that matter.

I can’t believe garrysmod is able to do this type of stuff now. Wow

Ralle105 made a really good tutorial on stencils, you should check it out.

I did, it’s nice but it doesn’t say much more than the wiki did.

I’m guessing this is related to the question you asked me in PM? I sat down and wrote you a template for the effect you asked me about.

You just need to fill in DrawOverlay() and DrawInterior() with whatever you want to draw.


function ENT:DrawMask( size )

	local pos = self:GetPos();
	local up = self:GetUp();
	local right = self:GetRight();

	local segments = 12;


	mesh.Begin( MATERIAL_POLYGON, segments );

	for i = 0, segments - 1 do

		local rot = math.pi * 2 * ( i / segments );
		local sin = math.sin( rot ) * size;
		local cos = math.cos( rot ) * size;

		mesh.Position( pos + ( up * sin ) + ( right * cos ) );




function ENT:DrawInterior()

function ENT:DrawOverlay()

function ENT:Draw()

	render.SetStencilEnable( true );
	render.SetStencilCompareFunction( STENCIL_ALWAYS );
	render.SetStencilPassOperation( STENCIL_REPLACE );
	render.SetStencilFailOperation( STENCIL_KEEP );
	render.SetStencilZFailOperation( STENCIL_KEEP );
	render.SetStencilWriteMask( 1 );
	render.SetStencilTestMask( 1 );
	render.SetStencilReferenceValue( 1 );

	self:DrawMask( 48 );

	render.SetStencilCompareFunction( STENCIL_EQUAL );

	-- clear the inside of our mask so we have a nice clean slate to draw in.
	render.ClearBuffersObeyStencil( 0, 0, 0, 0, true );


	render.SetStencilEnable( false );



You can draw pretty much whatever you want inside DrawInterior().


Actually, completely different project!
But I love you!