Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 24 May 2011
Offline Last Active Dec 19 2012 11:10 PM

#4980120 Parentheses in HLSL cause light attenuation function to not work correctly?

Posted by on 14 September 2012 - 11:10 AM

Wow, those posts are way over my head Posted Image

Hi again,

To get back to your problem, in what spaces are light_vector and input.pos? Are they both in world space? The values you reported to see anything at all are indeed a little extreme. Posted Image
And yes, in theory the attentuation won't fall down to zero. In practice, however, you just cut it off somewhere.

inpus.pos is in world space (transformed in vertex shader), but the light_vector is just raw input, no transformations. Is that correct?

Here are the lighting equations I'm using, from the book "Mathematics for 3D Game Programming and Computer Graphics":

D = diffuse reflection color
A = ambient intensity (should this be a float or a float3?)
C = light attenuation * light_color
N = surface normal
L = normalized light vector

S = specular reflection color
C = light attenuation * light_color
R = 2*( N dot L )*N - L
V = camera vector
m = specular exponent
N = surface normal
L = normalized light vector

Here is the dropbox link to the model: https://www.dropbox....pl6jls/kit2.obj