Directional light now fully added to all lists.
This commit is contained in:
@@ -12,12 +12,12 @@
|
|||||||
|
|
||||||
struct DirectionalLightJob : RenderJob
|
struct DirectionalLightJob : RenderJob
|
||||||
{
|
{
|
||||||
DirectionalLightJob(ComponentWrapper transformComponent, ComponentWrapper directionalLightCompoentn, World* m_World)
|
DirectionalLightJob(ComponentWrapper transformComponent, ComponentWrapper directionalLightComponent, World* m_World)
|
||||||
: RenderJob()
|
: RenderJob()
|
||||||
{
|
{
|
||||||
Direction = glm::vec4((glm::vec3)directionalLightCompoentn["Direction"], 1.f);
|
Direction = glm::vec4((glm::vec3)directionalLightComponent["Direction"], 1.f);
|
||||||
Color = (glm::vec4)directionalLightCompoentn["Color"];
|
Color = (glm::vec4)directionalLightComponent["Color"];
|
||||||
Intensity = (double)directionalLightCompoentn["Intensity"];
|
Intensity = (double)directionalLightComponent["Intensity"];
|
||||||
};
|
};
|
||||||
|
|
||||||
glm::vec4 Direction;
|
glm::vec4 Direction;
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ private:
|
|||||||
void updateProjectionMatrix(ComponentWrapper& cameraComponent);
|
void updateProjectionMatrix(ComponentWrapper& cameraComponent);
|
||||||
|
|
||||||
void fillModels(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
void fillModels(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
||||||
void fillLight(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
void fillPointLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
||||||
|
void fillDirectionalLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
||||||
|
|
||||||
EventRelay<RenderSystem, Events::InputCommand> m_EInputCommand;
|
EventRelay<RenderSystem, Events::InputCommand> m_EInputCommand;
|
||||||
bool OnInputCommand(const Events::InputCommand& e);
|
bool OnInputCommand(const Events::InputCommand& e);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<xs:include schemaLocation="Components/Camera.xsd"/>
|
<xs:include schemaLocation="Components/Camera.xsd"/>
|
||||||
<xs:include schemaLocation="Components/AABB.xsd"/>
|
<xs:include schemaLocation="Components/AABB.xsd"/>
|
||||||
<xs:include schemaLocation="Components/PointLight.xsd"/>
|
<xs:include schemaLocation="Components/PointLight.xsd"/>
|
||||||
|
<xs:include schemaLocation="Components/DirectionalLight.xsd"/>
|
||||||
<xs:include schemaLocation="Components/Trigger.xsd"/>
|
<xs:include schemaLocation="Components/Trigger.xsd"/>
|
||||||
<xs:include schemaLocation="Components/Health.xsd"/>
|
<xs:include schemaLocation="Components/Health.xsd"/>
|
||||||
</xs:schema>
|
</xs:schema>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<c:PointLight>
|
<c:DirectionalLight>
|
||||||
<Direction X="0" Y="0" Z="0"/>
|
<Direction X="0" Y="0" Z="0"/>
|
||||||
<Color R="1" G="1" B="1" A="1"/>
|
<Color R="1" G="1" B="1" A="1"/>
|
||||||
<Intensity>0.8</Intensity>
|
<Intensity>0.8</Intensity>
|
||||||
<Visible>true</Visible>
|
<Visible>true</Visible>
|
||||||
</c:PointLight>
|
</c:DirectionalLight>
|
||||||
@@ -96,19 +96,19 @@ void LightCullingPass::FillLightList(RenderScene& scene)
|
|||||||
//p.Padding = 123.f;
|
//p.Padding = 123.f;
|
||||||
p.Type = LightSource::Point;
|
p.Type = LightSource::Point;
|
||||||
m_LightSources.push_back(p);
|
m_LightSources.push_back(p);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(auto &job : scene.DirectionalLightJobs) {
|
for(auto &job : scene.DirectionalLightJobs) {
|
||||||
auto directionalLightJob = std::dynamic_pointer_cast<directionalLightJob>(job);
|
auto directionalLightJob = std::dynamic_pointer_cast<DirectionalLightJob>(job);
|
||||||
if(directionalLightJob) {
|
if(directionalLightJob) {
|
||||||
LightSource p;
|
LightSource p;
|
||||||
|
p.Direction = directionalLightJob->Direction;
|
||||||
p.Color = directionalLightJob->Color;
|
p.Color = directionalLightJob->Color;
|
||||||
p.Intensity = directionalLightJob->Intensity;
|
p.Intensity = directionalLightJob->Intensity;
|
||||||
p.Position = glm::vec4(glm::vec3(directionalLightJob->Position), 1.f);
|
|
||||||
p.Type = LightSource::Directional;
|
p.Type = LightSource::Directional;
|
||||||
m_LightSources.push_back(p);
|
m_LightSources.push_back(p);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& jobs, World
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RenderSystem::fillLight(std::list<std::shared_ptr<RenderJob>>& jobs, World* world)
|
void RenderSystem::fillPointLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world)
|
||||||
{
|
{
|
||||||
auto pointLights = world->GetComponents("PointLight");
|
auto pointLights = world->GetComponents("PointLight");
|
||||||
if (pointLights != nullptr) {
|
if (pointLights != nullptr) {
|
||||||
@@ -117,8 +117,11 @@ void RenderSystem::fillLight(std::list<std::shared_ptr<RenderJob>>& jobs, World*
|
|||||||
jobs.push_back(pointLightJob);
|
jobs.push_back(pointLightJob);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RenderSystem::fillDirectionalLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world)
|
||||||
|
{
|
||||||
auto directionalLights = world->GetComponents("DirectionalLight");
|
auto directionalLights = world->GetComponents("DirectionalLight");
|
||||||
if (directionalLights != nullptr) {
|
if (directionalLights != nullptr) {
|
||||||
for (auto& directionalLightC : *directionalLights) {
|
for (auto& directionalLightC : *directionalLights) {
|
||||||
@@ -162,7 +165,8 @@ void RenderSystem::Update(World* world, double dt)
|
|||||||
scene.Camera = m_Camera;
|
scene.Camera = m_Camera;
|
||||||
scene.Viewport = Rectangle(1280, 720);
|
scene.Viewport = Rectangle(1280, 720);
|
||||||
fillModels(scene.ForwardJobs, world);
|
fillModels(scene.ForwardJobs, world);
|
||||||
fillLight(scene.PointLightJobs, world);
|
fillPointLights(scene.PointLightJobs, world);
|
||||||
|
fillDirectionalLights(scene.DirectionalLightJobs, world);
|
||||||
m_RenderFrame->Add(scene);
|
m_RenderFrame->Add(scene);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user