From bb693756b9aace889f806a768b54655023d163ab Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 9 Jan 2024 20:17:55 +0000 Subject: Add the Illuminator (type) and Light (instance) classes --- game/scenary/illuminator.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 game/scenary/illuminator.h (limited to 'game/scenary/illuminator.h') diff --git a/game/scenary/illuminator.h b/game/scenary/illuminator.h new file mode 100644 index 0000000..db9acfb --- /dev/null +++ b/game/scenary/illuminator.h @@ -0,0 +1,26 @@ +#pragma once + +#include "assetFactory/asset.h" +#include "gfx/gl/instanceVertices.h" +#include "gfx/renderable.h" + +class SceneShader; +class Location; +class Texture; + +class Illuminator : public Asset, public Renderable, public StdTypeDefs { + Mesh::Ptr bodyMesh; + std::shared_ptr texture; + glVertexArray instanceVAO; + +public: + using LocationVertex = std::pair; + mutable InstanceVertices instances; + void render(const SceneShader &) const override; + void lights(const SceneShader &) const override; + +protected: + friend Persistence::SelectionPtrBase>; + bool persist(Persistence::PersistenceStore & store) override; + void postLoad() override; +}; -- cgit v1.2.3 From 8740d30b01f6c12e2fcea0450df73736cd17dc87 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 10 Jan 2024 01:10:44 +0000 Subject: Add spot light definition, loader, and rendering Rendering is untested, data is passed to whatever GL program is currently active. --- game/scenary/illuminator.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'game/scenary/illuminator.h') diff --git a/game/scenary/illuminator.h b/game/scenary/illuminator.h index db9acfb..99b87eb 100644 --- a/game/scenary/illuminator.h +++ b/game/scenary/illuminator.h @@ -11,11 +11,27 @@ class Texture; class Illuminator : public Asset, public Renderable, public StdTypeDefs { Mesh::Ptr bodyMesh; std::shared_ptr texture; - glVertexArray instanceVAO; + glVertexArray instanceVAO, instancesSpotLightVAO; + +public: + struct SpotLightVertex { + RelativePosition3D position; + Direction3D direction; + RGB colour; + RelativeDistance kq; + Angle arc; + }; + + struct SpotLight : Persistence::Persistable, SpotLightVertex, StdTypeDefs { + private: + friend Persistence::SelectionPtrBase>; + bool persist(Persistence::PersistenceStore & store) override; + }; public: using LocationVertex = std::pair; mutable InstanceVertices instances; + mutable InstanceVertices instancesSpotLight; void render(const SceneShader &) const override; void lights(const SceneShader &) const override; @@ -23,4 +39,7 @@ protected: friend Persistence::SelectionPtrBase>; bool persist(Persistence::PersistenceStore & store) override; void postLoad() override; + + std::vector spotLight; + std::vector::InstanceProxy> spotLightInstances; }; -- cgit v1.2.3 From 51eb25ea0f1373ca0442b02049406af38eae3b33 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 12 Jan 2024 19:35:58 +0000 Subject: Add model support for point lights Still invokes non-instanced point light shader --- game/scenary/illuminator.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'game/scenary/illuminator.h') diff --git a/game/scenary/illuminator.h b/game/scenary/illuminator.h index 99b87eb..a2b287d 100644 --- a/game/scenary/illuminator.h +++ b/game/scenary/illuminator.h @@ -11,7 +11,7 @@ class Texture; class Illuminator : public Asset, public Renderable, public StdTypeDefs { Mesh::Ptr bodyMesh; std::shared_ptr texture; - glVertexArray instanceVAO, instancesSpotLightVAO; + glVertexArray instanceVAO, instancesSpotLightVAO, instancesPointLightVAO; public: struct SpotLightVertex { @@ -22,16 +22,29 @@ public: Angle arc; }; + struct PointLightVertex { + RelativePosition3D position; + RGB colour; + RelativeDistance kq; + }; + struct SpotLight : Persistence::Persistable, SpotLightVertex, StdTypeDefs { private: friend Persistence::SelectionPtrBase>; bool persist(Persistence::PersistenceStore & store) override; }; + struct PointLight : Persistence::Persistable, PointLightVertex, StdTypeDefs { + private: + friend Persistence::SelectionPtrBase>; + bool persist(Persistence::PersistenceStore & store) override; + }; + public: using LocationVertex = std::pair; mutable InstanceVertices instances; mutable InstanceVertices instancesSpotLight; + mutable InstanceVertices instancesPointLight; void render(const SceneShader &) const override; void lights(const SceneShader &) const override; @@ -41,5 +54,7 @@ protected: void postLoad() override; std::vector spotLight; + std::vector pointLight; std::vector::InstanceProxy> spotLightInstances; + std::vector::InstanceProxy> pointLightInstances; }; -- cgit v1.2.3 From e942bec77c77201ed50a2f6ecc77f3279a6bb4df Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 13 Jan 2024 10:32:47 +0000 Subject: Merge common parts of light type vertices --- game/scenary/illuminator.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'game/scenary/illuminator.h') diff --git a/game/scenary/illuminator.h b/game/scenary/illuminator.h index a2b287d..1c493b2 100644 --- a/game/scenary/illuminator.h +++ b/game/scenary/illuminator.h @@ -14,20 +14,19 @@ class Illuminator : public Asset, public Renderable, public StdTypeDefs { private: friend Persistence::SelectionPtrBase>; -- cgit v1.2.3 From e31f69ec26f5c128ae421eb418628ebcdfafb8f3 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 13 Jan 2024 11:23:12 +0000 Subject: Only create VAOs for the light type(s) in use --- game/scenary/illuminator.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'game/scenary/illuminator.h') diff --git a/game/scenary/illuminator.h b/game/scenary/illuminator.h index 1c493b2..893e5c7 100644 --- a/game/scenary/illuminator.h +++ b/game/scenary/illuminator.h @@ -11,7 +11,8 @@ class Texture; class Illuminator : public Asset, public Renderable, public StdTypeDefs { Mesh::Ptr bodyMesh; std::shared_ptr texture; - glVertexArray instanceVAO, instancesSpotLightVAO, instancesPointLightVAO; + glVertexArray instanceVAO; + std::optional instancesSpotLightVAO, instancesPointLightVAO; public: struct LightCommonVertex { -- cgit v1.2.3