-
-
Notifications
You must be signed in to change notification settings - Fork 29
Adding lights
Romain Milbert edited this page Nov 1, 2022
·
11 revisions
RaZ supports for now two types of lights:
- A point light is a light source defined by its position; imagine a light bulb, for example.
- A directional light is a light source defined by its direction; this is similar to the sun's behavior, being so distant that its light rays are seemingly parallel to each other.
#include <RaZ/Render/Light.hpp>
// White point light, floating above the ground
Raz::Entity& pointLight = world.addEntityWithComponent<Raz::Transform>(Raz::Vec3f(0.f, 1.f, 0.f));
pointLight.addComponent<Raz::Light>(Raz::LightType::POINT, // Type
1.f, // Energy
Raz::ColorPreset::White); // Color; a Vec3f can be given
// Cyan directional light, pointing to the bottom left
// A directional light doesn't need transformations; no need for a Raz::Transform
Raz::Entity& directionalLight = world.addEntity();
directionalLight.addComponent<Raz::Light>(Raz::LightType::DIRECTIONAL, // Type
Raz::Vec3f(-1.f, -1.f, 0.f), // Direction
1.f, // Energy
Raz::Vec3f(0.f, 1.f, 1.f)); // Color (RGB)
Default shaders allow up to 100 lights.
- Home
- How to build RaZ
- Getting started
- General usage knowledge
- Some examples...
- Playground
- Tutorials
- File formats
- Modules
- Debug