light.c
 1  /* ************************************************************************** */
 2  /*                                                                            */
 3  /*                                                        :::      ::::::::   */
 4  /*   light.c                                            :+:      :+:    :+:   */
 5  /*                                                    +:+ +:+         +:+     */
 6  /*   By: gychoi <gychoi@student.42seoul.kr>         +#+  +:+       +#+        */
 7  /*                                                +#+#+#+#+#+   +#+           */
 8  /*   Created: 2023/05/28 20:06:59 by gychoi            #+#    #+#             */
 9  /*   Updated: 2023/05/28 20:57:23 by gychoi           ###   ########.fr       */
10  /*                                                                            */
11  /* ************************************************************************** */
12  
13  #include "light.h"
14  #include <stdlib.h>
15  
16  t_color3	phong_lighting(t_scene *scene)
17  {
18  	t_color3	light_color;
19  	t_object	*lights;
20  
21  	light_color = color3(0, 0, 0);
22  	lights = scene->light;
23  //	while (lights)
24  //	{
25  //		if (light->type == LIGHT_POINT)
26  //			light_color = vadd(light_color, point_light_get(scene, lights->element));
27  //		lights = lights->next;
28  //	}
29  	light_color = vadd(light_color, scene->ambient);
30  	return (vsub(vmult(light_color, scene->rec.albedo), color3(1, 1, 1)));
31  }
32  
33  t_light	*light_point(t_point3 light_origin, t_color3 light_color, double bright_ratio)
34  {
35  	t_light	*light;
36  
37  	light = malloc(sizeof(t_light));
38  	if (!light)
39  		return (NULL);
40  	light->origin = light_origin;
41  	light->light_color = light_color;
42  	light->bright_ratio = bright_ratio;
43  	return (light);
44  }