GMod Gamemodes & Addons - WAYWO - #28

Very nice touch with the spectator camera.

Made a scoreboard. It’s not very original and it’s still a work in progress, but I’m not too great at UI so I just ripped off the CS:S scoreboard. :zoid:

Could you please link me to the documentation on stencils you’ve (probably) been using? I’ve seen the stencil-related functions in the render library, but I don’t know anything about their workings. Looking at your video now, I want to try learning them.

I must compliment you on your absolutely impeccable shade of yellow.

http://www.facepunch.com/showthread.php?t=878986

Those are outdated a tad bit.

Here’s another example: http://forum.facepunch.com/showthread.php?t=1248618&p=39671972&viewfull=1#post39671972

the key part is the usage of render.SetStencilWriteMask(255) and render.SetStencilTestMask(255)
these are needed because of garry’s halos, which are just fancy stencils

[editline]29th September 2013[/editline]

In short, what you want to be doing, inside of a hook appropriate to your task (3D go with PostDrawOpaqueRenderables, 2D go with HUDPaint):


Clear the stencils
Enable the new stencil
     Set the masks for halo compatibility
     Set your reference value[1]
     Set various operations[2]
     Set the comparison function[3]
     Draw something to the screen to work with reference values in order to determine the filtered end drawing.[1]
     Optionally make the stencil more complex by doing more drawing and changing the comparison function/operations.
     Draw your desired object to the screen. It will only be drawn where the comparison function/operators allow.
Disable the new stencil

[1] Whenever you draw to the screen, the points of the screen that are drawn to will adopt the current reference value, should the comparison and operators allow it. The object can even be behind obstructions and count.
[2] The operations determine what points of the screen that something could be drawn to will get that reference value. For example, if the object is behind something then the ZFailOperation (see my link) will perform a stencil operation task such as STENCILOPERATION_REPLACE. STENCILOPERATION_KEEP would cause the points of the screen where the object resides behind another object to keep their original reference values. By using replace, you could draw objects through walls by replacing the reference value of that area and then drawing the object over the now selected area.
[3] The comparison function determines where things are allowed to draw, running before the operators over the points. STENCILCOMPARISONFUNCTION_ALWAYS is required before doing ANY drawing, that way the points drawn to will be accepted for the draw and be added to the stencil. Other comparison functions let you use only points that have a reference value equal to the current set reference value, greater, lower, etc.
Basically, you can draw to a range of screen to select the area the stencil draws onto (even if you make the filtering draw invisibly such as with render.SetBlend), and continue filtering the selected area by changing the comparison and operators until you’re ready to do your final draw to the screen, drawing over the selected area.

By combining clever filtering of the comparison function and your operators, you can achieve all sorts of effects.

-snip-

I was demonstrating the usage of stencils, but IIRC it is only broken with players objects, and perhaps NPCs.

halo lib is a good starting point, http://open.gl/depthstencils this was also very useful, function names are almost the same in glua

That’s correct, NPCs included. :tinfoil:

Oh, and only when used clientside. The server can set it just fine and the clients see it.

It’s not broken, you’re just using it wrong.

What’s the deal with sound.Add? None of the table parameters seem to affect the sound in game, or at least the volume.

You are using it incorrectly then. It also allows you to play multiple sounds using one alias for those sounds, instead of EmitSound(“mysound” … math.random(1,4) … “.wav”).

Yeah, but the sound will always have a huge radius even if the soundlevel is set to 0, opposed to just using the raw wav in EmitSound and changing the volume level, which works fine

Sound level 0 means play everywhere. See https://developer.valvesoftware.com/wiki/Soundscripts

Thanks for the link, but even when the sound level is at 0 it’s not global. Adjusting the sound level literally changes nothing, it’s like sound.Add doesn’t even know the paramater exists…

OK, I guess that means I’m not going crazy after all because I’ve been having that sound.Add problem too

Really your best bet would be to just control the volume with emitsound

Yeah, but then you don’t get access to things like channels and being able to use ENT.StopSound :frowning:

Sounds like something to bring up to Garry in the github.
Other than that, surface.PlaySound() on all clients with SendLua works fine for a global sound.