Created
May 29, 2020 07:15
-
-
Save realpack/507c3a4fe852c8991dad8ceea6e258e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local blur = Material("pp/blurscreen", "noclamp") | |
function draw.DrawBlur(x, y, w, h, amount) | |
render.ClearStencil() | |
render.SetStencilEnable( true ) | |
render.SetStencilReferenceValue( 1 ) | |
render.SetStencilTestMask( 1 ) | |
render.SetStencilWriteMask( 1 ) | |
render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_NEVER ) | |
render.SetStencilFailOperation( STENCILOPERATION_REPLACE ) | |
render.SetStencilPassOperation( STENCILOPERATION_REPLACE ) | |
render.SetStencilZFailOperation( STENCILOPERATION_REPLACE ) | |
surface.SetDrawColor( 255, 255, 255, 255 ) | |
surface.DrawRect(x,y,w,h) | |
render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_EQUAL ) | |
render.SetStencilFailOperation( STENCILOPERATION_KEEP ) | |
render.SetStencilPassOperation( STENCILOPERATION_KEEP ) | |
render.SetStencilZFailOperation( STENCILOPERATION_KEEP ) | |
surface.SetMaterial( blur ) | |
surface.SetDrawColor( 255, 255, 255, 255 ) | |
for i = 0, 1, 0.33 do | |
blur:SetFloat( '$blur', i * (amount or 0.2) ) | |
blur:Recompute() | |
render.UpdateScreenEffectTexture() | |
surface.DrawTexturedRect( 0, 0, ScrW(), ScrH() ) | |
end | |
render.SetStencilEnable( false ) | |
end | |
function draw.StencilBlur( panel, w, h ) | |
render.ClearStencil() | |
render.SetStencilEnable( true ) | |
render.SetStencilReferenceValue( 1 ) | |
render.SetStencilTestMask( 1 ) | |
render.SetStencilWriteMask( 1 ) | |
render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_NEVER ) | |
render.SetStencilFailOperation( STENCILOPERATION_REPLACE ) | |
render.SetStencilPassOperation( STENCILOPERATION_REPLACE ) | |
render.SetStencilZFailOperation( STENCILOPERATION_REPLACE ) | |
surface.SetDrawColor( 255, 255, 255, 255 ) | |
surface.DrawRect( 0, 0, w, h ) | |
render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_EQUAL ) | |
render.SetStencilFailOperation( STENCILOPERATION_KEEP ) | |
render.SetStencilPassOperation( STENCILOPERATION_KEEP ) | |
render.SetStencilZFailOperation( STENCILOPERATION_KEEP ) | |
surface.SetMaterial( blur ) | |
surface.SetDrawColor( 255, 255, 255, 255 ) | |
for i = 0, 1, 0.33 do | |
blur:SetFloat( '$blur', 5 *i ) | |
blur:Recompute() | |
render.UpdateScreenEffectTexture() | |
local x, y = panel:GetPos() | |
surface.DrawTexturedRect( -x, -y, ScrW(), ScrH() ) | |
end | |
render.SetStencilEnable( false ) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment