Transparent viewmodels #483
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR primarily implements transparent viewmodels in the same vein as the mod found in TF2, originally described here.
To briefly explain the technical implementation; rather than changing the render amount, which causes you to see obscured model geometry and doesn't look very good, the viewmodel is rendered to a separate texture and drawn over the frame buffer. The texture is created by writing to the stencil buffer, then clearing the alpha channel of the texture according to that.
A gross part of the implementation is the repurposing of the
STUDIO_DRAWTRANSLUCENTSUBMODELSflag to control the model draw and drawn functions. This was done so I can stencil out sprites drawn with the viewmodel as it looks a lot nicer than the sprite just showing through and stenciling doesn't really deal with transparency. The naming kind makes sense but I'm happy to redefine the flag with a different name or alter the implementation a bit.This also implements IClientRenderTargets for HL2 derivative mods so I also added hl2_water_resolution and hl2_monitor_resolution convars copied over from TF2's implementation.
Screenshots
Occlusion enabled
Occlusion disabled
Occlusion enabled
Occlusion disabled
0% opacity
PR Checklist
developbranch OR targets another branch with a specific goal in mind