Garry's Mod

Garry's Mod

35 ratings
[E2] Stencil Core
   
Award
Favorite
Favorited
Unfavorite
Content Type: Addon
Addon Type: Tool
Addon Tags: Build, Scenic
File Size
Posted
Updated
4.424 KB
25 Oct, 2019 @ 7:04pm
22 Nov, 2019 @ 6:50pm
14 Change Notes ( view )

Subscribe to download
[E2] Stencil Core

Description
This addon was rewritten to improve performance and capability! Get it here: https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2944110226
Please note, this version is incompatible with the rewritten version above.

An extension for WireMod Expression 2 that allows Expression 2 to use render entities with stencils and allows some (currently) minor customization of the stencils. Also, since it works for any entities a player has access to, it can be applied to players (normally the owner), holograms, and of course props.

WireMod

Functions
stencilAddEntity - Add an entity to the specified stencil's render stencilAddReferenceEntity - Add an entity to use as the stencil stencilColor - Change the color of the pixels written when clearing the buffer (only affects _STENCIL_WHITELIST) stencilCreate - Create a stencil with the specified index stencilGetEntities - Returns the indices of all entities added to a specified stencil stencilGetReferenceEntities - Returns the indices of all entities that are used as the stencil stencilRemove - Delete a stencil stencilRemoveEntity - Remove an entity from the stencil's render stencilRemoveReferenceEntity - Remove the entities which are used as the stencil stencilType - Change the stencil preset
Convars
wire_stencils_max (10) - Maximum amount of stencil declarations per chip wire_stencils_max_entities (200) - Maximum amount of entities for the entire chip. This is not just the renderable entities, but also the reference
FAQ
Why are entities in a blacklist stencil flickering when my toolgun is out?
I'm not sure. It's a bug I hope to fix, but for right now it is not priority.

Can you use this to go through walls?
Can you shoot through these?
Can props go through them?

No*, no, and if they're nocollided.

Why can't they be used for manipulating/disabling collisions?
*Stencils are just a feature that is part of GMod Lua's render library[wiki.garrysmod.com]. If you want to use these for projects like making interiors inside solid buildings, then I recommend using Gravity Hull as it is your best choice and it is decently common.
Popular Discussions View All (1)
3
24 Mar, 2020 @ 6:48pm
Stencil examples
Spectrox
17 Comments
1gabriel5 3 Oct, 2024 @ 7:12pm 
Im new to gmod coding, Can i have the code in the 2nd picture to modify it? @cryotheum
cryotheum  [author] 6 Sep, 2022 @ 12:59am 
Thank you for giving me a heads up!
Vurv 6 Sep, 2022 @ 12:27am 
This is a notice that some functionality this extension will likely be broken by wiremod/wire#2399 if you don't convert your ``e2function``s to return proper ``Vector`` and ``Angle`` userdata rather than tables of three numbers.

This is a copy pasted message, I cba to download the addon and check myself if it does contain use of these. Feel free to delete if this is non-applicable.
cryotheum  [author] 10 Jun, 2022 @ 12:23pm 
Thank you for the advice!
kilo 10 Jun, 2022 @ 6:38am 
Thank you for your response. For now i've followed you on github to watch any progress. Good luck on your other projects. A tip i like to give anyone with loads of projects is if you've hit a block. Step away don't think about it then come back to it later. Don't burn yourself out! Good luck and i look forward to seeing your work.
cryotheum  [author] 9 Jun, 2022 @ 5:52pm 
Part 2:
Additionally, the _STENCIL_WHITELIST_MATERIAL stencil would draw a material where the stencil passed instead of clearing the buffer with a color. This was cut because when I had made this addon I was still learning and didn't know how to validate a material's safety.

Do not expect the second version of the core to come out soon, as I have a ~4 projects queued up in front of it, and most of them are big projects.
cryotheum  [author] 9 Jun, 2022 @ 5:52pm 
Part 1:
Oops... that wasn't supposed to be in the example.
That type of stencil was fundamentally impossible to design in a performant method with how I wrote this core, so I gave up. Version 2 of this core has a much more robust and optimized architecture, and I plan to let players use something similar to what the _STENCIL_RENDER_TARGET stencils could do but with the control of convars to prevent abuse.

If you're wondering what it did, originally it used a render target of the current view with a further near clipping plane where the stencil passed. This was used to make windows through world geometry that still rendered the world. Basically, Lexicality's portable window addon.
kilo 8 Jun, 2022 @ 8:02am 
How do i use: _STENCIL_RENDER_TARGET ?
It is mentioned in a comment in the example but there is no enum?
The Big Jewbowski 27 Oct, 2021 @ 11:11am 
Understandable. My server staff have been begging me to add it. If you're also interested in doing some side development for a sandbox server, let me know our other dev (you might know him) got hit with school.
cryotheum  [author] 27 Oct, 2021 @ 4:06am 
It's because I made this addon unlisted.
You don't want this in your addon collection, trust me. It's broken due to neglect. It doesn't cause script errors but it's bad enough that I am making a rewrite. The rewrite I'm making should be a lot easier for players to use, and won't have the bugs this one does. But in case you still REALLY want this in your collection, I'll make it publicly visible.