mirror of
https://github.com/JonnyBro/beatrun.git
synced 2024-12-28 12:53:02 +05:00
Fancy ass bokeh DoF (optional, of course)
This commit is contained in:
parent
65a94f54e5
commit
d8acbaa10d
1 changed files with 69 additions and 0 deletions
69
beatrun/gamemodes/beatrun/gamemode/cl/PostprocessEffects.lua
Normal file
69
beatrun/gamemodes/beatrun/gamemode/cl/PostprocessEffects.lua
Normal file
|
@ -0,0 +1,69 @@
|
|||
local function MyNeedsDepthPass()
|
||||
return true
|
||||
end
|
||||
|
||||
doffocus = CreateClientConVar("doftest_focus", 0, true, false, "", 0, 1)
|
||||
doffocus2 = CreateClientConVar("doftest_focus2", 0, true, false, "", 0, 1)
|
||||
local postprocessenable = CreateClientConVar("Beatrun_PostprocessEffects", 0, true, false, "Enables silly ahh post-processing effects. EXPERIMENTAL.", 0, 1)
|
||||
|
||||
-- Add hook so that the _rt_ResolvedFullFrameDepth texture is updated
|
||||
hook.Add( "NeedsDepthPass", "MyNeedsDepthPass", MyNeedsDepthPass )
|
||||
|
||||
local blur_mat = Material('pp/bokehblur')
|
||||
local BOKEN_FOCUS = 0
|
||||
local BOKEN_FORCE = 0
|
||||
|
||||
cyclestate = false
|
||||
|
||||
hook.Add("RenderScreenspaceEffects", "funnybrdof", function()
|
||||
if !postprocessenable:GetBool() then return end
|
||||
local ply = LocalPlayer()
|
||||
|
||||
render.UpdateScreenEffectTexture(1)
|
||||
|
||||
local trace = {}
|
||||
if not ply:ShouldDrawLocalPlayer() then
|
||||
eye = ply:EyePos()
|
||||
langles = ply:EyeAngles()
|
||||
|
||||
if ply:InVehicle() then
|
||||
langles = ply:GetVehicle():GetAngles() + langles
|
||||
end
|
||||
else
|
||||
eye = EyePos()
|
||||
langles = EyeAngles()
|
||||
ignoreEnts = true
|
||||
end
|
||||
trace.start = ply:EyePos()
|
||||
trace.endpos = langles:Forward() * 300 + eye
|
||||
trace.filter = function(ent)
|
||||
return true
|
||||
end
|
||||
|
||||
local tr = util.TraceLine(trace)
|
||||
local dist = tr.HitPos:Distance(ply:GetPos())
|
||||
|
||||
if ply:GetSliding() or ply:GetClimbing() != 0 or ply:GetWallrun() == 1 or IsValid(ply:GetLadder()) then
|
||||
BOKEN_FORCE = math.Clamp(BOKEN_FORCE + 0.03 * (FrameTime() * 66), 0,1)
|
||||
else
|
||||
BOKEN_FORCE = math.Clamp(BOKEN_FORCE - 0.03 * (FrameTime() * 66), 0,1)
|
||||
end
|
||||
|
||||
blur_mat:SetTexture("$BASETEXTURE", render.GetScreenEffectTexture(1))
|
||||
blur_mat:SetTexture("$DEPTHTEXTURE", render.GetResolvedFullFrameDepth())
|
||||
|
||||
blur_mat:SetFloat("$size", BOKEN_FORCE * 10)
|
||||
blur_mat:SetFloat("$focus", 0)
|
||||
blur_mat:SetFloat("$focusradius", 2 - 0.5 * 2)
|
||||
|
||||
--blur_mat:SetFloat("$size", BOKEN_FORCE * 3)
|
||||
--blur_mat:SetFloat("$focus", 0)
|
||||
--blur_mat:SetFloat("$focusradius", 2 - 0.5 * 3)
|
||||
--print(BOKEN_FOCUS)
|
||||
|
||||
--render.SetMaterial(fbtexture)
|
||||
--render.DrawScreenQuadEx(0,0,960,540)
|
||||
render.SetMaterial(blur_mat)
|
||||
render.DrawScreenQuad()
|
||||
--render.DrawTextureToScreenRect(render.GetResolvedFullFrameDepth(),960,0,960,540)
|
||||
end)
|
Loading…
Reference in a new issue