bgfx/3rdparty/glsl-optimizer/tests/vertex/zun-Tree_Editor_Leaf_Shader-ir.txt
2014-02-10 23:06:13 -08:00

458 lines
11 KiB
Text

struct appdata_full {
vec4 vertex;
vec4 tangent;
vec3 normal;
vec4 texcoord;
vec4 texcoord1;
vec4 color;
};
struct v2f_surf {
vec4 pos;
float fog;
vec2 hip_pack0;
vec4 lop_color;
vec3 lightDir;
vec3 viewDir;
vec3 _LightCoord;
};
uniform vec4 _Color;
uniform mat4 _LightMatrix0;
uniform vec4 _MainTex_ST;
uniform mat4 _Object2World;
uniform vec4 _Scale;
uniform float _SquashAmount;
uniform vec4 _SquashPlaneNormal;
uniform float _TimeX;
uniform vec4 _Wind;
uniform mat4 _World2Object;
uniform vec3 _WorldSpaceCameraPos;
uniform vec4 _WorldSpaceLightPos0;
uniform vec4 unity_Scale;
attribute vec4 TANGENT;
varying vec4 xlv_FOG;
vec4 Squash (
in vec4 pos_1
)
{
vec3 planeNormal_2;
vec3 planePoint_3;
vec3 projectedVertex_4;
vec3 tmpvar_5;
tmpvar_5 = pos_1.xyz;
projectedVertex_4 = tmpvar_5;
vec3 tmpvar_6;
tmpvar_6.xz = vec2(0.0, 0.0);
tmpvar_6.y = _SquashPlaneNormal.w;
vec3 tmpvar_7;
tmpvar_7 = tmpvar_6;
planePoint_3 = tmpvar_7;
vec3 tmpvar_8;
tmpvar_8 = _SquashPlaneNormal.xyz;
planeNormal_2 = tmpvar_8;
vec3 tmpvar_9;
tmpvar_9 = pos_1.xyz;
float tmpvar_10;
tmpvar_10 = dot (planeNormal_2, (planePoint_3 - tmpvar_9));
vec3 tmpvar_11;
tmpvar_11 = (projectedVertex_4 + (tmpvar_10 * planeNormal_2));
projectedVertex_4 = tmpvar_11;
vec3 tmpvar_12;
tmpvar_12 = vec3(_SquashAmount);
vec3 tmpvar_13;
tmpvar_13 = mix (projectedVertex_4, pos_1.xyz, tmpvar_12);
vec4 tmpvar_14;
tmpvar_14.w = 1.0;
tmpvar_14.xyz = tmpvar_13.xyz;
vec4 tmpvar_15;
tmpvar_15 = tmpvar_14;
pos_1 = tmpvar_15;
return pos_1;
}
void ExpandBillboard (
in mat4 mat_16,
inout vec4 pos_17,
inout vec3 normal_18,
inout vec4 tangent_19
)
{
vec3 tanb_20;
vec3 norb_21;
float isBillboard_22;
float tmpvar_23;
tmpvar_23 = abs (tangent_19.w);
float tmpvar_24;
tmpvar_24 = (1.0 - tmpvar_23);
isBillboard_22 = tmpvar_24;
vec4 tmpvar_25;
tmpvar_25.w = 0.0;
tmpvar_25.xyz = normal_18.xyz;
vec4 tmpvar_26;
tmpvar_26 = normalize ((tmpvar_25 * mat_16));
vec3 tmpvar_27;
tmpvar_27 = tmpvar_26.xyz;
vec3 tmpvar_28;
tmpvar_28 = tmpvar_27;
norb_21 = tmpvar_28;
vec4 tmpvar_29;
tmpvar_29.yw = vec2(0.0, 0.0);
tmpvar_29.x = normal_18.z;
tmpvar_29.z = -(normal_18.x);
vec4 tmpvar_30;
tmpvar_30 = normalize ((tmpvar_29 * mat_16));
vec3 tmpvar_31;
tmpvar_31 = tmpvar_30.xyz;
vec3 tmpvar_32;
tmpvar_32 = tmpvar_31;
tanb_20 = tmpvar_32;
vec4 tmpvar_33;
tmpvar_33 = (pos_17 + ((tangent_19 * mat_16) * isBillboard_22));
pos_17 = tmpvar_33;
vec3 tmpvar_34;
tmpvar_34 = vec3(isBillboard_22);
vec3 tmpvar_35;
tmpvar_35 = mix (normal_18, norb_21, tmpvar_34);
vec3 tmpvar_36;
tmpvar_36 = tmpvar_35;
normal_18 = tmpvar_36;
vec4 tmpvar_37;
tmpvar_37.w = -1.0;
tmpvar_37.xyz = tanb_20.xyz;
vec4 tmpvar_38;
tmpvar_38 = vec4(isBillboard_22);
vec4 tmpvar_39;
tmpvar_39 = mix (tangent_19, tmpvar_37, tmpvar_38);
vec4 tmpvar_40;
tmpvar_40 = tmpvar_39;
tangent_19 = tmpvar_40;
}
vec4 TriangleWave (
in vec4 x_41
)
{
vec4 tmpvar_42;
tmpvar_42 = fract ((x_41 + 0.5));
vec4 tmpvar_43;
tmpvar_43 = abs (((tmpvar_42 * 2.0) - 1.0));
return tmpvar_43;
}
vec4 SmoothCurve (
in vec4 x_44
)
{
return ((x_44 * x_44) * (3.0 - (2.0 * x_44)));
}
vec4 SmoothTriangleWave (
in vec4 x_45
)
{
vec4 tmpvar_46;
tmpvar_46 = TriangleWave (x_45);
vec4 tmpvar_47;
tmpvar_47 = SmoothCurve (tmpvar_46);
return tmpvar_47;
}
vec4 AnimateVertex (
in vec4 pos_48,
in vec3 normal_49,
in vec4 animParams_50
)
{
vec3 bend_51;
vec2 vWavesSum_52;
vec4 vWaves_53;
vec2 vWavesIn_54;
float fVtxPhase_55;
float fBranchPhase_56;
float fObjPhase_57;
float fBranchAmp_58;
float fDetailAmp_59;
float tmpvar_60;
tmpvar_60 = 0.1;
fDetailAmp_59 = tmpvar_60;
float tmpvar_61;
tmpvar_61 = 0.3;
fBranchAmp_58 = tmpvar_61;
float tmpvar_62;
tmpvar_62 = dot (_Object2World[3].xyz, vec3(1.0, 1.0, 1.0));
float tmpvar_63;
tmpvar_63 = tmpvar_62;
fObjPhase_57 = tmpvar_63;
float tmpvar_64;
tmpvar_64 = (fObjPhase_57 + animParams_50.x);
fBranchPhase_56 = tmpvar_64;
vec3 tmpvar_65;
tmpvar_65 = vec3((animParams_50.y + fBranchPhase_56));
float tmpvar_66;
tmpvar_66 = dot (pos_48.xyz, tmpvar_65);
float tmpvar_67;
tmpvar_67 = tmpvar_66;
fVtxPhase_55 = tmpvar_67;
vec2 tmpvar_68;
tmpvar_68.x = fVtxPhase_55;
tmpvar_68.y = fBranchPhase_56;
vec2 tmpvar_69;
tmpvar_69 = (_TimeX + tmpvar_68);
vWavesIn_54 = tmpvar_69;
vec4 tmpvar_70;
tmpvar_70 = fract ((vWavesIn_54.xxyy * vec4(1.975, 0.793, 0.375, 0.193)));
vec4 tmpvar_71;
tmpvar_71 = ((tmpvar_70 * 2.0) - 1.0);
vWaves_53 = tmpvar_71;
vec4 tmpvar_72;
tmpvar_72 = SmoothTriangleWave (vWaves_53);
vec4 tmpvar_73;
tmpvar_73 = tmpvar_72;
vWaves_53 = tmpvar_73;
vec2 tmpvar_74;
tmpvar_74 = (vWaves_53.xz + vWaves_53.yw);
vWavesSum_52 = tmpvar_74;
vec3 tmpvar_75;
tmpvar_75 = ((animParams_50.y * fDetailAmp_59) * normal_49.xyz);
bend_51 = tmpvar_75;
float tmpvar_76;
tmpvar_76 = (animParams_50.w * fBranchAmp_58);
bend_51.y = vec2(tmpvar_76).y;
vec3 tmpvar_77;
tmpvar_77 = (pos_48.xyz + ((
(vWavesSum_52.xyx * bend_51)
+
((_Wind.xyz * vWavesSum_52.y) * animParams_50.w)
) * _Wind.w));
pos_48.xyz = tmpvar_77.xyz.xyz;
vec3 tmpvar_78;
tmpvar_78 = (pos_48.xyz + (animParams_50.z * _Wind.xyz));
pos_48.xyz = tmpvar_78.xyz.xyz;
return pos_48;
}
void TreeVertLeaf (
inout appdata_full v_79
)
{
ExpandBillboard (gl_ModelViewMatrixInverseTranspose, v_79.vertex, v_79.normal, v_79.tangent);
vec3 tmpvar_80;
tmpvar_80 = (v_79.vertex.xyz * _Scale.xyz);
v_79.vertex.xyz = tmpvar_80.xyz.xyz;
vec4 tmpvar_81;
tmpvar_81.xy = v_79.color.xy.xy;
tmpvar_81.zw = v_79.texcoord1.xy.xy;
vec4 tmpvar_82;
tmpvar_82 = AnimateVertex (v_79.vertex, v_79.normal, tmpvar_81);
vec4 tmpvar_83;
tmpvar_83 = tmpvar_82;
v_79.vertex = tmpvar_83;
vec4 tmpvar_84;
tmpvar_84 = Squash (v_79.vertex);
vec4 tmpvar_85;
tmpvar_85 = tmpvar_84;
v_79.vertex = tmpvar_85;
vec4 tmpvar_86;
tmpvar_86.xyz = (v_79.color.w * _Color.xyz).xyz;
tmpvar_86.w = _Color.w;
vec4 tmpvar_87;
tmpvar_87 = tmpvar_86;
v_79.color = tmpvar_87;
vec3 tmpvar_88;
tmpvar_88 = normalize (v_79.normal);
vec3 tmpvar_89;
tmpvar_89 = tmpvar_88;
v_79.normal = tmpvar_89;
vec3 tmpvar_90;
tmpvar_90 = normalize (v_79.tangent.xyz);
vec3 tmpvar_91;
tmpvar_91 = tmpvar_90;
v_79.tangent.xyz = tmpvar_91.xyz.xyz;
}
void PositionFog (
in vec4 v_92,
out vec4 pos_93,
out float fog_94
)
{
vec4 tmpvar_95;
tmpvar_95 = (gl_ModelViewProjectionMatrix * v_92);
pos_93 = tmpvar_95;
float tmpvar_96;
tmpvar_96 = pos_93.z;
fog_94 = tmpvar_96;
}
vec3 ObjSpaceViewDir (
in vec4 v_97
)
{
vec3 objSpaceCameraPos_98;
vec4 tmpvar_99;
tmpvar_99.w = 1.0;
tmpvar_99.xyz = _WorldSpaceCameraPos.xyz.xyz;
vec3 tmpvar_100;
tmpvar_100 = ((_World2Object * tmpvar_99).xyz * unity_Scale.w);
objSpaceCameraPos_98 = tmpvar_100;
return (objSpaceCameraPos_98 - v_97.xyz);
}
vec3 ObjSpaceLightDir (
in vec4 v_101
)
{
vec3 objSpaceLightPos_102;
vec3 tmpvar_103;
tmpvar_103 = (_World2Object * _WorldSpaceLightPos0).xyz;
objSpaceLightPos_102 = tmpvar_103;
return ((objSpaceLightPos_102.xyz * unity_Scale.w) - v_101.xyz);
}
v2f_surf vert_surf (
in appdata_full v_104
)
{
mat3 rotation_105;
vec3 binormal_106;
v2f_surf o_107;
TreeVertLeaf (v_104);
PositionFog (v_104.vertex, o_107.pos, o_107.fog);
vec2 tmpvar_108;
tmpvar_108 = ((v_104.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw);
o_107.hip_pack0 = tmpvar_108.xy.xy;
vec4 tmpvar_109;
tmpvar_109 = v_104.color;
o_107.lop_color = tmpvar_109;
vec3 tmpvar_110;
tmpvar_110 = cross (v_104.normal, v_104.tangent.xyz);
vec3 tmpvar_111;
tmpvar_111 = (tmpvar_110 * v_104.tangent.w);
binormal_106 = tmpvar_111;
mat3 tmpvar_112;
float tmpvar_113;
tmpvar_113 = v_104.tangent.x;
tmpvar_112[0].x = tmpvar_113;
float tmpvar_114;
tmpvar_114 = binormal_106.x;
tmpvar_112[0].y = tmpvar_114;
float tmpvar_115;
tmpvar_115 = v_104.normal.x;
tmpvar_112[0].z = tmpvar_115;
float tmpvar_116;
tmpvar_116 = v_104.tangent.y;
tmpvar_112[1].x = tmpvar_116;
float tmpvar_117;
tmpvar_117 = binormal_106.y;
tmpvar_112[1].y = tmpvar_117;
float tmpvar_118;
tmpvar_118 = v_104.normal.y;
tmpvar_112[1].z = tmpvar_118;
float tmpvar_119;
tmpvar_119 = v_104.tangent.z;
tmpvar_112[2].x = tmpvar_119;
float tmpvar_120;
tmpvar_120 = binormal_106.z;
tmpvar_112[2].y = tmpvar_120;
float tmpvar_121;
tmpvar_121 = v_104.normal.z;
tmpvar_112[2].z = tmpvar_121;
mat3 tmpvar_122;
tmpvar_122 = tmpvar_112;
rotation_105 = tmpvar_122;
vec3 tmpvar_123;
tmpvar_123 = ObjSpaceLightDir (v_104.vertex);
vec3 tmpvar_124;
tmpvar_124 = (rotation_105 * tmpvar_123);
o_107.lightDir = tmpvar_124;
vec3 tmpvar_125;
tmpvar_125 = ObjSpaceViewDir (v_104.vertex);
vec3 tmpvar_126;
tmpvar_126 = (rotation_105 * tmpvar_125);
o_107.viewDir = tmpvar_126;
vec3 tmpvar_127;
tmpvar_127 = (_LightMatrix0 * (_Object2World * v_104.vertex)).xyz;
o_107._LightCoord = tmpvar_127;
return o_107;
}
void main ()
{
appdata_full xlt_v_128;
v2f_surf xl_retval_129;
vec4 tmpvar_130;
tmpvar_130 = gl_Vertex.xyzw;
vec4 tmpvar_131;
tmpvar_131 = tmpvar_130;
xlt_v_128.vertex = tmpvar_131;
vec4 tmpvar_132;
tmpvar_132 = TANGENT.xyzw;
vec4 tmpvar_133;
tmpvar_133 = tmpvar_132;
xlt_v_128.tangent = tmpvar_133;
vec3 tmpvar_134;
tmpvar_134 = gl_Normal.xyz;
vec3 tmpvar_135;
tmpvar_135 = tmpvar_134;
xlt_v_128.normal = tmpvar_135;
vec4 tmpvar_136;
tmpvar_136 = gl_MultiTexCoord0.xyzw;
vec4 tmpvar_137;
tmpvar_137 = tmpvar_136;
xlt_v_128.texcoord = tmpvar_137;
vec4 tmpvar_138;
tmpvar_138 = gl_MultiTexCoord1.xyzw;
vec4 tmpvar_139;
tmpvar_139 = tmpvar_138;
xlt_v_128.texcoord1 = tmpvar_139;
vec4 tmpvar_140;
tmpvar_140 = gl_Color.xyzw;
vec4 tmpvar_141;
tmpvar_141 = tmpvar_140;
xlt_v_128.color = tmpvar_141;
v2f_surf tmpvar_142;
tmpvar_142 = vert_surf (xlt_v_128);
v2f_surf tmpvar_143;
tmpvar_143 = tmpvar_142;
xl_retval_129 = tmpvar_143;
vec4 tmpvar_144;
tmpvar_144 = xl_retval_129.pos.xyzw;
vec4 tmpvar_145;
tmpvar_145 = tmpvar_144;
gl_Position = tmpvar_145;
vec4 tmpvar_146;
tmpvar_146.yzw = vec3(0.0, 0.0, 0.0);
tmpvar_146.x = xl_retval_129.fog;
vec4 tmpvar_147;
tmpvar_147 = tmpvar_146;
xlv_FOG = tmpvar_147;
vec4 tmpvar_148;
tmpvar_148.zw = vec2(0.0, 0.0);
tmpvar_148.xy = xl_retval_129.hip_pack0.xy;
vec4 tmpvar_149;
tmpvar_149 = tmpvar_148;
gl_TexCoord[0] = tmpvar_149;
vec4 tmpvar_150;
tmpvar_150 = xl_retval_129.lop_color.xyzw;
vec4 tmpvar_151;
tmpvar_151 = tmpvar_150;
gl_FrontColor = tmpvar_151;
vec4 tmpvar_152;
tmpvar_152.w = 0.0;
tmpvar_152.xyz = xl_retval_129.lightDir.xyz;
vec4 tmpvar_153;
tmpvar_153 = tmpvar_152;
gl_TexCoord[1] = tmpvar_153;
vec4 tmpvar_154;
tmpvar_154.w = 0.0;
tmpvar_154.xyz = xl_retval_129.viewDir.xyz;
vec4 tmpvar_155;
tmpvar_155 = tmpvar_154;
gl_TexCoord[2] = tmpvar_155;
vec4 tmpvar_156;
tmpvar_156.w = 0.0;
tmpvar_156.xyz = xl_retval_129._LightCoord.xyz;
vec4 tmpvar_157;
tmpvar_157 = tmpvar_156;
gl_TexCoord[3] = tmpvar_157;
}