mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 18:45:54 -05:00
77 lines
1.9 KiB
Text
77 lines
1.9 KiB
Text
float xll_mod( float x, float y ) {
|
|
float d = x / y;
|
|
float f = fract (abs(d)) * y;
|
|
return d >= 0.0 ? f : -f;
|
|
}
|
|
vec2 xll_mod( vec2 x, vec2 y ) {
|
|
vec2 d = x / y;
|
|
vec2 f = fract (abs(d)) * y;
|
|
return vec2 (d.x >= 0.0 ? f.x : -f.x, d.y >= 0.0 ? f.y : -f.y);
|
|
}
|
|
vec3 xll_mod( vec3 x, vec3 y ) {
|
|
vec3 d = x / y;
|
|
vec3 f = fract (abs(d)) * y;
|
|
return vec3 (d.x >= 0.0 ? f.x : -f.x, d.y >= 0.0 ? f.y : -f.y, d.z >= 0.0 ? f.z : -f.z);
|
|
}
|
|
vec4 xll_mod( vec4 x, vec4 y ) {
|
|
vec4 d = x / y;
|
|
vec4 f = fract (abs(d)) * y;
|
|
return vec4 (d.x >= 0.0 ? f.x : -f.x, d.y >= 0.0 ? f.y : -f.y, d.z >= 0.0 ? f.z : -f.z, d.w >= 0.0 ? f.w : -f.w);
|
|
}
|
|
float xll_modf( float x, out int ip) {
|
|
ip = int (x);
|
|
return x-float(ip);
|
|
}
|
|
float xll_modf( float x, out float ip) {
|
|
int i = int (x);
|
|
ip = float(i);
|
|
return x-ip;
|
|
}
|
|
vec2 xll_modf( vec2 x, out ivec2 ip) {
|
|
ip = ivec2 (x);
|
|
return x-vec2(ip);
|
|
}
|
|
vec2 xll_modf( vec2 x, out vec2 ip) {
|
|
ivec2 i = ivec2 (x);
|
|
ip = vec2(i);
|
|
return x-ip;
|
|
}
|
|
vec3 xll_modf( vec3 x, out ivec3 ip) {
|
|
ip = ivec3 (x);
|
|
return x-vec3(ip);
|
|
}
|
|
vec3 xll_modf( vec3 x, out vec3 ip) {
|
|
ivec3 i = ivec3 (x);
|
|
ip = vec3(i);
|
|
return x-ip;
|
|
}
|
|
vec4 xll_modf( vec4 x, out ivec4 ip) {
|
|
ip = ivec4 (x);
|
|
return x-vec4(ip);
|
|
}
|
|
vec4 xll_modf( vec4 x, out vec4 ip) {
|
|
ivec4 i = ivec4 (x);
|
|
ip = vec4(i);
|
|
return x-ip;
|
|
}
|
|
vec4 xlat_main( in vec4 uv );
|
|
vec4 xlat_main( in vec4 uv ) {
|
|
vec4 c;
|
|
vec4 d;
|
|
c = vec4( 0.000000);
|
|
c.x += xll_mod( uv.x , 2.00000);
|
|
c.xy += xll_mod( uv.xy , vec2( 2.00000));
|
|
c.xyz += xll_mod( uv.xyz , vec3( 2.00000));
|
|
c.xyzw += xll_mod( uv.xyzw , vec4( 2.00000));
|
|
c.x += xll_modf( uv.x , d.x );
|
|
c.xy += xll_modf( uv.xy , d.xy );
|
|
c.xyz += xll_modf( uv.xyz , d.xyz );
|
|
c.xyzw += xll_modf( uv.xyzw , d.xyzw );
|
|
return c;
|
|
}
|
|
varying vec4 xlv_TEXCOORD0;
|
|
void main() {
|
|
vec4 xl_retval;
|
|
xl_retval = xlat_main( vec4(xlv_TEXCOORD0));
|
|
gl_FragData[0] = vec4( xl_retval);
|
|
}
|