Code | if CLIENT then
local ppex_sunbeams = CreateClientConVar( "ppex_sunbeams", "0", true, false )
local ppex_sunbeams_ignore = CreateClientConVar( "ppex_sunbeams_ignore", "0", false, false )
local ppex_sunbeams_darken = CreateClientConVar( "ppex_sunbeams_darken", "0.95", false, false )
local ppex_sunbeams_multiply = CreateClientConVar( "ppex_sunbeams_multiply", "1.0", false, false )
local ppex_sunbeams_sunsize = CreateClientConVar( "ppex_sunbeams_sunsize", "0.075", false, false )
local ppex_sunbeams_x_offset = CreateClientConVar( "ppex_sunbeams_x_offset", "0.000", false, false )
local ppex_sunbeams_y_offset = CreateClientConVar( "ppex_sunbeams_y_offset", "0.000", false, false )
local ppex_sunbeams_z_offset = CreateClientConVar( "ppex_sunbeams_z_offset", "0.000", false, false )
local function DrawInternal()
local modx = ppex_sunbeams_x_offset:GetFloat()
local mody = ppex_sunbeams_y_offset:GetFloat()
local modz = ppex_sunbeams_z_offset:GetFloat()
local sun = util.GetSunInfo()
if (!sun) then return end
if !ppex_sunbeams_ignore:GetBool() && (sun.obstruction == 0) then return end
sun.direction.x = sun.direction.x + modx
sun.direction.y = sun.direction.y + mody
sun.direction.z = sun.direction.z + modz
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
local newmul = ppex_sunbeams_multiply:GetFloat()
if ppex_sunbeams_ignore:GetBool() then
newmul = newmul * dot
else
newmul = newmul * dot * sun.obstruction
end
DrawSunbeams( ppex_sunbeams_darken:GetFloat(),
newmul,
ppex_sunbeams_sunsize:GetFloat(),
scrpos.x / ScrW(),
scrpos.y / ScrH()
);
end
hook.Add( "RenderScreenspaceEffects", "CocksPostProcess", DrawInternal )
/*
// Control Panel
*/
local function BuildControlPanel( CPanel )
CPanel:AddControl( "Header", { Text = "Sun Beams EX", Description = "Sun Beams EX" } )
CPanel:AddControl( "CheckBox", { Label = "#Enable", Command = "ppex_sunbeams" } )
CPanel:AddControl( "CheckBox", { Label = "Ignore Obstruction", Command = "ppex_sunbeams_ignore" } )
CPanel:AddControl( "Slider", { Label = "#Multiply", Command = "ppex_sunbeams_multiply", Type = "Float", Min = "0", Max = "1" } )
CPanel:AddControl( "Slider", { Label = "#Darken", Command = "ppex_sunbeams_darken", Type = "Float", Min = "0", Max = "1" } )
CPanel:AddControl( "Slider", { Label = "#Sun Size", Command = "ppex_sunbeams_sunsize", Type = "Float", Min = "0.01", Max = "0.25" } )
CPanel:AddControl( "Slider", { Label = "Sun X Offset", Command = "ppex_sunbeams_x_offset", Type = "Float", Min = "-1.5", Max = "1.5" } )
CPanel:AddControl( "Slider", { Label = "Sun Y Offset", Command = "ppex_sunbeams_y_offset", Type = "Float", Min = "-1.5", Max = "1.5" } )
CPanel:AddControl( "Slider", { Label = "Sun Z Offset", Command = "ppex_sunbeams_z_offset", Type = "Float", Min = "-1.5", Max = "1.5" } )
end
/*
// Tool Menu
*/
local function AddPostProcessMenu()
spawnmenu.AddToolMenuOption( "PostProcessing", "PPShader", "SunBeamsMod", "Sun Beams Mod", "", "", BuildControlPanel, { SwitchConVar = "ppex_sunbeams" } )
end
hook.Add( "PopulateToolMenu", "AddPostProcessMenu_SunBeamsEX", AddPostProcessMenu )
end
|