mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 17:18:12 -05:00
178 lines
3.9 KiB
Text
178 lines
3.9 KiB
Text
|
struct v2f {
|
||
|
vec4 pos;
|
||
|
vec2 uv;
|
||
|
vec4 nz;
|
||
|
};
|
||
|
struct appdata {
|
||
|
vec4 vertex;
|
||
|
vec3 normal;
|
||
|
vec4 color;
|
||
|
vec4 texcoord;
|
||
|
};
|
||
|
uniform mat4 _TerrainEngineBendTree;
|
||
|
uniform vec4 _SquashPlaneNormal;
|
||
|
uniform float _SquashAmount;
|
||
|
uniform vec4 _Scale;
|
||
|
uniform vec4 _ProjectionParams;
|
||
|
mat3 xll_constructMat3 (
|
||
|
in mat4 m_1
|
||
|
)
|
||
|
{
|
||
|
vec3 tmpvar_2;
|
||
|
tmpvar_2 = m_1[0].xyz;
|
||
|
vec3 tmpvar_3;
|
||
|
tmpvar_3 = m_1[1].xyz;
|
||
|
vec3 tmpvar_4;
|
||
|
tmpvar_4 = m_1[2].xyz;
|
||
|
mat3 tmpvar_5;
|
||
|
vec3 tmpvar_6;
|
||
|
tmpvar_6 = tmpvar_2;
|
||
|
tmpvar_5[0] = tmpvar_6;
|
||
|
vec3 tmpvar_7;
|
||
|
tmpvar_7 = tmpvar_3;
|
||
|
tmpvar_5[1] = tmpvar_7;
|
||
|
vec3 tmpvar_8;
|
||
|
tmpvar_8 = tmpvar_4;
|
||
|
tmpvar_5[2] = tmpvar_8;
|
||
|
return tmpvar_5;
|
||
|
}
|
||
|
|
||
|
vec4 Squash (
|
||
|
in vec4 pos_9
|
||
|
)
|
||
|
{
|
||
|
vec3 planeNormal_10;
|
||
|
vec3 planePoint_11;
|
||
|
vec3 projectedVertex_12;
|
||
|
vec3 tmpvar_13;
|
||
|
tmpvar_13 = pos_9.xyz;
|
||
|
projectedVertex_12 = tmpvar_13;
|
||
|
vec3 tmpvar_14;
|
||
|
tmpvar_14.xz = vec2(0.0, 0.0);
|
||
|
tmpvar_14.y = _SquashPlaneNormal.w;
|
||
|
vec3 tmpvar_15;
|
||
|
tmpvar_15 = tmpvar_14;
|
||
|
planePoint_11 = tmpvar_15;
|
||
|
vec3 tmpvar_16;
|
||
|
tmpvar_16 = _SquashPlaneNormal.xyz;
|
||
|
planeNormal_10 = tmpvar_16;
|
||
|
vec3 tmpvar_17;
|
||
|
tmpvar_17 = pos_9.xyz;
|
||
|
float tmpvar_18;
|
||
|
tmpvar_18 = dot (planeNormal_10, (planePoint_11 - tmpvar_17));
|
||
|
vec3 tmpvar_19;
|
||
|
tmpvar_19 = (projectedVertex_12 + (tmpvar_18 * planeNormal_10));
|
||
|
projectedVertex_12 = tmpvar_19;
|
||
|
vec3 tmpvar_20;
|
||
|
tmpvar_20 = vec3(_SquashAmount);
|
||
|
vec3 tmpvar_21;
|
||
|
tmpvar_21 = mix (projectedVertex_12, pos_9.xyz, tmpvar_20);
|
||
|
vec4 tmpvar_22;
|
||
|
tmpvar_22.w = 1.0;
|
||
|
tmpvar_22.xyz = tmpvar_21.xyz;
|
||
|
vec4 tmpvar_23;
|
||
|
tmpvar_23 = tmpvar_22;
|
||
|
pos_9 = tmpvar_23;
|
||
|
return pos_9;
|
||
|
}
|
||
|
|
||
|
void TerrainAnimateTree (
|
||
|
inout vec4 pos_24,
|
||
|
in float alpha_25
|
||
|
)
|
||
|
{
|
||
|
vec3 bent_26;
|
||
|
vec3 tmpvar_27;
|
||
|
tmpvar_27 = (pos_24.xyz * _Scale.xyz);
|
||
|
pos_24.xyz = tmpvar_27.xyz.xyz;
|
||
|
vec4 tmpvar_28;
|
||
|
tmpvar_28.w = 0.0;
|
||
|
tmpvar_28.xyz = pos_24.xyz.xyz;
|
||
|
vec3 tmpvar_29;
|
||
|
tmpvar_29 = (_TerrainEngineBendTree * tmpvar_28).xyz;
|
||
|
bent_26 = tmpvar_29;
|
||
|
vec3 tmpvar_30;
|
||
|
tmpvar_30 = vec3(alpha_25);
|
||
|
vec3 tmpvar_31;
|
||
|
tmpvar_31 = mix (pos_24.xyz, bent_26, tmpvar_30);
|
||
|
vec3 tmpvar_32;
|
||
|
tmpvar_32 = tmpvar_31;
|
||
|
pos_24.xyz = tmpvar_32.xyz.xyz;
|
||
|
vec4 tmpvar_33;
|
||
|
tmpvar_33 = Squash (pos_24);
|
||
|
vec4 tmpvar_34;
|
||
|
tmpvar_34 = tmpvar_33;
|
||
|
pos_24 = tmpvar_34;
|
||
|
}
|
||
|
|
||
|
v2f vert (
|
||
|
in appdata v_35
|
||
|
)
|
||
|
{
|
||
|
v2f o_36;
|
||
|
TerrainAnimateTree (v_35.vertex, v_35.color.w);
|
||
|
vec4 tmpvar_37;
|
||
|
tmpvar_37 = (gl_ModelViewProjectionMatrix * v_35.vertex);
|
||
|
o_36.pos = tmpvar_37;
|
||
|
vec2 tmpvar_38;
|
||
|
tmpvar_38 = v_35.texcoord.xy;
|
||
|
o_36.uv = tmpvar_38;
|
||
|
mat3 tmpvar_39;
|
||
|
tmpvar_39 = xll_constructMat3 (gl_ModelViewMatrixInverseTranspose);
|
||
|
vec3 tmpvar_40;
|
||
|
tmpvar_40 = (tmpvar_39 * v_35.normal);
|
||
|
o_36.nz.xyz = tmpvar_40.xyz.xyz;
|
||
|
float tmpvar_41;
|
||
|
tmpvar_41 = -(((gl_ModelViewMatrix * v_35.vertex).z * _ProjectionParams.w));
|
||
|
o_36.nz.w = vec4(tmpvar_41).w;
|
||
|
return o_36;
|
||
|
}
|
||
|
|
||
|
void main ()
|
||
|
{
|
||
|
appdata xlt_v_42;
|
||
|
v2f xl_retval_43;
|
||
|
vec4 tmpvar_44;
|
||
|
tmpvar_44 = gl_Vertex.xyzw;
|
||
|
vec4 tmpvar_45;
|
||
|
tmpvar_45 = tmpvar_44;
|
||
|
xlt_v_42.vertex = tmpvar_45;
|
||
|
vec3 tmpvar_46;
|
||
|
tmpvar_46 = gl_Normal.xyz;
|
||
|
vec3 tmpvar_47;
|
||
|
tmpvar_47 = tmpvar_46;
|
||
|
xlt_v_42.normal = tmpvar_47;
|
||
|
vec4 tmpvar_48;
|
||
|
tmpvar_48 = gl_Color.xyzw;
|
||
|
vec4 tmpvar_49;
|
||
|
tmpvar_49 = tmpvar_48;
|
||
|
xlt_v_42.color = tmpvar_49;
|
||
|
vec4 tmpvar_50;
|
||
|
tmpvar_50 = gl_MultiTexCoord0.xyzw;
|
||
|
vec4 tmpvar_51;
|
||
|
tmpvar_51 = tmpvar_50;
|
||
|
xlt_v_42.texcoord = tmpvar_51;
|
||
|
v2f tmpvar_52;
|
||
|
tmpvar_52 = vert (xlt_v_42);
|
||
|
v2f tmpvar_53;
|
||
|
tmpvar_53 = tmpvar_52;
|
||
|
xl_retval_43 = tmpvar_53;
|
||
|
vec4 tmpvar_54;
|
||
|
tmpvar_54 = xl_retval_43.pos.xyzw;
|
||
|
vec4 tmpvar_55;
|
||
|
tmpvar_55 = tmpvar_54;
|
||
|
gl_Position = tmpvar_55;
|
||
|
vec4 tmpvar_56;
|
||
|
tmpvar_56.zw = vec2(0.0, 0.0);
|
||
|
tmpvar_56.xy = xl_retval_43.uv.xy;
|
||
|
vec4 tmpvar_57;
|
||
|
tmpvar_57 = tmpvar_56;
|
||
|
gl_TexCoord[0] = tmpvar_57;
|
||
|
vec4 tmpvar_58;
|
||
|
tmpvar_58 = xl_retval_43.nz.xyzw;
|
||
|
vec4 tmpvar_59;
|
||
|
tmpvar_59 = tmpvar_58;
|
||
|
gl_TexCoord[1] = tmpvar_59;
|
||
|
}
|
||
|
|