~vladh/peony

peony/src/lights.hpp -rw-r--r-- 1.3 KiB
7fc9922bVlad-Stefan Harbuz changes shaders namespace into class a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
  Peony Game Engine
  Copyright (C) 2020 Vlad-Stefan Harbuz <vlad@vladh.net>
  All rights reserved.
*/

#pragma once

#include "types.hpp"
#include "entities.hpp"
#include "spatial.hpp"

namespace lights {
  // The position is used in positioning the shadow map, but not
  // in the light calculations. We need to scale the position
  // by some factor such that the shadow map covers the biggest
  // possible area.
  constexpr v3 DIRECTIONAL_LIGHT_DISTANCE = v3(75.0f, 15.0f, 75.0f);

  enum class LightType {none, point, directional};

  struct LightComponent {
    EntityHandle entity_handle;
    LightType type;
    v3 direction;
    v4 color;
    v4 attenuation;
  };

  struct LightComponentSet {
    Array<LightComponent> components;
  };

  struct LightsState {
    real32 dir_light_angle;
  };

  const char* light_type_to_string(LightType light_type);
  LightType light_type_from_string(const char *str);
  uint32 light_type_to_int(LightType light_type);
  bool32 is_light_component_valid(LightComponent *light_component);
  void update_light_components(
    LightsState *lights_state,
    LightComponentSet *light_component_set,
    SpatialComponentSet *spatial_component_set,
    v3 camera_position
  );
  void init(LightsState *state);
}

using lights::LightType, lights::LightComponent,
  lights::LightComponentSet, lights::LightsState;