Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

lerp

rerere284 Apr 12th, 2016 (edited) 155 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. --made by rerere284
  2. function init()
  3.     setName("Lerp")
  4.     setDesc("Linear interpolation. Combine two textures.")
  5.     setSize(100, 24+64+8+8+18+18+7+4)
  6.     addOutput(24+32)
  7.     addInputParameter("Texture", "The first value", 24+64+8+8, 0, 0, 100, true) --should probably be input parameters
  8.     addInputParameter("Texture", "The second value", 24+64+8+8+18, 100, 0, 100, true)
  9.     addInputParameter("t", "How much it is one texture or the other", 24+64+8+8+18+18, 50, 0, 100, true)
  10. end
  11.  
  12. function lerp(a,b,t)
  13.     return ((1-t)*a) + (t*b)
  14. end
  15.  
  16. function apply()
  17.     tileSize = getTileSize()
  18.     for i=0, tileSize*tileSize-1 do
  19.         x = i%tileSize
  20.         y = math.floor(i/tileSize)
  21.         ar, ag, ab = getValue(0, x, y, 100) --get pixels at that location for both
  22.         br, bg, bb = getValue(1, x, y, 100)
  23.         ttr, ttb, ttg = getValue(2, x, y, 100)
  24.         tt = (ttr+ttb+ttg)/3
  25.         fr = lerp(ar,br,tt)
  26.         fg = lerp(ag,bg,tt)
  27.         fb = lerp(ab,bb,tt)
  28.         setPixel(0, x, y, fr, fg, fb)
  29.     end
  30. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top