


local mat_ColorMod		= Material( "pp/colour" )
local tex_MotionBlur	= render.GetMoBlurTex0()

/*---------------------------------------------------------
   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 )

function DrawColorModify( tab )

	render.UpdateScreenEffectTexture()

	for k, v in pairs(tab) do
	
		mat_ColorMod:SetMaterialFloat( k, v )
		
	end

	render.SetMaterial( mat_ColorMod )
	render.DrawScreenQuad()
	
end

local function DrawInternal()

	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()
	tab[ "$pp_colour_addg" ] 		= pp_colormod_addg:GetFloat()
	tab[ "$pp_colour_addb" ] 		= pp_colormod_addb:GetFloat()
	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()
	tab[ "$pp_colour_mulg" ] 		= pp_colormod_mulg:GetFloat()
	tab[ "$pp_colour_mulb" ] 		= pp_colormod_mulb:GetFloat()
	
	DrawColorModify( tab );

end

hook.Add( "RenderScreenspaceEffects", "RenderColorModify", DrawInternal )