Anybody succeded to find a substitute for mod() and floor() in AGAL ?

Software: Away3D 4.x

Avatar
SasMaster, Sr. Member
Posted: 18 October 2011 08:37 PM   Total Posts: 127

Hi all,I have been porting some shaders from GLSL. Now I have a function where I have to calculate a modulo and get a floor for the numbers.In GLSL there are mod() and floor() methods.Anybody tried to “improvise ”  with this kind of calculations in AGAL?

 Signature 

This looks like a job for superman
http://blog.alladvanced.net

   

Somokon, Member
Posted: 18 October 2011 09:30 PM   Total Posts: 75   [ # 1 ]

The ‘frc’ opcode gets the fractional part of a number, so to get floor(x), you could do x - (frc x).

To calculate a mod b, you could divide a by b, take the fractional part of the result, and multiply that by b.  [a mod b = (frc (a / b)) * b]

   

Avatar
SasMaster, Sr. Member
Posted: 23 October 2011 09:21 AM   Total Posts: 127   [ # 2 ]

Thanks for that !Somehow never seen this opcode smile

Here is the result BTW-checker shader :
http://blog.alladvanced.net

 Signature 

This looks like a job for superman
http://blog.alladvanced.net

   
   
‹‹ Fog

X

Away3D Forum

Member Login

Username

Password

Remember_me



X