generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

I need some math functions checked.

Previous Thread :: Next Thread 
UnAdmin is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image