Skip to content

Commit b99c01a

Browse files
committed
Add FColour and IColour to Renderer
1 parent 3ca77f9 commit b99c01a

File tree

18 files changed

+179
-87
lines changed

18 files changed

+179
-87
lines changed

engine/render/renderer/lights/PointLight.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Siege
1313

1414
PointLight::PointLight() : PointLight(Vec3::Zero, {1.0f, 1.0f, 1.0f, 0.2f}, {1.f, 1.f, 1.f, .2f}) {}
1515

16-
PointLight::PointLight(Vec3 position, Vec4 color, Vec4 ambientColor) :
16+
PointLight::PointLight(Vec3 position, FColour color, FColour ambientColor) :
1717
lightData {color, ambientColor, position}
1818
{}
1919

engine/render/renderer/lights/PointLight.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ class PointLight
2121

2222
struct Data
2323
{
24-
Vec4 lightColor = {1.f, 1.f, 1.f, 0.2f};
25-
alignas(16) Vec4 ambientLightColor = {1.f, 1.f, 1.f, .02f};
24+
FColour lightColor = {1.f, 1.f, 1.f, 0.2f};
25+
alignas(16) FColour ambientLightColor = {1.f, 1.f, 1.f, .02f};
2626
alignas(16) Vec3 position = Vec3::Zero;
2727
};
2828

2929
PointLight();
30-
PointLight(Vec3 position, Vec4 color, Vec4 ambientColor);
30+
PointLight(Vec3 position, FColour color, FColour ambientColor);
3131
~PointLight();
3232

3333
Data& GetLightData()
@@ -42,11 +42,11 @@ class PointLight
4242
{
4343
lightData.position = position;
4444
}
45-
void SetColor(Vec4 color)
45+
void SetColor(FColour color)
4646
{
4747
lightData.lightColor = color;
4848
}
49-
void SetAmbientColor(Vec4 ambientColor)
49+
void SetAmbientColor(FColour ambientColor)
5050
{
5151
lightData.ambientLightColor = ambientColor;
5252
}

engine/render/renderer/mesh/Mesh.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#ifndef SIEGE_ENGINE_MESH_H
1010
#define SIEGE_ENGINE_MESH_H
1111

12+
#include <utils/Colour.h>
13+
1214
#include "../Core.h"
1315
#include "../buffer/Buffer.h"
1416
#include "render/renderer/platform/vulkan/CommandBuffer.h"
@@ -18,15 +20,15 @@ namespace Siege
1820
struct Vertex
1921
{
2022
Vec3 position;
21-
Vec3 color;
23+
FColour color;
2224
Vec3 normal;
2325
Vec2 uv;
2426
};
2527

2628
struct Vertex2D
2729
{
2830
Vec2 position;
29-
Vec3 color;
31+
FColour color;
3032
};
3133

3234
struct BillboardVertex

engine/render/renderer/model/Model.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,10 @@ void Model::LoadModelFromFile(const String& filePath)
120120
attrib.vertices[3 * index.vertex_index + 1],
121121
attrib.vertices[3 * index.vertex_index + 2]};
122122

123-
vertex.color = Vec3 {attrib.colors[3 * index.vertex_index + 0],
124-
attrib.colors[3 * index.vertex_index + 1],
125-
attrib.colors[3 * index.vertex_index + 2]};
123+
vertex.color = FColour {attrib.colors[3 * index.vertex_index + 0],
124+
attrib.colors[3 * index.vertex_index + 1],
125+
attrib.colors[3 * index.vertex_index + 2],
126+
1.f};
126127
}
127128

128129
if (index.normal_index >= 0)

engine/render/renderer/renderer/BillboardRenderer.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,15 @@ void BillboardRenderer::Destroy()
4545
billboardModel.DestroyModel();
4646
}
4747

