Stencils to cut holes in things

How do I get this, basically?

http://uppix.net/5/1/e/7d6ed149aa1f8a156fdf837951d83.jpg

Photoshop?

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.
http://forum.facepunch.com/showthread.php?t=1202822

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.

[img_thumb]http://cloud.steampowered.com/ugc/596979049402475552/0038ED6187826B48F10C1756C3F69DEE73B6E457/[/img_thumb]


function ENT:DrawMask( size )

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

	local segments = 12;

	render.SetColorMaterial();

	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 ) );
		mesh.AdvanceVertex();

	end

	mesh.End();

end


function ENT:DrawInterior()
end
	

function ENT:DrawOverlay()
end


function ENT:Draw()

	render.ClearStencil();
	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 );

	self:DrawInterior();

	render.SetStencilEnable( false );

	self:DrawOverlay();

end

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

[img_thumb]http://cloud.steampowered.com/ugc/596979049402585430/CBEA139959EA70DB3709C6126FE614AA06650B86/[/img_thumb]

Actually, completely different project!
But I love you!