Skip to main content
Commonmark migration
Source Link

One solution

###One solution UseUse an odd number in your power function (or some other function that keeps the sign of your previous specular intensity):

light_specular_intensity = pow(light_specular_intensity, 9.0); light_specular_intensity = pow(light_specular_intensity, 7.0); 

There may be other ways to perform the math such that you may still use an even power.

The problem

###The problem YourYour power function is (mathemtically) creating a phantom light behind the ball, and that's the reflection you're seeing along the edge. For clarity, I've added some parenthesis to this line:

world_reflec = 2 * ( dot(vertex_to_light, normalize(world_normal.xyz)) * normalize(world_normal) ) - vertex_to_light; //reflection of vertex_to_light 

When the camera aligns with the light, for the pixels on the edge, dot(vertex_to_light, world.normal.xyz) will yield nearly zero. So the value of world_reflec will be rough equal to -1 * vertex_to_light. And because vertex_to_eye and vertex_to_light are nearly equal, that means that this line:

light_specular_intensity = dot(normalize(vertex_to_eye), normalize(world_reflec)); 

...will yield a value of light_specular_intensity of almost -1. And then this line:

// (light_diffuse_intensity > 0) == true light_specular_intensity = pow(light_specular_intensity, 8.0); 

...will strip off the negative and give you a value near 1. That causes specular illumination.

###One solution Use an odd number in your power function (or some other function that keeps the sign of your previous specular intensity):

light_specular_intensity = pow(light_specular_intensity, 9.0); light_specular_intensity = pow(light_specular_intensity, 7.0); 

There may be other ways to perform the math such that you may still use an even power.

###The problem Your power function is (mathemtically) creating a phantom light behind the ball, and that's the reflection you're seeing along the edge. For clarity, I've added some parenthesis to this line:

world_reflec = 2 * ( dot(vertex_to_light, normalize(world_normal.xyz)) * normalize(world_normal) ) - vertex_to_light; //reflection of vertex_to_light 

When the camera aligns with the light, for the pixels on the edge, dot(vertex_to_light, world.normal.xyz) will yield nearly zero. So the value of world_reflec will be rough equal to -1 * vertex_to_light. And because vertex_to_eye and vertex_to_light are nearly equal, that means that this line:

light_specular_intensity = dot(normalize(vertex_to_eye), normalize(world_reflec)); 

...will yield a value of light_specular_intensity of almost -1. And then this line:

// (light_diffuse_intensity > 0) == true light_specular_intensity = pow(light_specular_intensity, 8.0); 

...will strip off the negative and give you a value near 1. That causes specular illumination.

One solution

Use an odd number in your power function (or some other function that keeps the sign of your previous specular intensity):

light_specular_intensity = pow(light_specular_intensity, 9.0); light_specular_intensity = pow(light_specular_intensity, 7.0); 

There may be other ways to perform the math such that you may still use an even power.

The problem

Your power function is (mathemtically) creating a phantom light behind the ball, and that's the reflection you're seeing along the edge. For clarity, I've added some parenthesis to this line:

world_reflec = 2 * ( dot(vertex_to_light, normalize(world_normal.xyz)) * normalize(world_normal) ) - vertex_to_light; //reflection of vertex_to_light 

When the camera aligns with the light, for the pixels on the edge, dot(vertex_to_light, world.normal.xyz) will yield nearly zero. So the value of world_reflec will be rough equal to -1 * vertex_to_light. And because vertex_to_eye and vertex_to_light are nearly equal, that means that this line:

light_specular_intensity = dot(normalize(vertex_to_eye), normalize(world_reflec)); 

...will yield a value of light_specular_intensity of almost -1. And then this line:

// (light_diffuse_intensity > 0) == true light_specular_intensity = pow(light_specular_intensity, 8.0); 

...will strip off the negative and give you a value near 1. That causes specular illumination.

Source Link
Seth Battin
  • 5.5k
  • 3
  • 29
  • 43

###One solution Use an odd number in your power function (or some other function that keeps the sign of your previous specular intensity):

light_specular_intensity = pow(light_specular_intensity, 9.0); light_specular_intensity = pow(light_specular_intensity, 7.0); 

There may be other ways to perform the math such that you may still use an even power.

###The problem Your power function is (mathemtically) creating a phantom light behind the ball, and that's the reflection you're seeing along the edge. For clarity, I've added some parenthesis to this line:

world_reflec = 2 * ( dot(vertex_to_light, normalize(world_normal.xyz)) * normalize(world_normal) ) - vertex_to_light; //reflection of vertex_to_light 

When the camera aligns with the light, for the pixels on the edge, dot(vertex_to_light, world.normal.xyz) will yield nearly zero. So the value of world_reflec will be rough equal to -1 * vertex_to_light. And because vertex_to_eye and vertex_to_light are nearly equal, that means that this line:

light_specular_intensity = dot(normalize(vertex_to_eye), normalize(world_reflec)); 

...will yield a value of light_specular_intensity of almost -1. And then this line:

// (light_diffuse_intensity > 0) == true light_specular_intensity = pow(light_specular_intensity, 8.0); 

...will strip off the negative and give you a value near 1. That causes specular illumination.