


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

/*---------------------------------------------------------
   Register the convars that will control this effect
---------------------------------------------------------*/   
CreateClientConVar( "pp_colormod", "0", false, false )
CreateClientConVar( "pp_colormod_addr", "0", false, false )
CreateClientConVar( "pp_colormod_addg", "0", false, false )
CreateClientConVar( "pp_colormod_addb", "0", false, false )
CreateClientConVar( "pp_colormod_brightness", "0", false, false )
CreateClientConVar( "pp_colormod_contrast", "1", false, false )
CreateClientConVar( "pp_colormod_color", "1", false, false )
CreateClientConVar( "pp_colormod_mulr", "0", false, false )
CreateClientConVar( "pp_colormod_mulg", "0", false, false )
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 ( GetConVarNumber( "pp_colormod" ) == 0 ) then return end
	if ( !GAMEMODE:PostProcessPermitted( "color mod" ) ) then return end

	local tab = {}
	
	tab[ "$pp_colour_addr" ] 		= GetConVarNumber( "pp_colormod_addr" )
	tab[ "$pp_colour_addg" ] 		= GetConVarNumber( "pp_colormod_addg" )
	tab[ "$pp_colour_addb" ] 		= GetConVarNumber( "pp_colormod_addb" )
	tab[ "$pp_colour_brightness" ] 	= GetConVarNumber( "pp_colormod_brightness" )
	tab[ "$pp_colour_contrast" ] 	= GetConVarNumber( "pp_colormod_contrast" )
	tab[ "$pp_colour_colour" ] 		= GetConVarNumber( "pp_colormod_color" )
	tab[ "$pp_colour_mulr" ] 		= GetConVarNumber( "pp_colormod_mulr" )
	tab[ "$pp_colour_mulg" ] 		= GetConVarNumber( "pp_colormod_mulg" )
	tab[ "$pp_colour_mulb" ] 		= GetConVarNumber( "pp_colormod_mulb" )
	
	DrawColorModify( tab );

end

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