mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-11 00:31:28 -05:00
266 lines
6.1 KiB
Text
266 lines
6.1 KiB
Text
struct appdata_full {
|
|
vec4 vertex;
|
|
vec4 tangent;
|
|
vec3 normal;
|
|
vec4 texcoord;
|
|
vec4 texcoord1;
|
|
vec4 color;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
};
|
|
uniform vec4 _Color;
|
|
uniform mat4 _Object2World;
|
|
uniform vec4 _Scale;
|
|
uniform float _SquashAmount;
|
|
uniform vec4 _SquashPlaneNormal;
|
|
uniform float _TimeX;
|
|
uniform vec4 _Wind;
|
|
uniform vec4 unity_LightShadowBias;
|
|
attribute vec4 TANGENT;
|
|
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;
|
|
}
|
|
|
|
vec4 TriangleWave (
|
|
in vec4 x_16
|
|
)
|
|
{
|
|
vec4 tmpvar_17;
|
|
tmpvar_17 = fract ((x_16 + 0.5));
|
|
vec4 tmpvar_18;
|
|
tmpvar_18 = abs (((tmpvar_17 * 2.0) - 1.0));
|
|
return tmpvar_18;
|
|
}
|
|
|
|
vec4 SmoothCurve (
|
|
in vec4 x_19
|
|
)
|
|
{
|
|
return ((x_19 * x_19) * (3.0 - (2.0 * x_19)));
|
|
}
|
|
|
|
vec4 SmoothTriangleWave (
|
|
in vec4 x_20
|
|
)
|
|
{
|
|
vec4 tmpvar_21;
|
|
tmpvar_21 = TriangleWave (x_20);
|
|
vec4 tmpvar_22;
|
|
tmpvar_22 = SmoothCurve (tmpvar_21);
|
|
return tmpvar_22;
|
|
}
|
|
|
|
vec4 AnimateVertex (
|
|
in vec4 pos_23,
|
|
in vec3 normal_24,
|
|
in vec4 animParams_25
|
|
)
|
|
{
|
|
vec3 bend_26;
|
|
vec2 vWavesSum_27;
|
|
vec4 vWaves_28;
|
|
vec2 vWavesIn_29;
|
|
float fVtxPhase_30;
|
|
float fBranchPhase_31;
|
|
float fObjPhase_32;
|
|
float fBranchAmp_33;
|
|
float fDetailAmp_34;
|
|
float tmpvar_35;
|
|
tmpvar_35 = 0.1;
|
|
fDetailAmp_34 = tmpvar_35;
|
|
float tmpvar_36;
|
|
tmpvar_36 = 0.3;
|
|
fBranchAmp_33 = tmpvar_36;
|
|
float tmpvar_37;
|
|
tmpvar_37 = dot (_Object2World[3].xyz, vec3(1.0, 1.0, 1.0));
|
|
float tmpvar_38;
|
|
tmpvar_38 = tmpvar_37;
|
|
fObjPhase_32 = tmpvar_38;
|
|
float tmpvar_39;
|
|
tmpvar_39 = (fObjPhase_32 + animParams_25.x);
|
|
fBranchPhase_31 = tmpvar_39;
|
|
vec3 tmpvar_40;
|
|
tmpvar_40 = vec3((animParams_25.y + fBranchPhase_31));
|
|
float tmpvar_41;
|
|
tmpvar_41 = dot (pos_23.xyz, tmpvar_40);
|
|
float tmpvar_42;
|
|
tmpvar_42 = tmpvar_41;
|
|
fVtxPhase_30 = tmpvar_42;
|
|
vec2 tmpvar_43;
|
|
tmpvar_43.x = fVtxPhase_30;
|
|
tmpvar_43.y = fBranchPhase_31;
|
|
vec2 tmpvar_44;
|
|
tmpvar_44 = (_TimeX + tmpvar_43);
|
|
vWavesIn_29 = tmpvar_44;
|
|
vec4 tmpvar_45;
|
|
tmpvar_45 = fract ((vWavesIn_29.xxyy * vec4(1.975, 0.793, 0.375, 0.193)));
|
|
vec4 tmpvar_46;
|
|
tmpvar_46 = ((tmpvar_45 * 2.0) - 1.0);
|
|
vWaves_28 = tmpvar_46;
|
|
vec4 tmpvar_47;
|
|
tmpvar_47 = SmoothTriangleWave (vWaves_28);
|
|
vec4 tmpvar_48;
|
|
tmpvar_48 = tmpvar_47;
|
|
vWaves_28 = tmpvar_48;
|
|
vec2 tmpvar_49;
|
|
tmpvar_49 = (vWaves_28.xz + vWaves_28.yw);
|
|
vWavesSum_27 = tmpvar_49;
|
|
vec3 tmpvar_50;
|
|
tmpvar_50 = ((animParams_25.y * fDetailAmp_34) * normal_24.xyz);
|
|
bend_26 = tmpvar_50;
|
|
float tmpvar_51;
|
|
tmpvar_51 = (animParams_25.w * fBranchAmp_33);
|
|
bend_26.y = vec2(tmpvar_51).y;
|
|
vec3 tmpvar_52;
|
|
tmpvar_52 = (pos_23.xyz + ((
|
|
(vWavesSum_27.xyx * bend_26)
|
|
+
|
|
((_Wind.xyz * vWavesSum_27.y) * animParams_25.w)
|
|
) * _Wind.w));
|
|
pos_23.xyz = tmpvar_52.xyz.xyz;
|
|
vec3 tmpvar_53;
|
|
tmpvar_53 = (pos_23.xyz + (animParams_25.z * _Wind.xyz));
|
|
pos_23.xyz = tmpvar_53.xyz.xyz;
|
|
return pos_23;
|
|
}
|
|
|
|
void TreeVertBark (
|
|
inout appdata_full v_54
|
|
)
|
|
{
|
|
vec3 tmpvar_55;
|
|
tmpvar_55 = (v_54.vertex.xyz * _Scale.xyz);
|
|
v_54.vertex.xyz = tmpvar_55.xyz.xyz;
|
|
vec4 tmpvar_56;
|
|
tmpvar_56.xy = v_54.color.xy.xy;
|
|
tmpvar_56.zw = v_54.texcoord1.xy.xy;
|
|
vec4 tmpvar_57;
|
|
tmpvar_57 = AnimateVertex (v_54.vertex, v_54.normal, tmpvar_56);
|
|
vec4 tmpvar_58;
|
|
tmpvar_58 = tmpvar_57;
|
|
v_54.vertex = tmpvar_58;
|
|
vec4 tmpvar_59;
|
|
tmpvar_59 = Squash (v_54.vertex);
|
|
vec4 tmpvar_60;
|
|
tmpvar_60 = tmpvar_59;
|
|
v_54.vertex = tmpvar_60;
|
|
vec4 tmpvar_61;
|
|
tmpvar_61.xyz = (v_54.color.w * _Color.xyz).xyz;
|
|
tmpvar_61.w = _Color.w;
|
|
vec4 tmpvar_62;
|
|
tmpvar_62 = tmpvar_61;
|
|
v_54.color = tmpvar_62;
|
|
vec3 tmpvar_63;
|
|
tmpvar_63 = normalize (v_54.normal);
|
|
vec3 tmpvar_64;
|
|
tmpvar_64 = tmpvar_63;
|
|
v_54.normal = tmpvar_64;
|
|
vec3 tmpvar_65;
|
|
tmpvar_65 = normalize (v_54.tangent.xyz);
|
|
vec3 tmpvar_66;
|
|
tmpvar_66 = tmpvar_65;
|
|
v_54.tangent.xyz = tmpvar_66.xyz.xyz;
|
|
}
|
|
|
|
v2f_surf vert_surf (
|
|
in appdata_full v_67
|
|
)
|
|
{
|
|
v2f_surf o_68;
|
|
TreeVertBark (v_67);
|
|
vec4 tmpvar_69;
|
|
tmpvar_69 = (gl_ModelViewProjectionMatrix * v_67.vertex);
|
|
o_68.pos = tmpvar_69;
|
|
float tmpvar_70;
|
|
tmpvar_70 = (o_68.pos.z + unity_LightShadowBias.x);
|
|
o_68.pos.z = vec3(tmpvar_70).z;
|
|
if ((o_68.pos.z < -(o_68.pos.w))) {
|
|
float tmpvar_71;
|
|
tmpvar_71 = -(o_68.pos.w);
|
|
o_68.pos.z = vec3(tmpvar_71).z;
|
|
};
|
|
return o_68;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
appdata_full xlt_v_72;
|
|
v2f_surf xl_retval_73;
|
|
vec4 tmpvar_74;
|
|
tmpvar_74 = gl_Vertex.xyzw;
|
|
vec4 tmpvar_75;
|
|
tmpvar_75 = tmpvar_74;
|
|
xlt_v_72.vertex = tmpvar_75;
|
|
vec4 tmpvar_76;
|
|
tmpvar_76 = TANGENT.xyzw;
|
|
vec4 tmpvar_77;
|
|
tmpvar_77 = tmpvar_76;
|
|
xlt_v_72.tangent = tmpvar_77;
|
|
vec3 tmpvar_78;
|
|
tmpvar_78 = gl_Normal.xyz;
|
|
vec3 tmpvar_79;
|
|
tmpvar_79 = tmpvar_78;
|
|
xlt_v_72.normal = tmpvar_79;
|
|
vec4 tmpvar_80;
|
|
tmpvar_80 = gl_MultiTexCoord0.xyzw;
|
|
vec4 tmpvar_81;
|
|
tmpvar_81 = tmpvar_80;
|
|
xlt_v_72.texcoord = tmpvar_81;
|
|
vec4 tmpvar_82;
|
|
tmpvar_82 = gl_MultiTexCoord1.xyzw;
|
|
vec4 tmpvar_83;
|
|
tmpvar_83 = tmpvar_82;
|
|
xlt_v_72.texcoord1 = tmpvar_83;
|
|
vec4 tmpvar_84;
|
|
tmpvar_84 = gl_Color.xyzw;
|
|
vec4 tmpvar_85;
|
|
tmpvar_85 = tmpvar_84;
|
|
xlt_v_72.color = tmpvar_85;
|
|
v2f_surf tmpvar_86;
|
|
tmpvar_86 = vert_surf (xlt_v_72);
|
|
v2f_surf tmpvar_87;
|
|
tmpvar_87 = tmpvar_86;
|
|
xl_retval_73 = tmpvar_87;
|
|
vec4 tmpvar_88;
|
|
tmpvar_88 = xl_retval_73.pos.xyzw;
|
|
vec4 tmpvar_89;
|
|
tmpvar_89 = tmpvar_88;
|
|
gl_Position = tmpvar_89;
|
|
}
|
|
|