I need help making a blurred derma panel.

Hi, I would like to make a blurred derma panel but i dont know exactly how to do that.

I tried that:


PANEL = {}

local mouseX, mouseY = ScrW() / 2, ScrH() / 2
function PANEL:Init()
    self.F4Down = true

    self:StretchToParent(100, 100, 100, 100)
    self:Center()
    self:SetVisible(false)
    self:MakePopup()
    self.Paint = function(s , w , h)

 
      local blur = Material("pp/blurscreen")
      local function DrawBlurRect(x, y, w, h)
    local X, Y = 0,0

    surface.SetDrawColor(255,255,255)
    surface.SetMaterial(blur)

    for i = 1, 5 do
        blur:SetFloat("$blur", (i / 3) * (5))
        blur:Recompute()

        render.UpdateScreenEffectTexture()

        render.SetScissorRect(x, y, x+w, y+h, true)
            surface.DrawTexturedRect(X * -1, Y * -1, ScrW(), ScrH())
        render.SetScissorRect(0, 0, 0, 0, false)
    end
   
   draw.RoundedBox(0,x,y,w,h,Color(0,0,0,205))
   surface.SetDrawColor(0,0,0)
   surface.DrawOutlinedRect(x,y,w,h)
   
end

DrawBlurRect(0, 0, w, h)


end

    self:SetupCloseButton(fn.Curry(self.Hide, 2)(self))
end 

But it didn’t work like expected. (http://imgur.com/baYOwaX)
It works just fine if I try to draw a blurred rectangle on my hud.


 self:SetBackgroundBlur( true ) 

That sets the background blur… Meaning it makes the background of the frame blurry.

I use this to make it blurry:




local blur = Material("pp/blurscreen")

local function DrawBlur( p, a, d )


	local x, y = p:LocalToScreen(0, 0)
	
	surface.SetDrawColor( 255, 255, 255 )
	
	surface.SetMaterial( blur )
	
	for i = 1, d do
	
	
		blur:SetFloat( "$blur", (i / d ) * ( a ) )
		
		blur:Recompute()
		
		render.UpdateScreenEffectTexture()
		
		surface.DrawTexturedRect( x * -1, y * -1, scrw, scrh )
		
		
	end
	
	
end



And inside your frame.Paint function do this:




myFrame.Paint = function( slf )

    DrawBlur( slf, 3, 6 ) --> You can change the 3 and 6 to whatever you want.

end



It doesn’t work. It says:


[ERROR] addons/darkrpmodification-master/lua/darkrp_modules/nova_f4menu/cl_frame.lua:107: attempt to call method 'SetBackgroundBlur' (a nil value)
  1. Init - addons/darkrpmodification-master/lua/darkrp_modules/nova_f4menu/cl_frame.lua:107
   2. Create - lua/includes/extensions/client/panel/scriptedpanels.lua:37
    3. openF4Menu - addons/darkrpmodification-master/lua/darkrp_modules/nova_f4menu/cl_init.lua:11
     4. Call - addons/darkrpmodification-master/lua/darkrp_modules/nova_f4menu/cl_init.lua:24
      5. unknown - gamemodes/darkrp/gamemode/modules/base/cl_gamemode_functions.lua:46


Doen’t it make the screen behind the derma window blurry? Because I would like to make the window itself blurry.

[editline]6th March 2016[/editline]

Thanks, it works. :happy: