bgfx/3rdparty/glsl-optimizer/tests/vertex/complex-treeleaf-irES.txt

434 lines
11 KiB
Text
Raw Normal View History

2012-04-03 23:30:07 -04:00
struct appdata_full {
highp vec4 vertex;
highp vec4 tangent;
highp vec3 normal;
highp vec4 texcoord;
highp vec4 texcoord1;
highp vec4 color;
};
struct v2f_surf {
highp vec4 pos;
highp vec2 hip_pack0;
highp vec4 lop_color;
highp vec3 lightDir;
highp vec3 viewDir;
highp vec2 _LightCoord;
};
varying highp vec2 xlv_TEXCOORD3;
varying highp vec3 xlv_TEXCOORD2;
varying highp vec3 xlv_TEXCOORD1;
varying highp vec4 xlv_COLOR0;
varying highp vec2 xlv_TEXCOORD0;
attribute vec4 TANGENT;
uniform highp vec4 unity_Scale;
uniform highp mat4 glstate_matrix_mvp;
uniform highp mat4 glstate_matrix_invtrans_modelview0;
uniform highp vec4 _WorldSpaceLightPos0;
uniform highp vec3 _WorldSpaceCameraPos;
uniform highp mat4 _World2Object;
uniform highp vec4 _Wind;
uniform highp vec4 _Time;
uniform highp vec4 _SquashPlaneNormal;
uniform highp float _SquashAmount;
uniform highp vec4 _Scale;
uniform highp mat4 _Object2World;
uniform highp vec4 _MainTex_ST;
uniform highp mat4 _LightMatrix0;
attribute lowp vec4 _glesColor;
attribute highp vec4 _glesMultiTexCoord1;
attribute highp vec4 _glesMultiTexCoord0;
attribute mediump vec3 _glesNormal;
attribute highp vec4 _glesVertex;
vec4 Squash (
in highp vec4 pos
)
{
highp vec3 projectedVertex;
highp vec3 planeNormal;
highp vec3 tmpvar_1;
tmpvar_1 = _SquashPlaneNormal.xyz;
planeNormal = tmpvar_1;
highp vec3 tmpvar_2;
tmpvar_2 = pos.xyz;
highp float tmpvar_3;
tmpvar_3 = dot (planeNormal, tmpvar_2);
highp vec3 tmpvar_4;
tmpvar_4 = (pos.xyz - ((tmpvar_3 + _SquashPlaneNormal.w) * planeNormal));
projectedVertex = tmpvar_4;
highp vec3 tmpvar_5;
tmpvar_5 = vec3(_SquashAmount);
highp vec3 tmpvar_6;
tmpvar_6 = mix (projectedVertex, pos.xyz, tmpvar_5);
highp vec4 tmpvar_7;
tmpvar_7.w = 1.0;
tmpvar_7.xyz = tmpvar_6.xyz;
highp vec4 tmpvar_8;
tmpvar_8 = tmpvar_7;
pos = tmpvar_8;
return pos;
}
void ExpandBillboard (
in highp mat4 mat,
inout highp vec4 pos,
inout highp vec3 normal,
inout highp vec4 tangent
)
{
highp vec3 tanb;
highp vec3 norb;
highp float isBillboard;
highp float tmpvar_1;
tmpvar_1 = abs (tangent.w);
highp float tmpvar_2;
tmpvar_2 = (1.0 - tmpvar_1);
isBillboard = tmpvar_2;
highp vec4 tmpvar_3;
tmpvar_3.w = 0.0;
tmpvar_3.xyz = normal.xyz;
highp vec4 tmpvar_4;
tmpvar_4 = normalize ((tmpvar_3 * mat));
highp vec3 tmpvar_5;
tmpvar_5 = tmpvar_4.xyz;
highp vec3 tmpvar_6;
tmpvar_6 = tmpvar_5;
norb = tmpvar_6;
highp vec4 tmpvar_7;
tmpvar_7.w = 0.0;
tmpvar_7.xyz = tangent.xyz.xyz;
highp vec4 tmpvar_8;
tmpvar_8 = normalize ((tmpvar_7 * mat));
highp vec3 tmpvar_9;
tmpvar_9 = tmpvar_8.xyz;
highp vec3 tmpvar_10;
tmpvar_10 = tmpvar_9;
tanb = tmpvar_10;
highp vec4 tmpvar_11;
tmpvar_11.zw = vec2(0.0, 0.0);
tmpvar_11.xy = normal.xy.xy;
highp vec4 tmpvar_12;
tmpvar_12 = (pos + ((tmpvar_11 * mat) * isBillboard));
pos = tmpvar_12;
highp vec3 tmpvar_13;
tmpvar_13 = vec3(isBillboard);
highp vec3 tmpvar_14;
tmpvar_14 = mix (normal, norb, tmpvar_13);
highp vec3 tmpvar_15;
tmpvar_15 = tmpvar_14;
normal = tmpvar_15;
highp vec4 tmpvar_16;
tmpvar_16.w = -1.0;
tmpvar_16.xyz = tanb.xyz;
highp vec4 tmpvar_17;
tmpvar_17 = vec4(isBillboard);
highp vec4 tmpvar_18;
tmpvar_18 = mix (tangent, tmpvar_16, tmpvar_17);
highp vec4 tmpvar_19;
tmpvar_19 = tmpvar_18;
tangent = tmpvar_19;
}
vec4 TriangleWave (
in highp vec4 x
)
{
highp vec4 tmpvar_1;
tmpvar_1 = fract ((x + 0.5));
highp vec4 tmpvar_2;
tmpvar_2 = abs (((tmpvar_1 * 2.0) - 1.0));
return tmpvar_2;
}
vec4 SmoothCurve (
in highp vec4 x
)
{
return ((x * x) * (3.0 - (2.0 * x)));
}
vec4 SmoothTriangleWave (
in highp vec4 x
)
{
highp vec4 tmpvar_1;
tmpvar_1 = TriangleWave (x);
highp vec4 tmpvar_2;
tmpvar_2 = SmoothCurve (tmpvar_1);
return tmpvar_2;
}
vec4 AnimateVertex (
in highp vec4 pos,
in highp vec3 normal,
in highp vec4 animParams
)
{
highp vec3 bend;
highp vec2 vWavesSum;
highp vec4 vWaves;
highp vec2 vWavesIn;
highp float fVtxPhase;
highp float fBranchPhase;
highp float fObjPhase;
highp float fBranchAmp;
highp float fDetailAmp;
float tmpvar_1;
tmpvar_1 = 0.1;
fDetailAmp = tmpvar_1;
float tmpvar_2;
tmpvar_2 = 0.3;
fBranchAmp = tmpvar_2;
highp float tmpvar_3;
tmpvar_3 = dot (_Object2World[3].xyz, vec3(1.0, 1.0, 1.0));
highp float tmpvar_4;
tmpvar_4 = tmpvar_3;
fObjPhase = tmpvar_4;
highp float tmpvar_5;
tmpvar_5 = (fObjPhase + animParams.x);
fBranchPhase = tmpvar_5;
highp vec3 tmpvar_6;
tmpvar_6 = vec3((animParams.y + fBranchPhase));
highp float tmpvar_7;
tmpvar_7 = dot (pos.xyz, tmpvar_6);
highp float tmpvar_8;
tmpvar_8 = tmpvar_7;
fVtxPhase = tmpvar_8;
highp vec2 tmpvar_9;
tmpvar_9.x = fVtxPhase;
tmpvar_9.y = fBranchPhase;
highp vec2 tmpvar_10;
tmpvar_10 = (_Time.yy + tmpvar_9);
vWavesIn = tmpvar_10;
highp vec4 tmpvar_11;
tmpvar_11 = fract ((vWavesIn.xxyy * vec4(1.975, 0.793, 0.375, 0.193)));
highp vec4 tmpvar_12;
tmpvar_12 = ((tmpvar_11 * 2.0) - 1.0);
vWaves = tmpvar_12;
highp vec4 tmpvar_13;
tmpvar_13 = SmoothTriangleWave (vWaves);
highp vec4 tmpvar_14;
tmpvar_14 = tmpvar_13;
vWaves = tmpvar_14;
highp vec2 tmpvar_15;
tmpvar_15 = (vWaves.xz + vWaves.yw);
vWavesSum = tmpvar_15;
highp vec3 tmpvar_16;
tmpvar_16 = ((animParams.y * fDetailAmp) * normal.xyz);
bend = tmpvar_16;
highp float tmpvar_17;
tmpvar_17 = (animParams.w * fBranchAmp);
bend.y = vec2(tmpvar_17).y;
highp vec3 tmpvar_18;
tmpvar_18 = (pos.xyz + (((vWavesSum.xyx * bend) + ((_Wind.xyz * vWavesSum.y) * animParams.w)) * _Wind.w));
pos.xyz = tmpvar_18.xyz.xyz;
highp vec3 tmpvar_19;
tmpvar_19 = (pos.xyz + (animParams.z * _Wind.xyz));
pos.xyz = tmpvar_19.xyz.xyz;
return pos;
}
void TreeVertLeaf (
inout appdata_full v
)
{
ExpandBillboard (glstate_matrix_invtrans_modelview0, v.vertex, v.normal, v.tangent);
highp vec3 tmpvar_1;
tmpvar_1 = (v.vertex.xyz * _Scale.xyz);
v.vertex.xyz = tmpvar_1.xyz.xyz;
highp vec4 tmpvar_2;
tmpvar_2.xy = v.color.xy.xy;
tmpvar_2.zw = v.texcoord1.xy.xy;
highp vec4 tmpvar_3;
tmpvar_3 = AnimateVertex (v.vertex, v.normal, tmpvar_2);
highp vec4 tmpvar_4;
tmpvar_4 = tmpvar_3;
v.vertex = tmpvar_4;
highp vec4 tmpvar_5;
tmpvar_5 = Squash (v.vertex);
highp vec4 tmpvar_6;
tmpvar_6 = tmpvar_5;
v.vertex = tmpvar_6;
highp vec4 tmpvar_7;
tmpvar_7.xyz = vec3(1.0, 1.0, 1.0);
tmpvar_7.w = v.color.w;
highp vec4 tmpvar_8;
tmpvar_8 = tmpvar_7;
v.color = tmpvar_8;
highp vec3 tmpvar_9;
tmpvar_9 = normalize (v.normal);
highp vec3 tmpvar_10;
tmpvar_10 = tmpvar_9;
v.normal = tmpvar_10;
highp vec3 tmpvar_11;
tmpvar_11 = normalize (v.tangent.xyz);
highp vec3 tmpvar_12;
tmpvar_12 = tmpvar_11;
v.tangent.xyz = tmpvar_12.xyz.xyz;
}
vec3 ObjSpaceViewDir (
in highp vec4 v
)
{
highp vec3 objSpaceCameraPos;
highp vec4 tmpvar_1;
tmpvar_1.w = 1.0;
tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz;
highp vec3 tmpvar_2;
tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w);
objSpaceCameraPos = tmpvar_2;
return (objSpaceCameraPos - v.xyz);
}
vec3 ObjSpaceLightDir (
in highp vec4 v
)
{
highp vec3 objSpaceLightPos;
highp vec3 tmpvar_1;
tmpvar_1 = (_World2Object * _WorldSpaceLightPos0).xyz;
objSpaceLightPos = tmpvar_1;
return objSpaceLightPos.xyz;
}
v2f_surf xlat_main (
in appdata_full v
)
{
highp mat3 rotation;
highp vec3 binormal;
v2f_surf o;
TreeVertLeaf (v);
highp vec4 tmpvar_1;
tmpvar_1 = (glstate_matrix_mvp * v.vertex);
o.pos = tmpvar_1;
highp vec2 tmpvar_2;
tmpvar_2 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw);
o.hip_pack0 = tmpvar_2.xy.xy;
highp vec4 tmpvar_3;
tmpvar_3 = v.color;
o.lop_color = tmpvar_3;
highp vec3 tmpvar_4;
tmpvar_4 = cross (v.normal, v.tangent.xyz);
highp vec3 tmpvar_5;
tmpvar_5 = (tmpvar_4 * v.tangent.w);
binormal = tmpvar_5;
mat3 tmpvar_6;
float tmpvar_7;
tmpvar_7 = v.tangent.x;
tmpvar_6[0].x = tmpvar_7;
float tmpvar_8;
tmpvar_8 = binormal.x;
tmpvar_6[0].y = tmpvar_8;
float tmpvar_9;
tmpvar_9 = v.normal.x;
tmpvar_6[0].z = tmpvar_9;
float tmpvar_10;
tmpvar_10 = v.tangent.y;
tmpvar_6[1].x = tmpvar_10;
float tmpvar_11;
tmpvar_11 = binormal.y;
tmpvar_6[1].y = tmpvar_11;
float tmpvar_12;
tmpvar_12 = v.normal.y;
tmpvar_6[1].z = tmpvar_12;
float tmpvar_13;
tmpvar_13 = v.tangent.z;
tmpvar_6[2].x = tmpvar_13;
float tmpvar_14;
tmpvar_14 = binormal.z;
tmpvar_6[2].y = tmpvar_14;
float tmpvar_15;
tmpvar_15 = v.normal.z;
tmpvar_6[2].z = tmpvar_15;
mat3 tmpvar_16;
tmpvar_16 = (tmpvar_6);
rotation = (tmpvar_16);
highp vec3 tmpvar_17;
tmpvar_17 = ObjSpaceLightDir (v.vertex);
highp vec3 tmpvar_18;
tmpvar_18 = (rotation * tmpvar_17);
o.lightDir = tmpvar_18;
highp vec3 tmpvar_19;
tmpvar_19 = ObjSpaceViewDir (v.vertex);
highp vec3 tmpvar_20;
tmpvar_20 = (rotation * tmpvar_19);
o.viewDir = tmpvar_20;
highp vec2 tmpvar_21;
tmpvar_21 = (_LightMatrix0 * (_Object2World * v.vertex)).xy;
o._LightCoord = tmpvar_21;
return o;
}
void main ()
{
appdata_full xlt_v;
v2f_surf xl_retval;
highp vec4 tmpvar_1;
tmpvar_1 = _glesVertex.xyzw;
highp vec4 tmpvar_2;
tmpvar_2 = tmpvar_1;
xlt_v.vertex = tmpvar_2;
highp vec4 tmpvar_3;
tmpvar_3 = TANGENT.xyzw;
highp vec4 tmpvar_4;
tmpvar_4 = tmpvar_3;
xlt_v.tangent = tmpvar_4;
highp vec3 tmpvar_5;
tmpvar_5 = _glesNormal.xyz;
highp vec3 tmpvar_6;
tmpvar_6 = tmpvar_5;
xlt_v.normal = tmpvar_6;
highp vec4 tmpvar_7;
tmpvar_7 = _glesMultiTexCoord0.xyzw;
highp vec4 tmpvar_8;
tmpvar_8 = tmpvar_7;
xlt_v.texcoord = tmpvar_8;
highp vec4 tmpvar_9;
tmpvar_9 = _glesMultiTexCoord1.xyzw;
highp vec4 tmpvar_10;
tmpvar_10 = tmpvar_9;
xlt_v.texcoord1 = tmpvar_10;
highp vec4 tmpvar_11;
tmpvar_11 = _glesColor.xyzw;
highp vec4 tmpvar_12;
tmpvar_12 = tmpvar_11;
xlt_v.color = tmpvar_12;
v2f_surf tmpvar_13;
tmpvar_13 = xlat_main (xlt_v);
v2f_surf tmpvar_14;
tmpvar_14 = tmpvar_13;
xl_retval = tmpvar_14;
highp vec4 tmpvar_15;
tmpvar_15 = xl_retval.pos.xyzw;
highp vec4 tmpvar_16;
tmpvar_16 = tmpvar_15;
gl_Position = tmpvar_16;
highp vec2 tmpvar_17;
tmpvar_17 = xl_retval.hip_pack0.xy;
highp vec2 tmpvar_18;
tmpvar_18 = tmpvar_17;
xlv_TEXCOORD0 = tmpvar_18;
highp vec4 tmpvar_19;
tmpvar_19 = xl_retval.lop_color.xyzw;
highp vec4 tmpvar_20;
tmpvar_20 = tmpvar_19;
xlv_COLOR0 = tmpvar_20;
highp vec3 tmpvar_21;
tmpvar_21 = xl_retval.lightDir.xyz;
highp vec3 tmpvar_22;
tmpvar_22 = tmpvar_21;
xlv_TEXCOORD1 = tmpvar_22;
highp vec3 tmpvar_23;
tmpvar_23 = xl_retval.viewDir.xyz;
highp vec3 tmpvar_24;
tmpvar_24 = tmpvar_23;
xlv_TEXCOORD2 = tmpvar_24;
highp vec2 tmpvar_25;
tmpvar_25 = xl_retval._LightCoord.xy;
highp vec2 tmpvar_26;
tmpvar_26 = tmpvar_25;
xlv_TEXCOORD3 = tmpvar_26;
}