Advertisement
CapsAdmin

Untitled

Apr 25th, 2013
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.05 KB | None | 0 0
  1. local entblur = {}
  2.  
  3. local render = render
  4. local cam = cam
  5.  
  6. local matColor = Material("model_color")
  7. local mat_Copy = Material("pp/copy")
  8. local mat_Add = Material("pp/add")
  9. local mat_Sub = Material("pp/sub")
  10. local rt_Stencil = GetRenderTarget("ent_blur_stencil" .. os.clock(), ScrW(), ScrH(), true)
  11. local rt_Store = GetRenderTarget("ent_blur_store" .. os.clock(), ScrW(), ScrH(), true)
  12.  
  13. local List = {}
  14.  
  15. function entblur.Add(ents, color, blurx, blury, passes, add, ignorez, amount, spherical, shape)
  16.  
  17.     if add == nil then add = true end
  18.     if ignorez == nil then ignorez = false end
  19.  
  20.     local t =
  21.     {
  22.         Ents = ents,
  23.         Color = color or Color(255, 255, 255),
  24.         Hidden = when_hidden,
  25.         BlurX = blurx or 2,
  26.         BlurY = blury or 2,
  27.         DrawPasses = passes or 1,
  28.         Additive = add,
  29.         IgnoreZ = ignorez,
  30.         Amount = amount or 1,
  31.         SphericalSize = spherical or 1,
  32.         Shape = shape or 1,
  33.     }
  34.    
  35.     table.insert(List, t)
  36.  
  37. end
  38.  
  39. function entblur.Render(entry)
  40.     -- get the current screen texture
  41.     local rt = render.GetRenderTarget()
  42.  
  43.     -- copy the current screen texture to rt_Store
  44.     render.CopyRenderTargetToTexture(rt_Store)
  45.        
  46.     -- clear the whole screen
  47.     render.Clear(0, 0, 0, 255, false, true)
  48.    
  49.         -- draw the entities
  50.         render.SetColorModulation(1,1,1)
  51.         render.SetBlend(1)
  52.                
  53.         cam.Start3D(EyePos(), EyeAngles())
  54.             entry.Ents:DrawModel()         
  55.         cam.End3D()
  56.            
  57.         -- draw the just the modified texture
  58.        
  59.         DrawBloom(0, 1, 1, 0, 10, -10, 1, 1, 1 )
  60.  
  61.         --DrawSobel(0.001)
  62.         --DrawSunbeams(0, 1,1, 0,0)
  63.         --[[local tbl = {}
  64.         tbl[ "$pp_colour_addr" ] = 0
  65.         tbl[ "$pp_colour_addg" ] = 0
  66.         tbl[ "$pp_colour_addb" ] = 0
  67.         tbl[ "$pp_colour_brightness" ] = 0
  68.         tbl[ "$pp_colour_contrast" ] = 1
  69.         tbl[ "$pp_colour_colour" ] = math.sin(SysTime()*5) * 10
  70.         tbl[ "$pp_colour_mulr" ] = 0
  71.         tbl[ "$pp_colour_mulg" ] = 0
  72.         tbl[ "$pp_colour_mulb" ] = 0
  73.         DrawColorModify(tbl)]]
  74.    
  75.         --[[cam.Start2D()          
  76.             mat_Add:SetTexture("$basetexture", rt_Stencil)
  77.             surface.SetDrawColor(255, 255, 255, 255)
  78.             surface.SetMaterial(mat_Add)
  79.             surface.DrawTexturedRect(0,0,ScrW(),ScrH())
  80.            
  81.             local len = entry.Ents:GetVelocity():Length() * 5
  82.                            
  83.             surface.SetDrawColor(0, 0, 0, -len + 255)
  84.             surface.DrawRect(0, 0, ScrW(), ScrH())
  85.    
  86.             surface.SetDrawColor(0, 0, 0, 15)
  87.             surface.DrawRect(0, 0, ScrW(), ScrH())
  88.         cam.End2D()]]
  89.        
  90.         -- copy what was drawn to rt_Stencil
  91.         render.CopyRenderTargetToTexture(rt_Stencil)
  92.         --render.BlurRenderTarget(rt_Stencil, 1, 1, 10)
  93.        
  94.  
  95.     -- set the old render target back
  96.     render.SetRenderTarget(rt)
  97.    
  98.     -- draw the original scene
  99.     mat_Copy:SetTexture("$basetexture", rt_Store)
  100.     render.SetMaterial(mat_Copy)
  101.     render.DrawScreenQuad()
  102.        
  103.     -- draw the just the modified texture
  104.     mat_Add:SetTexture("$basetexture", rt_Stencil)
  105.     render.SetMaterial(mat_Add)    
  106.     render.DrawScreenQuad()
  107. end
  108.  
  109. local ent = noi
  110.  
  111. hook.Add("PostDrawEffects", "Renderentblurs", function()
  112.  
  113.     entblur.Add(ent)
  114.        
  115.     if (#List == 0) then return end
  116.    
  117.     for k, v in pairs(List) do
  118.         entblur.Render(v)
  119.     end
  120.        
  121.     List = {}
  122.    
  123. end)
  124.  
  125. pac.entblur = entblur
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement