UnAdmin
|
  |
| Joined: 10 Jul 2012 |
| Total Posts: 4706 |
|
|
| 05 Nov 2013 07:33 PM |
I am not using ROBLOX for this so that is why I don't do the stuff like magnitude. I am trying to recreate this code for Love2D. Search pixelshaders and once you get to the main site put /editor/ at the end and plug in the code I just gave. This is what I am trying to do. I am using a 255x255 grid and the grid the site is using is using scales so .5 is half the screen I believe.
precision mediump float;
varying vec2 position; uniform float time;
float wave(vec2 p, float angle) { vec2 direction = vec2(cos(angle), sin(angle)); return cos(dot(p, direction)); }
float wrap(float x) { return abs(mod(x, 2.)-1.); }
void main() { vec2 p = (position - 0.5) * 50.;
float brightness = 0.; for (float i = 1.; i <= 11.; i++) { brightness += wave(p, time / i); }
brightness = wrap(brightness);
gl_FragColor.rgb = vec3(brightness); gl_FragColor.a = 1.; }
function dot(a,b) --Dot Product return a.X * b.X + a.Y * b.Y end
function length(vec2) --Get length of a Vector2 return math.sqrt(vec.X^2+vec.y^2) end
function wave(p, angle)--Look @ example local direction = Vector2.new(math.cos(angle), math.sin(angle)) return math.cos(dot(p,direction)) end
function wrap(x)-- Look @ example return(math.abs(x%2)-1) end |
|
|
| Report Abuse |
|