48-
void BillboardRenderer::DrawBillboard(const Vec3& position, const Vec2& scale, const Vec4& colour)
48+
void BillboardRenderer::DrawBillboard(const Vec3& position,
49+
const Vec2& scale,
50+
const IColour& colour)
4951
{
50-
vertices.Append({{1.f, 1.f, 1.f}, colour});
51-
vertices.Append({{1.f, -1.f, 1.f}, colour});
52-
vertices.Append({{-1.f, -1.f, 1.f}, colour});
53-
vertices.Append({{-1.f, 1.f, 1.f}, colour});
52+
auto fColour = ToFColour(colour);
53+
vertices.Append({{1.f, 1.f, 1.f}, fColour});
54+
vertices.Append({{1.f, -1.f, 1.f}, fColour});
55+
vertices.Append({{-1.f, -1.f, 1.f}, fColour});
56+
vertices.Append({{-1.f, 1.f, 1.f}, fColour});
5457

5558
// Pattern: 0, 1, 3, 1, 2, 3
5659
indices.Append(vertices.Count() - 4);

engine/render/renderer/renderer/BillboardRenderer.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#ifndef SIEGE_ENGINE_BILLBOARD_RENDERER_H
1010
#define SIEGE_ENGINE_BILLBOARD_RENDERER_H
1111

12+
#include <utils/Colour.h>
13+
1214
#include "../Core.h"
1315
#include "../model/Model.h"
1416

@@ -24,7 +26,7 @@ class BillboardRenderer
2426
void Initialise(const String& globalDataAttributeName, const uint64_t& globalDataSize);
2527
void Destroy();
2628

27-
void DrawBillboard(const Vec3& position, const Vec2& scale, const Vec4& colour);
29+
void DrawBillboard(const Vec3& position, const Vec2& scale, const IColour& colour);
2830

2931
void Render(Vulkan::CommandBuffer& commandBuffer,
3032
const uint64_t& globalDataSize,
@@ -39,7 +41,7 @@ class BillboardRenderer
3941
struct BillboardVertex
4042
{
4143
Vec3 position;
42-
Vec4 colour;
44+
FColour colour;
4345
};
4446

4547
struct BillboardUBO

engine/render/renderer/renderer/DebugRenderer3D.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@ void DebugRenderer3D::RecreateMaterials()
4747
}
4848

4949
// Wire primitives
50-
void DebugRenderer3D::DrawLine(const Vec3& origin, const Vec3& destination, const Vec4& colour)
50+
void DebugRenderer3D::DrawLine(const Vec3& origin, const Vec3& destination, const IColour& colour)
5151
{
52-
lines.Append({origin, colour});
53-
lines.Append({destination, colour});
52+
auto fColour = ToFColour(colour);
53+
lines.Append({origin, fColour});
54+
lines.Append({destination, fColour});
5455
}
5556

5657
void DebugRenderer3D::Flush()

engine/render/renderer/renderer/DebugRenderer3D.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ class DebugRenderer3D
2525
void Destroy();
2626

2727
// Wire primitives
28-
void DrawLine(const Siege::Vec3& origin,
29-
const Siege::Vec3& destination,
30-
const Siege::Vec4& colour);
28+
void DrawLine(const Vec3& origin, const Vec3& destination, const IColour& colour);
29+
void DrawCube(const Vec3& position, const Vec3& rotation, const Vec3& scale);
3130

3231
void Render(Vulkan::CommandBuffer& commandBuffer,
3332
const uint64_t& globalDataSize,
@@ -42,7 +41,7 @@ class DebugRenderer3D
4241
struct LineVertex
4342
{
4443
Vec3 position;
45-
Vec4 colour;
44+
FColour colour;
4645
};
4746

4847
void RenderLines(Vulkan::CommandBuffer& commandBuffer,

engine/render/renderer/renderer/LightRenderer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ void LightRenderer::Destroy()
3939

4040
void LightRenderer::DrawPointLight(const Vec3& position,
4141
float radius,
42-
const Vec4& colour,
43-
const Vec4& ambientColor)
42+
const IColour& colour,
43+
const IColour& ambientColor)
4444
{
4545
pointLightVertices.Append({1.f, 1.f});
4646
pointLightVertices.Append({1.f, -1.f});

engine/render/renderer/renderer/LightRenderer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ class LightRenderer
2424

2525
void DrawPointLight(const Vec3& position,
2626
float radius,
27-
const Vec4& colour,
28-
const Vec4& ambientColor);
27+
const IColour& colour,
28+
const IColour& ambientColor);
2929

3030
void Render(Vulkan::CommandBuffer& commandBuffer,
3131
const uint64_t& globalDataSize,

0 commit comments

Comments
 (0)