I am following tutorials to implement directional light in directx, the diffuse part is as below
diffuse = float4(0.0f, 0.0f, 0.0f, 0.0f);
float diffuseFactor = dot(lightVec, normal);
diffuse = saturate(diffuseFactor * mat.Diffuse * L.Diffuse);
what confused me is the result of diffuse.
mat.Diffuse * L.Diffuse should be a float4, how could it be saved to "diffuse", a float type variable.
the same question to the ambient part
ambient = float4(0.0f, 0.0f, 0.0f, 0.0f);
ambient = mat.Ambient * L.Ambient;
both mat.Ambient and L.Ambient are float4 types, after the * operation, it should be a float type.
I find materials on the internet and found there are only two multiply operations of vectors,dot product and cross product, so why the code mentioned above still use *, but not dot function?