mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-12 17:21:08 -05:00
433 lines
12 KiB
Text
433 lines
12 KiB
Text
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_1
|
|
)
|
|
{
|
|
highp vec3 projectedVertex_2;
|
|
highp vec3 planeNormal_3;
|
|
highp vec3 tmpvar_4;
|
|
tmpvar_4 = _SquashPlaneNormal.xyz;
|
|
planeNormal_3 = tmpvar_4;
|
|
highp vec3 tmpvar_5;
|
|
tmpvar_5 = pos_1.xyz;
|
|
highp float tmpvar_6;
|
|
tmpvar_6 = dot (planeNormal_3, tmpvar_5);
|
|
highp vec3 tmpvar_7;
|
|
tmpvar_7 = (pos_1.xyz - ((tmpvar_6 + _SquashPlaneNormal.w) * planeNormal_3));
|
|
projectedVertex_2 = tmpvar_7;
|
|
highp vec3 tmpvar_8;
|
|
tmpvar_8 = vec3(_SquashAmount);
|
|
highp vec3 tmpvar_9;
|
|
tmpvar_9 = mix (projectedVertex_2, pos_1.xyz, tmpvar_8);
|
|
highp vec4 tmpvar_10;
|
|
tmpvar_10.w = 1.0;
|
|
tmpvar_10.xyz = tmpvar_9.xyz;
|
|
highp vec4 tmpvar_11;
|
|
tmpvar_11 = tmpvar_10;
|
|
pos_1 = tmpvar_11;
|
|
return pos_1;
|
|
}
|
|
|
|
void ExpandBillboard (
|
|
in highp mat4 mat_12,
|
|
inout highp vec4 pos_13,
|
|
inout highp vec3 normal_14,
|
|
inout highp vec4 tangent_15
|
|
)
|
|
{
|
|
highp vec3 tanb_16;
|
|
highp vec3 norb_17;
|
|
highp float isBillboard_18;
|
|
highp float tmpvar_19;
|
|
tmpvar_19 = abs (tangent_15.w);
|
|
highp float tmpvar_20;
|
|
tmpvar_20 = (1.0 - tmpvar_19);
|
|
isBillboard_18 = tmpvar_20;
|
|
highp vec4 tmpvar_21;
|
|
tmpvar_21.w = 0.0;
|
|
tmpvar_21.xyz = normal_14.xyz;
|
|
highp vec4 tmpvar_22;
|
|
tmpvar_22 = normalize ((tmpvar_21 * mat_12));
|
|
highp vec3 tmpvar_23;
|
|
tmpvar_23 = tmpvar_22.xyz;
|
|
highp vec3 tmpvar_24;
|
|
tmpvar_24 = tmpvar_23;
|
|
norb_17 = tmpvar_24;
|
|
highp vec4 tmpvar_25;
|
|
tmpvar_25.w = 0.0;
|
|
tmpvar_25.xyz = tangent_15.xyz.xyz;
|
|
highp vec4 tmpvar_26;
|
|
tmpvar_26 = normalize ((tmpvar_25 * mat_12));
|
|
highp vec3 tmpvar_27;
|
|
tmpvar_27 = tmpvar_26.xyz;
|
|
highp vec3 tmpvar_28;
|
|
tmpvar_28 = tmpvar_27;
|
|
tanb_16 = tmpvar_28;
|
|
highp vec4 tmpvar_29;
|
|
tmpvar_29.zw = vec2(0.0, 0.0);
|
|
tmpvar_29.xy = normal_14.xy.xy;
|
|
highp vec4 tmpvar_30;
|
|
tmpvar_30 = (pos_13 + ((tmpvar_29 * mat_12) * isBillboard_18));
|
|
pos_13 = tmpvar_30;
|
|
highp vec3 tmpvar_31;
|
|
tmpvar_31 = vec3(isBillboard_18);
|
|
highp vec3 tmpvar_32;
|
|
tmpvar_32 = mix (normal_14, norb_17, tmpvar_31);
|
|
highp vec3 tmpvar_33;
|
|
tmpvar_33 = tmpvar_32;
|
|
normal_14 = tmpvar_33;
|
|
highp vec4 tmpvar_34;
|
|
tmpvar_34.w = -1.0;
|
|
tmpvar_34.xyz = tanb_16.xyz;
|
|
highp vec4 tmpvar_35;
|
|
tmpvar_35 = vec4(isBillboard_18);
|
|
highp vec4 tmpvar_36;
|
|
tmpvar_36 = mix (tangent_15, tmpvar_34, tmpvar_35);
|
|
highp vec4 tmpvar_37;
|
|
tmpvar_37 = tmpvar_36;
|
|
tangent_15 = tmpvar_37;
|
|
}
|
|
|
|
vec4 TriangleWave (
|
|
in highp vec4 x_38
|
|
)
|
|
{
|
|
highp vec4 tmpvar_39;
|
|
tmpvar_39 = fract ((x_38 + 0.5));
|
|
highp vec4 tmpvar_40;
|
|
tmpvar_40 = abs (((tmpvar_39 * 2.0) - 1.0));
|
|
return tmpvar_40;
|
|
}
|
|
|
|
vec4 SmoothCurve (
|
|
in highp vec4 x_41
|
|
)
|
|
{
|
|
return ((x_41 * x_41) * (3.0 - (2.0 * x_41)));
|
|
}
|
|
|
|
vec4 SmoothTriangleWave (
|
|
in highp vec4 x_42
|
|
)
|
|
{
|
|
highp vec4 tmpvar_43;
|
|
tmpvar_43 = TriangleWave (x_42);
|
|
highp vec4 tmpvar_44;
|
|
tmpvar_44 = SmoothCurve (tmpvar_43);
|
|
return tmpvar_44;
|
|
}
|
|
|
|
vec4 AnimateVertex (
|
|
in highp vec4 pos_45,
|
|
in highp vec3 normal_46,
|
|
in highp vec4 animParams_47
|
|
)
|
|
{
|
|
highp vec3 bend_48;
|
|
highp vec2 vWavesSum_49;
|
|
highp vec4 vWaves_50;
|
|
highp vec2 vWavesIn_51;
|
|
highp float fVtxPhase_52;
|
|
highp float fBranchPhase_53;
|
|
highp float fObjPhase_54;
|
|
highp float fBranchAmp_55;
|
|
highp float fDetailAmp_56;
|
|
float tmpvar_57;
|
|
tmpvar_57 = 0.1;
|
|
fDetailAmp_56 = tmpvar_57;
|
|
float tmpvar_58;
|
|
tmpvar_58 = 0.3;
|
|
fBranchAmp_55 = tmpvar_58;
|
|
highp float tmpvar_59;
|
|
tmpvar_59 = dot (_Object2World[3].xyz, vec3(1.0, 1.0, 1.0));
|
|
highp float tmpvar_60;
|
|
tmpvar_60 = tmpvar_59;
|
|
fObjPhase_54 = tmpvar_60;
|
|
highp float tmpvar_61;
|
|
tmpvar_61 = (fObjPhase_54 + animParams_47.x);
|
|
fBranchPhase_53 = tmpvar_61;
|
|
highp vec3 tmpvar_62;
|
|
tmpvar_62 = vec3((animParams_47.y + fBranchPhase_53));
|
|
highp float tmpvar_63;
|
|
tmpvar_63 = dot (pos_45.xyz, tmpvar_62);
|
|
highp float tmpvar_64;
|
|
tmpvar_64 = tmpvar_63;
|
|
fVtxPhase_52 = tmpvar_64;
|
|
highp vec2 tmpvar_65;
|
|
tmpvar_65.x = fVtxPhase_52;
|
|
tmpvar_65.y = fBranchPhase_53;
|
|
highp vec2 tmpvar_66;
|
|
tmpvar_66 = (_Time.yy + tmpvar_65);
|
|
vWavesIn_51 = tmpvar_66;
|
|
highp vec4 tmpvar_67;
|
|
tmpvar_67 = fract ((vWavesIn_51.xxyy * vec4(1.975, 0.793, 0.375, 0.193)));
|
|
highp vec4 tmpvar_68;
|
|
tmpvar_68 = ((tmpvar_67 * 2.0) - 1.0);
|
|
vWaves_50 = tmpvar_68;
|
|
highp vec4 tmpvar_69;
|
|
tmpvar_69 = SmoothTriangleWave (vWaves_50);
|
|
highp vec4 tmpvar_70;
|
|
tmpvar_70 = tmpvar_69;
|
|
vWaves_50 = tmpvar_70;
|
|
highp vec2 tmpvar_71;
|
|
tmpvar_71 = (vWaves_50.xz + vWaves_50.yw);
|
|
vWavesSum_49 = tmpvar_71;
|
|
highp vec3 tmpvar_72;
|
|
tmpvar_72 = ((animParams_47.y * fDetailAmp_56) * normal_46.xyz);
|
|
bend_48 = tmpvar_72;
|
|
highp float tmpvar_73;
|
|
tmpvar_73 = (animParams_47.w * fBranchAmp_55);
|
|
bend_48.y = vec2(tmpvar_73).y;
|
|
highp vec3 tmpvar_74;
|
|
tmpvar_74 = (pos_45.xyz + (((vWavesSum_49.xyx * bend_48) + ((_Wind.xyz * vWavesSum_49.y) * animParams_47.w)) * _Wind.w));
|
|
pos_45.xyz = tmpvar_74.xyz.xyz;
|
|
highp vec3 tmpvar_75;
|
|
tmpvar_75 = (pos_45.xyz + (animParams_47.z * _Wind.xyz));
|
|
pos_45.xyz = tmpvar_75.xyz.xyz;
|
|
return pos_45;
|
|
}
|
|
|
|
void TreeVertLeaf (
|
|
inout appdata_full v_76
|
|
)
|
|
{
|
|
ExpandBillboard (glstate_matrix_invtrans_modelview0, v_76.vertex, v_76.normal, v_76.tangent);
|
|
highp vec3 tmpvar_77;
|
|
tmpvar_77 = (v_76.vertex.xyz * _Scale.xyz);
|
|
v_76.vertex.xyz = tmpvar_77.xyz.xyz;
|
|
highp vec4 tmpvar_78;
|
|
tmpvar_78.xy = v_76.color.xy.xy;
|
|
tmpvar_78.zw = v_76.texcoord1.xy.xy;
|
|
highp vec4 tmpvar_79;
|
|
tmpvar_79 = AnimateVertex (v_76.vertex, v_76.normal, tmpvar_78);
|
|
highp vec4 tmpvar_80;
|
|
tmpvar_80 = tmpvar_79;
|
|
v_76.vertex = tmpvar_80;
|
|
highp vec4 tmpvar_81;
|
|
tmpvar_81 = Squash (v_76.vertex);
|
|
highp vec4 tmpvar_82;
|
|
tmpvar_82 = tmpvar_81;
|
|
v_76.vertex = tmpvar_82;
|
|
highp vec4 tmpvar_83;
|
|
tmpvar_83.xyz = vec3(1.0, 1.0, 1.0);
|
|
tmpvar_83.w = v_76.color.w;
|
|
highp vec4 tmpvar_84;
|
|
tmpvar_84 = tmpvar_83;
|
|
v_76.color = tmpvar_84;
|
|
highp vec3 tmpvar_85;
|
|
tmpvar_85 = normalize (v_76.normal);
|
|
highp vec3 tmpvar_86;
|
|
tmpvar_86 = tmpvar_85;
|
|
v_76.normal = tmpvar_86;
|
|
highp vec3 tmpvar_87;
|
|
tmpvar_87 = normalize (v_76.tangent.xyz);
|
|
highp vec3 tmpvar_88;
|
|
tmpvar_88 = tmpvar_87;
|
|
v_76.tangent.xyz = tmpvar_88.xyz.xyz;
|
|
}
|
|
|
|
vec3 ObjSpaceViewDir (
|
|
in highp vec4 v_89
|
|
)
|
|
{
|
|
highp vec3 objSpaceCameraPos_90;
|
|
highp vec4 tmpvar_91;
|
|
tmpvar_91.w = 1.0;
|
|
tmpvar_91.xyz = _WorldSpaceCameraPos.xyz.xyz;
|
|
highp vec3 tmpvar_92;
|
|
tmpvar_92 = ((_World2Object * tmpvar_91).xyz * unity_Scale.w);
|
|
objSpaceCameraPos_90 = tmpvar_92;
|
|
return (objSpaceCameraPos_90 - v_89.xyz);
|
|
}
|
|
|
|
vec3 ObjSpaceLightDir (
|
|
in highp vec4 v_93
|
|
)
|
|
{
|
|
highp vec3 objSpaceLightPos_94;
|
|
highp vec3 tmpvar_95;
|
|
tmpvar_95 = (_World2Object * _WorldSpaceLightPos0).xyz;
|
|
objSpaceLightPos_94 = tmpvar_95;
|
|
return objSpaceLightPos_94.xyz;
|
|
}
|
|
|
|
v2f_surf xlat_main (
|
|
in appdata_full v_96
|
|
)
|
|
{
|
|
highp mat3 rotation_97;
|
|
highp vec3 binormal_98;
|
|
v2f_surf o_99;
|
|
TreeVertLeaf (v_96);
|
|
highp vec4 tmpvar_100;
|
|
tmpvar_100 = (glstate_matrix_mvp * v_96.vertex);
|
|
o_99.pos = tmpvar_100;
|
|
highp vec2 tmpvar_101;
|
|
tmpvar_101 = ((v_96.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw);
|
|
o_99.hip_pack0 = tmpvar_101.xy.xy;
|
|
highp vec4 tmpvar_102;
|
|
tmpvar_102 = v_96.color;
|
|
o_99.lop_color = tmpvar_102;
|
|
highp vec3 tmpvar_103;
|
|
tmpvar_103 = cross (v_96.normal, v_96.tangent.xyz);
|
|
highp vec3 tmpvar_104;
|
|
tmpvar_104 = (tmpvar_103 * v_96.tangent.w);
|
|
binormal_98 = tmpvar_104;
|
|
mat3 tmpvar_105;
|
|
float tmpvar_106;
|
|
tmpvar_106 = v_96.tangent.x;
|
|
tmpvar_105[0].x = tmpvar_106;
|
|
float tmpvar_107;
|
|
tmpvar_107 = binormal_98.x;
|
|
tmpvar_105[0].y = tmpvar_107;
|
|
float tmpvar_108;
|
|
tmpvar_108 = v_96.normal.x;
|
|
tmpvar_105[0].z = tmpvar_108;
|
|
float tmpvar_109;
|
|
tmpvar_109 = v_96.tangent.y;
|
|
tmpvar_105[1].x = tmpvar_109;
|
|
float tmpvar_110;
|
|
tmpvar_110 = binormal_98.y;
|
|
tmpvar_105[1].y = tmpvar_110;
|
|
float tmpvar_111;
|
|
tmpvar_111 = v_96.normal.y;
|
|
tmpvar_105[1].z = tmpvar_111;
|
|
float tmpvar_112;
|
|
tmpvar_112 = v_96.tangent.z;
|
|
tmpvar_105[2].x = tmpvar_112;
|
|
float tmpvar_113;
|
|
tmpvar_113 = binormal_98.z;
|
|
tmpvar_105[2].y = tmpvar_113;
|
|
float tmpvar_114;
|
|
tmpvar_114 = v_96.normal.z;
|
|
tmpvar_105[2].z = tmpvar_114;
|
|
mat3 tmpvar_115;
|
|
tmpvar_115 = (tmpvar_105);
|
|
rotation_97 = (tmpvar_115);
|
|
highp vec3 tmpvar_116;
|
|
tmpvar_116 = ObjSpaceLightDir (v_96.vertex);
|
|
highp vec3 tmpvar_117;
|
|
tmpvar_117 = (rotation_97 * tmpvar_116);
|
|
o_99.lightDir = tmpvar_117;
|
|
highp vec3 tmpvar_118;
|
|
tmpvar_118 = ObjSpaceViewDir (v_96.vertex);
|
|
highp vec3 tmpvar_119;
|
|
tmpvar_119 = (rotation_97 * tmpvar_118);
|
|
o_99.viewDir = tmpvar_119;
|
|
highp vec2 tmpvar_120;
|
|
tmpvar_120 = (_LightMatrix0 * (_Object2World * v_96.vertex)).xy;
|
|
o_99._LightCoord = tmpvar_120;
|
|
return o_99;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
appdata_full xlt_v_121;
|
|
v2f_surf xl_retval_122;
|
|
highp vec4 tmpvar_123;
|
|
tmpvar_123 = _glesVertex.xyzw;
|
|
highp vec4 tmpvar_124;
|
|
tmpvar_124 = tmpvar_123;
|
|
xlt_v_121.vertex = tmpvar_124;
|
|
highp vec4 tmpvar_125;
|
|
tmpvar_125 = TANGENT.xyzw;
|
|
highp vec4 tmpvar_126;
|
|
tmpvar_126 = tmpvar_125;
|
|
xlt_v_121.tangent = tmpvar_126;
|
|
highp vec3 tmpvar_127;
|
|
tmpvar_127 = _glesNormal.xyz;
|
|
highp vec3 tmpvar_128;
|
|
tmpvar_128 = tmpvar_127;
|
|
xlt_v_121.normal = tmpvar_128;
|
|
highp vec4 tmpvar_129;
|
|
tmpvar_129 = _glesMultiTexCoord0.xyzw;
|
|
highp vec4 tmpvar_130;
|
|
tmpvar_130 = tmpvar_129;
|
|
xlt_v_121.texcoord = tmpvar_130;
|
|
highp vec4 tmpvar_131;
|
|
tmpvar_131 = _glesMultiTexCoord1.xyzw;
|
|
highp vec4 tmpvar_132;
|
|
tmpvar_132 = tmpvar_131;
|
|
xlt_v_121.texcoord1 = tmpvar_132;
|
|
highp vec4 tmpvar_133;
|
|
tmpvar_133 = _glesColor.xyzw;
|
|
highp vec4 tmpvar_134;
|
|
tmpvar_134 = tmpvar_133;
|
|
xlt_v_121.color = tmpvar_134;
|
|
v2f_surf tmpvar_135;
|
|
tmpvar_135 = xlat_main (xlt_v_121);
|
|
v2f_surf tmpvar_136;
|
|
tmpvar_136 = tmpvar_135;
|
|
xl_retval_122 = tmpvar_136;
|
|
highp vec4 tmpvar_137;
|
|
tmpvar_137 = xl_retval_122.pos.xyzw;
|
|
highp vec4 tmpvar_138;
|
|
tmpvar_138 = tmpvar_137;
|
|
gl_Position = tmpvar_138;
|
|
highp vec2 tmpvar_139;
|
|
tmpvar_139 = xl_retval_122.hip_pack0.xy;
|
|
highp vec2 tmpvar_140;
|
|
tmpvar_140 = tmpvar_139;
|
|
xlv_TEXCOORD0 = tmpvar_140;
|
|
highp vec4 tmpvar_141;
|
|
tmpvar_141 = xl_retval_122.lop_color.xyzw;
|
|
highp vec4 tmpvar_142;
|
|
tmpvar_142 = tmpvar_141;
|
|
xlv_COLOR0 = tmpvar_142;
|
|
highp vec3 tmpvar_143;
|
|
tmpvar_143 = xl_retval_122.lightDir.xyz;
|
|
highp vec3 tmpvar_144;
|
|
tmpvar_144 = tmpvar_143;
|
|
xlv_TEXCOORD1 = tmpvar_144;
|
|
highp vec3 tmpvar_145;
|
|
tmpvar_145 = xl_retval_122.viewDir.xyz;
|
|
highp vec3 tmpvar_146;
|
|
tmpvar_146 = tmpvar_145;
|
|
xlv_TEXCOORD2 = tmpvar_146;
|
|
highp vec2 tmpvar_147;
|
|
tmpvar_147 = xl_retval_122._LightCoord.xy;
|
|
highp vec2 tmpvar_148;
|
|
tmpvar_148 = tmpvar_147;
|
|
xlv_TEXCOORD3 = tmpvar_148;
|
|
}
|
|
|