mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 09:08:22 -05:00
185 lines
4.3 KiB
Text
185 lines
4.3 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_1,
|
|
inout vec4 pos_2,
|
|
inout vec3 normal_3,
|
|
inout vec4 tangent_4
|
|
)
|
|
{
|
|
vec3 tanb_5;
|
|
vec3 norb_6;
|
|
float isBillboard_7;
|
|
float tmpvar_8;
|
|
tmpvar_8 = abs (tangent_4.w);
|
|
float tmpvar_9;
|
|
tmpvar_9 = (1.0 - tmpvar_8);
|
|
isBillboard_7 = tmpvar_9;
|
|
vec4 tmpvar_10;
|
|
tmpvar_10.w = 0.0;
|
|
tmpvar_10.xyz = normal_3.xyz;
|
|
vec4 tmpvar_11;
|
|
tmpvar_11 = normalize ((tmpvar_10 * mat_1));
|
|
vec3 tmpvar_12;
|
|
tmpvar_12 = tmpvar_11.xyz;
|
|
vec3 tmpvar_13;
|
|
tmpvar_13 = tmpvar_12;
|
|
norb_6 = tmpvar_13;
|
|
vec4 tmpvar_14;
|
|
tmpvar_14.yw = vec2(0.0, 0.0);
|
|
tmpvar_14.x = normal_3.z;
|
|
tmpvar_14.z = -(normal_3.x);
|
|
vec4 tmpvar_15;
|
|
tmpvar_15 = normalize ((tmpvar_14 * mat_1));
|
|
vec3 tmpvar_16;
|
|
tmpvar_16 = tmpvar_15.xyz;
|
|
vec3 tmpvar_17;
|
|
tmpvar_17 = tmpvar_16;
|
|
tanb_5 = tmpvar_17;
|
|
vec4 tmpvar_18;
|
|
tmpvar_18 = (pos_2 + ((tangent_4 * mat_1) * isBillboard_7));
|
|
pos_2 = tmpvar_18;
|
|
vec3 tmpvar_19;
|
|
tmpvar_19 = vec3(isBillboard_7);
|
|
vec3 tmpvar_20;
|
|
tmpvar_20 = mix (normal_3, norb_6, tmpvar_19);
|
|
vec3 tmpvar_21;
|
|
tmpvar_21 = tmpvar_20;
|
|
normal_3 = tmpvar_21;
|
|
vec4 tmpvar_22;
|
|
tmpvar_22.w = -1.0;
|
|
tmpvar_22.xyz = tanb_5.xyz;
|
|
vec4 tmpvar_23;
|
|
tmpvar_23 = vec4(isBillboard_7);
|
|
vec4 tmpvar_24;
|
|
tmpvar_24 = mix (tangent_4, tmpvar_22, tmpvar_23);
|
|
vec4 tmpvar_25;
|
|
tmpvar_25 = tmpvar_24;
|
|
tangent_4 = tmpvar_25;
|
|
}
|
|
|
|
v2f vert (
|
|
in appdata_full v_26
|
|
)
|
|
{
|
|
float diff_27;
|
|
vec3 lightDir_28;
|
|
int i_29;
|
|
vec3 lightColor_30;
|
|
v2f o_31;
|
|
int tmpvar_32;
|
|
tmpvar_32 = 0;
|
|
i_29 = tmpvar_32;
|
|
ExpandBillboard (gl_ModelViewMatrixInverseTranspose, v_26.vertex, v_26.normal, v_26.tangent);
|
|
vec4 tmpvar_33;
|
|
tmpvar_33 = (gl_ModelViewProjectionMatrix * v_26.vertex);
|
|
o_31.pos = tmpvar_33;
|
|
vec2 tmpvar_34;
|
|
tmpvar_34 = v_26.texcoord.xy;
|
|
o_31.uv = tmpvar_34;
|
|
vec3 tmpvar_35;
|
|
tmpvar_35 = gl_LightModel.ambient.xyz;
|
|
lightColor_30 = tmpvar_35;
|
|
while (true) {
|
|
if (!((i_29 < 4))) {
|
|
break;
|
|
};
|
|
vec3 tmpvar_36;
|
|
tmpvar_36 = _TerrainTreeLightDirections[i_29];
|
|
lightDir_28 = tmpvar_36.xyz.xyz;
|
|
float tmpvar_37;
|
|
tmpvar_37 = dot (lightDir_28.xyz, v_26.normal);
|
|
float tmpvar_38;
|
|
tmpvar_38 = max (0.0, ((tmpvar_37 * 0.5) + 0.5));
|
|
float tmpvar_39;
|
|
tmpvar_39 = tmpvar_38;
|
|
diff_27 = tmpvar_39;
|
|
vec3 tmpvar_40;
|
|
tmpvar_40 = (_TerrainTreeLightColors[i_29] * diff_27).xyz;
|
|
vec3 tmpvar_41;
|
|
tmpvar_41 = (lightColor_30 + tmpvar_40);
|
|
lightColor_30 = tmpvar_41;
|
|
int _post_incdec_tmp_42;
|
|
_post_incdec_tmp_42 = i_29;
|
|
int tmpvar_43;
|
|
tmpvar_43 = (i_29 + 1);
|
|
i_29 = tmpvar_43;
|
|
};
|
|
vec3 tmpvar_44;
|
|
tmpvar_44 = (lightColor_30 * v_26.color.w);
|
|
o_31.color = tmpvar_44;
|
|
return o_31;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
appdata_full xlt_v_45;
|
|
v2f xl_retval_46;
|
|
vec4 tmpvar_47;
|
|
tmpvar_47 = gl_Vertex.xyzw;
|
|
vec4 tmpvar_48;
|
|
tmpvar_48 = tmpvar_47;
|
|
xlt_v_45.vertex = tmpvar_48;
|
|
vec4 tmpvar_49;
|
|
tmpvar_49 = TANGENT.xyzw;
|
|
vec4 tmpvar_50;
|
|
tmpvar_50 = tmpvar_49;
|
|
xlt_v_45.tangent = tmpvar_50;
|
|
vec3 tmpvar_51;
|
|
tmpvar_51 = gl_Normal.xyz;
|
|
vec3 tmpvar_52;
|
|
tmpvar_52 = tmpvar_51;
|
|
xlt_v_45.normal = tmpvar_52;
|
|
vec4 tmpvar_53;
|
|
tmpvar_53 = gl_MultiTexCoord0.xyzw;
|
|
vec4 tmpvar_54;
|
|
tmpvar_54 = tmpvar_53;
|
|
xlt_v_45.texcoord = tmpvar_54;
|
|
vec4 tmpvar_55;
|
|
tmpvar_55 = gl_MultiTexCoord1.xyzw;
|
|
vec4 tmpvar_56;
|
|
tmpvar_56 = tmpvar_55;
|
|
xlt_v_45.texcoord1 = tmpvar_56;
|
|
vec4 tmpvar_57;
|
|
tmpvar_57 = gl_Color.xyzw;
|
|
vec4 tmpvar_58;
|
|
tmpvar_58 = tmpvar_57;
|
|
xlt_v_45.color = tmpvar_58;
|
|
v2f tmpvar_59;
|
|
tmpvar_59 = vert (xlt_v_45);
|
|
v2f tmpvar_60;
|
|
tmpvar_60 = tmpvar_59;
|
|
xl_retval_46 = tmpvar_60;
|
|
vec4 tmpvar_61;
|
|
tmpvar_61 = xl_retval_46.pos.xyzw;
|
|
vec4 tmpvar_62;
|
|
tmpvar_62 = tmpvar_61;
|
|
gl_Position = tmpvar_62;
|
|
vec4 tmpvar_63;
|
|
tmpvar_63.zw = vec2(0.0, 0.0);
|
|
tmpvar_63.xy = xl_retval_46.uv.xy;
|
|
vec4 tmpvar_64;
|
|
tmpvar_64 = tmpvar_63;
|
|
gl_TexCoord[0] = tmpvar_64;
|
|
vec4 tmpvar_65;
|
|
tmpvar_65.w = 0.0;
|
|
tmpvar_65.xyz = xl_retval_46.color.xyz;
|
|
vec4 tmpvar_66;
|
|
tmpvar_66 = tmpvar_65;
|
|
gl_TexCoord[1] = tmpvar_66;
|
|
}
|
|
|