• Create Account

### #ActualCryZe

Posted 10 October 2012 - 08:19 AM

Looks ok, as far as I can tell. But you should multiply the factor with the image color instead of adding it. You might want to add a constant "ambient term" to your factor before multiplying it to have some kind of ambient lighting, so that the non-lit area's are not completely black (spherical harmonics or environment mapping are better approaches for ambient lighting though).

Also, the normals in your image are stored in the range (0, 1). But what you actually want are normals in the range (-1, 1). So you have to load them like this:
vec4 normalColor = 2 * texture2D( normal, tc ) - 1;

As a distance attenuation factor you might want to divide the resulting illumination by the light vectors length squared. This would be the most physically correct distance attenuation factor.

### #5CryZe

Posted 10 October 2012 - 08:17 AM

Looks ok, as far as I can tell. But you should multiply the factor with the image color instead of adding it. You might want to add a constant "ambient term" to your factor before multiplying it to have some kind of ambient lighting, so that the non-lit area's are not completely black (spherical harmonics or environment mapping are better approaches for ambient lighting though).

Also, the normals in your image are stored in the range (0, 1). But what you actually want are normals in the range (-1, 1). So you have to load them like this:
vec4 normalColor = 2 * texture2D( normal, tc ) - 1;

As a distance attuenuation factor you might want to divide the resulting illumination by the light vectors length squared.

### #4CryZe

Posted 10 October 2012 - 08:16 AM

Looks ok, as far as I can tell. But you should multiply the factor with the image color instead of adding it. You might want to add a constant "ambient term" to your factor before multiplying it to have some kind of ambient lighting, so that the non-lit area's are not completely black (spherical harmonics or environment mapping are better approaches for ambient lighting though).

Also, the normals in your image are stored in the range (0, 1). But what you actually want are normals in the range (-1, 1). So you have to load them like this:
vec4 normalColor = 2 * texture2D( normal, tc ) - 1;

As a distance attuenuation factor you might want to divide the resulting light by the light vectors length squared.

### #3CryZe

Posted 10 October 2012 - 08:14 AM

Looks ok, as far as I can tell. But you should multiply the factor with the image color instead of adding it. You might want to add a constant "ambient term" to your factor before multiplying it to have some kind of ambient lighting, so that the non-lit area's are not completely black (spherical harmonics or environment mapping are better approaches for ambient lighting though).

Also, the normals in your image are stored in the range (0, 1). But what you actually want are normals in the range (-1, 1). So you have to load them like this:
vec4 normalColor = 2 * texture2D( normal, tc ) - 1;

### #2CryZe

Posted 10 October 2012 - 08:13 AM

Looks ok, as far as I can tell. But you should multiply the factor with the image color instead of adding it. You might want to add a constant "ambient term" to your factor before multiplying it to have some kind of ambient lighting, so that the non-lit area's are not completely black (spherical harmonics or environment mapping are better approaches for ambient lighting though).

Also, the normals in your image are stored in the range (0, 1). But what you actually want is normals in the range (-1, 1). So you have to load them like this:
vec4 normalColor = 2 * texture2D( normal, tc ) - 1;

### #1CryZe

Posted 10 October 2012 - 08:11 AM

Looks ok, as far as I can tell. But you should multiply the factor with the image color instead of adding it. You might want to add a constant "ambient term" to your factor before multiplying it to have some kind of ambient lighting, so that the non-lit area's are not completely black (spherical harmonics or environment mapping are better approaches for ambient lighting though).

PARTNERS