local mat_Morph
= Material( "pp/morph/refract" )
local mat_Brush
= Material( "pp/morph/brush1" )
local mat_BrushOut
= Material( "pp/morph/brush_outline" )
Morph = {}
Morph.Drawing = false
Morph.BrushSize = 64
// This morph was so awesome. It was just like in photoshop or something
// But it turned out that it only worked on my Geforce 7800GTX
// So I had to make it dumb :(
// Maybe one day it'll be awesome again!
/*---------------------------------------------------------
Register the convars that will control this effect
---------------------------------------------------------*/
local function MorphFrameVisible()
if ( !Morph.Frame ) then return false end
end
/*---------------------------------------------------------
Draws the morph - you can call this from a function if you need to.
---------------------------------------------------------*/
// Copy the backbuffer to the screen effect texture
// Clear the morph buffer
end
// Here's the situation with this.
// I had it set up awesome, when it drew it just used the additive blend mode and it added/subtracted just fine.
// Then I found out it didn't work on ATI cards so I had to complicate everything.
if (Morph.Drawing && MorphFrameVisible()) then
// Interpolate the two positions
local vStart
= Vector ( Morph.oldX, Morph.oldY,
0 )
local vEnd
= Vector ( x, y,
0 )
local vDiff = vEnd-vStart
color
= Color( 128,
128,
128,
16 )
local r = (Morph.oldX - x)*10
local g = (Morph.oldY - y)*10
for i=0, fLen, 16 do
end
end
end
Morph.oldX = x
Morph.oldY = y
// Draw the handle
end
end
/*---------------------------------------------------------
Hooked function to draw the morph
---------------------------------------------------------*/
local function DrawInternal()
if ( !pp_morph:
GetBool() ) then return end
if ( !GAMEMODE:PostProcessPermitted( "morph" ) ) then return end
end
hook.Add( "RenderScreenspaceEffects",
"DrawMorph", DrawInternal
)
/*---------------------------------------------------------
Mouse button down
---------------------------------------------------------*/
local function MouseDown( mouse )
if (!MorphFrameVisible()) then return end
// This makes it so that even if you're hovering over another panel when you
// release the mouse - it will still send the release event to this panel
Morph.Drawing = true
end
/*---------------------------------------------------------
Mouse button released
---------------------------------------------------------*/
local function MouseUp( mouse )
if (!MorphFrameVisible()) then return end
Morph.Drawing = false
end
hook.Add( "GUIMousePressed",
"MorphMouseDown", MouseDown
)
hook.Add( "GUIMouseReleased",
"MorphMouseUp", MouseUp
)
/*---------------------------------------------------------
This is a console command that opens the morph window
---------------------------------------------------------*/
local function MorphFrame( player, command, arguments )
if (Morph.Frame) then
return end
// Brush Size Slider
local brushsize = function( panel, message, param1, param2 )
if (message != "SliderMoved") then return end
Morph.BrushSize = param1
end
local slider
= vgui.Create( "Slider", frame,
"MorphSlider" )
// Refract Size Slider
local refractsize = function( panel, message, param1, param2 )
if (message != "SliderMoved") then return end
end
local slider
= vgui.Create( "Slider", frame,
"RefractSlider" )
// Clear Button
local clear = function( panel, message, param1, param2 )
if (message != "Command") then return end
end
local button
= vgui.Create( "Button", frame,
"ClearButton" )
// Screenshot Button
local screenshot = function( panel, message, param1, param2 )
if (message != "Command") then return end
end
local button
= vgui.Create( "Button", frame,
"ScreenshotButton" )
Morph.Frame = frame
// Turn morphing on
end
/*
// Control Panel
*/
local function BuildControlPanel( CPanel )
CPanel:AddControl( "Header", { Text = "#Morph", Description = "#Morph_Information" } )
CPanel:AddControl
( "CheckBox",
{ Label = "#Morph_Toggle",
Command = "pp_morph" } )
CPanel:Button( "#Morph_Open", "pp_morph_open" )
end
/*
// Tool Menu
*/
local function AddPostProcessMenu()
spawnmenu.AddToolMenuOption( "PostProcessing",
"PPShader",
"Morph",
"#Morph",
"",
"", BuildControlPanel,
{ SwitchConVar
= "pp_morph" } )
end
hook.Add( "PopulateToolMenu",
"AddPostProcessMenu_Morph", AddPostProcessMenu
)