Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework the outline library and fix the outstanding issues with it #1628

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

WardenPotato
Copy link
Contributor

Its finally here, the rework of the outline library which started because of #1411
Ive spent quite some time on this trying over 50 different approaches, running into various setbacks each time.
Some of them got solved: Facepunch/garrysmod-issues#5744
And some didnt: Facepunch/garrysmod-requests#2308

But this is what i consider the best thats possible in gmod today in respect to functionality and performance.

This rework includes(i may have forgotten some, its been a while):

  • A switch to using the zbuffer instead of line of sight checking every single entity
  • Outline thickness option
  • Multiple render types for outlines
  • More performant drawing
  • Drawing not breaking when scopes are used in weapon addons
  • Full documentation
  • Fixed outlines being thinner on one side than the other

The comments in the code explain a lot so i hope those answer most questions.

Copy link
Member

@TimGoll TimGoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't say much about the rendering stuff, but it does look really good to me, awesome work!

Comment on lines +63 to +64
--FIXME: You can decide if you want this to be a option for users, should be adressed before merge
local enable_thin_line_workaround = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do have a performance section in the appearance menu. You could add it there if you like, enabled by default probably

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It really hinges on whether you find the appearance of them being slighty thicker fine, its super subjective but it does look better than the thin line scenarios where it can get cutoff

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you know what, if the performance is mostly similar, chose whatever you believe looks best and set it as default

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no perf difference, it just adjusts the offset by 1 pixel, theres 1 edge case where this looks worse and thats if you have a 1 pixel thick line of geometry on a model being outlined but thats exceptionally rare and even then you'd have to zoom in to notice it, the problem with lines being too thin is a lot more common and noticeable, i'll leave what looks best to you guys in this case because my opinion keeps flipping dependant on which ive been looking at longer so im kinda neutral on it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to me your discription sounds like it should be enabled

lua/ttt2/libraries/outline.lua Show resolved Hide resolved
InitializeCurrentListIfNeeded()

-- Get List and ListSize for this render type and outline thickness
local List, ListSize = GetCurrentList(), GetCurrentListSize()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variables in our lua style are always lower case - or is here a reason for this decision?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because of https://wiki.facepunch.com/gmod/list
though we could find another name

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. I'd prefer a different name then. Something like entsList, renderTargetList or so maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah i remember why i did that, theres also a global Lists and ListSize, i used shadowing locals there to make development easier keeping it portable between different parts of the module, but it does break the no uppercase for non globals rule, can adjust that if you still want it

lua/ttt2/libraries/outline.lua Outdated Show resolved Hide resolved
@TimGoll TimGoll added type/bug Something isn't working type/enhancement Enhancement or simple change to existing functionality labels Sep 22, 2024
@TimGoll TimGoll added this to the v0.14.1b milestone Sep 22, 2024
@TimGoll
Copy link
Member

TimGoll commented Sep 25, 2024

Okay, I tried tackling some of the warnings here and there is one thing I'd like you to change: List, Lists, ListSize, ListsSize are way too similar and I have no clue what they are about. Maybe make the name a bit more descriptive.
I don't know what the performance inpact would be, but it would also make sense to put it into the outline scope imho.

Once you get that done and the workflow errors are fixed, I can merge this PR

@WardenPotato
Copy link
Contributor Author

Performance impact should be zero because in the worst case i can localise the global anyways, ill get to changing the names then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working type/enhancement Enhancement or simple change to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Outline library does not behave well with non-screen-sized render targets
2 participants