   warn light in view space [SOLVED]
  Kind of a stupid bug, my warn light works in world space, but dosn't work properly in view space. It's directional part keeps following camera.float3light_pos = mul(float4(0,10,0,1), viewMatrix);float3light_dir = mul(float4(1,0,0,1), viewMatrix);float3LightVector = frag_view_pos - light_pos.xyz; LightVector = normalize(LightVector);float3 normal = normalize(normal.xyz);floatlambert = saturate(dot(-LightVector, normal));floatwarn_alpha = saturate(dot(LightVector, normalize(light_dir)));float3result = lambert * warn_alpha;this is some kind of stupid bug, it should work in view space if all other vectors are in view space as well. Lambert works just fine, but warn_alpha works like light_dir vector is pointing from camera to light's position.[Edited by - Viik on April 16, 2010 10:44:17 AM]
  Can you explain what you want warn_alpha to be?At the first glance I would say you multiply light_dir with the viewMatrix.As vieMatrix is applied light_dir will stay in thesame position relative to the camera thus creatingthe "effect" of the light beeing attached to the camera.It depends on what you want warn_alpha to be, whatyou have to change. I think you want to gain thesame effect like lambert, do you?   ;Quote:It depends on what you want warn_alpha to be, whatyou have to change. I think you want to gain thesame effect like lambert, do you?Basically in my setup it works like half of the omni light.Warn light without attentuation:I = cos^a(VL_angle) * cos(NL_angle)"a" is a Warn exponent, its 1 in my case"Vl_angle" is angle between light direction and light to fragment direction"cos(NL_angle)" is a basic N dot LSo warn_alpha should be a dot product between light direction vector and light to fragment position vector.I'm taking a vector that presents direction where light points and move it into view space by:float3light_dir = mul(float4(1,0,0,1), viewMatrix);I do the same for position and it works, maybe it's not a case for light direction.   ;  Found what the issue was, I didn't passed light direction properly, as it should be a vector starting from lights position, not from 0,0,0.   