mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 18:45:54 -05:00
276 lines
6.4 KiB
Text
276 lines
6.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;
|
|
vec3 backContrib;
|
|
vec3 nl;
|
|
vec3 nh;
|
|
};
|
|
attribute vec4 TANGENT;
|
|
uniform vec4 unity_Scale;
|
|
uniform vec3 _WorldSpaceCameraPos;
|
|
uniform mat4 _World2Object;
|
|
uniform float _TranslucencyViewDependency;
|
|
uniform vec3 _TerrainTreeLightDirections[4];
|
|
float xll_saturate (
|
|
in float x_1
|
|
)
|
|
{
|
|
float tmpvar_2;
|
|
tmpvar_2 = clamp (x_1, 0.0, 1.0);
|
|
return tmpvar_2;
|
|
}
|
|
|
|
vec3 ObjSpaceViewDir (
|
|
in vec4 v_3
|
|
)
|
|
{
|
|
vec3 objSpaceCameraPos_4;
|
|
vec4 tmpvar_5;
|
|
tmpvar_5.w = 1.0;
|
|
tmpvar_5.xyz = _WorldSpaceCameraPos.xyz.xyz;
|
|
vec3 tmpvar_6;
|
|
tmpvar_6 = ((_World2Object * tmpvar_5).xyz * unity_Scale.w);
|
|
objSpaceCameraPos_4 = tmpvar_6;
|
|
return (objSpaceCameraPos_4 - v_3.xyz);
|
|
}
|
|
|
|
void ExpandBillboard (
|
|
in mat4 mat_7,
|
|
inout vec4 pos_8,
|
|
inout vec3 normal_9,
|
|
inout vec4 tangent_10
|
|
)
|
|
{
|
|
vec3 tanb_11;
|
|
vec3 norb_12;
|
|
float isBillboard_13;
|
|
float tmpvar_14;
|
|
tmpvar_14 = abs (tangent_10.w);
|
|
float tmpvar_15;
|
|
tmpvar_15 = (1.0 - tmpvar_14);
|
|
isBillboard_13 = tmpvar_15;
|
|
vec4 tmpvar_16;
|
|
tmpvar_16.w = 0.0;
|
|
tmpvar_16.xyz = normal_9.xyz;
|
|
vec4 tmpvar_17;
|
|
tmpvar_17 = normalize ((tmpvar_16 * mat_7));
|
|
vec3 tmpvar_18;
|
|
tmpvar_18 = tmpvar_17.xyz;
|
|
vec3 tmpvar_19;
|
|
tmpvar_19 = tmpvar_18;
|
|
norb_12 = tmpvar_19;
|
|
vec4 tmpvar_20;
|
|
tmpvar_20.w = 0.0;
|
|
tmpvar_20.xyz = tangent_10.xyz.xyz;
|
|
vec4 tmpvar_21;
|
|
tmpvar_21 = normalize ((tmpvar_20 * mat_7));
|
|
vec3 tmpvar_22;
|
|
tmpvar_22 = tmpvar_21.xyz;
|
|
vec3 tmpvar_23;
|
|
tmpvar_23 = tmpvar_22;
|
|
tanb_11 = tmpvar_23;
|
|
vec4 tmpvar_24;
|
|
tmpvar_24.zw = vec2(0.0, 0.0);
|
|
tmpvar_24.xy = normal_9.xy.xy;
|
|
vec4 tmpvar_25;
|
|
tmpvar_25 = (pos_8 + ((tmpvar_24 * mat_7) * isBillboard_13));
|
|
pos_8 = tmpvar_25;
|
|
vec3 tmpvar_26;
|
|
tmpvar_26 = vec3(isBillboard_13);
|
|
vec3 tmpvar_27;
|
|
tmpvar_27 = mix (normal_9, norb_12, tmpvar_26);
|
|
vec3 tmpvar_28;
|
|
tmpvar_28 = tmpvar_27;
|
|
normal_9 = tmpvar_28;
|
|
vec4 tmpvar_29;
|
|
tmpvar_29.w = -1.0;
|
|
tmpvar_29.xyz = tanb_11.xyz;
|
|
vec4 tmpvar_30;
|
|
tmpvar_30 = vec4(isBillboard_13);
|
|
vec4 tmpvar_31;
|
|
tmpvar_31 = mix (tangent_10, tmpvar_29, tmpvar_30);
|
|
vec4 tmpvar_32;
|
|
tmpvar_32 = tmpvar_31;
|
|
tangent_10 = tmpvar_32;
|
|
}
|
|
|
|
v2f vert (
|
|
in appdata_full v_33
|
|
)
|
|
{
|
|
float nh_34;
|
|
vec3 h_35;
|
|
float backContrib_36;
|
|
float nl_37;
|
|
vec3 lightDir_38;
|
|
int j_39;
|
|
vec3 viewDir_40;
|
|
v2f o_41;
|
|
int tmpvar_42;
|
|
tmpvar_42 = 0;
|
|
j_39 = tmpvar_42;
|
|
ExpandBillboard (gl_ModelViewMatrixInverseTranspose, v_33.vertex, v_33.normal, v_33.tangent);
|
|
vec4 tmpvar_43;
|
|
tmpvar_43 = (gl_ModelViewProjectionMatrix * v_33.vertex);
|
|
o_41.pos = tmpvar_43;
|
|
vec2 tmpvar_44;
|
|
tmpvar_44 = v_33.texcoord.xy;
|
|
o_41.uv = tmpvar_44;
|
|
vec3 tmpvar_45;
|
|
tmpvar_45 = ObjSpaceViewDir (v_33.vertex);
|
|
vec3 tmpvar_46;
|
|
tmpvar_46 = normalize (tmpvar_45);
|
|
vec3 tmpvar_47;
|
|
tmpvar_47 = tmpvar_46;
|
|
viewDir_40 = tmpvar_47;
|
|
while (true) {
|
|
if (!((j_39 < 3))) {
|
|
break;
|
|
};
|
|
vec3 tmpvar_48;
|
|
tmpvar_48 = _TerrainTreeLightDirections[j_39];
|
|
lightDir_38 = tmpvar_48;
|
|
float tmpvar_49;
|
|
tmpvar_49 = dot (v_33.normal, lightDir_38);
|
|
float tmpvar_50;
|
|
tmpvar_50 = tmpvar_49;
|
|
nl_37 = tmpvar_50;
|
|
float tmpvar_51;
|
|
tmpvar_51 = dot (viewDir_40, -(lightDir_38));
|
|
float tmpvar_52;
|
|
tmpvar_52 = xll_saturate (tmpvar_51);
|
|
float tmpvar_53;
|
|
tmpvar_53 = tmpvar_52;
|
|
backContrib_36 = tmpvar_53;
|
|
float tmpvar_54;
|
|
tmpvar_54 = xll_saturate (-(nl_37));
|
|
float tmpvar_55;
|
|
tmpvar_55 = mix (tmpvar_54, backContrib_36, _TranslucencyViewDependency);
|
|
float tmpvar_56;
|
|
tmpvar_56 = tmpvar_55;
|
|
backContrib_36 = tmpvar_56;
|
|
float tmpvar_57;
|
|
tmpvar_57 = (backContrib_36 * 2.0);
|
|
o_41.backContrib[j_39] = tmpvar_57;
|
|
float tmpvar_58;
|
|
tmpvar_58 = max (0.0, ((nl_37 * 0.6) + 0.4));
|
|
float tmpvar_59;
|
|
tmpvar_59 = tmpvar_58;
|
|
nl_37 = tmpvar_59;
|
|
float tmpvar_60;
|
|
tmpvar_60 = nl_37;
|
|
o_41.nl[j_39] = tmpvar_60;
|
|
vec3 tmpvar_61;
|
|
tmpvar_61 = normalize ((lightDir_38 + viewDir_40));
|
|
vec3 tmpvar_62;
|
|
tmpvar_62 = tmpvar_61;
|
|
h_35 = tmpvar_62;
|
|
float tmpvar_63;
|
|
tmpvar_63 = dot (v_33.normal, h_35);
|
|
float tmpvar_64;
|
|
tmpvar_64 = max (0.0, tmpvar_63);
|
|
float tmpvar_65;
|
|
tmpvar_65 = tmpvar_64;
|
|
nh_34 = tmpvar_65;
|
|
float tmpvar_66;
|
|
tmpvar_66 = nh_34;
|
|
o_41.nh[j_39] = tmpvar_66;
|
|
int _post_incdec_tmp_67;
|
|
_post_incdec_tmp_67 = j_39;
|
|
int tmpvar_68;
|
|
tmpvar_68 = (j_39 + 1);
|
|
j_39 = tmpvar_68;
|
|
};
|
|
vec3 tmpvar_69;
|
|
tmpvar_69 = vec3(v_33.color.w);
|
|
vec3 tmpvar_70;
|
|
tmpvar_70 = tmpvar_69;
|
|
o_41.color = tmpvar_70;
|
|
return o_41;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
appdata_full xlt_v_71;
|
|
v2f xl_retval_72;
|
|
vec4 tmpvar_73;
|
|
tmpvar_73 = gl_Vertex.xyzw;
|
|
vec4 tmpvar_74;
|
|
tmpvar_74 = tmpvar_73;
|
|
xlt_v_71.vertex = tmpvar_74;
|
|
vec4 tmpvar_75;
|
|
tmpvar_75 = TANGENT.xyzw;
|
|
vec4 tmpvar_76;
|
|
tmpvar_76 = tmpvar_75;
|
|
xlt_v_71.tangent = tmpvar_76;
|
|
vec3 tmpvar_77;
|
|
tmpvar_77 = gl_Normal.xyz;
|
|
vec3 tmpvar_78;
|
|
tmpvar_78 = tmpvar_77;
|
|
xlt_v_71.normal = tmpvar_78;
|
|
vec4 tmpvar_79;
|
|
tmpvar_79 = gl_MultiTexCoord0.xyzw;
|
|
vec4 tmpvar_80;
|
|
tmpvar_80 = tmpvar_79;
|
|
xlt_v_71.texcoord = tmpvar_80;
|
|
vec4 tmpvar_81;
|
|
tmpvar_81 = gl_MultiTexCoord1.xyzw;
|
|
vec4 tmpvar_82;
|
|
tmpvar_82 = tmpvar_81;
|
|
xlt_v_71.texcoord1 = tmpvar_82;
|
|
vec4 tmpvar_83;
|
|
tmpvar_83 = gl_Color.xyzw;
|
|
vec4 tmpvar_84;
|
|
tmpvar_84 = tmpvar_83;
|
|
xlt_v_71.color = tmpvar_84;
|
|
v2f tmpvar_85;
|
|
tmpvar_85 = vert (xlt_v_71);
|
|
v2f tmpvar_86;
|
|
tmpvar_86 = tmpvar_85;
|
|
xl_retval_72 = tmpvar_86;
|
|
vec4 tmpvar_87;
|
|
tmpvar_87 = xl_retval_72.pos.xyzw;
|
|
vec4 tmpvar_88;
|
|
tmpvar_88 = tmpvar_87;
|
|
gl_Position = tmpvar_88;
|
|
vec4 tmpvar_89;
|
|
tmpvar_89.zw = vec2(0.0, 0.0);
|
|
tmpvar_89.xy = xl_retval_72.uv.xy;
|
|
vec4 tmpvar_90;
|
|
tmpvar_90 = tmpvar_89;
|
|
gl_TexCoord[0] = tmpvar_90;
|
|
vec4 tmpvar_91;
|
|
tmpvar_91.w = 0.0;
|
|
tmpvar_91.xyz = xl_retval_72.color.xyz;
|
|
vec4 tmpvar_92;
|
|
tmpvar_92 = tmpvar_91;
|
|
gl_TexCoord[1] = tmpvar_92;
|
|
vec4 tmpvar_93;
|
|
tmpvar_93.w = 0.0;
|
|
tmpvar_93.xyz = xl_retval_72.backContrib.xyz;
|
|
vec4 tmpvar_94;
|
|
tmpvar_94 = tmpvar_93;
|
|
gl_TexCoord[2] = tmpvar_94;
|
|
vec4 tmpvar_95;
|
|
tmpvar_95.w = 0.0;
|
|
tmpvar_95.xyz = xl_retval_72.nl.xyz;
|
|
vec4 tmpvar_96;
|
|
tmpvar_96 = tmpvar_95;
|
|
gl_TexCoord[3] = tmpvar_96;
|
|
vec4 tmpvar_97;
|
|
tmpvar_97.w = 0.0;
|
|
tmpvar_97.xyz = xl_retval_72.nh.xyz;
|
|
vec4 tmpvar_98;
|
|
tmpvar_98 = tmpvar_97;
|
|
gl_TexCoord[4] = tmpvar_98;
|
|
}
|
|
|