Point lights
This commit is contained in:
41
renderer/point_light.jai
Normal file
41
renderer/point_light.jai
Normal file
@@ -0,0 +1,41 @@
|
||||
Point_Light :: struct {
|
||||
using #as entity : Entity;
|
||||
entity.type = Point_Light;
|
||||
|
||||
color: Vector3;
|
||||
intensity: float = 1.0;
|
||||
attenuation_radius: float = 3.0;
|
||||
}
|
||||
|
||||
Point_Light_Shader_Data :: struct {
|
||||
position: Vector4;
|
||||
color: Vector4;
|
||||
attenuation_radius: float;
|
||||
|
||||
pad: Vector3;
|
||||
}
|
||||
|
||||
MAX_POINT_LIGHTS :: 64;
|
||||
|
||||
Point_Light_Array :: struct {
|
||||
point_lights: [MAX_POINT_LIGHTS] Point_Light_Shader_Data;
|
||||
num_point_lights: s32;
|
||||
|
||||
padding: Vector3;
|
||||
}
|
||||
|
||||
init_entity :: (light: *Point_Light) {
|
||||
light.intensity = 1.0;
|
||||
light.color = .{1,1,1};
|
||||
light.attenuation_radius = 3.0;
|
||||
}
|
||||
|
||||
to_shader_point_light :: (point_light: *Point_Light) -> Point_Light_Shader_Data {
|
||||
data : Point_Light_Shader_Data;
|
||||
|
||||
data.position = to_v4(get_position(point_light.transform));
|
||||
data.color = to_v4(point_light.color*point_light.intensity);
|
||||
data.attenuation_radius = point_light.attenuation_radius;
|
||||
|
||||
return data;
|
||||
}
|
||||
Reference in New Issue
Block a user