Blur

Hello,

I want to put a blur material under this draw.RoundedBox:


    draw.RoundedBox( 0, 775, ScrH() - 100, 350, 70, Color( 50, 50, 50, 165 ))
   draw.RoundedBox( 0, 800, ScrH() - 90, 260 * hp, 45, Color( 225, 255, 255, 150)) 

How would i do this? I already saw a other thread but that wasn’t working for me.

Thank you very much!

Literally the second result from Facepunch when searching “gmod blur”:
http://forum.facepunch.com/showthread.php?t=1509349

Literally another person that can’t read :stuck_out_tongue:

I already saw a other thread but that wasn’t working for me.

Second comment on the thread already linked
http://forum.facepunch.com/showthread.php?t=1509349&p=49878319&viewfull=1#post49878319

Mate, we’re trying to help you.
If you treat us like that you ain’t going to get more help from us.
And, you say i’m “another one that can’t read”, yet you didn’t even take a look at that thread i linked you.

Im not treating you… Im just trying to say that i already looked that the threat and that it did not work…

[editline]31st August 2017[/editline]

Tryed that already… It’s messing with my Arc…
And it doesn’t show up…

Once more, as I always say, saying “It doesn’t work” doesn’t supply us any info and we can’t even help you with that.
Care to share the code to see how it is so we can help you with it and see what’s wrong about it and how is it messing with your Arc?


 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

myFrame.Paint = function( slf )

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

end
 

Im using ARC Circle… But the textures of the arc is getting bugged… The same when im using a roundedbox the arc gets effected.
The Blur doesn’t show up aswell

The code Tupac has supplied is for rectangles only.


surface.DrawTexturedRect( x * -1, y * -1, scrw, scrh )

[editline]31st August 2017[/editline]

If you want this to work, you will need to involve this code into the arc code and remove some of its code.

For example i have a RoundedBox that is transparent… I want to have a layer under it that is blur…
What do i have to do then… Because the only thing that i get is this:


 
[ERROR] lua/autorun/client/cl_hud.lua:105: attempt to index global 'myFrame' (a nil value)
  1. unknown - lua/autorun/client/cl_hud.lua:105
 

(Sorry if im frustrating you)

Put the code in myFrame.Paint in the HUDPaint hook and get rid of the myFrame.Paint function.

Next time, try adapting your code.
So, i see that you’re trying to use HUDPaint instead of an actual panel.
So instead, in that case, you would need a different function.
http://forum.facepunch.com/showthread.php?t=1487492&p=48781436&viewfull=1#post48781436

which, again, is the 3rd result from google when searching for “gmod blur”

So where should i put the cordinates so there’s a blur under my draw.RoundedBox?


 draw.RoundedBox( 15, 1400, ScrH() - 970, 470, 850, Color( 50, 50, 50, 255 ))  


 local blur = Material("pp/blurscreen")
function draw.Blur(x, y, w, h, layers, density, alpha)
	local X, Y = 0,0
	local scrW, scrH = ScrW(), ScrH()

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

	for i = 1, 3 do
		blur:SetFloat("$blur", (i / layers) * density)
		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
end

 

Idk what’s the best coordinates for your blur. How about you do some trial and error with it and see which coordinates is the best (you have to realise this bit is based on visual look which you cannot be helped with)?

You’ve basically gotta put the same coords as on the box you’re drawing

Well that’s the problem… The blur just does not pup op…

How do you you have your code laid out? Saying that the blur doesn’t pop up and there’s a problem doesn’t tell me anything. In lua, a simple miss of a comma can screw up your whole code so I don’t know what you’ve done wrong right now. Sorry, but I can’t help without either guessing the problem or receiving your work to look at and solve the problem.


  local blur = Material("pp/blurscreen")
function draw.Blur(x, y, w, h, layers, density, alpha)
	local X, Y = 0,0
	local scrW, scrH = ScrW(), ScrH()

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

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

		render.UpdateScreenEffectTexture()

		render.SetScissorRect(x, y, x+w, y+h, true)
			surface.DrawTexturedRect(1067, ScrH() - 110, 80, 52)
		render.SetScissorRect(0, 0, 0, 0, false)
	end
end 

You’re not meant to change the code of the actual function, just pass the arguments to it

How then?