mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 09:08:22 -05:00
398 lines
9 KiB
Text
398 lines
9 KiB
Text
struct appdata_full {
|
|
vec4 vertex;
|
|
vec4 tangent;
|
|
vec3 normal;
|
|
vec4 texcoord;
|
|
vec4 texcoord1;
|
|
vec4 color;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
vec3 _ShadowCoord0;
|
|
vec3 _ShadowCoord1;
|
|
vec3 _ShadowCoord2;
|
|
vec3 _ShadowCoord3;
|
|
vec2 _ShadowZFade;
|
|
vec2 hip_pack0;
|
|
vec4 lop_color;
|
|
};
|
|
attribute vec4 TANGENT;
|
|
uniform mat4 _World2Shadow3;
|
|
uniform mat4 _World2Shadow2;
|
|
uniform mat4 _World2Shadow1;
|
|
uniform mat4 _World2Shadow;
|
|
uniform vec4 _Wind;
|
|
uniform float _TimeX;
|
|
uniform vec4 _SquashPlaneNormal;
|
|
uniform float _SquashAmount;
|
|
uniform vec4 _Scale;
|
|
uniform mat4 _Object2World;
|
|
uniform vec4 _MainTex_ST;
|
|
uniform vec4 _LightShadowData;
|
|
uniform vec4 _Color;
|
|
vec4 Squash (
|
|
in vec4 pos
|
|
)
|
|
{
|
|
vec3 planeNormal;
|
|
vec3 planePoint;
|
|
vec3 projectedVertex;
|
|
vec3 tmpvar_1;
|
|
tmpvar_1 = pos.xyz;
|
|
projectedVertex = tmpvar_1;
|
|
vec3 tmpvar_2;
|
|
tmpvar_2.xz = vec2(0.0, 0.0);
|
|
tmpvar_2.y = _SquashPlaneNormal.w;
|
|
vec3 tmpvar_3;
|
|
tmpvar_3 = tmpvar_2;
|
|
planePoint = tmpvar_3;
|
|
vec3 tmpvar_4;
|
|
tmpvar_4 = _SquashPlaneNormal.xyz;
|
|
planeNormal = tmpvar_4;
|
|
vec3 tmpvar_5;
|
|
tmpvar_5 = pos.xyz;
|
|
float tmpvar_6;
|
|
tmpvar_6 = dot (planeNormal, (planePoint - tmpvar_5));
|
|
vec3 tmpvar_7;
|
|
tmpvar_7 = (projectedVertex + (tmpvar_6 * planeNormal));
|
|
projectedVertex = tmpvar_7;
|
|
vec3 tmpvar_8;
|
|
tmpvar_8 = vec3(_SquashAmount);
|
|
vec3 tmpvar_9;
|
|
tmpvar_9 = mix (projectedVertex, pos.xyz, tmpvar_8);
|
|
vec4 tmpvar_10;
|
|
tmpvar_10.w = 1.0;
|
|
tmpvar_10.xyz = tmpvar_9.xyz;
|
|
vec4 tmpvar_11;
|
|
tmpvar_11 = tmpvar_10;
|
|
pos = tmpvar_11;
|
|
return pos;
|
|
}
|
|
|
|
void ExpandBillboard (
|
|
in mat4 mat,
|
|
inout vec4 pos,
|
|
inout vec3 normal,
|
|
inout vec4 tangent
|
|
)
|
|
{
|
|
vec3 tanb;
|
|
vec3 norb;
|
|
float isBillboard;
|
|
float tmpvar_1;
|
|
tmpvar_1 = abs (tangent.w);
|
|
float tmpvar_2;
|
|
tmpvar_2 = (1.0 - tmpvar_1);
|
|
isBillboard = tmpvar_2;
|
|
vec4 tmpvar_3;
|
|
tmpvar_3.w = 0.0;
|
|
tmpvar_3.xyz = normal.xyz;
|
|
vec4 tmpvar_4;
|
|
tmpvar_4 = normalize ((tmpvar_3 * mat));
|
|
vec3 tmpvar_5;
|
|
tmpvar_5 = tmpvar_4.xyz;
|
|
vec3 tmpvar_6;
|
|
tmpvar_6 = tmpvar_5;
|
|
norb = tmpvar_6;
|
|
vec4 tmpvar_7;
|
|
tmpvar_7.yw = vec2(0.0, 0.0);
|
|
tmpvar_7.x = normal.z;
|
|
tmpvar_7.z = -(normal.x);
|
|
vec4 tmpvar_8;
|
|
tmpvar_8 = normalize ((tmpvar_7 * mat));
|
|
vec3 tmpvar_9;
|
|
tmpvar_9 = tmpvar_8.xyz;
|
|
vec3 tmpvar_10;
|
|
tmpvar_10 = tmpvar_9;
|
|
tanb = tmpvar_10;
|
|
vec4 tmpvar_11;
|
|
tmpvar_11 = (pos + ((tangent * mat) * isBillboard));
|
|
pos = tmpvar_11;
|
|
vec3 tmpvar_12;
|
|
tmpvar_12 = vec3(isBillboard);
|
|
vec3 tmpvar_13;
|
|
tmpvar_13 = mix (normal, norb, tmpvar_12);
|
|
vec3 tmpvar_14;
|
|
tmpvar_14 = tmpvar_13;
|
|
normal = tmpvar_14;
|
|
vec4 tmpvar_15;
|
|
tmpvar_15.w = -1.0;
|
|
tmpvar_15.xyz = tanb.xyz;
|
|
vec4 tmpvar_16;
|
|
tmpvar_16 = vec4(isBillboard);
|
|
vec4 tmpvar_17;
|
|
tmpvar_17 = mix (tangent, tmpvar_15, tmpvar_16);
|
|
vec4 tmpvar_18;
|
|
tmpvar_18 = tmpvar_17;
|
|
tangent = tmpvar_18;
|
|
}
|
|
|
|
vec4 TriangleWave (
|
|
in vec4 x
|
|
)
|
|
{
|
|
vec4 tmpvar_1;
|
|
tmpvar_1 = fract ((x + 0.5));
|
|
vec4 tmpvar_2;
|
|
tmpvar_2 = abs (((tmpvar_1 * 2.0) - 1.0));
|
|
return tmpvar_2;
|
|
}
|
|
|
|
vec4 SmoothCurve (
|
|
in vec4 x
|
|
)
|
|
{
|
|
return ((x * x) * (3.0 - (2.0 * x)));
|
|
}
|
|
|
|
vec4 SmoothTriangleWave (
|
|
in vec4 x
|
|
)
|
|
{
|
|
vec4 tmpvar_1;
|
|
tmpvar_1 = TriangleWave (x);
|
|
vec4 tmpvar_2;
|
|
tmpvar_2 = SmoothCurve (tmpvar_1);
|
|
return tmpvar_2;
|
|
}
|
|
|
|
vec4 AnimateVertex (
|
|
in vec4 pos,
|
|
in vec3 normal,
|
|
in vec4 animParams
|
|
)
|
|
{
|
|
vec3 bend;
|
|
vec2 vWavesSum;
|
|
vec4 vWaves;
|
|
vec2 vWavesIn;
|
|
float fVtxPhase;
|
|
float fBranchPhase;
|
|
float fObjPhase;
|
|
float fBranchAmp;
|
|
float fDetailAmp;
|
|
float tmpvar_1;
|
|
tmpvar_1 = 0.1;
|
|
fDetailAmp = tmpvar_1;
|
|
float tmpvar_2;
|
|
tmpvar_2 = 0.3;
|
|
fBranchAmp = tmpvar_2;
|
|
float tmpvar_3;
|
|
tmpvar_3 = dot (_Object2World[3].xyz, vec3(1.0, 1.0, 1.0));
|
|
float tmpvar_4;
|
|
tmpvar_4 = tmpvar_3;
|
|
fObjPhase = tmpvar_4;
|
|
float tmpvar_5;
|
|
tmpvar_5 = (fObjPhase + animParams.x);
|
|
fBranchPhase = tmpvar_5;
|
|
vec3 tmpvar_6;
|
|
tmpvar_6 = vec3((animParams.y + fBranchPhase));
|
|
float tmpvar_7;
|
|
tmpvar_7 = dot (pos.xyz, tmpvar_6);
|
|
float tmpvar_8;
|
|
tmpvar_8 = tmpvar_7;
|
|
fVtxPhase = tmpvar_8;
|
|
vec2 tmpvar_9;
|
|
tmpvar_9.x = fVtxPhase;
|
|
tmpvar_9.y = fBranchPhase;
|
|
vec2 tmpvar_10;
|
|
tmpvar_10 = (_TimeX + tmpvar_9);
|
|
vWavesIn = tmpvar_10;
|
|
vec4 tmpvar_11;
|
|
tmpvar_11 = fract ((vWavesIn.xxyy * vec4(1.975, 0.793, 0.375, 0.193)));
|
|
vec4 tmpvar_12;
|
|
tmpvar_12 = ((tmpvar_11 * 2.0) - 1.0);
|
|
vWaves = tmpvar_12;
|
|
vec4 tmpvar_13;
|
|
tmpvar_13 = SmoothTriangleWave (vWaves);
|
|
vec4 tmpvar_14;
|
|
tmpvar_14 = tmpvar_13;
|
|
vWaves = tmpvar_14;
|
|
vec2 tmpvar_15;
|
|
tmpvar_15 = (vWaves.xz + vWaves.yw);
|
|
vWavesSum = tmpvar_15;
|
|
vec3 tmpvar_16;
|
|
tmpvar_16 = ((animParams.y * fDetailAmp) * normal.xyz);
|
|
bend = tmpvar_16;
|
|
float tmpvar_17;
|
|
tmpvar_17 = (animParams.w * fBranchAmp);
|
|
bend.y = vec2(tmpvar_17).y;
|
|
vec3 tmpvar_18;
|
|
tmpvar_18 = (pos.xyz + (((vWavesSum.xyx * bend) + ((_Wind.xyz * vWavesSum.y) * animParams.w)) * _Wind.w));
|
|
pos.xyz = tmpvar_18.xyz.xyz;
|
|
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 (gl_ModelViewMatrixInverseTranspose, v.vertex, v.normal, v.tangent);
|
|
vec3 tmpvar_1;
|
|
tmpvar_1 = (v.vertex.xyz * _Scale.xyz);
|
|
v.vertex.xyz = tmpvar_1.xyz.xyz;
|
|
vec4 tmpvar_2;
|
|
tmpvar_2.xy = v.color.xy.xy;
|
|
tmpvar_2.zw = v.texcoord1.xy.xy;
|
|
vec4 tmpvar_3;
|
|
tmpvar_3 = AnimateVertex (v.vertex, v.normal, tmpvar_2);
|
|
vec4 tmpvar_4;
|
|
tmpvar_4 = tmpvar_3;
|
|
v.vertex = tmpvar_4;
|
|
vec4 tmpvar_5;
|
|
tmpvar_5 = Squash (v.vertex);
|
|
vec4 tmpvar_6;
|
|
tmpvar_6 = tmpvar_5;
|
|
v.vertex = tmpvar_6;
|
|
vec4 tmpvar_7;
|
|
tmpvar_7.xyz = (v.color.w * _Color.xyz).xyz;
|
|
tmpvar_7.w = _Color.w;
|
|
vec4 tmpvar_8;
|
|
tmpvar_8 = tmpvar_7;
|
|
v.color = tmpvar_8;
|
|
vec3 tmpvar_9;
|
|
tmpvar_9 = normalize (v.normal);
|
|
vec3 tmpvar_10;
|
|
tmpvar_10 = tmpvar_9;
|
|
v.normal = tmpvar_10;
|
|
vec3 tmpvar_11;
|
|
tmpvar_11 = normalize (v.tangent.xyz);
|
|
vec3 tmpvar_12;
|
|
tmpvar_12 = tmpvar_11;
|
|
v.tangent.xyz = tmpvar_12.xyz.xyz;
|
|
}
|
|
|
|
v2f_surf vert_surf (
|
|
in appdata_full v
|
|
)
|
|
{
|
|
vec4 wpos;
|
|
float z;
|
|
v2f_surf o;
|
|
TreeVertLeaf (v);
|
|
vec2 tmpvar_1;
|
|
tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw);
|
|
o.hip_pack0 = tmpvar_1.xy.xy;
|
|
vec4 tmpvar_2;
|
|
tmpvar_2 = v.color;
|
|
o.lop_color = tmpvar_2;
|
|
vec4 tmpvar_3;
|
|
tmpvar_3 = (gl_ModelViewProjectionMatrix * v.vertex);
|
|
o.pos = tmpvar_3;
|
|
float tmpvar_4;
|
|
tmpvar_4 = -((gl_ModelViewMatrix * v.vertex).z);
|
|
z = tmpvar_4;
|
|
float tmpvar_5;
|
|
tmpvar_5 = z;
|
|
o._ShadowZFade.x = tmpvar_5;
|
|
float tmpvar_6;
|
|
tmpvar_6 = ((z * _LightShadowData.z) + _LightShadowData.w);
|
|
o._ShadowZFade.y = vec2(tmpvar_6).y;
|
|
vec4 tmpvar_7;
|
|
tmpvar_7 = (_Object2World * v.vertex);
|
|
wpos = tmpvar_7;
|
|
vec3 tmpvar_8;
|
|
tmpvar_8 = (_World2Shadow * wpos).xyz;
|
|
o._ShadowCoord0 = tmpvar_8;
|
|
vec3 tmpvar_9;
|
|
tmpvar_9 = (_World2Shadow1 * wpos).xyz;
|
|
o._ShadowCoord1 = tmpvar_9;
|
|
vec3 tmpvar_10;
|
|
tmpvar_10 = (_World2Shadow2 * wpos).xyz;
|
|
o._ShadowCoord2 = tmpvar_10;
|
|
vec3 tmpvar_11;
|
|
tmpvar_11 = (_World2Shadow3 * wpos).xyz;
|
|
o._ShadowCoord3 = tmpvar_11;
|
|
return o;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
appdata_full xlt_v;
|
|
v2f_surf xl_retval;
|
|
vec4 tmpvar_1;
|
|
tmpvar_1 = gl_Vertex.xyzw;
|
|
vec4 tmpvar_2;
|
|
tmpvar_2 = tmpvar_1;
|
|
xlt_v.vertex = tmpvar_2;
|
|
vec4 tmpvar_3;
|
|
tmpvar_3 = TANGENT.xyzw;
|
|
vec4 tmpvar_4;
|
|
tmpvar_4 = tmpvar_3;
|
|
xlt_v.tangent = tmpvar_4;
|
|
vec3 tmpvar_5;
|
|
tmpvar_5 = gl_Normal.xyz;
|
|
vec3 tmpvar_6;
|
|
tmpvar_6 = tmpvar_5;
|
|
xlt_v.normal = tmpvar_6;
|
|
vec4 tmpvar_7;
|
|
tmpvar_7 = gl_MultiTexCoord0.xyzw;
|
|
vec4 tmpvar_8;
|
|
tmpvar_8 = tmpvar_7;
|
|
xlt_v.texcoord = tmpvar_8;
|
|
vec4 tmpvar_9;
|
|
tmpvar_9 = gl_MultiTexCoord1.xyzw;
|
|
vec4 tmpvar_10;
|
|
tmpvar_10 = tmpvar_9;
|
|
xlt_v.texcoord1 = tmpvar_10;
|
|
vec4 tmpvar_11;
|
|
tmpvar_11 = gl_Color.xyzw;
|
|
vec4 tmpvar_12;
|
|
tmpvar_12 = tmpvar_11;
|
|
xlt_v.color = tmpvar_12;
|
|
v2f_surf tmpvar_13;
|
|
tmpvar_13 = vert_surf (xlt_v);
|
|
v2f_surf tmpvar_14;
|
|
tmpvar_14 = tmpvar_13;
|
|
xl_retval = tmpvar_14;
|
|
vec4 tmpvar_15;
|
|
tmpvar_15 = xl_retval.pos.xyzw;
|
|
vec4 tmpvar_16;
|
|
tmpvar_16 = tmpvar_15;
|
|
gl_Position = tmpvar_16;
|
|
vec4 tmpvar_17;
|
|
tmpvar_17.w = 0.0;
|
|
tmpvar_17.xyz = xl_retval._ShadowCoord0.xyz;
|
|
vec4 tmpvar_18;
|
|
tmpvar_18 = tmpvar_17;
|
|
gl_TexCoord[0] = tmpvar_18;
|
|
vec4 tmpvar_19;
|
|
tmpvar_19.w = 0.0;
|
|
tmpvar_19.xyz = xl_retval._ShadowCoord1.xyz;
|
|
vec4 tmpvar_20;
|
|
tmpvar_20 = tmpvar_19;
|
|
gl_TexCoord[1] = tmpvar_20;
|
|
vec4 tmpvar_21;
|
|
tmpvar_21.w = 0.0;
|
|
tmpvar_21.xyz = xl_retval._ShadowCoord2.xyz;
|
|
vec4 tmpvar_22;
|
|
tmpvar_22 = tmpvar_21;
|
|
gl_TexCoord[2] = tmpvar_22;
|
|
vec4 tmpvar_23;
|
|
tmpvar_23.w = 0.0;
|
|
tmpvar_23.xyz = xl_retval._ShadowCoord3.xyz;
|
|
vec4 tmpvar_24;
|
|
tmpvar_24 = tmpvar_23;
|
|
gl_TexCoord[3] = tmpvar_24;
|
|
vec4 tmpvar_25;
|
|
tmpvar_25.zw = vec2(0.0, 0.0);
|
|
tmpvar_25.xy = xl_retval._ShadowZFade.xy;
|
|
vec4 tmpvar_26;
|
|
tmpvar_26 = tmpvar_25;
|
|
gl_TexCoord[4] = tmpvar_26;
|
|
vec4 tmpvar_27;
|
|
tmpvar_27.zw = vec2(0.0, 0.0);
|
|
tmpvar_27.xy = xl_retval.hip_pack0.xy;
|
|
vec4 tmpvar_28;
|
|
tmpvar_28 = tmpvar_27;
|
|
gl_TexCoord[5] = tmpvar_28;
|
|
vec4 tmpvar_29;
|
|
tmpvar_29 = xl_retval.lop_color.xyzw;
|
|
vec4 tmpvar_30;
|
|
tmpvar_30 = tmpvar_29;
|
|
gl_FrontColor = tmpvar_30;
|
|
}
|
|
|