diff --git a/engine/inc/renderer/3d/pipeline/dynamic/bag/dynpip_bag.hpp b/engine/inc/renderer/3d/pipeline/dynamic/bag/dynpip_bag.hpp index 1a9cfc9..0b71e26 100644 --- a/engine/inc/renderer/3d/pipeline/dynamic/bag/dynpip_bag.hpp +++ b/engine/inc/renderer/3d/pipeline/dynamic/bag/dynpip_bag.hpp @@ -11,9 +11,10 @@ #pragma once #include "math/vec4.hpp" -#include "renderer/3d/pipeline/shared/bag/pipeline_lighting_bag.hpp" + #include "renderer/3d/pipeline/shared/bag/pipeline_info_bag.hpp" #include "./dynpip_color_bag.hpp" +#include "./dynpip_lighting_bag.hpp" #include "./dynpip_texture_bag.hpp" #include "renderer/core/texture/models/texture.hpp" @@ -35,17 +36,27 @@ class DynPipBag { /** Mandatory. Object color(s). */ DynPipColorBag* color; - /** Mandatory. Vertex count. */ + /** Mandatory. Vertex count per frame. */ u32 count; - /** Mandatory. Vertices. */ - Vec4* vertices; + /** Mandatory. From (frame) vertices */ + Vec4* verticesFrom; + + /** Mandatory. To (frame) vertices */ + Vec4* verticesTo; + + /** + * Mandatory. + * State of animation interpolation + * (between from and to) + */ + float interpolation; /** Optional. Texture coordinates and image. */ DynPipTextureBag* texture; /** Optional. Object lighting. */ - PipelineLightingBag* lighting; + DynPipLightingBag* lighting; void print() const; void print(const char* name) const; diff --git a/engine/inc/renderer/3d/pipeline/dynamic/bag/dynpip_color_bag.hpp b/engine/inc/renderer/3d/pipeline/dynamic/bag/dynpip_color_bag.hpp index 5ffeb32..39f42c7 100644 --- a/engine/inc/renderer/3d/pipeline/dynamic/bag/dynpip_color_bag.hpp +++ b/engine/inc/renderer/3d/pipeline/dynamic/bag/dynpip_color_bag.hpp @@ -23,10 +23,12 @@ class DynPipColorBag { ~DynPipColorBag(); /** Optional. Single color for all vertices. */ - Color* single; + Color* singleFrom; + Color* singleTo; /** Optional. Color per vertex. */ - Color* many; + Color* manyFrom; + Color* manyTo; }; } // namespace Tyra diff --git a/engine/inc/renderer/3d/pipeline/dynamic/bag/dynpip_lighting_bag.hpp b/engine/inc/renderer/3d/pipeline/dynamic/bag/dynpip_lighting_bag.hpp new file mode 100644 index 0000000..6f1797f --- /dev/null +++ b/engine/inc/renderer/3d/pipeline/dynamic/bag/dynpip_lighting_bag.hpp @@ -0,0 +1,34 @@ +/* +# ______ ____ ___ +# | \/ ____| |___| +# | | | \ | | +#----------------------------------------------------------------------- +# Copyright 2022, tyra - https://github.com/h4570/tyra +# Licenced under Apache License 2.0 +# Sandro Sobczyński +*/ + +#pragma once + +#include "math/vec4.hpp" +#include "renderer/3d/pipeline/shared/bag/pipeline_dir_lights_bag.hpp" + +namespace Tyra { + +class DynPipLightingBag { + public: + DynPipLightingBag(); + ~DynPipLightingBag(); + + /** Mandatory. Model matrix for lights. */ + M4x4* lightMatrix; + + /** Mandatory. Lighting normals per vertex. */ + Vec4* normalsFrom; + Vec4* normalsTo; + + /** Mandatory. Directional lights */ + PipelineDirLightsBag* dirLights; +}; + +} // namespace Tyra diff --git a/engine/inc/renderer/3d/pipeline/dynamic/bag/dynpip_texture_bag.hpp b/engine/inc/renderer/3d/pipeline/dynamic/bag/dynpip_texture_bag.hpp index cc3a6bf..eb2d246 100644 --- a/engine/inc/renderer/3d/pipeline/dynamic/bag/dynpip_texture_bag.hpp +++ b/engine/inc/renderer/3d/pipeline/dynamic/bag/dynpip_texture_bag.hpp @@ -21,7 +21,8 @@ class DynPipTextureBag { ~DynPipTextureBag(); /** Mandatory. Texture coordinates per vertex. */ - Vec4* coordinates; + Vec4* coordinatesFrom; + Vec4* coordinatesTo; /** Mandatory. Texture image. */ Texture* texture; diff --git a/engine/inc/renderer/3d/pipeline/dynamic/dynamic_pipeline.hpp b/engine/inc/renderer/3d/pipeline/dynamic/dynamic_pipeline.hpp index d86ecdb..118141d 100644 --- a/engine/inc/renderer/3d/pipeline/dynamic/dynamic_pipeline.hpp +++ b/engine/inc/renderer/3d/pipeline/dynamic/dynamic_pipeline.hpp @@ -27,10 +27,6 @@ class DynamicPipeline : public Renderer3DPipeline { void onUse(); - /** - * Render 3D data via "meshes". - * This render() method is a bridge to core.render() method. - */ void render(DynamicMesh* mesh, const DynPipOptions* options = nullptr); }; diff --git a/engine/inc/renderer/3d/pipeline/shared/bag/pipeline_lighting_bag.hpp b/engine/inc/renderer/3d/pipeline/shared/bag/pipeline_dir_lights_bag.hpp similarity index 83% rename from engine/inc/renderer/3d/pipeline/shared/bag/pipeline_lighting_bag.hpp rename to engine/inc/renderer/3d/pipeline/shared/bag/pipeline_dir_lights_bag.hpp index ae75e8e..7531688 100644 --- a/engine/inc/renderer/3d/pipeline/shared/bag/pipeline_lighting_bag.hpp +++ b/engine/inc/renderer/3d/pipeline/shared/bag/pipeline_dir_lights_bag.hpp @@ -16,15 +16,12 @@ namespace Tyra { -enum PipelineLightingBagMode { Auto, Manual }; +enum PipelineDirLightsBagMode { Auto, Manual }; -class PipelineLightingBag { +class PipelineDirLightsBag { public: - explicit PipelineLightingBag(const bool& manual = false); - ~PipelineLightingBag(); - - Vec4* normals; - M4x4* lightMatrix; + explicit PipelineDirLightsBag(const bool& manual = false); + ~PipelineDirLightsBag(); void setAmbientColor(const Color& color); void setDirectionalLightColors(Color* colors, const u8& count); @@ -47,7 +44,7 @@ class PipelineLightingBag { void deallocate(); void forceDeallocate(); u8 isAllocated; - PipelineLightingBagMode mode; + PipelineDirLightsBagMode mode; Vec4* lightColors; Vec4* lightDirections; diff --git a/engine/inc/renderer/3d/pipeline/static/core/bag/stapip_bag.hpp b/engine/inc/renderer/3d/pipeline/static/core/bag/stapip_bag.hpp index a4dcff0..a89d93c 100644 --- a/engine/inc/renderer/3d/pipeline/static/core/bag/stapip_bag.hpp +++ b/engine/inc/renderer/3d/pipeline/static/core/bag/stapip_bag.hpp @@ -11,9 +11,9 @@ #pragma once #include "math/vec4.hpp" -#include "renderer/3d/pipeline/shared/bag/pipeline_lighting_bag.hpp" #include "renderer/3d/pipeline/shared/bag/pipeline_info_bag.hpp" #include "./stapip_color_bag.hpp" +#include "./stapip_lighting_bag.hpp" #include "./stapip_texture_bag.hpp" #include "renderer/core/texture/models/texture.hpp" #include "./packaging/stapip_bag_packages_bbox.hpp" @@ -46,7 +46,7 @@ class StaPipBag { StaPipTextureBag* texture; /** Optional. Object lighting. */ - PipelineLightingBag* lighting; + StaPipLightingBag* lighting; /** * @param maxVertCount This parameter is available in renderer API. diff --git a/engine/inc/renderer/3d/pipeline/static/core/bag/stapip_lighting_bag.hpp b/engine/inc/renderer/3d/pipeline/static/core/bag/stapip_lighting_bag.hpp new file mode 100644 index 0000000..46f3223 --- /dev/null +++ b/engine/inc/renderer/3d/pipeline/static/core/bag/stapip_lighting_bag.hpp @@ -0,0 +1,33 @@ +/* +# ______ ____ ___ +# | \/ ____| |___| +# | | | \ | | +#----------------------------------------------------------------------- +# Copyright 2022, tyra - https://github.com/h4570/tyra +# Licenced under Apache License 2.0 +# Sandro Sobczyński +*/ + +#pragma once + +#include "math/vec4.hpp" +#include "renderer/3d/pipeline/shared/bag/pipeline_dir_lights_bag.hpp" + +namespace Tyra { + +class StaPipLightingBag { + public: + StaPipLightingBag(); + ~StaPipLightingBag(); + + /** Mandatory. Model matrix for lights. */ + M4x4* lightMatrix; + + /** Mandatory. Lighting normals per vertex. */ + Vec4* normals; + + /** Mandatory. Directional lights */ + PipelineDirLightsBag* dirLights; +}; + +} // namespace Tyra diff --git a/engine/inc/renderer/3d/pipeline/static/static_pipeline.hpp b/engine/inc/renderer/3d/pipeline/static/static_pipeline.hpp index a384218..c35a857 100644 --- a/engine/inc/renderer/3d/pipeline/static/static_pipeline.hpp +++ b/engine/inc/renderer/3d/pipeline/static/static_pipeline.hpp @@ -29,7 +29,7 @@ class StaticPipeline : public Renderer3DPipeline { void onUse(); /** - * Render 3D data via "meshes". + * Render 3D via "meshes". * This render() method is a bridge to core.render() method. */ void render(DynamicMesh* mesh, const StaPipOptions* options = nullptr); @@ -47,10 +47,10 @@ class StaticPipeline : public Renderer3DPipeline { MeshFrame* frameFrom, MeshFrame* frameTo) const; StaPipTextureBag* getTextureBag(DynamicMesh* mesh, MeshMaterial* material, MeshFrame* frameFrom, MeshFrame* frameTo); - PipelineLightingBag* getLightingBag(DynamicMesh* mesh, MeshMaterial* material, - M4x4* model, MeshFrame* frameFrom, - MeshFrame* frameTo, - const StaPipOptions* options) const; + StaPipLightingBag* getLightingBag(DynamicMesh* mesh, MeshMaterial* material, + M4x4* model, MeshFrame* frameFrom, + MeshFrame* frameTo, + const StaPipOptions* options) const; void deallocDrawBags(StaPipBag* bag, MeshMaterial* material) const; void setLightingColorsCache(StaPipLightingOptions* lightingOptions); diff --git a/engine/src/renderer/3d/pipeline/dynamic/bag/dynpip_bag.cpp b/engine/src/renderer/3d/pipeline/dynamic/bag/dynpip_bag.cpp index 52dfab3..a840cfe 100644 --- a/engine/src/renderer/3d/pipeline/dynamic/bag/dynpip_bag.cpp +++ b/engine/src/renderer/3d/pipeline/dynamic/bag/dynpip_bag.cpp @@ -43,8 +43,10 @@ std::string DynPipBag::getPrint(const char* name) const { res << std::fixed << std::setprecision(4); res << std::endl; res << "Count: " << count << ", " << std::endl; - res << "Vertices present: " << (vertices != nullptr ? "Yes" : "No") << ", " - << std::endl; + res << "Vertices from present: " << (verticesFrom != nullptr ? "Yes" : "No") + << ", " << std::endl; + res << "Vertices to present: " << (verticesTo != nullptr ? "Yes" : "No") + << ", " << std::endl; res << "Info present: " << (info != nullptr ? "Yes" : "No") << ", " << std::endl; res << "Color present: " << (color != nullptr ? "Yes" : "No") << ", " @@ -54,20 +56,32 @@ std::string DynPipBag::getPrint(const char* name) const { res << "Lighting present: " << (lighting != nullptr ? "Yes" : "No") << ", " << std::endl; res << "Model matrix: " << info->model->getPrint() << ", " << std::endl; - if (color->single) { - res << "Color single: " << color->single->getPrint() << ", " << std::endl; + if (color->singleFrom) { + res << "Color from single: " << color->singleFrom->getPrint() << ", " + << std::endl; + res << "Color to single: " << color->singleTo->getPrint() << ", " + << std::endl; } else { - res << "Color many: " << color->many->getPrint() << ", " << std::endl; + res << "Color many from present: " + << (color->manyFrom != nullptr ? "Yes" : "No") << ", " << std::endl; + res << "Color many to present: " + << (color->manyTo != nullptr ? "Yes" : "No") << ", " << std::endl; } if (texture) { - res << "Texture coords present: " - << (texture->coordinates != nullptr ? "Yes" : "No") << ", " + res << "Texture coords from present: " + << (texture->coordinatesFrom != nullptr ? "Yes" : "No") << ", " + << std::endl; + res << "Texture coords to present: " + << (texture->coordinatesTo != nullptr ? "Yes" : "No") << ", " << std::endl; res << "Texture: " << texture->texture->getPrint() << ", " << std::endl; } + if (lighting) { - res << "Lighting normals present: " << (lighting->normals ? "Yes" : "No") - << ", " << std::endl; + res << "Lighting normals from present: " + << (lighting->normalsFrom ? "Yes" : "No") << ", " << std::endl; + res << "Lighting normals to present: " + << (lighting->normalsTo ? "Yes" : "No") << ", " << std::endl; res << "Lighting matrix: " << lighting->lightMatrix->getPrint() << ", " << std::endl; } diff --git a/engine/src/renderer/3d/pipeline/dynamic/bag/dynpip_color_bag.cpp b/engine/src/renderer/3d/pipeline/dynamic/bag/dynpip_color_bag.cpp index 18f43b2..d2031b9 100644 --- a/engine/src/renderer/3d/pipeline/dynamic/bag/dynpip_color_bag.cpp +++ b/engine/src/renderer/3d/pipeline/dynamic/bag/dynpip_color_bag.cpp @@ -13,8 +13,10 @@ namespace Tyra { DynPipColorBag::DynPipColorBag() { - single = nullptr; - many = nullptr; + singleFrom = nullptr; + singleTo = nullptr; + manyFrom = nullptr; + manyTo = nullptr; } DynPipColorBag::~DynPipColorBag() {} diff --git a/engine/src/renderer/3d/pipeline/dynamic/bag/dynpip_lighting_bag.cpp b/engine/src/renderer/3d/pipeline/dynamic/bag/dynpip_lighting_bag.cpp new file mode 100644 index 0000000..05750eb --- /dev/null +++ b/engine/src/renderer/3d/pipeline/dynamic/bag/dynpip_lighting_bag.cpp @@ -0,0 +1,24 @@ +/* +# ______ ____ ___ +# | \/ ____| |___| +# | | | \ | | +#----------------------------------------------------------------------- +# Copyright 2022, tyra - https://github.com/h4570/tyra +# Licenced under Apache License 2.0 +# Sandro Sobczyński +*/ + +#include "renderer/3d/pipeline/dynamic/bag/dynpip_lighting_bag.hpp" + +namespace Tyra { + +DynPipLightingBag::DynPipLightingBag() { + lightMatrix = nullptr; + normalsFrom = nullptr; + normalsTo = nullptr; + dirLights = nullptr; +} + +DynPipLightingBag::~DynPipLightingBag() {} + +} // namespace Tyra diff --git a/engine/src/renderer/3d/pipeline/dynamic/bag/dynpip_texture_bag.cpp b/engine/src/renderer/3d/pipeline/dynamic/bag/dynpip_texture_bag.cpp index d5c7f7e..d755d54 100644 --- a/engine/src/renderer/3d/pipeline/dynamic/bag/dynpip_texture_bag.cpp +++ b/engine/src/renderer/3d/pipeline/dynamic/bag/dynpip_texture_bag.cpp @@ -13,7 +13,8 @@ namespace Tyra { DynPipTextureBag::DynPipTextureBag() { - coordinates = nullptr; + coordinatesFrom = nullptr; + coordinatesTo = nullptr; texture = nullptr; } diff --git a/engine/src/renderer/3d/pipeline/shared/bag/pipeline_lighting_bag.cpp b/engine/src/renderer/3d/pipeline/shared/bag/pipeline_dir_lights_bag.cpp similarity index 64% rename from engine/src/renderer/3d/pipeline/shared/bag/pipeline_lighting_bag.cpp rename to engine/src/renderer/3d/pipeline/shared/bag/pipeline_dir_lights_bag.cpp index b32a500..0638810 100644 --- a/engine/src/renderer/3d/pipeline/shared/bag/pipeline_lighting_bag.cpp +++ b/engine/src/renderer/3d/pipeline/shared/bag/pipeline_dir_lights_bag.cpp @@ -9,15 +9,13 @@ */ #include "debug/debug.hpp" -#include "renderer/3d/pipeline/shared/bag/pipeline_lighting_bag.hpp" +#include "renderer/3d/pipeline/shared/bag/pipeline_dir_lights_bag.hpp" namespace Tyra { -PipelineLightingBag::PipelineLightingBag(const bool& manual) { +PipelineDirLightsBag::PipelineDirLightsBag(const bool& manual) { isAllocated = false; mode = Auto; - normals = nullptr; - lightMatrix = nullptr; lightColors = nullptr; lightDirections = nullptr; if (manual) { @@ -27,33 +25,33 @@ PipelineLightingBag::PipelineLightingBag(const bool& manual) { } } -PipelineLightingBag::~PipelineLightingBag() { deallocate(); } +PipelineDirLightsBag::~PipelineDirLightsBag() { deallocate(); } -void PipelineLightingBag::setAmbientColor(const Color& color) { +void PipelineDirLightsBag::setAmbientColor(const Color& color) { TYRA_ASSERT(mode != Manual, "Ambient color cannot be set in manual mode"); lightColors[3].set(reinterpret_cast(color)); } -void PipelineLightingBag::setDirectionalLightColors(Color* colors, - const u8& count) { +void PipelineDirLightsBag::setDirectionalLightColors(Color* colors, + const u8& count) { for (u8 i = 0; i < count; i++) setDirectionalLightColor(colors[i], i); } -void PipelineLightingBag::setDirectionalLightDirections(Vec4* directions, - const u8& count) { +void PipelineDirLightsBag::setDirectionalLightDirections(Vec4* directions, + const u8& count) { for (u8 i = 0; i < count; i++) setDirectionalLightDirection(directions[i], i); } -void PipelineLightingBag::setDirectionalLightColor(const Color& color, - const u8& index) { +void PipelineDirLightsBag::setDirectionalLightColor(const Color& color, + const u8& index) { TYRA_ASSERT(mode != Manual, "Directional lights cannot be set in manual mode"); TYRA_ASSERT(index < 3, "There are max 3 directional lights"); lightColors[index].set(reinterpret_cast(color)); } -void PipelineLightingBag::setDirectionalLightDirection(const Vec4& direction, - const u8& index) { +void PipelineDirLightsBag::setDirectionalLightDirection(const Vec4& direction, + const u8& index) { TYRA_ASSERT(mode != Manual, "Directional lights cannot be set in manual mode"); TYRA_ASSERT(index < 3, "There are max 3 directional lights"); @@ -61,19 +59,19 @@ void PipelineLightingBag::setDirectionalLightDirection(const Vec4& direction, lightDirections[index].set(direction); } -void PipelineLightingBag::setLightsManually(Vec4* colors, Vec4* directions) { +void PipelineDirLightsBag::setLightsManually(Vec4* colors, Vec4* directions) { deallocate(); lightColors = colors; lightDirections = directions; mode = Manual; } -void PipelineLightingBag::disableManualMode() { +void PipelineDirLightsBag::disableManualMode() { allocate(); mode = Auto; } -void PipelineLightingBag::allocate() { +void PipelineDirLightsBag::allocate() { if (isAllocated) return; lightColors = new Vec4[4]; @@ -92,27 +90,27 @@ void PipelineLightingBag::allocate() { isAllocated = true; } -void PipelineLightingBag::deallocate() { +void PipelineDirLightsBag::deallocate() { if (!isAllocated) return; forceDeallocate(); } -void PipelineLightingBag::forceDeallocate() { +void PipelineDirLightsBag::forceDeallocate() { forceDeallocateColors(); forceDeallocateDirections(); isAllocated = false; } -void PipelineLightingBag::forceDeallocateColors() { +void PipelineDirLightsBag::forceDeallocateColors() { if (lightColors != nullptr) { delete[] lightColors; lightColors = nullptr; } } -void PipelineLightingBag::forceDeallocateDirections() { +void PipelineDirLightsBag::forceDeallocateDirections() { if (lightDirections != nullptr) { delete[] lightDirections; lightDirections = nullptr; diff --git a/engine/src/renderer/3d/pipeline/static/core/bag/stapip_bag.cpp b/engine/src/renderer/3d/pipeline/static/core/bag/stapip_bag.cpp index fe989fd..25830d8 100644 --- a/engine/src/renderer/3d/pipeline/static/core/bag/stapip_bag.cpp +++ b/engine/src/renderer/3d/pipeline/static/core/bag/stapip_bag.cpp @@ -63,7 +63,8 @@ std::string StaPipBag::getPrint(const char* name) const { if (color->single) { res << "Color single: " << color->single->getPrint() << ", " << std::endl; } else { - res << "Color many: " << color->many->getPrint() << ", " << std::endl; + res << "Color many present: " << (color->many != nullptr ? "Yes" : "No") + << ", " << std::endl; } if (texture) { res << "Texture coords present: " diff --git a/engine/src/renderer/3d/pipeline/static/core/bag/stapip_lighting_bag.cpp b/engine/src/renderer/3d/pipeline/static/core/bag/stapip_lighting_bag.cpp new file mode 100644 index 0000000..8312d8e --- /dev/null +++ b/engine/src/renderer/3d/pipeline/static/core/bag/stapip_lighting_bag.cpp @@ -0,0 +1,23 @@ +/* +# ______ ____ ___ +# | \/ ____| |___| +# | | | \ | | +#----------------------------------------------------------------------- +# Copyright 2022, tyra - https://github.com/h4570/tyra +# Licenced under Apache License 2.0 +# Sandro Sobczyński +*/ + +#include "renderer/3d/pipeline/static/core/bag/stapip_lighting_bag.hpp" + +namespace Tyra { + +StaPipLightingBag::StaPipLightingBag() { + lightMatrix = nullptr; + normals = nullptr; + dirLights = nullptr; +} + +StaPipLightingBag::~StaPipLightingBag() {} + +} // namespace Tyra diff --git a/engine/src/renderer/3d/pipeline/static/core/stapip_qbuffer_renderer.cpp b/engine/src/renderer/3d/pipeline/static/core/stapip_qbuffer_renderer.cpp index 195b295..389b959 100644 --- a/engine/src/renderer/3d/pipeline/static/core/stapip_qbuffer_renderer.cpp +++ b/engine/src/renderer/3d/pipeline/static/core/stapip_qbuffer_renderer.cpp @@ -91,12 +91,13 @@ void StaPipQBufferRenderer::sendObjectData( packet2_utils_vu_add_unpack_data(objectDataPacket, VU1_LIGHTS_MATRIX_ADDR, bag->lighting->lightMatrix, 3, false); - packet2_utils_vu_add_unpack_data(objectDataPacket, VU1_LIGHTS_DIRS_ADDR, - bag->lighting->getLightDirections(), 3, - false); + packet2_utils_vu_add_unpack_data( + objectDataPacket, VU1_LIGHTS_DIRS_ADDR, + bag->lighting->dirLights->getLightDirections(), 3, false); packet2_utils_vu_add_unpack_data(objectDataPacket, VU1_LIGHTS_COLORS_ADDR, - bag->lighting->getLightColors(), 4, false); + bag->lighting->dirLights->getLightColors(), + 4, false); } u8 singleColorEnabled = bag->color->single != nullptr; diff --git a/engine/src/renderer/3d/pipeline/static/core/static_pipeline_core.cpp b/engine/src/renderer/3d/pipeline/static/core/static_pipeline_core.cpp index 5da1095..898afc2 100644 --- a/engine/src/renderer/3d/pipeline/static/core/static_pipeline_core.cpp +++ b/engine/src/renderer/3d/pipeline/static/core/static_pipeline_core.cpp @@ -65,8 +65,10 @@ void StaPipelineCore::render(StaPipBag* bag, StaPipBagPackagesBBox* bbox) { (!bag->color->many && bag->lighting), "Multicolor is not supported with lighting, please choose one!"); TYRA_ASSERT( - !bag->lighting || (bag->lighting->lightMatrix && bag->lighting->normals), - "If you want lighting, please provide light matrix and normals!"); + !bag->lighting || (bag->lighting->lightMatrix && bag->lighting->normals && + bag->lighting->dirLights), + "If you want lighting, please provide light matrix normals and dir " + "lights!"); TYRA_ASSERT( !bag->texture || (bag->texture->texture && bag->texture->coordinates), "If you want texture, please provide texture and coordinates!"); diff --git a/engine/src/renderer/3d/pipeline/static/static_pipeline.cpp b/engine/src/renderer/3d/pipeline/static/static_pipeline.cpp index 008dd5e..7f4bf1d 100644 --- a/engine/src/renderer/3d/pipeline/static/static_pipeline.cpp +++ b/engine/src/renderer/3d/pipeline/static/static_pipeline.cpp @@ -163,7 +163,7 @@ StaPipTextureBag* StaticPipeline::getTextureBag(DynamicMesh* mesh, return result; } -PipelineLightingBag* StaticPipeline::getLightingBag( +StaPipLightingBag* StaticPipeline::getLightingBag( DynamicMesh* mesh, MeshMaterial* material, M4x4* model, MeshFrame* frameFrom, MeshFrame* frameTo, const StaPipOptions* options) const { @@ -171,11 +171,14 @@ PipelineLightingBag* StaticPipeline::getLightingBag( options->lighting == nullptr) return nullptr; - auto* result = new PipelineLightingBag(true); + auto* result = new StaPipLightingBag(); + auto* dirLightsBag = new PipelineDirLightsBag(true); + result->dirLights = dirLightsBag; + result->lightMatrix = model; - result->setLightsManually(colorsCache, - options->lighting->directionalDirections); + result->dirLights->setLightsManually( + colorsCache, options->lighting->directionalDirections); result->normals = new Vec4[material->getFacesCount()]; @@ -215,6 +218,7 @@ void StaticPipeline::deallocDrawBags(StaPipBag* bag, if (bag->lighting) { delete[] bag->lighting->normals; + delete bag->lighting->dirLights; delete bag->lighting; }