Permalink
Browse files

Minor updates to Post Processing Effects

* Added presets for all PP effects
* All convars now save over sessions
  • Loading branch information...
1 parent 6262886 commit aafc9bcd0113eb29e62e9e5b761f39b2e26d7ef0 @robotboy655 robotboy655 committed Mar 8, 2014
@@ -1,5 +1,4 @@
-
local mat_Downsample = Material( "pp/downsample" )
local mat_Bloom = Material( "pp/bloom" )
local mat_BlurX = Material( "pp/blurx" )
@@ -12,17 +11,17 @@ mat_Downsample:SetTexture( "$fbtexture", render.GetScreenEffectTexture() )
--[[---------------------------------------------------------
Register the convars that will control this effect
------------------------------------------------------------]]
+-----------------------------------------------------------]]
local pp_bloom = CreateClientConVar( "pp_bloom", "0", true, false ) -- On/Off
-local pp_bloom_darken = CreateClientConVar( "pp_bloom_darken", "0.65", false, false ) -- Decides the strength of the bloom
-local pp_bloom_multiply = CreateClientConVar( "pp_bloom_multiply", "2.0", false, false ) -- Decides the strength of the bloom
-local pp_bloom_sizex = CreateClientConVar( "pp_bloom_sizex", "9.0", false, false ) -- Horizontal blur size
-local pp_bloom_sizey = CreateClientConVar( "pp_bloom_sizey", "9.0", false, false ) -- Vertical blur size
-local pp_bloom_color = CreateClientConVar( "pp_bloom_color", "1.0", false, false )
-local pp_bloom_color_r = CreateClientConVar( "pp_bloom_color_r", "255", false, false )
-local pp_bloom_color_g = CreateClientConVar( "pp_bloom_color_g", "255", false, false )
-local pp_bloom_color_b = CreateClientConVar( "pp_bloom_color_b", "255", false, false )
-local pp_bloom_passes = CreateClientConVar( "pp_bloom_passes", "1", false, false )
+local pp_bloom_darken = CreateClientConVar( "pp_bloom_darken", "0.65", true, false ) -- Decides the strength of the bloom
+local pp_bloom_multiply = CreateClientConVar( "pp_bloom_multiply", "1.0", true, false ) -- Decides the strength of the bloom
+local pp_bloom_sizex = CreateClientConVar( "pp_bloom_sizex", "4.0", true, false ) -- Horizontal blur size
+local pp_bloom_sizey = CreateClientConVar( "pp_bloom_sizey", "4.0", true, false ) -- Vertical blur size
+local pp_bloom_color = CreateClientConVar( "pp_bloom_color", "2.0", true, false )
+local pp_bloom_color_r = CreateClientConVar( "pp_bloom_color_r", "255", true, false )
+local pp_bloom_color_g = CreateClientConVar( "pp_bloom_color_g", "255", true, false )
+local pp_bloom_color_b = CreateClientConVar( "pp_bloom_color_b", "255", true, false )
+local pp_bloom_passes = CreateClientConVar( "pp_bloom_passes", "4", true, false )
--[[---------------------------------------------------------
Can be called from engine or hooks using bloom.Draw
@@ -40,7 +39,7 @@ function DrawBloom( darken, multiply, sizex, sizey, passes, color, colr, colg, c
render.UpdateScreenEffectTexture()
-- Store the render target so we can swap back at the end
- local OldRT = render.GetRenderTarget();
+ local OldRT = render.GetRenderTarget()
-- The downsample material adjusts the contrast
mat_Downsample:SetFloat( "$darken", darken )
@@ -104,42 +103,29 @@ list.Set( "PostProcess", "#bloom_pp", {
CPanel:AddControl( "Header", { Description = "#bloom_pp.desc" } )
CPanel:AddControl( "CheckBox", { Label = "#bloom_pp.enable", Command = "pp_bloom" } )
- local params = { Options = {}, CVars = {}, Label = "#tool.presets", MenuButton = "1", Folder = "bloom" }
-
+ local params = { Options = {}, CVars = {}, MenuButton = "1", Folder = "bloom" }
params.Options[ "#preset.default" ] = {
- pp_bloom_passes = "1",
+ pp_bloom_passes = "4",
pp_bloom_darken = "0.65",
- pp_bloom_multiply = "2.0",
- pp_bloom_sizex = "9",
- pp_bloom_sizey = "9",
- pp_bloom_color = "1.0",
+ pp_bloom_multiply = "1.0",
+ pp_bloom_sizex = "4.0",
+ pp_bloom_sizey = "4.0",
+ pp_bloom_color = "2.0",
pp_bloom_color_r = "255",
pp_bloom_color_g = "255",
pp_bloom_color_b = "255"
}
-
- params.CVars = {
- "pp_bloom_passes",
- "pp_bloom_darken",
- "pp_bloom_multiply",
- "pp_bloom_sizex",
- "pp_bloom_sizey",
- "pp_bloom_color",
- "pp_bloom_color_r",
- "pp_bloom_color_g",
- "pp_bloom_color_b"
- }
-
+ params.CVars = table.GetKeys( params.Options[ "#preset.default" ] )
CPanel:AddControl( "ComboBox", params )
CPanel:AddControl( "Slider", { Label = "#bloom_pp.passes", Command = "pp_bloom_passes", Type = "Integer", Min = "0", Max = "30" } )
CPanel:AddControl( "Slider", { Label = "#bloom_pp.darken", Command = "pp_bloom_darken", Type = "Float", Min = "0", Max = "1" } )
- CPanel:AddControl( "Slider", { Label = "#bloom_pp.multiply", Command = "pp_bloom_multiply", Type = "Float", Min = "0", Max = "5" } )
- CPanel:AddControl( "Slider", { Label = "#bloom_pp.blurx", Command = "pp_bloom_sizex", Type = "Float", Min = "0", Max = "50" } )
- CPanel:AddControl( "Slider", { Label = "#bloom_pp.blury", Command = "pp_bloom_sizey", Type = "Float", Min = "0", Max = "50" } )
- CPanel:AddControl( "Slider", { Label = "#bloom_pp.multiplier", Command = "pp_bloom_color", Type = "Float", Min = "0", Max = "20" } )
+ CPanel:AddControl( "Slider", { Label = "#bloom_pp.multiply", Command = "pp_bloom_multiply", Type = "Float", Min = "0", Max = "5" } )
+ CPanel:AddControl( "Slider", { Label = "#bloom_pp.blurx", Command = "pp_bloom_sizex", Type = "Float", Min = "0", Max = "50" } )
+ CPanel:AddControl( "Slider", { Label = "#bloom_pp.blury", Command = "pp_bloom_sizey", Type = "Float", Min = "0", Max = "50" } )
+ CPanel:AddControl( "Slider", { Label = "#bloom_pp.multiplier", Command = "pp_bloom_color", Type = "Float", Min = "0", Max = "20" } )
- CPanel:AddControl( "Color", { Label = "#bloom_pp.color", Red = "pp_bloom_color_r", Green = "pp_bloom_color_g", Blue = "pp_bloom_color_b", ShowAlpha = "0", ShowHSV = "1", ShowRGB = "1" } )
+ CPanel:AddControl( "Color", { Label = "#bloom_pp.color", Red = "pp_bloom_color_r", Green = "pp_bloom_color_g", Blue = "pp_bloom_color_b", ShowAlpha = "0", ShowHSV = "1", ShowRGB = "1" } )
end
@@ -1,10 +1,10 @@
local blur_mat = Material( "pp/bokehblur" )
-local pp_bokeh_blur = CreateClientConVar( "pp_bokeh_blur", "5", false, false )
-local pp_bokeh_distance = CreateClientConVar( "pp_bokeh_distance", "0.1", false, false )
-local pp_bokeh_focus = CreateClientConVar( "pp_bokeh_focus", "1.0", false, false )
-local pp_bokeh = CreateClientConVar( "pp_bokeh", "0", false, false )
+local pp_bokeh_blur = CreateClientConVar( "pp_bokeh_blur", "5", true, false )
+local pp_bokeh_distance = CreateClientConVar( "pp_bokeh_distance", "0.1", true, false )
+local pp_bokeh_focus = CreateClientConVar( "pp_bokeh_focus", "1.0", true, false )
+local pp_bokeh = CreateClientConVar( "pp_bokeh", "0", true, false )
local function DrawBokehDOF()
@@ -5,17 +5,17 @@ mat_ColorMod:SetTexture( "$fbtexture", render.GetScreenEffectTexture() )
--[[---------------------------------------------------------
Register the convars that will control this effect
------------------------------------------------------------]]
-local pp_colormod = CreateClientConVar( "pp_colormod", "0", false, false )
-local pp_colormod_addr = CreateClientConVar( "pp_colormod_addr", "0", false, false )
-local pp_colormod_addg = CreateClientConVar( "pp_colormod_addg", "0", false, false )
-local pp_colormod_addb = CreateClientConVar( "pp_colormod_addb", "0", false, false )
-local pp_colormod_brightness = CreateClientConVar( "pp_colormod_brightness", "0", false, false )
-local pp_colormod_contrast = CreateClientConVar( "pp_colormod_contrast", "1", false, false )
-local pp_colormod_color = CreateClientConVar( "pp_colormod_color", "1", false, false )
-local pp_colormod_mulr = CreateClientConVar( "pp_colormod_mulr", "0", false, false )
-local pp_colormod_mulg = CreateClientConVar( "pp_colormod_mulg", "0", false, false )
-local pp_colormod_mulb = CreateClientConVar( "pp_colormod_mulb", "0", false, false )
+-----------------------------------------------------------]]
+local pp_colormod = CreateClientConVar( "pp_colormod", "0", true, false )
+local pp_colormod_addr = CreateClientConVar( "pp_colormod_addr", "0", true, false )
+local pp_colormod_addg = CreateClientConVar( "pp_colormod_addg", "0", true, false )
+local pp_colormod_addb = CreateClientConVar( "pp_colormod_addb", "0", true, false )
+local pp_colormod_brightness = CreateClientConVar( "pp_colormod_brightness", "0", true, false )
+local pp_colormod_contrast = CreateClientConVar( "pp_colormod_contrast", "1", true, false )
+local pp_colormod_color = CreateClientConVar( "pp_colormod_color", "1", true, false )
+local pp_colormod_mulr = CreateClientConVar( "pp_colormod_mulr", "0", true, false )
+local pp_colormod_mulg = CreateClientConVar( "pp_colormod_mulg", "0", true, false )
+local pp_colormod_mulb = CreateClientConVar( "pp_colormod_mulb", "0", true, false )
function DrawColorModify( tab )
@@ -65,18 +65,18 @@ list.Set( "PostProcess", "#colormod_pp", {
CPanel:AddControl( "Header", { Description = "#colormod_pp.desc" } )
CPanel:AddControl( "CheckBox", { Label = "#colormod_pp.enable", Command = "pp_colormod" } )
- local params = { Options = {}, CVars = {}, Label = "#tool.presets", MenuButton = "1", Folder = "colormod" }
- params.Options[ "#preset.default" ] = { pp_colormod = "1", pp_colormod_addr = "0", pp_colormod_addg = "0", pp_colormod_addb = "0", pp_colormod_brightness = "0", pp_colormod_contrast = "1", pp_colormod_color = "1", pp_colormod_mulr = "0", pp_colormod_mulg = "0", pp_colormod_mulb = "0" }
- params.CVars = { "pp_colormod", "pp_colormod_addr", "pp_colormod_addg", "pp_colormod_addb", "pp_colormod_brightness", "pp_colormod_contrast", "pp_colormod_color", "pp_colormod_mulr", "pp_colormod_mulg", "pp_colormod_mulb" }
+ local params = { Options = {}, CVars = {}, MenuButton = "1", Folder = "colormod" }
+ params.Options[ "#preset.default" ] = { pp_colormod_addr = "0", pp_colormod_addg = "0", pp_colormod_addb = "0", pp_colormod_brightness = "0", pp_colormod_contrast = "1", pp_colormod_color = "1", pp_colormod_mulr = "0", pp_colormod_mulg = "0", pp_colormod_mulb = "0" }
+ params.CVars = table.GetKeys( params.Options[ "#preset.default" ] )
CPanel:AddControl( "ComboBox", params )
CPanel:AddControl( "Slider", { Label = "#colormod_pp.brightness", Command = "pp_colormod_brightness", Type = "Float", Min = "-2", Max = "2" } )
CPanel:AddControl( "Slider", { Label = "#colormod_pp.contrast", Command = "pp_colormod_contrast", Type = "Float", Min = "0", Max = "10" } )
- CPanel:AddControl( "Slider", { Label = "#colormod_pp.color", Command = "pp_colormod_color", Type = "Float", Min = "0", Max = "5" } )
+ CPanel:AddControl( "Slider", { Label = "#colormod_pp.color", Command = "pp_colormod_color", Type = "Float", Min = "0", Max = "5" } )
- CPanel:AddControl( "Color", { Label = "#colormod_pp.color_add", Red = "pp_colormod_addr", Green = "pp_colormod_addg", Blue = "pp_colormod_addb", ShowAlpha = "0", ShowHSV = "1", ShowRGB = "1" } )
- CPanel:AddControl( "Color", { Label = "#colormod_pp.color_multiply", Red = "pp_colormod_mulr", Green = "pp_colormod_mulg", Blue = "pp_colormod_mulb", ShowAlpha = "0", ShowHSV = "1", ShowRGB = "1" } )
+ CPanel:AddControl( "Color", { Label = "#colormod_pp.color_add", Red = "pp_colormod_addr", Green = "pp_colormod_addg", Blue = "pp_colormod_addb", ShowAlpha = "0", ShowHSV = "1", ShowRGB = "1" } )
+ CPanel:AddControl( "Color", { Label = "#colormod_pp.color_multiply", Red = "pp_colormod_mulr", Green = "pp_colormod_mulg", Blue = "pp_colormod_mulb", ShowAlpha = "0", ShowHSV = "1", ShowRGB = "1" } )
end
-} )
+} )
@@ -1,7 +1,7 @@
-CreateClientConVar( "pp_dof", "0", false, false )
-local pp_dof_initlength = CreateClientConVar( "pp_dof_initlength", "256", false, false )
-local pp_dof_spacing = CreateClientConVar( "pp_dof_spacing", "512", false, false )
+CreateClientConVar( "pp_dof", "0", true, false )
+local pp_dof_initlength = CreateClientConVar( "pp_dof_initlength", "256", true, false )
+local pp_dof_spacing = CreateClientConVar( "pp_dof_spacing", "512", true, false )
-- Global table to hold the DoF effect
DOF_Ents = {}
@@ -74,11 +74,16 @@ list.Set( "PostProcess", "#dof_pp", {
cpanel = function( CPanel )
- CPanel:AddControl( "Header", { Description = "#dof_pp.desc" } )
- CPanel:AddControl( "CheckBox", { Label = "#dof_pp.enable", Command = "pp_dof" } )
+ CPanel:AddControl( "Header", { Description = "#dof_pp.desc" } )
+ CPanel:AddControl( "CheckBox", { Label = "#dof_pp.enable", Command = "pp_dof" } )
+
+ local params = { Options = {}, CVars = {}, MenuButton = "1", Folder = "dof" }
+ params.Options[ "#preset.default" ] = { pp_dof_initlength = "256", pp_dof_spacing = "512" }
+ params.CVars = table.GetKeys( params.Options[ "#preset.default" ] )
+ CPanel:AddControl( "ComboBox", params )
- CPanel:AddControl( "Slider", { Label = "#dof_pp.spacing", Command = "pp_dof_spacing", Type = "Float", Min = "8", Max = "1024" } )
- CPanel:AddControl( "Slider", { Label = "#dof_pp.start_distance", Command = "pp_dof_initlength", Type = "Float", Min = "9", Max = "1024" } )
+ CPanel:AddControl( "Slider", { Label = "#dof_pp.spacing", Command = "pp_dof_spacing", Type = "Float", Min = "8", Max = "1024" } )
+ CPanel:AddControl( "Slider", { Label = "#dof_pp.start_distance", Command = "pp_dof_initlength", Type = "Float", Min = "9", Max = "1024" } )
end
@@ -3,8 +3,8 @@ local FrameCurves = {}
local function FixupCurve( num )
- local overflow = num;
- for k, v in pairs( FrameCurves[num] ) do
+ local overflow = num
+ for k, v in pairs( FrameCurves[ num ] ) do
overflow = overflow - v
end
@@ -20,8 +20,8 @@ end
local function FrameCurve( f, num )
- if ( FrameCurves[num] ) then
- return FrameCurves[num][f]
+ if ( FrameCurves[ num ] ) then
+ return FrameCurves[ num ][ f ]
end
local curve = {}
@@ -33,9 +33,9 @@ local function FrameCurve( f, num )
end
- FrameCurves[num] = curve;
+ FrameCurves[ num ] = curve
- for i=0, 10 do
+ for i=0, 10 do
FixupCurve( num )
end
@@ -46,18 +46,18 @@ end
--
-- The number of frames to blend
--
-local pp_fb = CreateConVar( "pp_fb", "0", { FCVAR_DONTRECORD } )
+local pp_fb = CreateClientConVar( "pp_fb", "0", true, false )
--
-- The number of frames to blend
--
-local pp_fb_frames = CreateConVar( "pp_fb_frames", "16", { FCVAR_DONTRECORD } )
+local pp_fb_frames = CreateClientConVar( "pp_fb_frames", "16", true, false )
--
-- The amount of time the shutter is open. If this is 0.5 then we will blend only
-- 50% of the frames. This is normally 0.5. Lowering it will make it more blurry.
--
-local pp_fb_shutter = CreateConVar( "pp_fb_shutter", "0.5", { FCVAR_DONTRECORD } )
+local pp_fb_shutter = CreateClientConVar( "pp_fb_shutter", "0.5", true, false )
-- 8 low
-- 16 avg
@@ -91,7 +91,7 @@ end
frame_blend.RenderableFrames = function()
local padding = math.floor( pp_fb_frames:GetInt() * pp_fb_shutter:GetFloat() * 0.5 ) * 2
- return pp_fb_frames:GetInt()-padding
+ return pp_fb_frames:GetInt() - padding
end
@@ -112,7 +112,7 @@ frame_blend.ShouldSkipFrame = function()
local padding = math.floor( pp_fb_frames:GetInt() * pp_fb_shutter:GetFloat() * 0.5 )
- if ( NumFramesTaken < padding || NumFramesTaken >= pp_fb_frames:GetInt()-padding ) then
+ if ( NumFramesTaken < padding || NumFramesTaken >= pp_fb_frames:GetInt() - padding ) then
return true
end
@@ -148,24 +148,22 @@ frame_blend.AddFrame = function()
end
-
-
frame_blend.BlendFrame = function()
local padding = math.floor( pp_fb_frames:GetInt() * pp_fb_shutter:GetFloat() * 0.5 )
local frames = pp_fb_frames:GetInt()
render.UpdateScreenEffectTexture()
- local delta = (NumFramesTaken-padding) / (frames-padding*2)
- local curve = FrameCurve( (NumFramesTaken-padding), (frames-padding*2) )
+ local delta = ( NumFramesTaken - padding ) / ( frames - padding * 2 )
+ local curve = FrameCurve( ( NumFramesTaken - padding ), ( frames-padding * 2 ) )
if ( !curve ) then return end
- curve = ( 1 / (NumFramesTaken-padding) ) * curve
+ curve = ( 1 / ( NumFramesTaken - padding ) ) * curve
matFB:SetFloat( "$alpha", curve )
- local OldRT = render.GetRenderTarget();
+ local OldRT = render.GetRenderTarget()
render.SetRenderTarget( texMB0 )
render.SetMaterial( matFB )
render.DrawScreenQuad()
@@ -194,10 +192,10 @@ hook.Add( "PreRender", "PreRenderFrameBlend", function()
frame_blend.AddFrame()
if ( frame_blend.ShouldSkipFrame() ) then
- return true
+ return true
end
- return
+ return
end )
@@ -213,22 +211,14 @@ list.Set( "PostProcess", "#frame_blend_pp", {
CPanel:AddControl( "Header", { Description = "#frame_blend_pp.desc2" } )
CPanel:AddControl( "CheckBox", { Label = "#frame_blend_pp.enable", Command = "pp_fb" } )
-
- CPanel:AddControl( "Slider", {
- Label = "#frame_blend_pp.frames",
- Command = "pp_fb_frames",
- Type = "Int",
- Min = "3",
- Max = "64"
- } )
-
- CPanel:AddControl( "Slider", {
- Label = "#frame_blend_pp.shutter",
- Command = "pp_fb_shutter",
- Type = "Float",
- Min = "0",
- Max = "1"
- } )
+
+ local params = { Options = {}, CVars = {}, MenuButton = "1", Folder = "frame_blend" }
+ params.Options[ "#preset.default" ] = { pp_fb_frames = "16", pp_fb_shutter = "0.5" }
+ params.CVars = table.GetKeys( params.Options[ "#preset.default" ] )
+ CPanel:AddControl( "ComboBox", params )
+
+ CPanel:AddControl( "Slider", { Label = "#frame_blend_pp.frames", Command = "pp_fb_frames", Type = "Int", Min = "3", Max = "64" } )
+ CPanel:AddControl( "Slider", { Label = "#frame_blend_pp.shutter", Command = "pp_fb_shutter", Type = "Float", Min = "0", Max = "1" } )
end
Oops, something went wrong.

0 comments on commit aafc9bc

Please sign in to comment.