@@ -49,39 +49,15 @@ float textureProjSoft(sampler2DShadow tex, vec4 uv, float bias, float blur) {
4949 return result/ 13.0 ;
5050}
5151
52- // float shadowCoef(vec4 vPos, sampler2DShadow shadowMap, mat4 shadowViewMatrix) {
53- // int index = 3;
54- // // find the appropriate depth map to look up in
55- // // based on the depth of this fragment
56- // if(gl_FragCoord.z < far_d.x) index = 0;
57- // else if(gl_FragCoord.z < far_d.y) index = 1;
58- // else if(gl_FragCoord.z < far_d.z) index = 2;
59- //
60- // // transform this fragment's position from view space to
61- // // scaled light clip space such that the xy coordinates
62- // // lie in [0;1]. Note that there is no need to divide by w
63- // // for othogonal light sources
64- // vec4 shadow_coord = shadowViewMatrix*vPos;
65- // // set the current depth to compare with
66- // shadow_coord.w = shadow_coord.z;
67- //
68- // // tell glsl in which layer to do the look up
69- // shadow_coord.z = float(index);
70- //
71- // // let the hardware do the comparison for us
72- // return shadow2DArray(shadowMap, shadow_coord).x;
73- // }
52+
7453
7554void main() {
7655 vec3 illumLightSum = vec3 (0 );
7756 vec3 normal = normalize (primNormal);
7857
79- // diffuseColor = p3d_Material.diffuse.xyz;
80- // specStrength = p3d_Material.specular.x;
81-
8258 for (int i = 0 ; i < p3d_LightSource.length (); i++ ) {
8359 float shadowScale = 1 ;
84- // shadowScale = textureProj(p3d_LightSource[i].shadowMap, shadow_uv[i]);
60+ shadowScale = textureProj(p3d_LightSource[i].shadowMap, shadow_uv[i]);
8561 // shadowScale = textureProjSoft(p3d_LightSource[i].shadowMap, shadow_uv[i], 0.0001, 0.001);
8662 vec3 lightDir = p3d_LightSource[i].position.xyz;
8763 if (p3d_LightSource[i].position.w != 0 ) {
@@ -93,7 +69,7 @@ void main() {
9369 lightDir = normalize (- lightDir);
9470
9571 float lambertian = max (dot (lightDir, normal), 0.0 );
96- // lambertian = texture(p3d_Texture1, vec2(lambertian, 0.5)).x;
72+ // lambertian = texture(p3d_Texture1, vec2(lambertian, 0.5)).x; // --Adds diffuse toon shading
9773
9874 float specular = 0.0 ;
9975
@@ -104,15 +80,15 @@ void main() {
10480 vec3 halfDir = normalize (lightDir + viewDir);
10581 float specAngle = max (dot (halfDir, normal), 0.0 );
10682 specular = pow (specAngle, p3d_Material.shininess);
107- // specular = texture(p3d_Texture1, vec2(specular, 0.5)).x;
83+ // specular = texture(p3d_Texture1, vec2(specular, 0.5)).x; // --Adds specular toon shading
10884 }
10985 vec3 illumDiffuse = diffuseColor * lambertian * p3d_LightSource[i].color.xyz / (distance );
11086 vec3 illumSpecular = diffuseColor * specStrength * specular * p3d_LightSource[i].color.xyz / (distance );
11187 illumLightSum += (illumDiffuse+ illumSpecular)* shadowScale;
11288 }
11389
11490 vec3 colorGammaCorrected = pow (p3d_LightModel.ambient.xyz* diffuseColor+ illumLightSum, vec3 (0.49504950495 ));
115- // colorGammaCorrected = texture(p3d_Texture1, vec2(length(colorGammaCorrected.xyz), 0.5), 0).x*colorGammaCorrected;
91+ // colorGammaCorrected = texture(p3d_Texture1, vec2(length(colorGammaCorrected.xyz), 0.5), 0).x*colorGammaCorrected; // - Adds brightness toon shading
11692
11793 // use the gamma corrected color in the fragment0
11894 outputColor = vec4 (colorGammaCorrected, 1 );
0 commit comments