mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-16 21:33:46 +03:00
Upload
This commit is contained in:
126
lua/postprocess/bloom.lua
Normal file
126
lua/postprocess/bloom.lua
Normal file
@@ -0,0 +1,126 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
local mat_Downsample = Material( "pp/downsample" )
|
||||
mat_Downsample:SetTexture( "$fbtexture", render.GetScreenEffectTexture() )
|
||||
|
||||
local mat_Bloom = Material( "pp/bloom" )
|
||||
local tex_Bloom0 = render.GetBloomTex0()
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
Register the convars that will control this effect
|
||||
-----------------------------------------------------------]]
|
||||
local pp_bloom = CreateClientConVar( "pp_bloom", "0", false, false ) -- On/Off
|
||||
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
|
||||
-----------------------------------------------------------]]
|
||||
function DrawBloom( darken, multiply, sizex, sizey, passes, color, colr, colg, colb )
|
||||
|
||||
-- No bloom for crappy gpus
|
||||
if ( !render.SupportsPixelShaders_2_0() ) then return end
|
||||
|
||||
-- Copy the backbuffer to the screen effect texture
|
||||
render.CopyRenderTargetToTexture( render.GetScreenEffectTexture() )
|
||||
|
||||
-- Store the render target so we can swap back at the end
|
||||
local OldRT = render.GetRenderTarget()
|
||||
|
||||
-- The downsample material adjusts the contrast
|
||||
mat_Downsample:SetFloat( "$darken", darken )
|
||||
mat_Downsample:SetFloat( "$multiply", multiply )
|
||||
|
||||
-- Downsample to BloomTexture0
|
||||
render.SetRenderTarget( tex_Bloom0 )
|
||||
|
||||
render.SetMaterial( mat_Downsample )
|
||||
render.DrawScreenQuad()
|
||||
|
||||
render.BlurRenderTarget( tex_Bloom0, sizex, sizey, passes )
|
||||
|
||||
render.SetRenderTarget( OldRT )
|
||||
|
||||
mat_Bloom:SetFloat( "$levelr", colr )
|
||||
mat_Bloom:SetFloat( "$levelg", colg )
|
||||
mat_Bloom:SetFloat( "$levelb", colb )
|
||||
mat_Bloom:SetFloat( "$colormul", color )
|
||||
mat_Bloom:SetTexture( "$basetexture", tex_Bloom0 )
|
||||
|
||||
render.SetMaterial( mat_Bloom )
|
||||
render.DrawScreenQuad()
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
The function to draw the bloom (called from the hook)
|
||||
-----------------------------------------------------------]]
|
||||
hook.Add( "RenderScreenspaceEffects", "RenderBloom", function()
|
||||
|
||||
-- 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(),
|
||||
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 )
|
||||
|
||||
list.Set( "PostProcess", "#bloom_pp", {
|
||||
|
||||
icon = "gui/postprocess/bloom.png",
|
||||
convar = "pp_bloom",
|
||||
category = "#shaders_pp",
|
||||
|
||||
cpanel = function( CPanel )
|
||||
|
||||
CPanel:AddControl( "Header", { Description = "#bloom_pp.desc" } )
|
||||
CPanel:AddControl( "CheckBox", { Label = "#bloom_pp.enable", Command = "pp_bloom" } )
|
||||
|
||||
local params = { Options = {}, CVars = {}, MenuButton = "1", Folder = "bloom" }
|
||||
params.Options[ "#preset.default" ] = {
|
||||
pp_bloom_passes = "4",
|
||||
pp_bloom_darken = "0.65",
|
||||
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 = 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( "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
|
||||
|
||||
} )
|
||||
61
lua/postprocess/bokeh_dof.lua
Normal file
61
lua/postprocess/bokeh_dof.lua
Normal file
@@ -0,0 +1,61 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
local blur_mat = Material( "pp/bokehblur" )
|
||||
|
||||
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 )
|
||||
|
||||
function DrawBokehDOF( intensity, distance, focus )
|
||||
|
||||
render.UpdateScreenEffectTexture()
|
||||
|
||||
blur_mat:SetTexture( "$BASETEXTURE", render.GetScreenEffectTexture() )
|
||||
blur_mat:SetTexture( "$DEPTHTEXTURE", render.GetResolvedFullFrameDepth() )
|
||||
|
||||
blur_mat:SetFloat( "$size", intensity )
|
||||
blur_mat:SetFloat( "$focus", distance )
|
||||
blur_mat:SetFloat( "$focusradius", focus )
|
||||
|
||||
render.SetMaterial( blur_mat )
|
||||
render.DrawScreenQuad()
|
||||
|
||||
end
|
||||
|
||||
local function OnChange( name, oldvalue, newvalue )
|
||||
|
||||
if ( !GAMEMODE:PostProcessPermitted( "bokeh" ) ) then return end
|
||||
|
||||
if ( newvalue != "0" ) then
|
||||
DOFModeHack( true )
|
||||
else
|
||||
DOFModeHack( false )
|
||||
end
|
||||
|
||||
end
|
||||
cvars.AddChangeCallback( "pp_bokeh", OnChange )
|
||||
|
||||
hook.Add( "RenderScreenspaceEffects", "RenderBokeh", function()
|
||||
|
||||
if ( !pp_bokeh:GetBool() ) then return end
|
||||
if ( !GAMEMODE:PostProcessPermitted( "bokeh" ) ) then return end
|
||||
|
||||
DrawBokehDOF( pp_bokeh_blur:GetFloat(), pp_bokeh_distance:GetFloat(), pp_bokeh_focus:GetFloat() )
|
||||
|
||||
end )
|
||||
|
||||
hook.Add( "NeedsDepthPass", "NeedsDepthPass_Bokeh", function()
|
||||
|
||||
if ( pp_bokeh:GetBool() ) then return true end
|
||||
|
||||
end )
|
||||
93
lua/postprocess/color_modify.lua
Normal file
93
lua/postprocess/color_modify.lua
Normal file
@@ -0,0 +1,93 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
local mat_ColorMod = Material( "pp/colour" )
|
||||
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", 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 )
|
||||
local pp_colormod_inv = CreateClientConVar( "pp_colormod_inv", "0", true, false )
|
||||
|
||||
function DrawColorModify( tab )
|
||||
|
||||
render.CopyRenderTargetToTexture( render.GetScreenEffectTexture() )
|
||||
|
||||
for k, v in pairs( tab ) do
|
||||
|
||||
mat_ColorMod:SetFloat( k, v )
|
||||
|
||||
end
|
||||
|
||||
render.SetMaterial( mat_ColorMod )
|
||||
render.DrawScreenQuad()
|
||||
|
||||
end
|
||||
|
||||
hook.Add( "RenderScreenspaceEffects", "RenderColorModify", function()
|
||||
|
||||
if ( !pp_colormod:GetBool() ) then return end
|
||||
if ( !GAMEMODE:PostProcessPermitted( "color mod" ) ) then return end
|
||||
|
||||
local tab = {}
|
||||
|
||||
tab[ "$pp_colour_addr" ] = pp_colormod_addr:GetFloat() * 0.02
|
||||
tab[ "$pp_colour_addg" ] = pp_colormod_addg:GetFloat() * 0.02
|
||||
tab[ "$pp_colour_addb" ] = pp_colormod_addb:GetFloat() * 0.02
|
||||
tab[ "$pp_colour_brightness" ] = pp_colormod_brightness:GetFloat()
|
||||
tab[ "$pp_colour_contrast" ] = pp_colormod_contrast:GetFloat()
|
||||
tab[ "$pp_colour_colour" ] = pp_colormod_color:GetFloat()
|
||||
tab[ "$pp_colour_mulr" ] = pp_colormod_mulr:GetFloat() * 0.1
|
||||
tab[ "$pp_colour_mulg" ] = pp_colormod_mulg:GetFloat() * 0.1
|
||||
tab[ "$pp_colour_mulb" ] = pp_colormod_mulb:GetFloat() * 0.1
|
||||
tab[ "$pp_colour_inv" ] = pp_colormod_inv:GetFloat()
|
||||
|
||||
DrawColorModify( tab )
|
||||
|
||||
end )
|
||||
|
||||
list.Set( "PostProcess", "#colormod_pp", {
|
||||
|
||||
icon = "gui/postprocess/colourmod.png",
|
||||
convar = "pp_colormod",
|
||||
category = "#shaders_pp",
|
||||
|
||||
cpanel = function( CPanel )
|
||||
|
||||
CPanel:AddControl( "Header", { Description = "#colormod_pp.desc" } )
|
||||
CPanel:AddControl( "CheckBox", { Label = "#colormod_pp.enable", Command = "pp_colormod" } )
|
||||
|
||||
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", pp_colormod_inv = "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.invert", Command = "pp_colormod_inv", Type = "Float", Min = "0", Max = "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
|
||||
|
||||
} )
|
||||
99
lua/postprocess/dof.lua
Normal file
99
lua/postprocess/dof.lua
Normal file
@@ -0,0 +1,99 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
CreateClientConVar( "pp_dof", "0", false, 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 = {}
|
||||
DOF_SPACING = 0
|
||||
DOF_OFFSET = 0
|
||||
|
||||
local NUM_DOF_NODES = 16
|
||||
|
||||
function DOF_Kill()
|
||||
|
||||
for i = #DOF_Ents, 1, -1 do
|
||||
|
||||
local v = DOF_Ents[i]
|
||||
|
||||
if ( IsValid( v ) ) then
|
||||
v:Remove()
|
||||
end
|
||||
|
||||
DOF_Ents[i] = nil
|
||||
|
||||
end
|
||||
|
||||
DOFModeHack( false )
|
||||
|
||||
end
|
||||
|
||||
function DOF_Start()
|
||||
|
||||
DOF_Kill()
|
||||
|
||||
for i = 0, NUM_DOF_NODES do
|
||||
|
||||
local effectdata = EffectData()
|
||||
effectdata:SetScale( i )
|
||||
util.Effect( "dof_node", effectdata )
|
||||
|
||||
end
|
||||
|
||||
DOFModeHack( true )
|
||||
|
||||
end
|
||||
|
||||
hook.Add( "Think", "DOFThink", function()
|
||||
|
||||
DOF_SPACING = pp_dof_spacing:GetFloat()
|
||||
DOF_OFFSET = pp_dof_initlength:GetFloat()
|
||||
|
||||
end )
|
||||
|
||||
cvars.AddChangeCallback( "pp_dof", function( name, oldvalue, newvalue )
|
||||
|
||||
if ( !GAMEMODE:PostProcessPermitted( "dof" ) ) then return end
|
||||
|
||||
if ( newvalue != "0" ) then
|
||||
DOF_Start()
|
||||
else
|
||||
DOF_Kill()
|
||||
end
|
||||
|
||||
end )
|
||||
|
||||
|
||||
list.Set( "PostProcess", "#dof_pp", {
|
||||
|
||||
icon = "gui/postprocess/dof.png",
|
||||
convar = "pp_dof",
|
||||
category = "#effects_pp",
|
||||
|
||||
cpanel = function( CPanel )
|
||||
|
||||
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" } )
|
||||
|
||||
end
|
||||
|
||||
} )
|
||||
224
lua/postprocess/frame_blend.lua
Normal file
224
lua/postprocess/frame_blend.lua
Normal file
@@ -0,0 +1,224 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
--
|
||||
-- The number of frames to blend
|
||||
--
|
||||
local pp_fb = CreateClientConVar( "pp_fb", "0", false, false )
|
||||
|
||||
--
|
||||
-- The number of frames to blend
|
||||
--
|
||||
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 = CreateClientConVar( "pp_fb_shutter", "0.5", true, false )
|
||||
|
||||
local FrameCurves = {}
|
||||
|
||||
local function FixupCurve( num )
|
||||
|
||||
local overflow = num
|
||||
for k, v in pairs( FrameCurves[ num ] ) do
|
||||
overflow = overflow - v
|
||||
end
|
||||
|
||||
overflow = overflow * math.Rand( 0, 0.5 )
|
||||
|
||||
for i=0, num-1 do
|
||||
|
||||
FrameCurves[ num ][ i ] = FrameCurves[ num ][ i ] + ( overflow / num )
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local function FrameCurve( f, num )
|
||||
|
||||
if ( FrameCurves[ num ] ) then
|
||||
return FrameCurves[ num ][ f ]
|
||||
end
|
||||
|
||||
local curve = {}
|
||||
|
||||
for i=0, num-1 do
|
||||
|
||||
local delta = ( i + 1 ) / num
|
||||
curve[ i ] = math.sin( delta * math.pi )
|
||||
|
||||
end
|
||||
|
||||
FrameCurves[ num ] = curve
|
||||
|
||||
for i=0, 10 do
|
||||
FixupCurve( num )
|
||||
end
|
||||
|
||||
return 1.0
|
||||
|
||||
end
|
||||
|
||||
local texFB = GetRenderTargetEx( "_GMOD_FrameBlend", -1, -1, RT_SIZE_FULL_FRAME_BUFFER, MATERIAL_RT_DEPTH_NONE, 0, 0, IMAGE_FORMAT_DEFAULT )
|
||||
local matFB = Material( "pp/frame_blend" )
|
||||
local matFSB = Material( "pp/motionblur" )
|
||||
local texMB0 = render.GetMoBlurTex0()
|
||||
local texMB1 = render.GetMoBlurTex1()
|
||||
local NumFramesTaken = 0
|
||||
|
||||
frame_blend = {}
|
||||
|
||||
frame_blend.IsActive = function()
|
||||
|
||||
return pp_fb:GetBool()
|
||||
|
||||
end
|
||||
|
||||
frame_blend.IsLastFrame = function()
|
||||
|
||||
if ( !frame_blend.IsActive() ) then return true end
|
||||
|
||||
local padding = math.floor( pp_fb_frames:GetInt() * pp_fb_shutter:GetFloat() * 0.5 )
|
||||
|
||||
return NumFramesTaken == ( pp_fb_frames:GetInt() - padding - 1 )
|
||||
|
||||
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
|
||||
|
||||
end
|
||||
|
||||
frame_blend.DrawPreview = function()
|
||||
|
||||
render.Clear( 0, 0, 0, 255, true, true )
|
||||
matFSB:SetFloat( "$alpha", 1.0 )
|
||||
matFSB:SetTexture( "$basetexture", texMB1 )
|
||||
render.SetMaterial( matFSB )
|
||||
render.DrawScreenQuad()
|
||||
|
||||
end
|
||||
|
||||
frame_blend.ShouldSkipFrame = function()
|
||||
|
||||
if ( pp_fb_shutter:GetFloat() <= 0 ) then return false end
|
||||
if ( pp_fb_shutter:GetFloat() >= 1 ) then return false end
|
||||
|
||||
local padding = math.floor( pp_fb_frames:GetInt() * pp_fb_shutter:GetFloat() * 0.5 )
|
||||
|
||||
if ( NumFramesTaken < padding || NumFramesTaken >= pp_fb_frames:GetInt() - padding ) then
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
|
||||
end
|
||||
|
||||
frame_blend.CompleteFrame = function()
|
||||
|
||||
matFSB:SetFloat( "$alpha", 1.0 )
|
||||
matFSB:SetTexture( "$basetexture", texMB0 )
|
||||
|
||||
local OldRT = render.GetRenderTarget()
|
||||
render.SetRenderTarget( texMB1 )
|
||||
render.SetMaterial( matFSB )
|
||||
render.DrawScreenQuad()
|
||||
render.SetRenderTarget( OldRT )
|
||||
|
||||
render.SetRenderTarget( texMB0 )
|
||||
render.Clear( 0, 0, 0, 255, true, true )
|
||||
render.SetRenderTarget( OldRT )
|
||||
|
||||
end
|
||||
|
||||
frame_blend.AddFrame = function()
|
||||
|
||||
NumFramesTaken = NumFramesTaken + 1
|
||||
|
||||
if ( NumFramesTaken >= pp_fb_frames:GetInt() ) then
|
||||
frame_blend.CompleteFrame()
|
||||
NumFramesTaken = 0
|
||||
end
|
||||
|
||||
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.PushRenderTarget( texFB )
|
||||
render.UpdateScreenEffectTexture()
|
||||
render.PopRenderTarget()
|
||||
|
||||
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
|
||||
|
||||
matFB:SetFloat( "$alpha", curve )
|
||||
|
||||
local OldRT = render.GetRenderTarget()
|
||||
render.SetRenderTarget( texMB0 )
|
||||
render.SetMaterial( matFB )
|
||||
render.DrawScreenQuad()
|
||||
render.SetRenderTarget( OldRT )
|
||||
|
||||
end
|
||||
|
||||
--
|
||||
-- Don't use these hooks when rendering a demo
|
||||
--
|
||||
if ( engine.IsPlayingDemo() ) then return end
|
||||
|
||||
hook.Add( "PostRender", "RenderFrameBlend", function()
|
||||
|
||||
if ( !frame_blend.IsActive() ) then return end
|
||||
|
||||
if ( !frame_blend.ShouldSkipFrame() ) then
|
||||
render.CopyRenderTargetToTexture( texFB )
|
||||
frame_blend.BlendFrame()
|
||||
end
|
||||
|
||||
frame_blend.AddFrame()
|
||||
frame_blend.DrawPreview()
|
||||
|
||||
end )
|
||||
|
||||
list.Set( "PostProcess", "#frame_blend_pp", {
|
||||
|
||||
icon = "gui/postprocess/frame_blend.png",
|
||||
convar = "pp_fb",
|
||||
category = "#effects_pp",
|
||||
|
||||
cpanel = function( CPanel )
|
||||
|
||||
CPanel:AddControl( "Header", { Description = "#frame_blend_pp.desc" } )
|
||||
CPanel:AddControl( "Header", { Description = "#frame_blend_pp.desc2" } )
|
||||
|
||||
CPanel:AddControl( "CheckBox", { Label = "#frame_blend_pp.enable", Command = "pp_fb" } )
|
||||
|
||||
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 = "0.99" } )
|
||||
|
||||
end
|
||||
|
||||
} )
|
||||
104
lua/postprocess/motion_blur.lua
Normal file
104
lua/postprocess/motion_blur.lua
Normal file
@@ -0,0 +1,104 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
local mat_MotionBlur = Material( "pp/motionblur" )
|
||||
local mat_Screen = Material( "pp/fb" )
|
||||
local tex_MotionBlur = render.GetMoBlurTex0()
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
Register the convars that will control this effect
|
||||
-----------------------------------------------------------]]
|
||||
local pp_motionblur = CreateClientConVar( "pp_motionblur", "0", false, false )
|
||||
local pp_motionblur_addalpha = CreateClientConVar( "pp_motionblur_addalpha", "0.2", true, false )
|
||||
local pp_motionblur_drawalpha = CreateClientConVar( "pp_motionblur_drawalpha", "0.99", true, false )
|
||||
local pp_motionblur_delay = CreateClientConVar( "pp_motionblur_delay", "0.05", true, false )
|
||||
|
||||
local NextDraw = 0
|
||||
local LastDraw = 0
|
||||
|
||||
function DrawMotionBlur( addalpha, drawalpha, delay )
|
||||
|
||||
if ( drawalpha == 0 ) then return end
|
||||
|
||||
-- Copy the backbuffer to the screen effect texture
|
||||
render.UpdateScreenEffectTexture()
|
||||
|
||||
-- If it's been a long time then the buffer is probably dirty, update it
|
||||
if ( CurTime() - LastDraw > 0.5 ) then
|
||||
|
||||
mat_Screen:SetFloat( "$alpha", 1 )
|
||||
|
||||
local OldRT = render.GetRenderTarget()
|
||||
render.SetRenderTarget( tex_MotionBlur )
|
||||
render.SetMaterial( mat_Screen )
|
||||
render.DrawScreenQuad()
|
||||
render.SetRenderTarget( OldRT )
|
||||
|
||||
end
|
||||
|
||||
-- Set up out materials
|
||||
mat_MotionBlur:SetFloat( "$alpha", drawalpha )
|
||||
mat_MotionBlur:SetTexture( "$basetexture", tex_MotionBlur )
|
||||
|
||||
if ( NextDraw < CurTime() && addalpha > 0 ) then
|
||||
|
||||
NextDraw = CurTime() + delay
|
||||
|
||||
mat_Screen:SetFloat( "$alpha", addalpha )
|
||||
local OldRT = render.GetRenderTarget()
|
||||
render.SetRenderTarget( tex_MotionBlur )
|
||||
|
||||
render.SetMaterial( mat_Screen )
|
||||
render.DrawScreenQuad()
|
||||
|
||||
render.SetRenderTarget( OldRT )
|
||||
|
||||
end
|
||||
|
||||
render.SetMaterial( mat_MotionBlur )
|
||||
render.DrawScreenQuad( true )
|
||||
|
||||
LastDraw = CurTime()
|
||||
|
||||
end
|
||||
|
||||
hook.Add( "RenderScreenspaceEffects", "RenderMotionBlur", function()
|
||||
|
||||
if ( !pp_motionblur:GetBool() ) then return end
|
||||
if ( !GAMEMODE:PostProcessPermitted( "motion blur" ) ) then return end
|
||||
|
||||
DrawMotionBlur( pp_motionblur_addalpha:GetFloat(), pp_motionblur_drawalpha:GetFloat(), pp_motionblur_delay:GetFloat() )
|
||||
|
||||
end )
|
||||
|
||||
list.Set( "PostProcess", "#motion_blur_pp", {
|
||||
|
||||
icon = "gui/postprocess/accummotionblur.png",
|
||||
convar = "pp_motionblur",
|
||||
category = "#effects_pp",
|
||||
|
||||
cpanel = function( CPanel )
|
||||
|
||||
CPanel:AddControl( "Header", { Description = "#motion_blur_pp.desc" } )
|
||||
CPanel:AddControl( "CheckBox", { Label = "#motion_blur_pp.enable", Command = "pp_motionblur" } )
|
||||
|
||||
local params = { Options = {}, CVars = {}, MenuButton = "1", Folder = "motionblur" }
|
||||
params.Options[ "#preset.default" ] = { pp_motionblur_addalpha = "0.2", pp_motionblur_delay = "0.05", pp_motionblur_drawalpha = "0.99" }
|
||||
params.CVars = table.GetKeys( params.Options[ "#preset.default" ] )
|
||||
CPanel:AddControl( "ComboBox", params )
|
||||
|
||||
CPanel:AddControl( "Slider", { Label = "#motion_blur_pp.add_alpha", Command = "pp_motionblur_addalpha", Type = "Float", Min = "0", Max = "1" } )
|
||||
CPanel:AddControl( "Slider", { Label = "#motion_blur_pp.draw_alpha", Command = "pp_motionblur_drawalpha", Type = "Float", Min = "0", Max = "1" } )
|
||||
CPanel:AddControl( "Slider", { Label = "#motion_blur_pp.delay", Command = "pp_motionblur_delay", Type = "Float", Min = "0", Max = "1" } )
|
||||
|
||||
end
|
||||
|
||||
} )
|
||||
120
lua/postprocess/overlay.lua
Normal file
120
lua/postprocess/overlay.lua
Normal file
@@ -0,0 +1,120 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
Register the convars that will control this effect
|
||||
-----------------------------------------------------------]]
|
||||
local pp_mat_overlay = CreateClientConVar( "pp_mat_overlay", "", false, false )
|
||||
local pp_mat_overlay_refractamount = CreateClientConVar( "pp_mat_overlay_refractamount", "0.3", true, false )
|
||||
|
||||
local lastTexture = nil
|
||||
local mat_Overlay = nil
|
||||
|
||||
function DrawMaterialOverlay( texture, refractamount )
|
||||
|
||||
if ( texture ~= lastTexture or mat_Overlay == nil ) then
|
||||
mat_Overlay = Material( texture )
|
||||
lastTexture = texture
|
||||
end
|
||||
|
||||
if ( mat_Overlay == nil || mat_Overlay:IsError() ) then return end
|
||||
|
||||
render.UpdateScreenEffectTexture()
|
||||
|
||||
// FIXME: Changing refract amount affects textures used in the map/models.
|
||||
mat_Overlay:SetFloat( "$envmap", 0 )
|
||||
mat_Overlay:SetFloat( "$envmaptint", 0 )
|
||||
mat_Overlay:SetFloat( "$refractamount", refractamount )
|
||||
mat_Overlay:SetInt( "$ignorez", 1 )
|
||||
|
||||
render.SetMaterial( mat_Overlay )
|
||||
render.DrawScreenQuad( true )
|
||||
|
||||
end
|
||||
|
||||
hook.Add( "RenderScreenspaceEffects", "RenderMaterialOverlay", function()
|
||||
|
||||
local overlay = pp_mat_overlay:GetString()
|
||||
|
||||
if ( overlay == "" ) then return end
|
||||
if ( !GAMEMODE:PostProcessPermitted( "material overlay" ) ) then return end
|
||||
|
||||
DrawMaterialOverlay( overlay, pp_mat_overlay_refractamount:GetFloat() )
|
||||
|
||||
end )
|
||||
|
||||
list.Set( "OverlayMaterials", "#overlay_pp.binocoverlay", { Material = "effects/combine_binocoverlay", Icon = "effects/combine_binocoverlay" } )
|
||||
list.Set( "OverlayMaterials", "#overlay_pp.waterfall", { Material = "models/shadertest/shader3", Icon = "models/shadertest/shader3" } )
|
||||
list.Set( "OverlayMaterials", "#overlay_pp.jelly", { Material = "models/shadertest/shader4", Icon = "models/shadertest/shader4" } )
|
||||
list.Set( "OverlayMaterials", "#overlay_pp.stainedglass", { Material = "models/shadertest/shader5", Icon = "models/shadertest/shader5" } )
|
||||
list.Set( "OverlayMaterials", "#overlay_pp.statis", { Material = "models/props_combine/stasisshield_sheet", Icon = "models/props_combine/stasisshield_sheet" } )
|
||||
list.Set( "OverlayMaterials", "#overlay_pp.shield", { Material = "models/props_combine/com_shield001a", Icon = "models/props_combine/com_shield001a" } )
|
||||
list.Set( "OverlayMaterials", "#overlay_pp.froested", { Material = "models/props_c17/frostedglass_01a", Icon = "models/props_c17/frostedglass_01a" } )
|
||||
list.Set( "OverlayMaterials", "#overlay_pp.tankglass", { Material = "models/props_lab/tank_glass001", Icon = "models/props_lab/tank_glass001" } )
|
||||
list.Set( "OverlayMaterials", "#overlay_pp.waves", { Material = "models/props_combine/tprings_globe", Icon = "models/props_combine/tprings_globe" } )
|
||||
list.Set( "OverlayMaterials", "#overlay_pp.fisheye", { Material = "models/props_c17/fisheyelens", Icon = "models/props_c17/fisheyelens" } )
|
||||
list.Set( "OverlayMaterials", "#overlay_pp.rendertarget", { Material = "models/overlay_rendertarget", Icon = "models/overlay_rendertarget" } )
|
||||
list.Set( "OverlayMaterials", "#overlay_pp.strider_pinch_dudv", { Material = "effects/strider_pinch_dudv", Icon = "effects/strider_pinch_dudv" } )
|
||||
list.Set( "OverlayMaterials", "#overlay_pp.teleport", { Material = "effects/tp_eyefx/tpeye", Icon = "effects/tp_eyefx/tpeye" } )
|
||||
list.Set( "OverlayMaterials", "#overlay_pp.teleport2", { Material = "effects/tp_eyefx/tpeye2", Icon = "effects/tp_eyefx/tpeye2" } )
|
||||
list.Set( "OverlayMaterials", "#overlay_pp.teleport3", { Material = "effects/tp_eyefx/tpeye3", Icon = "effects/tp_eyefx/tpeye3" } )
|
||||
list.Set( "OverlayMaterials", "#overlay_pp.tvnoise", { Material = "effects/tvscreen_noise002a", Icon = "effects/tvscreen_noise002a" } )
|
||||
list.Set( "OverlayMaterials", "#overlay_pp.water_warp01", { Material = "effects/water_warp01", Icon = "effects/water_warp01" } )
|
||||
|
||||
if ( IsMounted( "tf" ) ) then
|
||||
list.Set( "OverlayMaterials", "#overlay_pp.jarate", { Material = "effects/jarate_overlay", Icon = "effects/jarate_overlay" } )
|
||||
list.Set( "OverlayMaterials", "#overlay_pp.invuln_overlay_red", { Material = "effects/invuln_overlay_red", Icon = "effects/invuln_overlay_red" } )
|
||||
list.Set( "OverlayMaterials", "#overlay_pp.invuln_overlay_blu", { Material = "effects/invuln_overlay_blue", Icon = "effects/invuln_overlay_blue" } )
|
||||
list.Set( "OverlayMaterials", "#overlay_pp.water_warp", { Material = "effects/water_warp", Icon = "effects/water_warp" } )
|
||||
list.Set( "OverlayMaterials", "#overlay_pp.bleed_overlay", { Material = "effects/bleed_overlay", Icon = "effects/bleed_overlay" } )
|
||||
list.Set( "OverlayMaterials", "#overlay_pp.bombinomicon_distortion", { Material = "effects/bombinomicon_distortion", Icon = "effects/bombinomicon_distortion" } )
|
||||
list.Set( "OverlayMaterials", "#overlay_pp.dodge_overlay", { Material = "effects/dodge_overlay", Icon = "effects/dodge_overlay" } )
|
||||
list.Set( "OverlayMaterials", "#overlay_pp.distortion_normal", { Material = "effects/distortion_normal001", Icon = "effects/distortion_normal001" } )
|
||||
end
|
||||
|
||||
list.Set( "PostProcess", "#overlay_pp", {
|
||||
|
||||
category = "#overlay_pp",
|
||||
|
||||
func = function( content )
|
||||
|
||||
for k, overlay in pairs( list.Get( "OverlayMaterials" ) ) do
|
||||
|
||||
spawnmenu.CreateContentIcon( "postprocess", content, {
|
||||
name = "#overlay_pp",
|
||||
label = k,
|
||||
icon = overlay.Icon,
|
||||
convars = {
|
||||
pp_mat_overlay = {
|
||||
on = overlay.Material,
|
||||
off = ""
|
||||
}
|
||||
}
|
||||
} )
|
||||
|
||||
end
|
||||
|
||||
end,
|
||||
|
||||
cpanel = function( CPanel )
|
||||
|
||||
CPanel:AddControl( "Header", { Description = "#overlay_pp.desc" } )
|
||||
|
||||
local params = { Options = {}, CVars = {}, MenuButton = "1", Folder = "overlay" }
|
||||
params.Options[ "#preset.default" ] = { pp_mat_overlay_refractamount = "0.3" }
|
||||
params.CVars = table.GetKeys( params.Options[ "#preset.default" ] )
|
||||
CPanel:AddControl( "ComboBox", params )
|
||||
|
||||
CPanel:AddControl( "Slider", { Label = "#overlay_pp.refract", Command = "pp_mat_overlay_refractamount", Type = "Float", Min = "-1", Max = "1" } )
|
||||
|
||||
end
|
||||
|
||||
} )
|
||||
64
lua/postprocess/sharpen.lua
Normal file
64
lua/postprocess/sharpen.lua
Normal file
@@ -0,0 +1,64 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
local matSharpen = Material( "pp/sharpen" )
|
||||
matSharpen:SetTexture( "$fbtexture", render.GetScreenEffectTexture() )
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
Register the convars that will control this effect
|
||||
-----------------------------------------------------------]]
|
||||
local pp_sharpen = CreateClientConVar( "pp_sharpen", "0", false, false )
|
||||
local pp_sharpen_contrast = CreateClientConVar( "pp_sharpen_contrast", "1", true, false )
|
||||
local pp_sharpen_distance = CreateClientConVar( "pp_sharpen_distance", "1", true, false )
|
||||
|
||||
function DrawSharpen( contrast, distance )
|
||||
|
||||
render.CopyRenderTargetToTexture( render.GetScreenEffectTexture() )
|
||||
|
||||
matSharpen:SetFloat( "$contrast", contrast )
|
||||
matSharpen:SetFloat( "$distance", distance / ScrW() )
|
||||
|
||||
render.SetMaterial( matSharpen )
|
||||
render.DrawScreenQuad()
|
||||
|
||||
end
|
||||
|
||||
hook.Add( "RenderScreenspaceEffects", "RenderSharpen", function()
|
||||
|
||||
if ( !pp_sharpen:GetBool() ) then return end
|
||||
if ( !GAMEMODE:PostProcessPermitted( "sharpen" ) ) then return end
|
||||
|
||||
DrawSharpen( pp_sharpen_contrast:GetFloat(), pp_sharpen_distance:GetFloat() )
|
||||
|
||||
end )
|
||||
|
||||
list.Set( "PostProcess", "#sharpen_pp", {
|
||||
|
||||
icon = "gui/postprocess/sharpen.png",
|
||||
convar = "pp_sharpen",
|
||||
category = "#shaders_pp",
|
||||
|
||||
cpanel = function( CPanel )
|
||||
|
||||
CPanel:AddControl( "Header", { Description = "#sharpen_pp.desc" } )
|
||||
CPanel:AddControl( "CheckBox", { Label = "#sharpen_pp.enable", Command = "pp_sharpen" } )
|
||||
|
||||
local params = { Options = {}, CVars = {}, MenuButton = "1", Folder = "sharpen" }
|
||||
params.Options[ "#preset.default" ] = { pp_sharpen_distance = "1", pp_sharpen_contrast = "1" }
|
||||
params.CVars = table.GetKeys( params.Options[ "#preset.default" ] )
|
||||
CPanel:AddControl( "ComboBox", params )
|
||||
|
||||
CPanel:AddControl( "Slider", { Label = "#sharpen_pp.distance", Command = "pp_sharpen_distance", Type = "Float", Min = "-5", Max = "5" } )
|
||||
CPanel:AddControl( "Slider", { Label = "#sharpen_pp.contrast", Command = "pp_sharpen_contrast", Type = "Float", Min = "0", Max = "20" } )
|
||||
|
||||
end
|
||||
|
||||
} )
|
||||
59
lua/postprocess/sobel.lua
Normal file
59
lua/postprocess/sobel.lua
Normal file
@@ -0,0 +1,59 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
local SobelMaterial = Material( "pp/sobel" )
|
||||
SobelMaterial:SetTexture( "$fbtexture", render.GetScreenEffectTexture() )
|
||||
|
||||
local pp_sobel = CreateClientConVar( "pp_sobel", "0", false, false )
|
||||
local pp_sobel_threshold = CreateClientConVar( "pp_sobel_threshold", "0.11", true, false )
|
||||
|
||||
function DrawSobel( threshold )
|
||||
|
||||
render.CopyRenderTargetToTexture( render.GetScreenEffectTexture() )
|
||||
|
||||
-- update threshold value
|
||||
SobelMaterial:SetFloat( "$threshold", threshold )
|
||||
|
||||
render.SetMaterial( SobelMaterial )
|
||||
render.DrawScreenQuad()
|
||||
|
||||
end
|
||||
|
||||
hook.Add( "RenderScreenspaceEffects", "RenderSobel", function()
|
||||
|
||||
if ( !pp_sobel:GetBool() ) then return end
|
||||
if ( !GAMEMODE:PostProcessPermitted( "sobel" ) ) then return end
|
||||
|
||||
DrawSobel( pp_sobel_threshold:GetFloat() )
|
||||
|
||||
end )
|
||||
|
||||
list.Set( "PostProcess", "#sobel_pp", {
|
||||
|
||||
icon = "gui/postprocess/sobel.png",
|
||||
convar = "pp_sobel",
|
||||
category = "#shaders_pp",
|
||||
|
||||
cpanel = function( CPanel )
|
||||
|
||||
CPanel:AddControl( "Header", { Description = "#sobel_pp.desc" } )
|
||||
CPanel:AddControl( "CheckBox", { Label = "#sobel_pp.enable", Command = "pp_sobel" } )
|
||||
|
||||
local params = { Options = {}, CVars = {}, MenuButton = "1", Folder = "sobel" }
|
||||
params.Options[ "#preset.default" ] = { pp_sobel_threshold = "0.11" }
|
||||
params.CVars = table.GetKeys( params.Options[ "#preset.default" ] )
|
||||
CPanel:AddControl( "ComboBox", params )
|
||||
|
||||
CPanel:AddControl( "Slider", { Label = "#sobel_pp.threshold", Command = "pp_sobel_threshold", Type = "Float", Min = "0", Max = "1" } )
|
||||
|
||||
end
|
||||
|
||||
} )
|
||||
83
lua/postprocess/stereoscopy.lua
Normal file
83
lua/postprocess/stereoscopy.lua
Normal file
@@ -0,0 +1,83 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
Register the convars that will control this effect
|
||||
-----------------------------------------------------------]]
|
||||
local pp_stereoscopy = CreateClientConVar( "pp_stereoscopy", "0", false, false )
|
||||
local pp_stereoscopy_size = CreateClientConVar( "pp_stereoscopy_size", "6", true, false, nil, -11.5, 11.5 )
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
Can be called from engine or hooks using bloom.Draw
|
||||
-----------------------------------------------------------]]
|
||||
function RenderStereoscopy( ViewOrigin, ViewAngles )
|
||||
|
||||
render.Clear( 0, 0, 0, 255 )
|
||||
|
||||
local w = ScrW() / 2.2
|
||||
local h = ScrH() / 2.2
|
||||
|
||||
local Right = ViewAngles:Right() * pp_stereoscopy_size:GetFloat()
|
||||
|
||||
local view = {}
|
||||
|
||||
view.y = ScrH() / 2 - h / 2
|
||||
view.w = w
|
||||
view.h = h
|
||||
view.angles = ViewAngles
|
||||
|
||||
-- Left
|
||||
view.x = ScrW() / 2 - w - 10
|
||||
view.origin = ViewOrigin + Right
|
||||
render.RenderView( view )
|
||||
|
||||
-- Right
|
||||
view.x = ScrW() / 2 + 10
|
||||
view.origin = ViewOrigin - Right
|
||||
render.RenderView( view )
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
The function to draw the bloom (called from the hook)
|
||||
-----------------------------------------------------------]]
|
||||
hook.Add( "RenderScene", "RenderStereoscopy", function( ViewOrigin, ViewAngles, ViewFOV )
|
||||
|
||||
if ( !pp_stereoscopy:GetBool() ) then return end
|
||||
|
||||
RenderStereoscopy( ViewOrigin, ViewAngles )
|
||||
|
||||
-- Return true to override drawing the scene
|
||||
return true
|
||||
|
||||
end )
|
||||
|
||||
list.Set( "PostProcess", "#stereoscopy_pp", {
|
||||
|
||||
icon = "gui/postprocess/stereoscopy.png",
|
||||
convar = "pp_stereoscopy",
|
||||
category = "#effects_pp",
|
||||
|
||||
cpanel = function( CPanel )
|
||||
|
||||
CPanel:AddControl( "Header", { Description = "#stereoscopy_pp.desc" } )
|
||||
CPanel:AddControl( "CheckBox", { Label = "#stereoscopy_pp.enable", Command = "pp_stereoscopy" } )
|
||||
|
||||
local params = { Options = {}, CVars = {}, MenuButton = "1", Folder = "stereoscopy" }
|
||||
params.Options[ "#preset.default" ] = { pp_stereoscopy_size = "6" }
|
||||
params.CVars = table.GetKeys( params.Options[ "#preset.default" ] )
|
||||
CPanel:AddControl( "ComboBox", params )
|
||||
|
||||
CPanel:AddControl( "Slider", { Label = "#stereoscopy_pp.size", Command = "pp_stereoscopy_size", Type = "Float", Min = "0", Max = "10" } )
|
||||
|
||||
end
|
||||
|
||||
} )
|
||||
84
lua/postprocess/sunbeams.lua
Normal file
84
lua/postprocess/sunbeams.lua
Normal file
@@ -0,0 +1,84 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
local matSunbeams = Material( "pp/sunbeams" )
|
||||
matSunbeams:SetTexture( "$fbtexture", render.GetScreenEffectTexture() )
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
Register the convars that will control this effect
|
||||
-----------------------------------------------------------]]
|
||||
local pp_sunbeams = CreateClientConVar( "pp_sunbeams", "0", false, false )
|
||||
local pp_sunbeams_darken = CreateClientConVar( "pp_sunbeams_darken", "0.95", true, false )
|
||||
local pp_sunbeams_multiply = CreateClientConVar( "pp_sunbeams_multiply", "1.0", true, false )
|
||||
local pp_sunbeams_sunsize = CreateClientConVar( "pp_sunbeams_sunsize", "0.075", true, false )
|
||||
|
||||
|
||||
function DrawSunbeams( darken, multiply, sunsize, sunx, suny )
|
||||
|
||||
if ( !render.SupportsPixelShaders_2_0() ) then return end
|
||||
|
||||
render.CopyRenderTargetToTexture( render.GetScreenEffectTexture() )
|
||||
|
||||
matSunbeams:SetFloat( "$darken", darken )
|
||||
matSunbeams:SetFloat( "$multiply", multiply )
|
||||
matSunbeams:SetFloat( "$sunx", sunx )
|
||||
matSunbeams:SetFloat( "$suny", suny )
|
||||
matSunbeams:SetFloat( "$sunsize", sunsize )
|
||||
|
||||
render.SetMaterial( matSunbeams )
|
||||
render.DrawScreenQuad()
|
||||
|
||||
end
|
||||
|
||||
hook.Add( "RenderScreenspaceEffects", "RenderSunbeams", function()
|
||||
|
||||
if ( !pp_sunbeams:GetBool() ) then return end
|
||||
if ( !GAMEMODE:PostProcessPermitted( "sunbeams" ) ) then return end
|
||||
if ( !render.SupportsPixelShaders_2_0() ) then return end
|
||||
|
||||
local sun = util.GetSunInfo()
|
||||
|
||||
if ( !sun ) then return end
|
||||
if ( sun.obstruction == 0 ) then return end
|
||||
|
||||
local sunpos = EyePos() + sun.direction * 4096
|
||||
local scrpos = sunpos:ToScreen()
|
||||
|
||||
local dot = ( sun.direction:Dot( EyeVector() ) - 0.8 ) * 5
|
||||
if ( dot <= 0 ) then return end
|
||||
|
||||
DrawSunbeams( pp_sunbeams_darken:GetFloat(), pp_sunbeams_multiply:GetFloat() * dot * sun.obstruction, pp_sunbeams_sunsize:GetFloat(), scrpos.x / ScrW(), scrpos.y / ScrH() )
|
||||
|
||||
end )
|
||||
|
||||
list.Set( "PostProcess", "#sunbeams_pp", {
|
||||
|
||||
icon = "gui/postprocess/sunrays.png",
|
||||
convar = "pp_sunbeams",
|
||||
category = "#shaders_pp",
|
||||
|
||||
cpanel = function( CPanel )
|
||||
|
||||
CPanel:AddControl( "Header", { Description = "#sunbeams_pp.desc" } )
|
||||
CPanel:AddControl( "CheckBox", { Label = "#sunbeams_pp.enable", Command = "pp_sunbeams" } )
|
||||
|
||||
local params = { Options = {}, CVars = {}, MenuButton = "1", Folder = "sunbeams" }
|
||||
params.Options[ "#preset.default" ] = { pp_sunbeams = "0", pp_sunbeams_darken = "0.95", pp_sunbeams_multiply = "1", pp_sunbeams_sunsize = "0.075" }
|
||||
params.CVars = table.GetKeys( params.Options[ "#preset.default" ] )
|
||||
CPanel:AddControl( "ComboBox", params )
|
||||
|
||||
CPanel:AddControl( "Slider", { Label = "#sunbeams_pp.multiply", Command = "pp_sunbeams_multiply", Type = "Float", Min = "0", Max = "1" } )
|
||||
CPanel:AddControl( "Slider", { Label = "#sunbeams_pp.darken", Command = "pp_sunbeams_darken", Type = "Float", Min = "0", Max = "1" } )
|
||||
CPanel:AddControl( "Slider", { Label = "#sunbeams_pp.size", Command = "pp_sunbeams_sunsize", Type = "Float", Min = "0.01", Max = "0.25" } )
|
||||
|
||||
end
|
||||
|
||||
} )
|
||||
400
lua/postprocess/super_dof.lua
Normal file
400
lua/postprocess/super_dof.lua
Normal file
@@ -0,0 +1,400 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
local PANEL = {}
|
||||
|
||||
local Distance = 256
|
||||
local BlurSize = 0.5
|
||||
local Passes = 12
|
||||
local Steps = 24
|
||||
local Shape = 0.5
|
||||
|
||||
local SuperDOFWindow = nil
|
||||
local Status = "Preview"
|
||||
|
||||
local FocusGrabber = false
|
||||
|
||||
function PANEL:Init()
|
||||
|
||||
self:SetTitle( "#superdof_pp.title" )
|
||||
self:SetRenderInScreenshots( false )
|
||||
|
||||
local Panel = vgui.Create( "DPanel", self )
|
||||
|
||||
local lbl = Label( "#superdof_pp.settings", Panel )
|
||||
lbl:SetContentAlignment( 8 )
|
||||
lbl:Dock( TOP )
|
||||
lbl:SetDark( true )
|
||||
|
||||
self.BlurSize = vgui.Create( "DNumSlider", Panel )
|
||||
self.BlurSize:SetMin( 0 )
|
||||
self.BlurSize:SetMax( 10 )
|
||||
self.BlurSize:SetDecimals( 3 )
|
||||
self.BlurSize:SetText( "#superdof_pp.size" )
|
||||
self.BlurSize:SetValue( BlurSize )
|
||||
self.BlurSize:SetDefaultValue( 0.5 )
|
||||
function self.BlurSize:OnValueChanged( val ) BlurSize = val end
|
||||
self.BlurSize:Dock( TOP )
|
||||
self.BlurSize:DockMargin( 0, 0, 0, 16 )
|
||||
self.BlurSize:SetDark( true )
|
||||
|
||||
self.Distance = vgui.Create( "DNumSlider", Panel )
|
||||
self.Distance:SetMin( 0 )
|
||||
self.Distance:SetMax( 4096 )
|
||||
self.Distance:SetText( "#superdof_pp.distance" )
|
||||
self.Distance:SetValue( Distance )
|
||||
self.Distance:SetDefaultValue( 256 )
|
||||
function self.Distance:OnValueChanged( val ) Distance = val end
|
||||
self.Distance:Dock( TOP )
|
||||
self.Distance:SetDark( true )
|
||||
self.Distance:SetTooltip( "#superdof_pp.distance.tooltip" )
|
||||
|
||||
Panel:SetPos( 10, 30 )
|
||||
Panel:SetSize( 300, 90 )
|
||||
Panel:DockPadding( 8, 8, 8, 8 )
|
||||
Panel:DockMargin( 0, 0, 4, 0 )
|
||||
Panel:Dock( FILL )
|
||||
|
||||
local Panel = vgui.Create( "DPanel", self )
|
||||
|
||||
local lbl = Label( "#superdof_pp.adv", Panel )
|
||||
lbl:SetContentAlignment( 8 )
|
||||
lbl:Dock( TOP )
|
||||
lbl:SetDark( true )
|
||||
|
||||
local PassesCtrl = vgui.Create( "DNumSlider", Panel )
|
||||
PassesCtrl:SetMin( 1 )
|
||||
PassesCtrl:SetMax( 64 )
|
||||
PassesCtrl:SetDecimals( 0 )
|
||||
PassesCtrl:SetText( "#superdof_pp.passes" )
|
||||
PassesCtrl:SetValue( Passes )
|
||||
PassesCtrl:SetDefaultValue( 12 )
|
||||
function PassesCtrl:OnValueChanged( val ) Passes = val end
|
||||
PassesCtrl:Dock( TOP )
|
||||
PassesCtrl:DockMargin( 0, 0, 0, 4 )
|
||||
PassesCtrl:SetDark( true )
|
||||
|
||||
local RadialsCtrl = vgui.Create( "DNumSlider", Panel )
|
||||
RadialsCtrl:SetMin( 1 )
|
||||
RadialsCtrl:SetMax( 64 )
|
||||
RadialsCtrl:SetDecimals( 0 )
|
||||
RadialsCtrl:SetText( "#superdof_pp.radials" )
|
||||
RadialsCtrl:SetValue( Steps )
|
||||
RadialsCtrl:SetDefaultValue( 24 )
|
||||
function RadialsCtrl:OnValueChanged( val ) Steps = val end
|
||||
RadialsCtrl:Dock( TOP )
|
||||
RadialsCtrl:DockMargin( 0, 0, 0, 4 )
|
||||
RadialsCtrl:SetDark( true )
|
||||
|
||||
local ShapeCtrl = vgui.Create( "DNumSlider", Panel )
|
||||
ShapeCtrl:SetMin( 0 )
|
||||
ShapeCtrl:SetMax( 1 )
|
||||
ShapeCtrl:SetDecimals( 3 )
|
||||
ShapeCtrl:SetText( "#superdof_pp.shape" )
|
||||
ShapeCtrl:SetValue( Shape )
|
||||
ShapeCtrl:SetDefaultValue( 0.5 )
|
||||
function ShapeCtrl:OnValueChanged( val ) Shape = val end
|
||||
ShapeCtrl:Dock( TOP )
|
||||
ShapeCtrl:DockMargin( 0, 0, 0, 4 )
|
||||
ShapeCtrl:SetDark( true )
|
||||
|
||||
Panel:SetPos( 10, 30 )
|
||||
Panel:SetSize( 150, 100 )
|
||||
Panel:DockPadding( 8, 8, 8, 8 )
|
||||
Panel:Dock( RIGHT )
|
||||
|
||||
local Panel = vgui.Create( "DPanel", self )
|
||||
|
||||
self.Render = vgui.Create( "DButton", Panel )
|
||||
self.Render:SetText( "#superdof_pp.render" )
|
||||
function self.Render:DoClick() Status = "Render" end
|
||||
self.Render:Dock( RIGHT ) self.Render:SetSize( 70, 20 )
|
||||
|
||||
self.Screenshot = vgui.Create( "DButton", Panel )
|
||||
self.Screenshot:SetText( "#superdof_pp.screenshot" )
|
||||
function self.Screenshot:DoClick() RunConsoleCommand( "jpeg" ) end
|
||||
self.Screenshot:Dock( RIGHT )
|
||||
self.Screenshot:SetSize( 120, 20 )
|
||||
self.Screenshot:DockMargin( 0, 0, 8, 0 )
|
||||
|
||||
local Break = vgui.Create( "DButton", Panel )
|
||||
Break:SetText( "5" )
|
||||
local THIS = self
|
||||
function Break:DoClick()
|
||||
THIS:SetVisible( false )
|
||||
timer.Simple( 5, function()
|
||||
if IsValid( THIS ) then
|
||||
THIS:SetVisible( true )
|
||||
end
|
||||
end )
|
||||
end
|
||||
Break:Dock( LEFT )
|
||||
Break:SetSize( 20, 20 )
|
||||
Break:SetTooltip( "#superdof_pp.5hint" )
|
||||
|
||||
Panel:Dock( BOTTOM )
|
||||
Panel:DockPadding( 4, 4, 4, 4 )
|
||||
Panel:DockMargin( 0, 4, 0, 0 )
|
||||
Panel:SetTall( 28 )
|
||||
Panel:MoveToBack()
|
||||
|
||||
self:SetSize( 600, 220 )
|
||||
|
||||
end
|
||||
|
||||
function PANEL:ChangeDistanceTo( dist )
|
||||
|
||||
self.Distance:SetValue( dist )
|
||||
|
||||
end
|
||||
|
||||
function PANEL:PositionMyself()
|
||||
|
||||
self:AlignBottom( 50 )
|
||||
self:CenterHorizontal()
|
||||
|
||||
end
|
||||
|
||||
function PANEL:OnScreenSizeChanged( what, ever )
|
||||
|
||||
self:PositionMyself()
|
||||
|
||||
end
|
||||
|
||||
local paneltypeSuperDOF = vgui.RegisterTable( PANEL, "DFrame" )
|
||||
local texFSB = render.GetSuperFPTex()
|
||||
local matFSB = Material( "pp/motionblur" )
|
||||
local matFB = Material( "pp/fb" )
|
||||
|
||||
surface.CreateFont( "SuperDofText",
|
||||
{
|
||||
font = "Helvetica",
|
||||
size = 20,
|
||||
weight = 700
|
||||
})
|
||||
|
||||
function RenderDoF( vOrigin, vAngle, vFocus, fAngleSize, radial_steps, passes, bSpin, inView, ViewFOV )
|
||||
|
||||
local OldRT = render.GetRenderTarget()
|
||||
local view = { x = 0, y = 0, w = ScrW(), h = ScrH() }
|
||||
local fDistance = vOrigin:Distance( vFocus )
|
||||
|
||||
fAngleSize = fAngleSize * math.Clamp( 256 / fDistance, 0.1, 1 ) * 0.5
|
||||
|
||||
local view = inView
|
||||
|
||||
if ( !view ) then
|
||||
|
||||
view = {
|
||||
x = 0,
|
||||
y = 0,
|
||||
w = ScrW(),
|
||||
h = ScrH(),
|
||||
dopostprocess = true,
|
||||
origin = vOrigin,
|
||||
angles = vAngle,
|
||||
fov = ViewFOV
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
-- Straight render (to act as a canvas)
|
||||
render.RenderView( view )
|
||||
|
||||
render.UpdateScreenEffectTexture()
|
||||
|
||||
render.SetRenderTarget( texFSB )
|
||||
render.Clear( 0, 0, 0, 255, true, true )
|
||||
matFB:SetFloat( "$alpha", 1 )
|
||||
render.SetMaterial( matFB )
|
||||
render.DrawScreenQuad()
|
||||
|
||||
local Radials = ( math.pi * 2 ) / radial_steps
|
||||
|
||||
for mul = 1 / passes, 1, 1 / passes do
|
||||
|
||||
for i = 0, math.pi * 2, Radials do
|
||||
|
||||
local VA = vAngle * 1 -- hack - this makes it copy the angles instead of the reference
|
||||
local VRot = vAngle * 1
|
||||
-- Rotate around the focus point
|
||||
VA:RotateAroundAxis( VRot:Right(), math.sin( i + mul ) * fAngleSize * mul * Shape * 2 )
|
||||
VA:RotateAroundAxis( VRot:Up(), math.cos( i + mul ) * fAngleSize * mul * ( 1 - Shape ) * 2 )
|
||||
|
||||
view.origin = vFocus - VA:Forward() * fDistance
|
||||
view.angles = VA
|
||||
|
||||
-- Render to the front buffer
|
||||
render.SetRenderTarget( OldRT )
|
||||
render.Clear( 0, 0, 0, 255, true, true )
|
||||
render.RenderView( view )
|
||||
render.UpdateScreenEffectTexture()
|
||||
|
||||
-- Copy it to our floating point buffer at a reduced alpha
|
||||
render.SetRenderTarget( texFSB )
|
||||
local alpha = ( Radials / ( math.pi * 2 ) ) -- Divide alpha by number of radials
|
||||
alpha = alpha * ( 1 - mul ) -- Reduce alpha the further away from center we are
|
||||
matFB:SetFloat( "$alpha", alpha )
|
||||
|
||||
render.SetMaterial( matFB )
|
||||
render.DrawScreenQuad()
|
||||
|
||||
-- We have to SPIN here to stop the Source engine running out of render queue space.
|
||||
if ( bSpin ) then
|
||||
|
||||
-- Restore RT
|
||||
render.SetRenderTarget( OldRT )
|
||||
|
||||
-- Render our result buffer to the screen
|
||||
matFSB:SetFloat( "$alpha", 1 )
|
||||
matFSB:SetTexture( "$basetexture", texFSB )
|
||||
|
||||
render.SetMaterial( matFSB )
|
||||
render.DrawScreenQuad()
|
||||
|
||||
cam.Start2D()
|
||||
local add = ( i / ( math.pi * 2 ) ) * ( 1 / passes )
|
||||
local percent = string.format( "%.1f", ( mul - ( 1 / passes ) + add ) * 100 )
|
||||
draw.DrawText( percent .. "%", "SuperDofText", view.w - 100, view.h - 100, color_black, TEXT_ALIGN_CENTER )
|
||||
draw.DrawText( percent .. "%", "SuperDofText", view.w - 101, view.h - 101, color_white, TEXT_ALIGN_CENTER )
|
||||
cam.End2D()
|
||||
|
||||
render.Spin()
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Restore RT
|
||||
render.SetRenderTarget( OldRT )
|
||||
render.Clear( 0, 255, 0, 255, true, true )
|
||||
|
||||
-- Render our result buffer to the screen
|
||||
matFSB:SetFloat( "$alpha", 1 )
|
||||
matFSB:SetTexture( "$basetexture", texFSB )
|
||||
|
||||
render.SetMaterial( matFSB )
|
||||
render.DrawScreenQuad()
|
||||
|
||||
end
|
||||
|
||||
function RenderSuperDoF( ViewOrigin, ViewAngles, ViewFOV )
|
||||
|
||||
if ( FocusGrabber ) then
|
||||
|
||||
local x, y = input.GetCursorPos()
|
||||
local dir = util.AimVector( ViewAngles, ViewFOV, x, y, ScrW(), ScrH() )
|
||||
|
||||
local tr = util.TraceLine( util.GetPlayerTrace( LocalPlayer(), dir ) )
|
||||
Distance = tr.HitPos:Distance( ViewOrigin )
|
||||
Status = "Preview"
|
||||
|
||||
-- debugoverlay.Cross( tr.HitPos, 10 )
|
||||
|
||||
SuperDOFWindow:ChangeDistanceTo( Distance )
|
||||
|
||||
local effectdata = EffectData()
|
||||
effectdata:SetOrigin( tr.HitPos )
|
||||
effectdata:SetNormal( tr.HitNormal )
|
||||
effectdata:SetMagnitude( 1 )
|
||||
effectdata:SetScale( 1 )
|
||||
effectdata:SetRadius( 16 )
|
||||
|
||||
util.Effect( "Sparks", effectdata )
|
||||
|
||||
end
|
||||
|
||||
local FocusPoint = ViewOrigin + ViewAngles:Forward() * Distance
|
||||
|
||||
if ( Status == "Preview" ) then
|
||||
|
||||
-- A low quality, pretty quickly drawn rough outline
|
||||
RenderDoF( ViewOrigin, ViewAngles, FocusPoint, BlurSize, 2, 2, false, nil, ViewFOV )
|
||||
|
||||
elseif ( Status == "Render" ) then
|
||||
|
||||
-- A great quality render..
|
||||
RenderDoF( ViewOrigin, ViewAngles, FocusPoint, BlurSize, Steps, Passes, true, nil, ViewFOV )
|
||||
Status = "ViewShot"
|
||||
|
||||
elseif ( Status == "ViewShot" ) then
|
||||
|
||||
matFSB:SetFloat( "$alpha", 1 )
|
||||
matFSB:SetTexture( "$basetexture", texFSB )
|
||||
render.SetMaterial( matFSB )
|
||||
render.DrawScreenQuad()
|
||||
|
||||
end
|
||||
|
||||
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"
|
||||
|
||||
if ( IsValid( SuperDOFWindow ) ) then
|
||||
SuperDOFWindow:Remove()
|
||||
end
|
||||
|
||||
SuperDOFWindow = vgui.CreateFromTable( paneltypeSuperDOF )
|
||||
|
||||
SuperDOFWindow:InvalidateLayout( true )
|
||||
SuperDOFWindow:MakePopup()
|
||||
SuperDOFWindow:PositionMyself()
|
||||
|
||||
end )
|
||||
|
||||
hook.Add( "GUIMousePressed", "SuperDOFMouseDown", function( mouse )
|
||||
|
||||
if ( !IsValid( SuperDOFWindow ) ) then return end
|
||||
|
||||
vgui.GetWorldPanel():MouseCapture( true )
|
||||
FocusGrabber = true
|
||||
|
||||
end )
|
||||
|
||||
hook.Add( "GUIMouseReleased", "SuperDOFMouseUp", function( mouse )
|
||||
|
||||
if ( !IsValid( SuperDOFWindow ) ) then return end
|
||||
|
||||
vgui.GetWorldPanel():MouseCapture( false )
|
||||
FocusGrabber = false
|
||||
|
||||
end )
|
||||
|
||||
list.Set( "PostProcess", "#superdof_pp", {
|
||||
icon = "gui/postprocess/superdof.png",
|
||||
category = "#effects_pp",
|
||||
onclick = function() RunConsoleCommand( "pp_superdof" ) end
|
||||
} )
|
||||
|
||||
--
|
||||
-- We don't want people using weapons when they click on the screen
|
||||
--
|
||||
hook.Add( "PreventScreenClicks", "SuperDOFPreventClicks", function()
|
||||
|
||||
if ( IsValid( SuperDOFWindow ) ) then return true end
|
||||
|
||||
end )
|
||||
73
lua/postprocess/texturize.lua
Normal file
73
lua/postprocess/texturize.lua
Normal file
@@ -0,0 +1,73 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
local matMaterial = Material( "pp/texturize" )
|
||||
matMaterial:SetTexture( "$fbtexture", render.GetScreenEffectTexture() )
|
||||
|
||||
local pp_texturize = CreateClientConVar( "pp_texturize", "", false, false )
|
||||
local pp_texturize_scale = CreateClientConVar( "pp_texturize_scale", "1", true, false )
|
||||
|
||||
function DrawTexturize( scale, pMaterial )
|
||||
|
||||
render.CopyRenderTargetToTexture( render.GetScreenEffectTexture() )
|
||||
|
||||
matMaterial:SetFloat( "$scalex", ( ScrW() / 64 ) * scale )
|
||||
matMaterial:SetFloat( "$scaley", ( ScrH() / 64 / 8 ) * scale )
|
||||
matMaterial:SetTexture( "$basetexture", pMaterial:GetTexture( "$basetexture" ) )
|
||||
|
||||
render.SetMaterial( matMaterial )
|
||||
render.DrawScreenQuad()
|
||||
|
||||
end
|
||||
|
||||
hook.Add( "RenderScreenspaceEffects", "RenderTexturize", function()
|
||||
|
||||
local texturize = pp_texturize:GetString()
|
||||
|
||||
if ( texturize == "" ) then return end
|
||||
if ( !GAMEMODE:PostProcessPermitted( "texurize" ) ) then return end
|
||||
|
||||
DrawTexturize( pp_texturize_scale:GetFloat(), Material( texturize ) )
|
||||
|
||||
end )
|
||||
|
||||
list.Set( "TexturizeMaterials", "plain", { Material = "pp/texturize/plain.png", Icon = "pp/texturize/plain.png" } )
|
||||
list.Set( "TexturizeMaterials", "pattern1", { Material = "pp/texturize/pattern1.png", Icon = "pp/texturize/pattern1.png" } )
|
||||
list.Set( "TexturizeMaterials", "rainbow", { Material = "pp/texturize/rainbow.png", Icon = "pp/texturize/rainbow.png" } )
|
||||
list.Set( "TexturizeMaterials", "lines", { Material = "pp/texturize/lines.png", Icon = "pp/texturize/lines.png" } )
|
||||
list.Set( "TexturizeMaterials", "pinko", { Material = "pp/texturize/pinko.png", Icon = "pp/texturize/pinko.png" } )
|
||||
list.Set( "TexturizeMaterials", "squaredo", { Material = "pp/texturize/squaredo.png", Icon = "pp/texturize/squaredo.png" } )
|
||||
|
||||
list.Set( "PostProcess", "#texturize_pp", {
|
||||
|
||||
category = "#texturize_pp",
|
||||
|
||||
func = function( content )
|
||||
|
||||
for k, textr in pairs( list.Get( "TexturizeMaterials" ) ) do
|
||||
|
||||
spawnmenu.CreateContentIcon( "postprocess", content, {
|
||||
name = "#texturize_pp",
|
||||
label = string.gsub( k, "^%a", string.upper( string.sub( k, 1, 1 ) ) ),
|
||||
icon = textr.Icon,
|
||||
convars = {
|
||||
pp_texturize = {
|
||||
on = textr.Material,
|
||||
off = ""
|
||||
}
|
||||
}
|
||||
} )
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
} )
|
||||
74
lua/postprocess/toytown.lua
Normal file
74
lua/postprocess/toytown.lua
Normal file
@@ -0,0 +1,74 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
local matToytown = Material( "pp/toytown-top" )
|
||||
//matToytown:SetTexture( "$fbtexture", render.GetScreenEffectTexture() )
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
Register the convars that will control this effect
|
||||
-----------------------------------------------------------]]
|
||||
local pp_toytown = CreateClientConVar( "pp_toytown", "0", false, false )
|
||||
local pp_toytown_passes = CreateClientConVar( "pp_toytown_passes", "3", true, false )
|
||||
local pp_toytown_size = CreateClientConVar( "pp_toytown_size", "0.4", true, false )
|
||||
|
||||
function DrawToyTown( NumPasses, H )
|
||||
cam.Start2D()
|
||||
|
||||
surface.SetMaterial( matToytown )
|
||||
surface.SetDrawColor( 255, 255, 255, 255 )
|
||||
|
||||
for i = 1, NumPasses do
|
||||
|
||||
render.CopyRenderTargetToTexture( render.GetScreenEffectTexture() )
|
||||
|
||||
surface.DrawTexturedRect( 0, 0, ScrW(), H )
|
||||
surface.DrawTexturedRectUV( 0, ScrH() - H, ScrW(), H, 0, 1, 1, 0 )
|
||||
|
||||
end
|
||||
|
||||
cam.End2D()
|
||||
end
|
||||
|
||||
hook.Add( "RenderScreenspaceEffects", "RenderToyTown", function()
|
||||
|
||||
if ( !pp_toytown:GetBool() ) then return end
|
||||
if ( !GAMEMODE:PostProcessPermitted( "toytown" ) ) then return end
|
||||
if ( !render.SupportsPixelShaders_2_0() ) then return end
|
||||
|
||||
local NumPasses = pp_toytown_passes:GetInt()
|
||||
local H = math.floor( ScrH() * pp_toytown_size:GetFloat() )
|
||||
|
||||
DrawToyTown( NumPasses, H )
|
||||
|
||||
end )
|
||||
|
||||
list.Set( "PostProcess", "#toytown_pp", {
|
||||
|
||||
icon = "gui/postprocess/toytown.png",
|
||||
convar = "pp_toytown",
|
||||
category = "#shaders_pp",
|
||||
|
||||
cpanel = function( CPanel )
|
||||
|
||||
CPanel:AddControl( "Header", { Description = "#toytown_pp.desc" } )
|
||||
CPanel:AddControl( "CheckBox", { Label = "#toytown_pp.enable", Command = "pp_toytown" } )
|
||||
|
||||
local params = { Options = {}, CVars = {}, MenuButton = "1", Folder = "frame_blend" }
|
||||
params.Options[ "#preset.default" ] = { pp_toytown_passes = "3", pp_toytown_size = "0.5" }
|
||||
params.CVars = table.GetKeys( params.Options[ "#preset.default" ] )
|
||||
CPanel:AddControl( "ComboBox", params )
|
||||
|
||||
CPanel:AddControl( "Slider", { Label = "#toytown_pp.passes", Command = "pp_toytown_passes", Type = "Int", Min = "1", Max = "100" } )
|
||||
CPanel:AddControl( "Slider", { Label = "#toytown_pp.height", Command = "pp_toytown_size", Type = "Float", Min = "0", Max = "1" } )
|
||||
|
||||
end
|
||||
|
||||
} )
|
||||
Reference in New Issue
Block a user