mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 17:18:12 -05:00
151 lines
3.3 KiB
Text
151 lines
3.3 KiB
Text
struct v2f {
|
|
vec4 pos;
|
|
vec4 color;
|
|
};
|
|
struct appdata {
|
|
vec4 vertex;
|
|
vec3 normal;
|
|
};
|
|
uniform mat4 UNITY_MATRIX_IT_MV;
|
|
uniform mat4 UNITY_MATRIX_MV;
|
|
uniform mat4 UNITY_MATRIX_MVP;
|
|
uniform vec4 unity_LightAtten[4];
|
|
uniform vec4 unity_LightColor[4];
|
|
uniform vec4 unity_LightPosition[4];
|
|
varying vec4 xlv_TEXCOORD0;
|
|
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;
|
|
}
|
|
|
|
vec3 ShadeMyVertexLights (
|
|
in vec4 vertex_9,
|
|
in vec3 normal_10
|
|
)
|
|
{
|
|
float diff_11;
|
|
float atten_12;
|
|
float lengthSq_13;
|
|
vec3 toLight_14;
|
|
int i_15;
|
|
vec3 lightColor_16;
|
|
vec3 viewN_17;
|
|
vec3 viewpos_18;
|
|
vec3 tmpvar_19;
|
|
tmpvar_19 = vec3(0.0, 0.0, 0.0);
|
|
lightColor_16 = tmpvar_19;
|
|
int tmpvar_20;
|
|
tmpvar_20 = 0;
|
|
i_15 = tmpvar_20;
|
|
vec3 tmpvar_21;
|
|
tmpvar_21 = (UNITY_MATRIX_MV * vertex_9).xyz;
|
|
viewpos_18 = tmpvar_21;
|
|
mat3 tmpvar_22;
|
|
tmpvar_22 = xll_constructMat3 (UNITY_MATRIX_IT_MV);
|
|
vec3 tmpvar_23;
|
|
tmpvar_23 = (tmpvar_22 * normal_10);
|
|
viewN_17 = tmpvar_23;
|
|
while (true) {
|
|
if (!((i_15 < 2))) {
|
|
break;
|
|
};
|
|
vec3 tmpvar_24;
|
|
tmpvar_24 = (unity_LightPosition[i_15].xyz - viewpos_18.xyz);
|
|
toLight_14 = tmpvar_24;
|
|
float tmpvar_25;
|
|
tmpvar_25 = dot (toLight_14, toLight_14);
|
|
float tmpvar_26;
|
|
tmpvar_26 = tmpvar_25;
|
|
lengthSq_13 = tmpvar_26;
|
|
float tmpvar_27;
|
|
tmpvar_27 = (1.0 / (1.0 + (lengthSq_13 * unity_LightAtten[i_15].z)));
|
|
atten_12 = tmpvar_27;
|
|
vec3 tmpvar_28;
|
|
tmpvar_28 = normalize (toLight_14);
|
|
float tmpvar_29;
|
|
tmpvar_29 = dot (viewN_17, tmpvar_28);
|
|
float tmpvar_30;
|
|
tmpvar_30 = max (0.0, tmpvar_29);
|
|
float tmpvar_31;
|
|
tmpvar_31 = tmpvar_30;
|
|
diff_11 = tmpvar_31;
|
|
vec3 tmpvar_32;
|
|
tmpvar_32 = (lightColor_16 + (unity_LightColor[i_15].xyz * (diff_11 * atten_12)));
|
|
lightColor_16 = tmpvar_32;
|
|
int _post_incdec_tmp_33;
|
|
_post_incdec_tmp_33 = i_15;
|
|
int tmpvar_34;
|
|
tmpvar_34 = (i_15 + 1);
|
|
i_15 = tmpvar_34;
|
|
};
|
|
return (lightColor_16 * 2.0);
|
|
}
|
|
|
|
v2f xlat_main (
|
|
in appdata v_35
|
|
)
|
|
{
|
|
v2f o_36;
|
|
vec4 tmpvar_37;
|
|
tmpvar_37 = (UNITY_MATRIX_MVP * v_35.vertex);
|
|
o_36.pos = tmpvar_37;
|
|
vec3 tmpvar_38;
|
|
tmpvar_38 = ShadeMyVertexLights (v_35.vertex, v_35.normal);
|
|
vec4 tmpvar_39;
|
|
tmpvar_39.w = 1.0;
|
|
tmpvar_39.xyz = tmpvar_38.xyz;
|
|
vec4 tmpvar_40;
|
|
tmpvar_40 = tmpvar_39;
|
|
o_36.color = tmpvar_40;
|
|
return o_36;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
appdata xlt_v_41;
|
|
v2f xl_retval_42;
|
|
vec4 tmpvar_43;
|
|
tmpvar_43 = gl_Vertex.xyzw;
|
|
vec4 tmpvar_44;
|
|
tmpvar_44 = tmpvar_43;
|
|
xlt_v_41.vertex = tmpvar_44;
|
|
vec3 tmpvar_45;
|
|
tmpvar_45 = gl_Normal.xyz;
|
|
vec3 tmpvar_46;
|
|
tmpvar_46 = tmpvar_45;
|
|
xlt_v_41.normal = tmpvar_46;
|
|
v2f tmpvar_47;
|
|
tmpvar_47 = xlat_main (xlt_v_41);
|
|
v2f tmpvar_48;
|
|
tmpvar_48 = tmpvar_47;
|
|
xl_retval_42 = tmpvar_48;
|
|
vec4 tmpvar_49;
|
|
tmpvar_49 = xl_retval_42.pos.xyzw;
|
|
vec4 tmpvar_50;
|
|
tmpvar_50 = tmpvar_49;
|
|
gl_Position = tmpvar_50;
|
|
vec4 tmpvar_51;
|
|
tmpvar_51 = xl_retval_42.color.xyzw;
|
|
vec4 tmpvar_52;
|
|
tmpvar_52 = tmpvar_51;
|
|
xlv_TEXCOORD0 = tmpvar_52;
|
|
}
|
|
|