Changeset 2146 for trunk/src/easymesh
 Timestamp:
 Dec 18, 2012, 8:48:08 PM (8 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/easymesh/shiny.lolfx
r2145 r2146 43 43 44 44 // FIXME: the light direction should be passed in the code 45 vec3 in_LightDir = vec3(0.3, 0.3, 0.7); 46 vec4 in_Light2_Pos = vec4(100.0, 100.0, 100.0, 1.0); 45 vec3 in_LightDir = vec3(0.3, 0.3, 0.7); 46 vec4 in_Light2_Pos = vec4(0.0, 10.0, 0.0, 1.0); 47 float in_Light2_Radius = 20.0; 48 vec3 in_Light2_diffuse = vec3(0.4, 0.4, 1.0); 47 49 48 50 void main(void) … … 55 57 float ambient_mul = 0.5; 56 58 vec3 ambient_color = vec3(0.0, 0.0, 0.0); 57 vec3 diffuse_color = vec3( 1.0, 1.0, 0.6);59 vec3 diffuse_color = vec3(0.4, 0.4, 0.4); 58 60 vec3 specular_color = vec3(1.0, 1.0, 0.6); 59 61 … … 66 68 float sdotn = 0.0; 67 69 68 /*69 70 //Light calculation for directional light 70 s = normalize( in_LightDir);71 s = normalize(in_LightDir); 71 72 v = normalize(pass_Vertex.xyz); 72 r = reflect( s, pass_TNormal);73 r = reflect(s, pass_TNormal); 73 74 74 75 sdotn = max(dot(s, pass_TNormal), 0.0); … … 77 78 specular += specular_color * specular_reflect 78 79 * pow(max(dot(r, v), 0.0), specular_power); 79 */80 80 81 81 82 //Light calculation for point light 82 s = normalize((in_View * in_Light2_Pos).xyz  pass_Vertex.xyz); 83 vec3 tmpLightDir = (in_View * in_Light2_Pos).xyz  pass_Vertex.xyz; 84 float light_radius_mod = max(0.0, 1.0  (length(tmpLightDir) / in_Light2_Radius)); 85 s = normalize(tmpLightDir); 83 86 v = normalize(pass_Vertex.xyz); 84 87 r = reflect(s, pass_TNormal); 85 88 86 89 sdotn = max(dot(s, pass_TNormal), 0.0); 87 diffuse += diffuse_color * sdotn;88 //if (sdotn> 0.0)89 // specular += specular_color * specular_reflect90 //* pow(max(dot(r, v), 0.0), specular_power);91 90 diffuse += in_Light2_diffuse * min(sdotn, light_radius_mod); 91 if (sdotn > 0.0 && light_radius_mod > 0.0) 92 specular += specular_color * min(specular_reflect, light_radius_mod) 93 * pow(max(dot(r, v), 0.0), specular_power); 94 92 95 93 96 vec3 light = ambient + diffuse + specular;
Note: See TracChangeset
for help on using the changeset viewer.