Changeset 2148 for trunk/src/easymesh/shiny.lolfx
 Timestamp:
 Dec 18, 2012, 10:59:23 PM (7 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/easymesh/shiny.lolfx
r2146 r2148 37 37 uniform float in_Damage; 38 38 uniform mat4 in_View; 39 uniform mat4 in_Inv_View; 39 40 40 41 varying vec4 pass_Vertex; /* View space */ … … 42 43 varying vec4 pass_Color; 43 44 44 // FIXME: the light direction should be passed in the code 45 // FIXME: all the light parameters should be passed in the code 46 //Dir Light 45 47 vec3 in_LightDir = vec3(0.3, 0.3, 0.7); 46 vec4 in_Light2_Pos = vec4(0.0, 10.0, 0.0, 1.0); 48 49 //Point Light 50 vec4 in_Light2_Pos = vec4(20.0, 10.0, 0.0, 1.0); 47 51 float in_Light2_Radius = 20.0; 48 52 vec3 in_Light2_diffuse = vec3(0.4, 0.4, 1.0); 53 54 //Cube Light 55 vec4 in_Light3_Pos = vec4(10.0, 10.0, 5.0, 1.0); 56 vec3 in_Light3_Size_Inner = vec3(1.0, 1.0, 1.0); 57 vec3 in_Light3_Size_Outer = vec3(10.0, 10.0, 10.0); 58 vec3 in_Light3_diffuse = vec3(0.4, 1.0, 0.4); 49 59 50 60 void main(void) … … 67 77 vec3 r = vec3(0.0, 0.0, 0.0); 68 78 float sdotn = 0.0; 79 float light_radius_mod = 0.0; 69 80 70 81 //Light calculation for directional light … … 78 89 specular += specular_color * specular_reflect 79 90 * pow(max(dot(r, v), 0.0), specular_power); 80 91 // 81 92 82 93 //Light calculation for point light 83 94 vec3 tmpLightDir = (in_View * in_Light2_Pos).xyz  pass_Vertex.xyz; 84 floatlight_radius_mod = max(0.0, 1.0  (length(tmpLightDir) / in_Light2_Radius));95 light_radius_mod = max(0.0, 1.0  (length(tmpLightDir) / in_Light2_Radius)); 85 96 s = normalize(tmpLightDir); 86 97 v = normalize(pass_Vertex.xyz); … … 92 103 specular += specular_color * min(specular_reflect, light_radius_mod) 93 104 * pow(max(dot(r, v), 0.0), specular_power); 105 // 94 106 107 //Light calculation for cube light 108 vec3 Local_Vertex = (in_Inv_View * pass_Vertex).xyz  (in_Light3_Pos).xyz; 109 vec3 Proj_Vertex = clamp(Local_Vertex.xyz, in_Light3_Size_Inner, in_Light3_Size_Inner); 110 vec3 new_LightDir = Local_Vertex  Proj_Vertex; 111 112 vec3 light_radius = max(vec3(0.0,0.0,0.0), vec3(1.0,1.0,1.0)  abs(new_LightDir / in_Light3_Size_Outer)); 113 light_radius_mod = min(light_radius.x, min(light_radius.y, light_radius.z)); 114 115 if (length(new_LightDir) == 0.0) 116 sdotn = 1.0; 117 else 118 { 119 new_LightDir = (in_View * vec4(Proj_Vertex + in_Light3_Pos.xyz,1.0)).xyz  pass_Vertex.xyz; 120 sdotn = max(dot(normalize(new_LightDir), pass_TNormal), 0.0); 121 } 122 diffuse += in_Light3_diffuse * min(sdotn, light_radius_mod); 123 // 95 124 96 125 vec3 light = ambient + diffuse + specular;
Note: See TracChangeset
for help on using the changeset viewer.