   Per-Pixel Lighting Model?
  Here is the code.. is this accurate?void LightF(float4 color : COLOR,out float4 oColor : COLOR,float2 texcoord : TEXCOORD0, uniform float3 lightColor,uniform float3 lightPosition,uniform float4 Ke,uniform float4 Ka,uniform float4 Kd,uniform float4 Ks,uniform float kC,uniform float kL,uniform float kQ,uniform sampler2D pos,uniform sampler2D nor,uniform sampler2D dif,uniform float3 eyeP){float4 ambient = float4( 0.0, 0.0, 0.0, 0.0);float4 diffuse = float4( 0.0, 0.0, 0.0, 0.0);float4 specular = float4( 0.0, 0.0, 0.0, 0.0);//Sample the G-Buffer float4 position4 = tex2D(pos, texcoord);float4 normal4 = tex2D(nor, texcoord);float4 diffuse4 = tex2D(dif, texcoord);float3 position3 = position4.xyz;float3 normalS = normal4.xyz;//expand(normal4.xyz);float3 normal3 = normalS;float3 diffuse3 = diffuse4.xyz;float3 sem = float3( position4.w , normal4.w, diffuse4.w);float4 emission = sem.yyyy;float4 shininess = sem.x;float3 lightDir = float3(lightPosition.xyz - position3);float d = length(lightDir);lightDir = normalize(lightDir);float attenuation = 1.0/(kC + kL * d + kQ *d *d);float3 halfAngle = normalize(lightDir + eyeP);float nDotLD = max(0.0, dot(normal3, lightDir) );float nDotHA = max(0.0, dot(normal3, halfAngle) );float spec_power;if(nDotLD == 0.0)spec_power = 0.0;elsespec_power = pow(nDotHA, shininess);float4 LightColor = float4 (lightColor.xyz, 0.0f );ambient = Ka;diffuse = Kd * LightColor * nDotLD * attenuation;specular = Ks * LightColor * spec_power * attenuation;float4 colorr = float4( diffuse3, 1.0);oColor = (emission + ambient + diffuse)*colorr + specular;}and are these numbers good for an ambient light?Ke: 1.0 ,1.0, 1.0 , 0.0, Kd: 1.0, 1.0, 1.0, 0.0, Ka: 0.9, 0.9, 0.9, 0.0, Ks: 0.9, 0.9, 0.9, 0.0, Shininess: 1.0Color(1.0, 0.0, 0.0);kC: 0.4kL: 0.1kQ: 0.03   
  I assume this is for a renderer with a deferred lighting pipeline?Where did this code come from? (I.e. how the G-Buffer is being filled will affect whether this code is accurate or not...)Quote:and are these numbers good for an ambient light?That's an art question... It entirely depends on the scene!   ;  Yeah its from a deferred rendering pipeline i set up. its running... but its a little buggy and im trying to figure out why. i'm pretty confidnent in the lighting model, not 100% sure about the numbers though.The Normals in the buffer dont need to be remapped so i commented out that part.   