bgfx/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Twist_Effect-in.txt

76 lines
1.9 KiB
Text
Raw Normal View History

2012-04-03 23:30:07 -04:00
void xll_sincos( float x, out float s, out float c) {
s = sin(x);
c = cos(x);
}
void xll_sincos( vec2 x, out vec2 s, out vec2 c) {
s = sin(x);
c = cos(x);
}
void xll_sincos( vec3 x, out vec3 s, out vec3 c) {
s = sin(x);
c = cos(x);
}
void xll_sincos( vec4 x, out vec4 s, out vec4 c) {
s = sin(x);
c = cos(x);
}
void xll_sincos( mat2 x, out mat2 s, out mat2 c) {
s = mat2( sin ( x[0] ), sin ( x[1] ) );
c = mat2( cos ( x[0] ), cos ( x[1] ) );
}
void xll_sincos( mat3 x, out mat3 s, out mat3 c) {
s = mat3( sin ( x[0] ), sin ( x[1] ), sin ( x[2] ) );
c = mat3( cos ( x[0] ), cos ( x[1] ), cos ( x[2] ) );
}
void xll_sincos( mat4 x, out mat4 s, out mat4 c) {
s = mat4( sin ( x[0] ), sin ( x[1] ), sin ( x[2] ), sin ( x[3] ) );
c = mat4( cos ( x[0] ), cos ( x[1] ), cos ( x[2] ), cos ( x[3] ) );
}
struct v2f_vertex_lit {
vec2 uv;
vec4 diff;
vec4 spec;
};
struct v2f_img {
vec4 pos;
vec2 uv;
};
struct appdata_img {
vec4 vertex;
vec2 texcoord;
};
struct v2f {
vec4 pos;
vec2 uv;
vec2 uvOrig;
};
uniform float _Angle;
uniform vec4 _CenterRadius;
uniform sampler2D _MainTex;
vec4 frag( in v2f i );
vec4 frag( in v2f i ) {
vec2 offset;
float angle;
float sinLength;
float cosLength;
vec2 uv;
offset = i.uvOrig;
angle = (1.00000 - length( (offset / _CenterRadius.zw ) ));
angle = max( 0.000000, angle);
angle = ((angle * angle) * _Angle);
xll_sincos( angle, sinLength, cosLength);
uv.x = ((cosLength * offset.x ) - (sinLength * offset.y ));
uv.y = ((sinLength * offset.x ) + (cosLength * offset.y ));
uv += _CenterRadius.xy ;
return texture2D( _MainTex, uv);
}
void main() {
vec4 xl_retval;
v2f xlt_i;
xlt_i.pos = vec4(0.0);
xlt_i.uv = vec2( gl_TexCoord[0]);
xlt_i.uvOrig = vec2( gl_TexCoord[1]);
xl_retval = frag( xlt_i);
gl_FragData[0] = vec4( xl_retval);
}