garrysmod icon indicating copy to clipboard operation
garrysmod copied to clipboard

Outline system for entities (not halo)

Open ShadowBonnieRUS opened this issue 5 years ago • 17 comments

Maybe you know that standard halo system greatly reduces FPS if called many times for example for other colors on entities, because of blur. And halo looks like glow. I make other system with better performance and looks like outline, not like glow (and still greatly visible on big distance).

Some screenshots: image image image

I believe 28 fps is gone when drawing models to fill stencil buffer.

ShadowBonnieRUS avatar Jun 21 '19 15:06 ShadowBonnieRUS

Thanks for all the changes, I think this will now be much more efficient than halos. The code style does still need some cleaning up, though: it doesn't match the rest of the codebase. There should be spaces around operators (local List, ListSize = {}, 0), logical operators should use the C versions ([MODE] = mode || OUTLINE_MODE_BOTH), and there should be spaces between parentheses and arguments (render.SetStencilPassOperation( STENCIL_REPLACE )).

Kefta avatar Jun 21 '19 17:06 Kefta

How about just adding the PostDrawEffects hook for the outline drawing if ListSize ~= 0? This should reduce the number of hooks called. This would just be possible if there is a option to cache the ents instead of adding them every frame. Like I did here. https://github.com/TTT-2/TTT2/blob/master/lua/includes/modules/marks.lua

Alf21 avatar Oct 15 '19 18:10 Alf21

@Alf21 I don't think that's a good idea. Many hook library replacements put a huge load on hook.Add in order to make hook.Call faster. Calling one extra function and doing a length check is really not going to have any noticeable difference on performance.

@ShadowBonnieRUS Caching global functions/tables at the top of the file instead of using package.seeall will make a difference though.

Kefta avatar Oct 15 '19 18:10 Kefta

Would like to see the FPS changes after those optimizations aswell) Compared to your original halo version of course

UAVXP avatar Feb 19 '20 16:02 UAVXP

@UAVXP all this add 1 fps to me.

ShadowBonnieRUS avatar Jun 28 '20 04:06 ShadowBonnieRUS

Can't relate it's significantly faster for me

GitSparTV avatar Jun 28 '20 05:06 GitSparTV

The only small issue I've had since I've been using this library is the effect is even displayed through the player model (in comparison with the halo library). If players want to use this library as a replacement for better performance, this problem needs to be fixed.

Halo library: image Outline library: image

FlorianLeChat avatar Feb 18 '21 17:02 FlorianLeChat

the effect is even displayed through the player model

I'm personally do not think it's a much of a problem

UAVXP avatar Feb 19 '21 09:02 UAVXP

the effect is even displayed through the player model

I personally do not think it's a much of a problem

It would still be nice if it got fixed

FoksVHox avatar Feb 19 '21 09:02 FoksVHox

the effect is even displayed through the player model

I'm personally do not think it's a much of a problem

It must be fixed if this were to be merged. Better yet, make it a config option if it shows thru players.

Kefta avatar Feb 19 '21 15:02 Kefta

the effect is even displayed through the player model

I'm personally do not think it's a much of a problem

It must be fixed if this were to be merged. Better yet, make it a config option if it shows thru players.

The problem is that used IsLineOfSightClear instead of checking the depth buffer. It does not care about where render origin is. I used IsLineOfSightClear because of problems with the depth buffer when I tried to do this first time. I will try again make this with the depth fuffer.

ShadowBonnieRUS avatar Apr 12 '21 04:04 ShadowBonnieRUS

So now it looks like this. Front canister (red) uses OUTLINE_MODE_VISIBLE mode. Other canister (cyan) uses OUTLINE_MODE_NOTVISIBLE mode. image

ShadowBonnieRUS avatar Apr 12 '21 18:04 ShadowBonnieRUS

I can't seem to get the outlines to draw for some transparent props. For example:

models/props_building_details/Storefront_Template001a_Bars.mdl

models/props_junk/PlasticCrate01a.mdl

WilliamVenner avatar May 07 '21 05:05 WilliamVenner

I can't seem to get the outlines to draw for some transparent props. For example:

models/props_building_details/Storefront_Template001a_Bars.mdl

models/props_junk/PlasticCrate01a.mdl

Should be fixed. Seems render.SetBlend (0) has a bad effect on the depth buffer when rendering transparent objects.

ShadowBonnieRUS avatar Jun 10 '21 20:06 ShadowBonnieRUS

is this going anywhere? the current halo system is just absolutely awful for performance

Andrew-Eathan avatar Feb 03 '22 14:02 Andrew-Eathan

You can just include this library in your code for now, I have never had a problem in more than a year of use.

FlorianLeChat avatar Feb 03 '22 19:02 FlorianLeChat

Could be a performance option

thegrb93 avatar Feb 03 '22 22:02 thegrb93

New to E2, but looking for a way to do this but on MY playermodel to where everyone else can see it too. I've seen other people using one that does a color changing outline on them if anyone knows where something like that is at, because I am too awful to know how.

CosmoKz avatar Mar 07 '23 09:03 CosmoKz

'Broken' as of the most recent gmod update After using the outline.Add on an entity, the physgun halo effects can be seen through walls https://media.discordapp.net/attachments/589120351238225940/1125558175316312124/image.png

Rubat is inclined to believe it was one of these highlighted changes https://media.discordapp.net/attachments/589120351238225940/1125557605398482974/image.png

Edit: apparently it was caused by render.ClearDepth()

blobles-dev avatar Jul 04 '23 15:07 blobles-dev

Thickness cannot be changed to be per-outline, because of how the end outline is applied (drawing colored texture with specified offsets, 'thickness' will just increase the offsets). Maybe thickness functionality is unnecessary at all?

For render type, "SetupOutlines" should be called for each render type with parameter indicating the current render type, at the moment, 3 times per frame. It may affect performance. Or use different hook event names for each type.

I'm not sure how it would be more correct to implement this in the halo library, since on the one hand, they do the same thing, and on the other hand, they work differently.

ShadowBonnieRUS avatar Aug 04 '23 14:08 ShadowBonnieRUS

Why was this closed?

Kefta avatar Sep 08 '23 22:09 Kefta

Clearly there's an impasse in how I would expect (and I am going to assume everyone else as well) this to work, and how it actually works, in regards to the library's global settings. Given authors inability/unwillingness to conform to requested changes, I see no reason to keep this open. It will not be merged in its current state.

robotboy655 avatar Sep 09 '23 00:09 robotboy655