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?
Anybody succeded to find a substitute for mod() and floor() in AGAL ?Software: Away3D 4.x |
||
|
||
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] |
||
SasMaster, Sr. Member
Posted: 23 October 2011 09:21 AM Total Posts: 127 [ # 2 ] Thanks for that !Somehow never seen this opcode Here is the result BTW-checker shader : |