mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 09:08:22 -05:00
216 lines
4.8 KiB
Text
216 lines
4.8 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;
|
|
};
|
|
attribute vec4 TANGENT;
|
|
uniform mat4 _World2Shadow3;
|
|
uniform mat4 _World2Shadow2;
|
|
uniform mat4 _World2Shadow1;
|
|
uniform mat4 _World2Shadow;
|
|
uniform mat4 _TerrainEngineBendTree;
|
|
uniform vec4 _SquashPlaneNormal;
|
|
uniform float _SquashAmount;
|
|
uniform vec4 _Scale;
|
|
uniform mat4 _Object2World;
|
|
uniform vec4 _LightShadowData;
|
|
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 TerrainAnimateTree (
|
|
inout vec4 pos,
|
|
in float alpha
|
|
)
|
|
{
|
|
vec3 bent;
|
|
vec3 tmpvar_1;
|
|
tmpvar_1 = (pos.xyz * _Scale.xyz);
|
|
pos.xyz = tmpvar_1.xyz.xyz;
|
|
vec4 tmpvar_2;
|
|
tmpvar_2.w = 0.0;
|
|
tmpvar_2.xyz = pos.xyz.xyz;
|
|
vec3 tmpvar_3;
|
|
tmpvar_3 = (_TerrainEngineBendTree * tmpvar_2).xyz;
|
|
bent = tmpvar_3;
|
|
vec3 tmpvar_4;
|
|
tmpvar_4 = vec3(alpha);
|
|
vec3 tmpvar_5;
|
|
tmpvar_5 = mix (pos.xyz, bent, tmpvar_4);
|
|
vec3 tmpvar_6;
|
|
tmpvar_6 = tmpvar_5;
|
|
pos.xyz = tmpvar_6.xyz.xyz;
|
|
vec4 tmpvar_7;
|
|
tmpvar_7 = Squash (pos);
|
|
vec4 tmpvar_8;
|
|
tmpvar_8 = tmpvar_7;
|
|
pos = tmpvar_8;
|
|
}
|
|
|
|
void treevertex (
|
|
inout appdata_full v
|
|
)
|
|
{
|
|
TerrainAnimateTree (v.vertex, v.color.w);
|
|
}
|
|
|
|
v2f_surf vert_surf (
|
|
in appdata_full v
|
|
)
|
|
{
|
|
vec4 wpos;
|
|
float z;
|
|
v2f_surf o;
|
|
treevertex (v);
|
|
vec4 tmpvar_1;
|
|
tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex);
|
|
o.pos = tmpvar_1;
|
|
float tmpvar_2;
|
|
tmpvar_2 = -((gl_ModelViewMatrix * v.vertex).z);
|
|
z = tmpvar_2;
|
|
float tmpvar_3;
|
|
tmpvar_3 = z;
|
|
o._ShadowZFade.x = tmpvar_3;
|
|
float tmpvar_4;
|
|
tmpvar_4 = ((z * _LightShadowData.z) + _LightShadowData.w);
|
|
o._ShadowZFade.y = vec2(tmpvar_4).y;
|
|
vec4 tmpvar_5;
|
|
tmpvar_5 = (_Object2World * v.vertex);
|
|
wpos = tmpvar_5;
|
|
vec3 tmpvar_6;
|
|
tmpvar_6 = (_World2Shadow * wpos).xyz;
|
|
o._ShadowCoord0 = tmpvar_6;
|
|
vec3 tmpvar_7;
|
|
tmpvar_7 = (_World2Shadow1 * wpos).xyz;
|
|
o._ShadowCoord1 = tmpvar_7;
|
|
vec3 tmpvar_8;
|
|
tmpvar_8 = (_World2Shadow2 * wpos).xyz;
|
|
o._ShadowCoord2 = tmpvar_8;
|
|
vec3 tmpvar_9;
|
|
tmpvar_9 = (_World2Shadow3 * wpos).xyz;
|
|
o._ShadowCoord3 = tmpvar_9;
|
|
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;
|
|
}
|
|
|