Python1320

pixelrender luascreen edition

Nov 6th, 2011
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.53 KB | None | 0 0
  1.  
  2. local ENT=Entity(343)
  3.  
  4. if not IsValid(ENT) then return end
  5.  
  6. local len=ScrW()*ScrH()
  7. local t = {}
  8.  
  9. for i = 1, len do t[i] = i end
  10.  
  11.  
  12.  
  13. function shuffle(t)
  14.   local n = #t
  15.   while n > 2 do
  16.     local k = math.random(n)
  17.     t[n], t[k] = t[k], t[n]
  18.     n = n - 1
  19.   end
  20.   return t
  21. end
  22. shuffle(t)
  23.  
  24. local tl=#t
  25. local rand={}
  26. local i=tl
  27. local varnum=0
  28. local lastpos=1
  29.  
  30. local function rand()
  31.  
  32.     local pos=lastpos
  33.     while not t[pos] and pos<tl do
  34.         pos=pos+1
  35.     end
  36.    
  37.     found=t[pos]
  38.     if found  then
  39.         t[pos]=false
  40.         lastpos=pos
  41.     end    
  42.  
  43.     return found
  44.        
  45. end
  46.  
  47.  
  48. local surface=surface
  49. local render=render
  50.        
  51.  
  52. local texFSB = render.GetSuperFPTex()
  53. local matFSB = Material( "pp/motionblur" )
  54.  
  55.  
  56. function ENT.Draw3D2D(s,w,h)
  57.  
  58.  
  59.     matFSB:SetMaterialFloat( "$alpha", 1 )
  60.     matFSB:SetMaterialTexture( "$basetexture", texFSB )
  61.                
  62.     render.SetMaterial( matFSB )
  63.         surface.SetDrawColor(255,255,255,255)
  64.  
  65.         render.DrawQuad(Vector(0, 0),
  66.                 Vector(w, 0, 0),
  67.                 Vector(w, h, 0),
  68.                 Vector(0, h, 0))
  69.                            
  70. end
  71.  
  72. /*
  73. render.CapturePixels()
  74.  
  75. local OldRT = render.GetRenderTarget()
  76.  
  77. render.SetRenderTarget( texFSB )
  78.         render.Clear( 50, 200, 255 )
  79. render.SetRenderTarget( OldRT )*/
  80.  
  81. local sw,sh=ScrW(),ScrH()
  82. local function RenderPixel(  )
  83.     local r=rand()
  84.     if not r then return true end
  85.     local y=math.floor(r/sw)
  86.     local x=r-y*sw
  87.    
  88.    
  89.        
  90.     surface.SetDrawColor( math.tan(x/sw)*255,math.tan(y/sh)*255,0, 255 )
  91.     surface.DrawRect( x,y, 1,1 )
  92.  
  93.  
  94. end
  95.  local done=false
  96. local function RenderPixels()
  97.  
  98.     local TimeEnd = SysTime() + ( 1 / 60 )
  99.        
  100.     while ( not done ) do
  101.    
  102.         done = RenderPixel()
  103.        
  104.         if ( TimeEnd < SysTime() ) then
  105.             return
  106.         end
  107.     end
  108.  
  109. end
  110.  
  111.  
  112.  
  113.  
  114. function ENT:BaseDraw3D2D()
  115.  
  116.     if self.debug and self:IsScrAccessible() then
  117.         self:DrawDebugOutline()
  118.     end
  119.    
  120.     local pos, ang = self:GetPos(), self:GetAngles()
  121.  
  122.     pos=pos+self:GetRight()*(self.Width/2)
  123.     pos=pos+self:GetUp()*(self.Height/2)
  124.    
  125.     ang:RotateAroundAxis(ang:Up(), 90)
  126.     ang:RotateAroundAxis(ang:Forward(), 90)
  127.  
  128.     local wide=self.Width*(1/self.Scale)
  129.     local tall=self.Height*(1/self.Scale)
  130.    
  131.         render.SetRenderTarget( texFSB )
  132.         cam.Start2D()
  133.             RenderPixels()
  134.         cam.End2D()
  135.     render.SetRenderTarget( nil )
  136.        
  137.     cam.Start3D2D(pos,ang,self.Scale)
  138.         local ret,err=pcall(self.Draw3D2D,self,wide,tall)
  139.     cam.End3D2D()
  140.    
  141.     if !ret then
  142.         return err
  143.     end
  144.    
  145. end
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
Advertisement
Add Comment
Please, Sign In to add comment