mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-29 02:55:36 -05:00
186 lines
4 KiB
Text
186 lines
4 KiB
Text
|
struct appdata_full {
|
||
|
vec4 vertex;
|
||
|
vec4 tangent;
|
||
|
vec3 normal;
|
||
|
vec4 texcoord;
|
||
|
vec4 texcoord1;
|
||
|
vec4 color;
|
||
|
};
|
||
|
struct v2f {
|
||
|
vec4 pos;
|
||
|
vec2 uv;
|
||
|
vec3 color;
|
||
|
};
|
||
|
attribute vec4 TANGENT;
|
||
|
uniform vec3 _TerrainTreeLightDirections[4];
|
||
|
uniform vec4 _TerrainTreeLightColors[4];
|
||
|
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;
|
||
|
}
|
||
|
|
||
|
v2f vert (
|
||
|
in appdata_full v
|
||
|
)
|
||
|
{
|
||
|
float diff;
|
||
|
vec3 lightDir;
|
||
|
int i;
|
||
|
vec3 lightColor;
|
||
|
v2f o;
|
||
|
int tmpvar_1;
|
||
|
tmpvar_1 = 0;
|
||
|
i = tmpvar_1;
|
||
|
ExpandBillboard (gl_ModelViewMatrixInverseTranspose, v.vertex, v.normal, v.tangent);
|
||
|
vec4 tmpvar_2;
|
||
|
tmpvar_2 = (gl_ModelViewProjectionMatrix * v.vertex);
|
||
|
o.pos = tmpvar_2;
|
||
|
vec2 tmpvar_3;
|
||
|
tmpvar_3 = v.texcoord.xy;
|
||
|
o.uv = tmpvar_3;
|
||
|
vec3 tmpvar_4;
|
||
|
tmpvar_4 = gl_LightModel.ambient.xyz;
|
||
|
lightColor = tmpvar_4;
|
||
|
while (true) {
|
||
|
if (!((i < 4))) {
|
||
|
break;
|
||
|
};
|
||
|
vec3 tmpvar_5;
|
||
|
tmpvar_5 = _TerrainTreeLightDirections[i];
|
||
|
lightDir = tmpvar_5.xyz.xyz;
|
||
|
float tmpvar_6;
|
||
|
tmpvar_6 = dot (lightDir.xyz, v.normal);
|
||
|
float tmpvar_7;
|
||
|
tmpvar_7 = max (0.0, ((tmpvar_6 * 0.5) + 0.5));
|
||
|
float tmpvar_8;
|
||
|
tmpvar_8 = tmpvar_7;
|
||
|
diff = tmpvar_8;
|
||
|
vec3 tmpvar_9;
|
||
|
tmpvar_9 = (_TerrainTreeLightColors[i] * diff).xyz;
|
||
|
vec3 tmpvar_10;
|
||
|
tmpvar_10 = (lightColor + tmpvar_9);
|
||
|
lightColor = tmpvar_10;
|
||
|
int _post_incdec_tmp;
|
||
|
_post_incdec_tmp = i;
|
||
|
int tmpvar_11;
|
||
|
tmpvar_11 = (i + 1);
|
||
|
i = tmpvar_11;
|
||
|
};
|
||
|
vec3 tmpvar_12;
|
||
|
tmpvar_12 = (lightColor * v.color.w);
|
||
|
o.color = tmpvar_12;
|
||
|
return o;
|
||
|
}
|
||
|
|
||
|
void main ()
|
||
|
{
|
||
|
appdata_full xlt_v;
|
||
|
v2f 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 tmpvar_13;
|
||
|
tmpvar_13 = vert (xlt_v);
|
||
|
v2f 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.zw = vec2(0.0, 0.0);
|
||
|
tmpvar_17.xy = xl_retval.uv.xy;
|
||
|
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.color.xyz;
|
||
|
vec4 tmpvar_20;
|
||
|
tmpvar_20 = tmpvar_19;
|
||
|
gl_TexCoord[1] = tmpvar_20;
|
||
|
}
|
||
|
|