From 4e0785754ece40095a2489f487f9306651ff9d97 Mon Sep 17 00:00:00 2001 From: h4570 Date: Tue, 19 Jul 2022 13:16:18 +0200 Subject: [PATCH] init of dynpip bag --- .../pipeline/dynamic/core/dynpip_qbuffer.hpp | 29 +++ .../core/programs/dynpip_vu1_shared_defines.h | 2 +- .../3d/pipeline/dynamic/dynamic_pipeline.hpp | 22 +- .../dynamic/{core => }/dynpip_options.hpp | 10 + .../pipeline/shared/bag/pipeline_info_bag.hpp | 3 +- .../pipeline_lighting_options.hpp} | 6 +- .../{bag => }/pipeline_shading_type.hpp | 4 +- .../3d/pipeline/static/stapip_options.hpp | 6 +- .../3d/pipeline/static/static_pipeline.hpp | 5 +- .../pipeline/dynamic/core/dynpip_qbuffer.cpp | 72 ++++++ .../core/programs/dynpip_td_vu1_program.cpp | 47 ++-- .../3d/pipeline/dynamic/dynamic_pipeline.cpp | 209 +++++++++++++++++- .../pipeline/shared/bag/pipeline_info_bag.cpp | 2 +- .../pipeline/static/core/stapip_qbuffer.cpp | 4 +- .../3d/pipeline/static/static_pipeline.cpp | 6 +- samples/h4570/inc/h4570.hpp | 2 + samples/h4570/src/h4570.cpp | 22 +- samples/wellinator/src/wellinator.cpp | 4 +- 18 files changed, 406 insertions(+), 49 deletions(-) rename engine/inc/renderer/3d/pipeline/dynamic/{core => }/dynpip_options.hpp (62%) rename engine/inc/renderer/3d/pipeline/{static/stapip_lighting_options.hpp => shared/pipeline_lighting_options.hpp} (89%) rename engine/inc/renderer/3d/pipeline/shared/{bag => }/pipeline_shading_type.hpp (85%) diff --git a/engine/inc/renderer/3d/pipeline/dynamic/core/dynpip_qbuffer.hpp b/engine/inc/renderer/3d/pipeline/dynamic/core/dynpip_qbuffer.hpp index 606ae99..192fc7a 100644 --- a/engine/inc/renderer/3d/pipeline/dynamic/core/dynpip_qbuffer.hpp +++ b/engine/inc/renderer/3d/pipeline/dynamic/core/dynpip_qbuffer.hpp @@ -10,12 +10,41 @@ #pragma once +#include "./bag/dynpip_bag.hpp" + namespace Tyra { class DynPipQBuffer { public: DynPipQBuffer(); ~DynPipQBuffer(); + + void setMaxVertCount(const u32& count); + + DynPipBag* bag; + + Vec4* verticesFrom; + Vec4* verticesTo; + + Vec4* stsFrom; + Vec4* stsTo; + + Vec4* colorsFrom; + Vec4* colorsTo; + + Vec4* normalsFrom; + Vec4* normalsTo; + + /** Size per frame */ + u32 size; + + void print() const; + void print(const char* name) const; + void print(const std::string& name) const { print(name.c_str()); } + std::string getPrint(const char* name = nullptr) const; + + private: + u32 maxVertCount; }; } // namespace Tyra diff --git a/engine/inc/renderer/3d/pipeline/dynamic/core/programs/dynpip_vu1_shared_defines.h b/engine/inc/renderer/3d/pipeline/dynamic/core/programs/dynpip_vu1_shared_defines.h index fab2116..1ff5468 100644 --- a/engine/inc/renderer/3d/pipeline/dynamic/core/programs/dynpip_vu1_shared_defines.h +++ b/engine/inc/renderer/3d/pipeline/dynamic/core/programs/dynpip_vu1_shared_defines.h @@ -21,4 +21,4 @@ // #define VU1_LAST_ITEM_ADDR 18 // Buffer data (xtop) -// #define VU1_VERT_DATA_ADDR 2 +#define VU1_VERT_DATA_ADDR 2 diff --git a/engine/inc/renderer/3d/pipeline/dynamic/dynamic_pipeline.hpp b/engine/inc/renderer/3d/pipeline/dynamic/dynamic_pipeline.hpp index da923bd..5ba6f94 100644 --- a/engine/inc/renderer/3d/pipeline/dynamic/dynamic_pipeline.hpp +++ b/engine/inc/renderer/3d/pipeline/dynamic/dynamic_pipeline.hpp @@ -12,7 +12,7 @@ #include #include "../renderer_3d_pipeline.hpp" -#include "./core/dynpip_options.hpp" +#include "./dynpip_options.hpp" #include "./core/dynpip_core.hpp" #include "renderer/core/renderer_core.hpp" #include "renderer/3d/mesh/dynamic/dynamic_mesh.hpp" @@ -35,6 +35,26 @@ class DynamicPipeline : public Renderer3DPipeline { * This render() method is a bridge to core.render() method. */ void render(DynamicMesh* mesh, const DynPipOptions* options = nullptr); + + private: + RendererCore* rendererCore; + Vec4* colorsCache; + + void addVertices(DynamicMesh* mesh, MeshMaterial* material, DynPipBag* bag, + MeshFrame* frameFrom, MeshFrame* frameTo) const; + PipelineInfoBag* getInfoBag(DynamicMesh* mesh, const DynPipOptions* options, + M4x4* model) const; + DynPipColorBag* getColorBag(DynamicMesh* mesh, MeshMaterial* material, + MeshFrame* frameFrom, MeshFrame* frameTo) const; + DynPipTextureBag* getTextureBag(DynamicMesh* mesh, MeshMaterial* material, + MeshFrame* frameFrom, MeshFrame* frameTo); + DynPipLightingBag* getLightingBag(DynamicMesh* mesh, MeshMaterial* material, + M4x4* model, MeshFrame* frameFrom, + MeshFrame* frameTo, + const DynPipOptions* options) const; + void deallocDrawBags(DynPipBag* bag, MeshMaterial* material) const; + + void setLightingColorsCache(PipelineLightingOptions* lightingOptions); }; } // namespace Tyra diff --git a/engine/inc/renderer/3d/pipeline/dynamic/core/dynpip_options.hpp b/engine/inc/renderer/3d/pipeline/dynamic/dynpip_options.hpp similarity index 62% rename from engine/inc/renderer/3d/pipeline/dynamic/core/dynpip_options.hpp rename to engine/inc/renderer/3d/pipeline/dynamic/dynpip_options.hpp index f355b0d..a3dcd96 100644 --- a/engine/inc/renderer/3d/pipeline/dynamic/core/dynpip_options.hpp +++ b/engine/inc/renderer/3d/pipeline/dynamic/dynpip_options.hpp @@ -10,12 +10,22 @@ #pragma once +#include "renderer/3d/pipeline/shared/pipeline_shading_type.hpp" +#include "../shared/pipeline_lighting_options.hpp" + namespace Tyra { class DynPipOptions { public: DynPipOptions() {} ~DynPipOptions() {} + + PipelineShadingType shadingType; + bool blendingEnabled; + bool antiAliasingEnabled; + + /** Optional */ + PipelineLightingOptions* lighting; }; } // namespace Tyra diff --git a/engine/inc/renderer/3d/pipeline/shared/bag/pipeline_info_bag.hpp b/engine/inc/renderer/3d/pipeline/shared/bag/pipeline_info_bag.hpp index 6a1f473..4a5e07c 100644 --- a/engine/inc/renderer/3d/pipeline/shared/bag/pipeline_info_bag.hpp +++ b/engine/inc/renderer/3d/pipeline/shared/bag/pipeline_info_bag.hpp @@ -13,7 +13,7 @@ #include #include "math/m4x4.hpp" #include "math/vec4.hpp" -#include "./pipeline_shading_type.hpp" +#include "../pipeline_shading_type.hpp" namespace Tyra { @@ -36,6 +36,7 @@ class PipelineInfoBag { * Full clip checks are slow, but they are * preventing visual artifacts, which can happen * for big 3D objects (or objects near camera eyes) + * Force enabled in dynamic pipe, because of efficiency. */ bool noFullClipChecks; }; diff --git a/engine/inc/renderer/3d/pipeline/static/stapip_lighting_options.hpp b/engine/inc/renderer/3d/pipeline/shared/pipeline_lighting_options.hpp similarity index 89% rename from engine/inc/renderer/3d/pipeline/static/stapip_lighting_options.hpp rename to engine/inc/renderer/3d/pipeline/shared/pipeline_lighting_options.hpp index 039e681..df8d484 100644 --- a/engine/inc/renderer/3d/pipeline/static/stapip_lighting_options.hpp +++ b/engine/inc/renderer/3d/pipeline/shared/pipeline_lighting_options.hpp @@ -15,10 +15,10 @@ namespace Tyra { -class StaPipLightingOptions { +class PipelineLightingOptions { public: - StaPipLightingOptions() {} - ~StaPipLightingOptions() {} + PipelineLightingOptions() {} + ~PipelineLightingOptions() {} /** * Mandatory. diff --git a/engine/inc/renderer/3d/pipeline/shared/bag/pipeline_shading_type.hpp b/engine/inc/renderer/3d/pipeline/shared/pipeline_shading_type.hpp similarity index 85% rename from engine/inc/renderer/3d/pipeline/shared/bag/pipeline_shading_type.hpp rename to engine/inc/renderer/3d/pipeline/shared/pipeline_shading_type.hpp index 441beee..9fa387f 100644 --- a/engine/inc/renderer/3d/pipeline/shared/bag/pipeline_shading_type.hpp +++ b/engine/inc/renderer/3d/pipeline/shared/pipeline_shading_type.hpp @@ -13,8 +13,8 @@ namespace Tyra { enum PipelineShadingType { - StaPipShadingFlat, - StaPipShadingGouraud, + TyraShadingFlat, + TyraShadingGouraud, }; } // namespace Tyra diff --git a/engine/inc/renderer/3d/pipeline/static/stapip_options.hpp b/engine/inc/renderer/3d/pipeline/static/stapip_options.hpp index 756389f..f1a4cf6 100644 --- a/engine/inc/renderer/3d/pipeline/static/stapip_options.hpp +++ b/engine/inc/renderer/3d/pipeline/static/stapip_options.hpp @@ -10,8 +10,8 @@ #pragma once -#include "renderer/3d/pipeline/shared/bag/pipeline_shading_type.hpp" -#include "./stapip_lighting_options.hpp" +#include "renderer/3d/pipeline/shared/pipeline_shading_type.hpp" +#include "../shared/pipeline_lighting_options.hpp" namespace Tyra { @@ -35,7 +35,7 @@ class StaPipOptions { bool noFullClipChecks; /** Optional */ - StaPipLightingOptions* lighting; + PipelineLightingOptions* lighting; }; } // 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 46b77db..09fa39f 100644 --- a/engine/inc/renderer/3d/pipeline/static/static_pipeline.hpp +++ b/engine/inc/renderer/3d/pipeline/static/static_pipeline.hpp @@ -12,10 +12,11 @@ #include #include "../renderer_3d_pipeline.hpp" -#include "./stapip_options.hpp" +#include "../shared/pipeline_lighting_options.hpp" #include "renderer/core/renderer_core.hpp" #include "renderer/3d/mesh/dynamic/dynamic_mesh.hpp" #include "./core/stapip_core.hpp" +#include "./stapip_options.hpp" namespace Tyra { @@ -54,7 +55,7 @@ class StaticPipeline : public Renderer3DPipeline { const StaPipOptions* options) const; void deallocDrawBags(StaPipBag* bag, MeshMaterial* material) const; - void setLightingColorsCache(StaPipLightingOptions* lightingOptions); + void setLightingColorsCache(PipelineLightingOptions* lightingOptions); }; } // namespace Tyra diff --git a/engine/src/renderer/3d/pipeline/dynamic/core/dynpip_qbuffer.cpp b/engine/src/renderer/3d/pipeline/dynamic/core/dynpip_qbuffer.cpp index 4136fe6..779d4e9 100644 --- a/engine/src/renderer/3d/pipeline/dynamic/core/dynpip_qbuffer.cpp +++ b/engine/src/renderer/3d/pipeline/dynamic/core/dynpip_qbuffer.cpp @@ -18,4 +18,76 @@ DynPipQBuffer::DynPipQBuffer() {} DynPipQBuffer::~DynPipQBuffer() {} +void DynPipQBuffer::setMaxVertCount(const u32& count) { maxVertCount = count; } + +void DynPipQBuffer::print() const { + auto text = getPrint(nullptr); + printf("%s\n", text.c_str()); +} + +void DynPipQBuffer::print(const char* name) const { + auto text = getPrint(name); + printf("%s\n", text.c_str()); +} + +std::string DynPipQBuffer::getPrint(const char* name) const { + std::stringstream res; + if (name) { + res << name << "("; + } else { + res << "DynPipQBuffer("; + } + res << std::fixed << std::setprecision(2); + res << std::endl; + res << "Size: " << static_cast(size) << std::endl; + + res << "Vertices from: " << std::endl; + for (u32 i = 0; i < size; i++) + res << i << ": " << verticesFrom[i].getPrint() << std::endl; + + res << "Vertices to: " << std::endl; + for (u32 i = 0; i < size; i++) + res << i << ": " << verticesTo[i].getPrint() << std::endl; + + if (bag->texture != nullptr) { + res << "STs from: " << std::endl; + for (u32 i = 0; i < size; i++) + res << i << ": " << stsFrom[i].getPrint() << std::endl; + + res << "STs to: " << std::endl; + for (u32 i = 0; i < size; i++) + res << i << ": " << stsTo[i].getPrint() << std::endl; + } + + if (bag->color->manyFrom != nullptr) { + res << "Colors from: " << std::endl; + for (u32 i = 0; i < size; i++) + res << i << ": " << colorsFrom[i].getPrint() << std::endl; + } + + if (bag->color->manyTo != nullptr) { + res << "Colors to: " << std::endl; + for (u32 i = 0; i < size; i++) + res << i << ": " << colorsTo[i].getPrint() << std::endl; + } + + if (bag->lighting != nullptr) { + res << "Normals from: " << std::endl; + for (u32 i = 0; i < size; i++) { + res << i << ": " << normalsFrom[i].getPrint() << std::endl; + } + + res << "Normals to: " << std::endl; + for (u32 i = 0; i < size; i++) { + res << i << ": " << normalsTo[i].getPrint(); + if (i < size - 1) { + res << std::endl; + } + } + } + + res << ")"; + return res.str(); +} + } // namespace Tyra diff --git a/engine/src/renderer/3d/pipeline/dynamic/core/programs/dynpip_td_vu1_program.cpp b/engine/src/renderer/3d/pipeline/dynamic/core/programs/dynpip_td_vu1_program.cpp index 84abba6..d437daa 100644 --- a/engine/src/renderer/3d/pipeline/dynamic/core/programs/dynpip_td_vu1_program.cpp +++ b/engine/src/renderer/3d/pipeline/dynamic/core/programs/dynpip_td_vu1_program.cpp @@ -31,28 +31,39 @@ std::string DynPipTDVU1Program::getStringName() const { void DynPipTDVU1Program::addProgramQBufferDataToPacket( packet2_t* packet, DynPipQBuffer* qbuffer) const { - // u32 addr = VU1_VERT_DATA_ADDR; + u32 addr = VU1_VERT_DATA_ADDR; - // // Add vertices - // packet2_utils_vu_add_unpack_data(packet, addr, qbuffer->vertices, - // qbuffer->size, true); - // addr += qbuffer->size; + // Add vertices + packet2_utils_vu_add_unpack_data(packet, addr, qbuffer->verticesFrom, + qbuffer->size, true); + addr += qbuffer->size; + packet2_utils_vu_add_unpack_data(packet, addr, qbuffer->verticesTo, + qbuffer->size, true); + addr += qbuffer->size; - // // Add sts - // packet2_utils_vu_add_unpack_data(packet, addr, qbuffer->sts, qbuffer->size, - // true); - // addr += qbuffer->size; + // Add sts + packet2_utils_vu_add_unpack_data(packet, addr, qbuffer->stsFrom, + qbuffer->size, true); + addr += qbuffer->size; + packet2_utils_vu_add_unpack_data(packet, addr, qbuffer->stsTo, qbuffer->size, + true); + addr += qbuffer->size; - // // Add normal - // packet2_utils_vu_add_unpack_data(packet, addr, qbuffer->normals, - // qbuffer->size, true); + // Add normal + packet2_utils_vu_add_unpack_data(packet, addr, qbuffer->normalsFrom, + qbuffer->size, true); + addr += qbuffer->size; + packet2_utils_vu_add_unpack_data(packet, addr, qbuffer->normalsTo, + qbuffer->size, true); + addr += qbuffer->size; - // // Add colors - // if (qbuffer->bag->color->single == nullptr) { - // addr += qbuffer->size; - // packet2_utils_vu_add_unpack_data(packet, addr, qbuffer->colors, - // qbuffer->size, true); - // } + // Add colors + if (qbuffer->bag->color->singleFrom == nullptr) { + packet2_utils_vu_add_unpack_data(packet, addr, qbuffer->colorsFrom, + qbuffer->size, true); + packet2_utils_vu_add_unpack_data(packet, addr, qbuffer->colorsTo, + qbuffer->size, true); + } } } // namespace Tyra diff --git a/engine/src/renderer/3d/pipeline/dynamic/dynamic_pipeline.cpp b/engine/src/renderer/3d/pipeline/dynamic/dynamic_pipeline.cpp index 8b74c7a..1744bcb 100644 --- a/engine/src/renderer/3d/pipeline/dynamic/dynamic_pipeline.cpp +++ b/engine/src/renderer/3d/pipeline/dynamic/dynamic_pipeline.cpp @@ -20,6 +20,213 @@ void DynamicPipeline::init(RendererCore* t_core) {} void DynamicPipeline::onUse() {} -void DynamicPipeline::render(DynamicMesh* mesh, const DynPipOptions* options) {} +void DynamicPipeline::render(DynamicMesh* mesh, const DynPipOptions* options) { + auto model = mesh->getModelMatrix(); + + MeshFrame* frameFrom = mesh->getFramesCount() > 0 + ? mesh->getFrame(mesh->getCurrentAnimationFrame()) + : mesh->getFrame(0); + + MeshFrame* frameTo = mesh->getFramesCount() > 0 + ? mesh->getFrame(mesh->getNextAnimationFrame()) + : nullptr; + + // auto* infoBag = getInfoBag(mesh, options, &model); + + if (options && options->lighting) setLightingColorsCache(options->lighting); + + for (u32 i = 0; i < mesh->getMaterialsCount(); i++) { + auto* material = mesh->getMaterial(i); + + // 2x bufory[maxVertCount*2] -> pętla po mniejszych częściach i czestsze + // rendery + + // TODO: Double buffering in future + // auto maxVertCount = core->renderer3D.getMaxVertCountByParams( + // material->isSingleColorActivated(), material->getNormalFaces(), + // material->getTextureCoordFaces()); + + DynPipBag bag; + addVertices(mesh, material, &bag, frameFrom, frameTo); + // bag.info = infoBag; + // bag.color = getColorBag(mesh, material, frameFrom, frameTo); + // bag.texture = getTextureBag(mesh, material, frameFrom, frameTo); + // bag.lighting = + // getLightingBag(mesh, material, &model, frameFrom, frameTo, options); + + core.render(&bag); + + // deallocDrawBags(&bag, material); + } + + // delete infoBag; // TODO +} + +void DynamicPipeline::addVertices(DynamicMesh* mesh, MeshMaterial* material, + DynPipBag* bag, MeshFrame* frameFrom, + MeshFrame* frameTo) const { + // bag->count = material->getFacesCount(); + // bag->vertices = new Vec4[bag->count]; + + // for (u32 i = 0; i < bag->count; i++) { + // auto& face = material->getVertexFaces()[i]; + // if (frameTo == nullptr) { + // bag->vertices[i] = frameFrom->getVertices()[face]; + // } else { + // Vec4::setLerp(&bag->vertices[i], frameFrom->getVertices()[face], + // frameTo->getVertices()[face], + // mesh->getAnimState().interpolation); + // } + // } +} + +PipelineInfoBag* DynamicPipeline::getInfoBag(DynamicMesh* mesh, + const DynPipOptions* options, + M4x4* model) const { + auto* result = new PipelineInfoBag(); + + if (options) { + result->antiAliasingEnabled = options->antiAliasingEnabled; + result->blendingEnabled = options->blendingEnabled; + result->shadingType = options->shadingType; + } else { + result->antiAliasingEnabled = false; + result->blendingEnabled = true; + result->shadingType = TyraShadingFlat; + } + + result->model = model; + + return result; +} + +DynPipColorBag* DynamicPipeline::getColorBag(DynamicMesh* mesh, + MeshMaterial* material, + MeshFrame* frameFrom, + MeshFrame* frameTo) const { + // auto* result = new DynPipColorBag(); + + // if (material->isSingleColorActivated()) { + // result->single = &material->singleColor; + // } else { + // result->many = new Color[material->getFacesCount()]; + + // for (u32 i = 0; i < material->getFacesCount(); i++) { + // auto& face = material->getColorFaces()[i]; + // if (frameTo == nullptr) { + // result->many[i] = frameFrom->getColors()[face]; + // } else { + // Vec4::setLerp( + // reinterpret_cast(&result->many[i]), + // reinterpret_cast(frameFrom->getColors()[face]), + // reinterpret_cast(frameTo->getColors()[face]), + // mesh->getAnimState().interpolation); + // } + // } + // } + + // return result; + return nullptr; // TODO +} + +DynPipTextureBag* DynamicPipeline::getTextureBag(DynamicMesh* mesh, + MeshMaterial* material, + MeshFrame* frameFrom, + MeshFrame* frameTo) { + // if (!material->getTextureCoordFaces()) return nullptr; + + // auto* result = new DynPipTextureBag(); + + // result->texture = + // rendererCore->texture.repository.getBySpriteOrMesh(material->getId()); + // TYRA_ASSERT(result->texture, "Texture for material id: ", + // material->getId(), + // " was not found in texture repository!"); + + // result->coordinates = new Vec4[material->getFacesCount()]; + + // for (u32 i = 0; i < material->getFacesCount(); i++) { + // auto& face = material->getTextureCoordFaces()[i]; + // if (frameTo == nullptr) { + // result->coordinates[i] = frameFrom->getTextureCoords()[face]; + // } else { + // Vec4::setLerp(&result->coordinates[i], + // frameFrom->getTextureCoords()[face], + // frameTo->getTextureCoords()[face], + // mesh->getAnimState().interpolation); + // } + // } + + // return result; + return nullptr; // TODO +} + +DynPipLightingBag* DynamicPipeline::getLightingBag( + DynamicMesh* mesh, MeshMaterial* material, M4x4* model, + MeshFrame* frameFrom, MeshFrame* frameTo, + const DynPipOptions* options) const { + // if (!material->getNormalFaces() || options == nullptr || + // options->lighting == nullptr) + // return nullptr; + + // auto* result = new DynPipLightingBag(); + // auto* dirLightsBag = new PipelineDirLightsBag(true); + // result->dirLights = dirLightsBag; + + // result->lightMatrix = model; + + // result->dirLights->setLightsManually( + // colorsCache, options->lighting->directionalDirections); + + // result->normals = new Vec4[material->getFacesCount()]; + + // for (u32 i = 0; i < material->getFacesCount(); i++) { + // auto& face = material->getNormalFaces()[i]; + // if (frameTo == nullptr) { + // result->normals[i] = frameFrom->getNormals()[face]; + // } else { + // Vec4::setLerp(&result->normals[i], frameFrom->getNormals()[face], + // frameTo->getNormals()[face], + // mesh->getAnimState().interpolation); + // } + // } + + // return result; + return nullptr; // TODO +} + +void DynamicPipeline::setLightingColorsCache( + PipelineLightingOptions* lightingOptions) { + for (int i = 0; i < 3; i++) { + colorsCache[i] = + reinterpret_cast(lightingOptions->directionalColors[i]); + } + colorsCache[3] = reinterpret_cast(*lightingOptions->ambientColor); +} + +void DynamicPipeline::deallocDrawBags(DynPipBag* bag, + MeshMaterial* material) const { + if (bag->color->manyFrom) { + delete[] bag->color->manyFrom; + delete[] bag->color->manyTo; + } + + if (bag->texture) { + delete[] bag->texture->coordinatesFrom; + delete[] bag->texture->coordinatesTo; + delete bag->texture; + } + + if (bag->lighting) { + delete[] bag->lighting->normalsFrom; + delete[] bag->lighting->normalsTo; + delete bag->lighting->dirLights; + delete bag->lighting; + } + + delete[] bag->verticesFrom; + delete[] bag->verticesTo; + delete bag->color; +} } // namespace Tyra diff --git a/engine/src/renderer/3d/pipeline/shared/bag/pipeline_info_bag.cpp b/engine/src/renderer/3d/pipeline/shared/bag/pipeline_info_bag.cpp index 2389618..e42b02e 100644 --- a/engine/src/renderer/3d/pipeline/shared/bag/pipeline_info_bag.cpp +++ b/engine/src/renderer/3d/pipeline/shared/bag/pipeline_info_bag.cpp @@ -13,7 +13,7 @@ namespace Tyra { PipelineInfoBag::PipelineInfoBag() { - shadingType = StaPipShadingFlat; + shadingType = TyraShadingFlat; blendingEnabled = true; antiAliasingEnabled = false; model = nullptr; diff --git a/engine/src/renderer/3d/pipeline/static/core/stapip_qbuffer.cpp b/engine/src/renderer/3d/pipeline/static/core/stapip_qbuffer.cpp index 56ef9ae..03825a6 100644 --- a/engine/src/renderer/3d/pipeline/static/core/stapip_qbuffer.cpp +++ b/engine/src/renderer/3d/pipeline/static/core/stapip_qbuffer.cpp @@ -228,13 +228,13 @@ std::string StaPipQBuffer::getPrint(const char* name) const { if (name) { res << name << "("; } else { - res << "Path1Buffer("; + res << "StaPipQBuffer("; } res << std::fixed << std::setprecision(2); res << std::endl; res << "Size: " << static_cast(size) << std::endl; - res << "Vectors: " << std::endl; + res << "Vertices: " << std::endl; for (u32 i = 0; i < size; i++) res << i << ": " << vertices[i].getPrint() << std::endl; diff --git a/engine/src/renderer/3d/pipeline/static/static_pipeline.cpp b/engine/src/renderer/3d/pipeline/static/static_pipeline.cpp index b568764..f54a603 100644 --- a/engine/src/renderer/3d/pipeline/static/static_pipeline.cpp +++ b/engine/src/renderer/3d/pipeline/static/static_pipeline.cpp @@ -36,7 +36,7 @@ void StaticPipeline::render(DynamicMesh* mesh, const StaPipOptions* options) { auto* infoBag = getInfoBag(mesh, options, &model); - if (options->lighting) setLightingColorsCache(options->lighting); + if (options && options->lighting) setLightingColorsCache(options->lighting); for (u32 i = 0; i < mesh->getMaterialsCount(); i++) { auto* material = mesh->getMaterial(i); @@ -96,7 +96,7 @@ PipelineInfoBag* StaticPipeline::getInfoBag(DynamicMesh* mesh, } else { result->antiAliasingEnabled = false; result->blendingEnabled = true; - result->shadingType = StaPipShadingFlat; + result->shadingType = TyraShadingFlat; result->noFullClipChecks = false; } @@ -197,7 +197,7 @@ StaPipLightingBag* StaticPipeline::getLightingBag( } void StaticPipeline::setLightingColorsCache( - StaPipLightingOptions* lightingOptions) { + PipelineLightingOptions* lightingOptions) { for (int i = 0; i < 3; i++) { colorsCache[i] = reinterpret_cast(lightingOptions->directionalColors[i]); diff --git a/samples/h4570/inc/h4570.hpp b/samples/h4570/inc/h4570.hpp index 8d62c75..de13f2d 100644 --- a/samples/h4570/inc/h4570.hpp +++ b/samples/h4570/inc/h4570.hpp @@ -14,6 +14,7 @@ #include #include "renderer/3d/pipeline/minecraft/minecraft_pipeline.hpp" #include "renderer/3d/pipeline/static/static_pipeline.hpp" +#include "renderer/3d/pipeline/dynamic/dynamic_pipeline.hpp" namespace Tyra { @@ -39,6 +40,7 @@ class H4570 : public Game { Vec4 cameraPosition, cameraLookAt; MinecraftPipeline mcPip; + DynamicPipeline dynpip; StaticPipeline stapip; StaPipOptions* renderOptions; Texture* blocksTex; diff --git a/samples/h4570/src/h4570.cpp b/samples/h4570/src/h4570.cpp index b0a0ece..7d08daa 100644 --- a/samples/h4570/src/h4570.cpp +++ b/samples/h4570/src/h4570.cpp @@ -65,6 +65,7 @@ void H4570::init() { FileUtils::fromCwd("blocks.png")); mcPip.init(&engine->renderer.core); + dynpip.init(&engine->renderer.core); stapip.init(&engine->renderer.core); picture = get2DPicture(&engine->renderer); @@ -137,13 +138,16 @@ void H4570::loop() { // engine->renderer.renderer2D.render(picture); - engine->renderer.renderer3D.usePipeline(&stapip); - { - stapip.render(warrior, renderOptions); - // stapip.render(warrior2, renderOptions); - // stapip.render(warrior3, renderOptions); - // stapip.render(warrior4, renderOptions); - } + // engine->renderer.renderer3D.usePipeline(&stapip); + // { + // stapip.render(warrior, renderOptions); + // // stapip.render(warrior2, renderOptions); + // // stapip.render(warrior3, renderOptions); + // // stapip.render(warrior4, renderOptions); + // } + + engine->renderer.renderer3D.usePipeline(&dynpip); + { dynpip.render(warrior); } engine->renderer.renderer3D.usePipeline(&mcPip); { mcPip.render(blocks, blocksCount, blocksTex, false); } @@ -189,12 +193,12 @@ StaPipOptions* getRenderingOptions() { for (int i = 0; i < 3; i++) directionalDirections[i].set(1.0F, 1.0F, 1.0F, 1.0F); - auto* lightingOptions = new StaPipLightingOptions(); // Memory leak! + auto* lightingOptions = new PipelineLightingOptions(); // Memory leak! lightingOptions->ambientColor = ambientColor; lightingOptions->directionalColors = directionalColors; lightingOptions->directionalDirections = directionalDirections; - options->shadingType = Tyra::StaPipShadingGouraud; + options->shadingType = Tyra::TyraShadingGouraud; options->blendingEnabled = true; options->antiAliasingEnabled = false; options->lighting = lightingOptions; diff --git a/samples/wellinator/src/wellinator.cpp b/samples/wellinator/src/wellinator.cpp index 05482e6..3658058 100644 --- a/samples/wellinator/src/wellinator.cpp +++ b/samples/wellinator/src/wellinator.cpp @@ -160,12 +160,12 @@ StaPipOptions* getRenderingOptions() { for (int i = 0; i < 3; i++) directionalDirections[i].set(1.0F, 1.0F, 1.0F, 1.0F); - auto* lightingOptions = new StaPipLightingOptions(); // Memory leak! + auto* lightingOptions = new PipelineLightingOptions(); // Memory leak! lightingOptions->ambientColor = ambientColor; lightingOptions->directionalColors = directionalColors; lightingOptions->directionalDirections = directionalDirections; - options->shadingType = Tyra::StaPipShadingGouraud; + options->shadingType = Tyra::TyraShadingGouraud; options->blendingEnabled = true; options->antiAliasingEnabled = false; options->lighting = lightingOptions;