From af1919092910e92ea72b9f227e4b58487ab0f6c2 Mon Sep 17 00:00:00 2001 From: plouj Date: Fri, 11 Jan 2008 21:50:29 +0000 Subject: [PATCH] added the effect of the light colour into the lighting_function git-svn-id: http://svn.plouj.com/repos/eraytracer@25 b8c14938-b733-429d-887c-d66ed1f8cd15 --- raytracer.erl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/raytracer.erl b/raytracer.erl index 4265346..2e41ca4 100644 --- a/raytracer.erl +++ b/raytracer.erl @@ -53,6 +53,8 @@ lighting_function(Object, Hit_location, Hit_normal, Scene) -> location=Light_location}, Final_colour) -> vector_add( + vector_component_mult( + colour_to_vector(Light_colour), vector_scalar_mult( colour_to_vector(object_colour(Object)), Diffuse_scale*lists:max([vector_dot_product( @@ -60,7 +62,7 @@ lighting_function(Object, Hit_location, Hit_normal, Scene) -> vector_normalize( vector_sub( Light_location, - Hit_location))), 0])), + Hit_location))), 0]))), Final_colour); (_Not_a_point_light, Final_colour) -> Final_colour @@ -224,6 +226,9 @@ vector_mag(V) -> vector_scalar_mult(#vector{x=X, y=Y, z=Z}, Scalar) -> #vector{x=X*Scalar, y=Y*Scalar, z=Z*Scalar}. +vector_component_mult(#vector{x=X1, y=Y1, z=Z1}, #vector{x=X2, y=Y2, z=Z2}) -> + #vector{x=X1*X2, y=Y1*Y2, z=Z1*Z2}. + vector_dot_product(#vector{x=A1, y=A2, z=A3}, #vector{x=B1, y=B2, z=B3}) -> A1*B1 + A2*B2 + A3*B3. -- 2.11.4.GIT