|
|
@@ -76,7 +76,7 @@ void main(void) |
|
|
|
vec3 v = vec3(0.0, 0.0, 0.0); |
|
|
|
vec3 r = vec3(0.0, 0.0, 0.0); |
|
|
|
float sdotn = 0.0; |
|
|
|
float light_radius_mod = 0.0; |
|
|
|
float light_radius_mod = 0.0; |
|
|
|
|
|
|
|
//Light calculation for directional light |
|
|
|
s = normalize(-in_LightDir); |
|
|
@@ -88,11 +88,11 @@ void main(void) |
|
|
|
if (sdotn > 0.0) |
|
|
|
specular += specular_color * specular_reflect |
|
|
|
* pow(max(dot(r, v), 0.0), specular_power); |
|
|
|
//---------- |
|
|
|
|
|
|
|
//---------- |
|
|
|
|
|
|
|
//Light calculation for point light |
|
|
|
vec3 tmpLightDir = (in_View * in_Light2_Pos).xyz - pass_Vertex.xyz; |
|
|
|
light_radius_mod = max(0.0, 1.0 - (length(tmpLightDir) / in_Light2_Radius)); |
|
|
|
vec3 tmpLightDir = (in_View * in_Light2_Pos).xyz - pass_Vertex.xyz; |
|
|
|
light_radius_mod = max(0.0, 1.0 - (length(tmpLightDir) / in_Light2_Radius)); |
|
|
|
s = normalize(tmpLightDir); |
|
|
|
v = normalize(-pass_Vertex.xyz); |
|
|
|
r = reflect(-s, pass_TNormal); |
|
|
@@ -102,29 +102,29 @@ void main(void) |
|
|
|
if (sdotn > 0.0 && light_radius_mod > 0.0) |
|
|
|
specular += specular_color * min(specular_reflect, light_radius_mod) |
|
|
|
* pow(max(dot(r, v), 0.0), specular_power); |
|
|
|
//---------- |
|
|
|
|
|
|
|
//---------- |
|
|
|
|
|
|
|
//Light calculation for cube light |
|
|
|
vec3 Local_Vertex = (in_Inv_View * pass_Vertex).xyz - (in_Light3_Pos).xyz; |
|
|
|
vec3 Proj_Vertex = clamp(Local_Vertex.xyz, -in_Light3_Size_Inner, in_Light3_Size_Inner); |
|
|
|
vec3 new_LightDir = Local_Vertex - Proj_Vertex; |
|
|
|
|
|
|
|
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)); |
|
|
|
light_radius_mod = min(light_radius.x, min(light_radius.y, light_radius.z)); |
|
|
|
|
|
|
|
if (length(new_LightDir) == 0.0) |
|
|
|
sdotn = 1.0; |
|
|
|
else |
|
|
|
{ |
|
|
|
new_LightDir = normalize((in_View * vec4(Proj_Vertex + in_Light3_Pos.xyz,1.0)).xyz - pass_Vertex.xyz); |
|
|
|
sdotn = max(dot(new_LightDir, pass_TNormal), 0.0); |
|
|
|
r = reflect(-new_LightDir, pass_TNormal); |
|
|
|
if (sdotn > 0.0 && light_radius_mod > 0.0) |
|
|
|
specular += specular_color * min(specular_reflect, light_radius_mod) |
|
|
|
* pow(max(dot(r, v), 0.0), specular_power); |
|
|
|
} |
|
|
|
vec3 Local_Vertex = (in_Inv_View * pass_Vertex).xyz - (in_Light3_Pos).xyz; |
|
|
|
vec3 Proj_Vertex = clamp(Local_Vertex.xyz, -in_Light3_Size_Inner, in_Light3_Size_Inner); |
|
|
|
vec3 new_LightDir = Local_Vertex - Proj_Vertex; |
|
|
|
|
|
|
|
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)); |
|
|
|
light_radius_mod = min(light_radius.x, min(light_radius.y, light_radius.z)); |
|
|
|
|
|
|
|
if (length(new_LightDir) == 0.0) |
|
|
|
sdotn = 1.0; |
|
|
|
else |
|
|
|
{ |
|
|
|
new_LightDir = normalize((in_View * vec4(Proj_Vertex + in_Light3_Pos.xyz,1.0)).xyz - pass_Vertex.xyz); |
|
|
|
sdotn = max(dot(new_LightDir, pass_TNormal), 0.0); |
|
|
|
r = reflect(-new_LightDir, pass_TNormal); |
|
|
|
if (sdotn > 0.0 && light_radius_mod > 0.0) |
|
|
|
specular += specular_color * min(specular_reflect, light_radius_mod) |
|
|
|
* pow(max(dot(r, v), 0.0), specular_power); |
|
|
|
} |
|
|
|
diffuse += in_Light3_diffuse * min(sdotn, light_radius_mod); |
|
|
|
//---------- |
|
|
|
//---------- |
|
|
|
|
|
|
|
vec3 light = ambient + diffuse + specular; |
|
|
|
|
|
|
|