mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-29 11:05:36 -05:00
135 lines
3.7 KiB
Text
135 lines
3.7 KiB
Text
|
struct lightSource {
|
||
|
vec4 position;
|
||
|
vec4 diffuse;
|
||
|
vec4 specular;
|
||
|
float invLinearAttenuation;
|
||
|
float spotCutoff;
|
||
|
float spotExponent;
|
||
|
vec3 spotDirection;
|
||
|
};
|
||
|
struct material {
|
||
|
vec4 ambient;
|
||
|
vec4 diffuse;
|
||
|
vec4 specular;
|
||
|
float shininess;
|
||
|
};
|
||
|
material tmpvar_1;
|
||
|
vec4 tmpvar_2;
|
||
|
lightSource tmpvar_3;
|
||
|
varying vec4 position;
|
||
|
varying vec3 varyingNormalDirection;
|
||
|
uniform mat4 m;
|
||
|
uniform mat4 v;
|
||
|
uniform mat4 p;
|
||
|
uniform mat4 v_inv;
|
||
|
lightSource light0;
|
||
|
vec4 scene_ambient;
|
||
|
material frontMaterial;
|
||
|
//;
|
||
|
//;
|
||
|
//;
|
||
|
//;
|
||
|
//;
|
||
|
//;
|
||
|
void main ()
|
||
|
{
|
||
|
tmpvar_3 = lightSource(vec4(0.0, 3.0, 0.0, 1.0), vec4(1.0, 1.0, 1.0, 1.0), vec4(1.0, 1.0, 1.0, 1.0), 2.0, 180.0, 0.0, vec3(0.0, 0.0, 0.0));
|
||
|
light0 = tmpvar_3;
|
||
|
tmpvar_2 = vec4(0.2, 0.2, 0.2, 1.0);
|
||
|
scene_ambient = tmpvar_2;
|
||
|
tmpvar_1 = material(vec4(0.2, 0.2, 0.2, 1.0), vec4(1.0, 0.8, 0.8, 1.0), vec4(1.0, 1.0, 1.0, 1.0), 5.0);
|
||
|
frontMaterial = tmpvar_1;
|
||
|
vec3 specularReflection_4;
|
||
|
vec3 diffuseReflection_5;
|
||
|
float distanceSqr_6;
|
||
|
vec3 positionToLightSource_7;
|
||
|
vec3 totalLighting_8;
|
||
|
float attenuation_9;
|
||
|
vec3 lightDirection_10;
|
||
|
vec3 viewDirection_11;
|
||
|
vec3 normalDirection_12;
|
||
|
vec3 tmpvar_13;
|
||
|
tmpvar_13 = normalize (varyingNormalDirection);
|
||
|
vec3 tmpvar_14;
|
||
|
tmpvar_14 = tmpvar_13;
|
||
|
normalDirection_12 = tmpvar_14;
|
||
|
vec3 tmpvar_15;
|
||
|
tmpvar_15 = ((v_inv * vec4(0.0, 0.0, 0.0, 1.0)) - position).xyz;
|
||
|
vec3 tmpvar_16;
|
||
|
tmpvar_16 = normalize (tmpvar_15);
|
||
|
vec3 tmpvar_17;
|
||
|
tmpvar_17 = tmpvar_16;
|
||
|
viewDirection_11 = tmpvar_17;
|
||
|
vec3 tmpvar_18;
|
||
|
tmpvar_18 = scene_ambient.xyz;
|
||
|
vec3 tmpvar_19;
|
||
|
tmpvar_19 = frontMaterial.ambient.xyz;
|
||
|
vec3 tmpvar_20;
|
||
|
tmpvar_20 = (tmpvar_18 * tmpvar_19);
|
||
|
totalLighting_8 = tmpvar_20;
|
||
|
vec3 tmpvar_21;
|
||
|
tmpvar_21 = (light0.position - position).xyz;
|
||
|
vec3 tmpvar_22;
|
||
|
tmpvar_22 = tmpvar_21;
|
||
|
positionToLightSource_7 = tmpvar_22;
|
||
|
float tmpvar_23;
|
||
|
tmpvar_23 = dot (positionToLightSource_7, positionToLightSource_7);
|
||
|
float tmpvar_24;
|
||
|
tmpvar_24 = tmpvar_23;
|
||
|
distanceSqr_6 = tmpvar_24;
|
||
|
float tmpvar_25;
|
||
|
tmpvar_25 = inversesqrt (distanceSqr_6);
|
||
|
vec3 tmpvar_26;
|
||
|
tmpvar_26 = (tmpvar_25 * positionToLightSource_7);
|
||
|
lightDirection_10 = tmpvar_26;
|
||
|
float tmpvar_27;
|
||
|
tmpvar_27 = inversesqrt (distanceSqr_6);
|
||
|
float tmpvar_28;
|
||
|
tmpvar_28 = (light0.invLinearAttenuation * tmpvar_27);
|
||
|
attenuation_9 = tmpvar_28;
|
||
|
vec3 tmpvar_29;
|
||
|
tmpvar_29 = light0.diffuse.xyz;
|
||
|
vec3 tmpvar_30;
|
||
|
tmpvar_30 = frontMaterial.diffuse.xyz;
|
||
|
float tmpvar_31;
|
||
|
tmpvar_31 = dot (normalDirection_12, lightDirection_10);
|
||
|
float tmpvar_32;
|
||
|
tmpvar_32 = max (0.0, tmpvar_31);
|
||
|
vec3 tmpvar_33;
|
||
|
tmpvar_33 = (((attenuation_9 * tmpvar_29) * tmpvar_30) * tmpvar_32);
|
||
|
diffuseReflection_5 = tmpvar_33;
|
||
|
float tmpvar_34;
|
||
|
tmpvar_34 = dot (normalDirection_12, lightDirection_10);
|
||
|
if ((tmpvar_34 < 0.0)) {
|
||
|
vec3 tmpvar_35;
|
||
|
tmpvar_35 = vec3(0.0, 0.0, 0.0);
|
||
|
specularReflection_4 = tmpvar_35;
|
||
|
} else {
|
||
|
vec3 tmpvar_36;
|
||
|
tmpvar_36 = light0.specular.xyz;
|
||
|
vec3 tmpvar_37;
|
||
|
tmpvar_37 = frontMaterial.specular.xyz;
|
||
|
vec3 tmpvar_38;
|
||
|
tmpvar_38 = reflect (-(lightDirection_10), normalDirection_12);
|
||
|
float tmpvar_39;
|
||
|
tmpvar_39 = dot (tmpvar_38, viewDirection_11);
|
||
|
float tmpvar_40;
|
||
|
tmpvar_40 = max (0.0, tmpvar_39);
|
||
|
float tmpvar_41;
|
||
|
tmpvar_41 = pow (tmpvar_40, frontMaterial.shininess);
|
||
|
vec3 tmpvar_42;
|
||
|
tmpvar_42 = (((attenuation_9 * tmpvar_36) * tmpvar_37) * tmpvar_41);
|
||
|
specularReflection_4 = tmpvar_42;
|
||
|
};
|
||
|
vec3 tmpvar_43;
|
||
|
tmpvar_43 = ((totalLighting_8 + diffuseReflection_5) + specularReflection_4);
|
||
|
totalLighting_8 = tmpvar_43;
|
||
|
vec4 tmpvar_44;
|
||
|
tmpvar_44.w = 1.0;
|
||
|
tmpvar_44.xyz = totalLighting_8.xyz;
|
||
|
vec4 tmpvar_45;
|
||
|
tmpvar_45 = tmpvar_44;
|
||
|
gl_FragColor = tmpvar_45;
|
||
|
}
|
||
|
|