-
Notifications
You must be signed in to change notification settings - Fork 810
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
Make all post-processing conditional #2173
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,22 +58,26 @@ function DrawBloom( darken, multiply, sizex, sizey, passes, color, colr, colg, c | |
|
||
end | ||
|
||
--[[--------------------------------------------------------- | ||
The function to draw the bloom (called from the hook) | ||
-----------------------------------------------------------]] | ||
hook.Add( "RenderScreenspaceEffects", "RenderBloom", function() | ||
cvars.AddChangeCallback( "pp_bloom", function( _, _, newValue ) | ||
|
||
-- No bloom for crappy gpus | ||
|
||
if ( !render.SupportsPixelShaders_2_0() ) then return end | ||
if ( !pp_bloom:GetBool() ) then return end | ||
if ( !GAMEMODE:PostProcessPermitted( "bloom" ) ) then return end | ||
|
||
DrawBloom( pp_bloom_darken:GetFloat(), pp_bloom_multiply:GetFloat(), | ||
if ( newValue != "0" ) then | ||
hook.Add( "RenderScreenspaceEffects", "RenderBloom", function() | ||
|
||
DrawBloom( pp_bloom_darken:GetFloat(), pp_bloom_multiply:GetFloat(), | ||
pp_bloom_sizex:GetFloat(), pp_bloom_sizey:GetFloat(), | ||
pp_bloom_passes:GetFloat(), pp_bloom_color:GetFloat(), | ||
pp_bloom_color_r:GetFloat() / 255, pp_bloom_color_g:GetFloat() / 255, pp_bloom_color_b:GetFloat() / 255 ) | ||
|
||
end) | ||
else | ||
hook.Remove( "RenderScreenspaceEffects", "RenderBloom" ) | ||
end | ||
|
||
end ) | ||
|
||
list.Set( "PostProcess", "#bloom_pp", { | ||
|
@@ -113,4 +117,4 @@ list.Set( "PostProcess", "#bloom_pp", { | |
|
||
end | ||
|
||
} ) | ||
} ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary change. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,8 @@ function DOF_Kill() | |
|
||
DOFModeHack( false ) | ||
|
||
hook.Remove( "Think", "DOFThink" ) | ||
|
||
end | ||
|
||
function DOF_Start() | ||
|
@@ -43,14 +45,14 @@ function DOF_Start() | |
|
||
DOFModeHack( true ) | ||
|
||
end | ||
hook.Add( "Think", "DOFThink", function() | ||
|
||
hook.Add( "Think", "DOFThink", function() | ||
DOF_SPACING = pp_dof_spacing:GetFloat() | ||
DOF_OFFSET = pp_dof_initlength:GetFloat() | ||
|
||
DOF_SPACING = pp_dof_spacing:GetFloat() | ||
DOF_OFFSET = pp_dof_initlength:GetFloat() | ||
end) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary change that does not conform to the style guidelines: |
||
|
||
end ) | ||
end | ||
|
||
cvars.AddChangeCallback( "pp_dof", function( name, oldvalue, newvalue ) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,9 +174,9 @@ end | |
-- | ||
if ( engine.IsPlayingDemo() ) then return end | ||
|
||
hook.Add( "PostRender", "RenderFrameBlend", function() | ||
local function RenderFrameBlend() | ||
|
||
if ( !frame_blend.IsActive() ) then return end | ||
if ( !frame_blend.IsActive() ) then hook.Remove( "RenderFrameBlend", "RenderFrameBlend" ) return end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this necessary? |
||
|
||
if ( !frame_blend.ShouldSkipFrame() ) then | ||
render.CopyRenderTargetToTexture( texFB ) | ||
|
@@ -186,6 +186,18 @@ hook.Add( "PostRender", "RenderFrameBlend", function() | |
frame_blend.AddFrame() | ||
frame_blend.DrawPreview() | ||
|
||
end | ||
|
||
cvars.AddChangeCallback( "pp_fb", function( _, _, newValue ) | ||
|
||
if ( !GAMEMODE:PostProcessPermitted( "fb" ) ) then return end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
|
||
if ( newValue != "0" ) then | ||
hook.Add( "PostRender", "RenderFrameBlend", RenderFrameBlend ) | ||
else | ||
hook.Remove( "RenderFrameBlend", "RenderFrameBlend" ) | ||
end | ||
|
||
end ) | ||
|
||
list.Set( "PostProcess", "#frame_blend_pp", { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -328,18 +328,6 @@ function RenderSuperDoF( ViewOrigin, ViewAngles, ViewFOV ) | |
|
||
end | ||
|
||
hook.Add( "RenderScene", "RenderSuperDoF", function( ViewOrigin, ViewAngles, ViewFOV ) | ||
|
||
if ( !IsValid( SuperDOFWindow ) ) then return end | ||
|
||
-- Don't render it when the console is up | ||
if ( FrameTime() == 0 ) then return end | ||
|
||
RenderSuperDoF( ViewOrigin, ViewAngles, ViewFOV ) | ||
return true | ||
|
||
end ) | ||
|
||
concommand.Add( "pp_superdof", function() | ||
|
||
Status = "Preview" | ||
|
@@ -354,23 +342,35 @@ concommand.Add( "pp_superdof", function() | |
SuperDOFWindow:MakePopup() | ||
SuperDOFWindow:PositionMyself() | ||
|
||
end ) | ||
hook.Add( "RenderScene", "RenderSuperDoF", function( ViewOrigin, ViewAngles, ViewFOV ) | ||
|
||
hook.Add( "GUIMousePressed", "SuperDOFMouseDown", function( mouse ) | ||
if ( !IsValid( SuperDOFWindow ) ) then hook.Remove( "RenderScene", "RenderSuperDoF" ) return end | ||
|
||
if ( !IsValid( SuperDOFWindow ) ) then return end | ||
-- Don't render it when the console is up | ||
if ( FrameTime() == 0 ) then return end | ||
|
||
vgui.GetWorldPanel():MouseCapture( true ) | ||
FocusGrabber = true | ||
RenderSuperDoF( ViewOrigin, ViewAngles, ViewFOV ) | ||
return true | ||
|
||
end ) | ||
end ) | ||
|
||
hook.Add( "GUIMousePressed", "SuperDOFMouseDown", function( mouse ) | ||
|
||
if ( !IsValid( SuperDOFWindow ) ) then hook.Remove( "GUIMousePressed", "SuperDOFMouseDown" ) return end | ||
|
||
vgui.GetWorldPanel():MouseCapture( true ) | ||
FocusGrabber = true | ||
|
||
end ) | ||
|
||
hook.Add( "GUIMouseReleased", "SuperDOFMouseUp", function( mouse ) | ||
|
||
hook.Add( "GUIMouseReleased", "SuperDOFMouseUp", function( mouse ) | ||
if ( !IsValid( SuperDOFWindow ) ) then hook.Remove( "GUIMouseReleased", "SuperDOFMouseUp" ) return end | ||
|
||
if ( !IsValid( SuperDOFWindow ) ) then return end | ||
vgui.GetWorldPanel():MouseCapture( false ) | ||
FocusGrabber = false | ||
|
||
vgui.GetWorldPanel():MouseCapture( false ) | ||
FocusGrabber = false | ||
end ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This entire file is a mess. See previous comments. I also think this can be all done better, such as removing the hooks from |
||
|
||
end ) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing it this way introduces a regression where the result of
GAMEMODE:PostProcessPermitted
is not updated live.I can understand
SupportsPixelShaders_2_0
being a static thing and can be moved outside of the hook.I also think it's a better idea to make a the hook a local function and reference that in the
cvars.AddChangeCallback
callback, rather than nesting functions like this.