From 7b165574c08297b1f7bb4f8e4415aecdd3934853 Mon Sep 17 00:00:00 2001 From: vlj Date: Sun, 28 Sep 2014 02:27:17 +0200 Subject: [PATCH] Merge MAT_* with shadertype --- src/graphics/material.hpp | 5 +- src/graphics/render_geometry.cpp | 66 ++++++------- src/graphics/stkanimatedmesh.cpp | 6 +- src/graphics/stkmesh.cpp | 21 ++-- src/graphics/stkmesh.hpp | 19 +--- src/graphics/stkmeshscenenode.cpp | 6 +- src/graphics/stkscenemanager.cpp | 158 +++++++++++++++--------------- src/graphics/stkscenemanager.hpp | 6 +- 8 files changed, 139 insertions(+), 148 deletions(-) diff --git a/src/graphics/material.hpp b/src/graphics/material.hpp index 99f0951e2..4e95e648b 100644 --- a/src/graphics/material.hpp +++ b/src/graphics/material.hpp @@ -57,7 +57,10 @@ public: SHADERTYPE_VEGETATION, SHADERTYPE_WATER, SHADERTYPE_SPHERE_MAP, - SHADERTYPE_SPLATTING + SHADERTYPE_NORMAL_MAP, + SHADERTYPE_DETAIL_MAP, + SHADERTYPE_SPLATTING, + SHADERTYPE_COUNT, }; enum ParticleConditions diff --git a/src/graphics/render_geometry.cpp b/src/graphics/render_geometry.cpp index f42f04b0b..fca20e664 100644 --- a/src/graphics/render_geometry.cpp +++ b/src/graphics/render_geometry.cpp @@ -67,7 +67,7 @@ struct DefaultMaterial typedef MeshShader::ObjectPass2Shader SecondPassShader; typedef ListMatDefault List; static const enum video::E_VERTEX_TYPE VertexType = video::EVT_STANDARD; - static const enum MeshMaterial MaterialType = MAT_DEFAULT; + static const enum Material::ShaderType MaterialType = Material::SHADERTYPE_SOLID; static const enum InstanceType Instance = InstanceTypeDualTex; static const std::vector FirstPassTextures; static const std::vector SecondPassTextures; @@ -85,7 +85,7 @@ struct AlphaRef typedef MeshShader::ObjectRefPass2Shader SecondPassShader; typedef ListMatAlphaRef List; static const enum video::E_VERTEX_TYPE VertexType = video::EVT_STANDARD; - static const enum MeshMaterial MaterialType = MAT_ALPHA_REF; + static const enum Material::ShaderType MaterialType = Material::SHADERTYPE_ALPHA_TEST; static const enum InstanceType Instance = InstanceTypeDualTex; static const std::vector FirstPassTextures; static const std::vector SecondPassTextures; @@ -103,7 +103,7 @@ struct SphereMap typedef MeshShader::SphereMapShader SecondPassShader; typedef ListMatSphereMap List; static const enum video::E_VERTEX_TYPE VertexType = video::EVT_STANDARD; - static const enum MeshMaterial MaterialType = MAT_SPHEREMAP; + static const enum Material::ShaderType MaterialType = Material::SHADERTYPE_SPHERE_MAP; static const enum InstanceType Instance = InstanceTypeDualTex; static const std::vector FirstPassTextures; static const std::vector SecondPassTextures; @@ -121,7 +121,7 @@ struct UnlitMat typedef MeshShader::ObjectUnlitShader SecondPassShader; typedef ListMatUnlit List; static const enum video::E_VERTEX_TYPE VertexType = video::EVT_STANDARD; - static const enum MeshMaterial MaterialType = MAT_UNLIT; + static const enum Material::ShaderType MaterialType = Material::SHADERTYPE_SOLID_UNLIT; static const enum InstanceType Instance = InstanceTypeDualTex; static const std::vector FirstPassTextures; static const std::vector SecondPassTextures; @@ -139,7 +139,7 @@ struct GrassMat typedef MeshShader::GrassPass2Shader SecondPassShader; typedef ListMatGrass List; static const enum video::E_VERTEX_TYPE VertexType = video::EVT_STANDARD; - static const enum MeshMaterial MaterialType = MAT_GRASS; + static const enum Material::ShaderType MaterialType = Material::SHADERTYPE_VEGETATION; static const enum InstanceType Instance = InstanceTypeDualTex; static const std::vector FirstPassTextures; static const std::vector SecondPassTextures; @@ -157,7 +157,7 @@ struct NormalMat typedef MeshShader::ObjectPass2Shader SecondPassShader; typedef ListMatNormalMap List; static const enum video::E_VERTEX_TYPE VertexType = video::EVT_TANGENTS; - static const enum MeshMaterial MaterialType = MAT_NORMAL_MAP; + static const enum Material::ShaderType MaterialType = Material::SHADERTYPE_NORMAL_MAP; static const enum InstanceType Instance = InstanceTypeThreeTex; static const std::vector FirstPassTextures; static const std::vector SecondPassTextures; @@ -175,7 +175,7 @@ struct DetailMat typedef MeshShader::DetailledObjectPass2Shader SecondPassShader; typedef ListMatDetails List; static const enum video::E_VERTEX_TYPE VertexType = video::EVT_2TCOORDS; - static const enum MeshMaterial MaterialType = MAT_DETAIL; + static const enum Material::ShaderType MaterialType = Material::SHADERTYPE_DETAIL_MAP; static const enum InstanceType Instance = InstanceTypeThreeTex; static const std::vector FirstPassTextures; static const std::vector SecondPassTextures; @@ -823,7 +823,7 @@ void renderShadow(const std::vector TextureUnits, unsigned cascade, cons } } -template +template void renderInstancedShadow(const std::vector TextureUnits, unsigned cascade, const std::vector &t, Args ...args) { glUseProgram(Shader::getInstance()->Program); @@ -844,7 +844,7 @@ void renderInstancedShadow(const std::vector TextureUnits, unsigned casc } } -template +template static void multidrawShadow(unsigned i, Args ...args) { glUseProgram(Shader::getInstance()->Program); @@ -892,21 +892,21 @@ void IrrDriver::renderShadows() if (UserConfigParams::m_azdo) { - multidrawShadow(cascade); - multidrawShadow(cascade); - multidrawShadow(cascade); - multidrawShadow(cascade); - multidrawShadow(cascade); - multidrawShadow(cascade, windDir); + multidrawShadow(cascade); + multidrawShadow(cascade); + multidrawShadow(cascade); + multidrawShadow(cascade); + multidrawShadow(cascade); + multidrawShadow(cascade, windDir); } else if (irr_driver->hasARB_draw_indirect()) { - renderInstancedShadow(noTexUnits, cascade, ListInstancedMatDefault::getInstance()->Shadows[cascade]); - renderInstancedShadow(noTexUnits, cascade, ListInstancedMatDetails::getInstance()->Shadows[cascade]); - renderInstancedShadow(std::vector < GLuint > { 0 }, cascade, ListInstancedMatAlphaRef::getInstance()->Shadows[cascade]); - renderInstancedShadow(std::vector < GLuint > { 0 }, cascade, ListInstancedMatUnlit::getInstance()->Shadows[cascade]); - renderInstancedShadow(std::vector < GLuint > { 0 }, cascade, ListInstancedMatGrass::getInstance()->Shadows[cascade], windDir); - renderInstancedShadow(noTexUnits, cascade, ListInstancedMatNormalMap::getInstance()->Shadows[cascade]); + renderInstancedShadow(noTexUnits, cascade, ListInstancedMatDefault::getInstance()->Shadows[cascade]); + renderInstancedShadow(noTexUnits, cascade, ListInstancedMatDetails::getInstance()->Shadows[cascade]); + renderInstancedShadow(std::vector < GLuint > { 0 }, cascade, ListInstancedMatAlphaRef::getInstance()->Shadows[cascade]); + renderInstancedShadow(std::vector < GLuint > { 0 }, cascade, ListInstancedMatUnlit::getInstance()->Shadows[cascade]); + renderInstancedShadow(std::vector < GLuint > { 0 }, cascade, ListInstancedMatGrass::getInstance()->Shadows[cascade], windDir); + renderInstancedShadow(noTexUnits, cascade, ListInstancedMatNormalMap::getInstance()->Shadows[cascade]); } } @@ -957,7 +957,7 @@ void drawRSM(const core::matrix4 & rsm_matrix, const std::vector &Textur } } -template +template void renderRSMShadow(const std::vector TextureUnits, const std::vector &t, Args ...args) { glUseProgram(Shader::getInstance()->Program); @@ -977,7 +977,7 @@ void renderRSMShadow(const std::vector TextureUnits, const std::vector +template void multidrawRSM(Args...args) { glUseProgram(Shader::getInstance()->Program); @@ -1009,18 +1009,18 @@ void IrrDriver::renderRSM() if (UserConfigParams::m_azdo) { - multidrawRSM(rsm_matrix); - multidrawRSM(rsm_matrix); - multidrawRSM(rsm_matrix); - multidrawRSM(rsm_matrix); - multidrawRSM(rsm_matrix); + multidrawRSM(rsm_matrix); + multidrawRSM(rsm_matrix); + multidrawRSM(rsm_matrix); + multidrawRSM(rsm_matrix); + multidrawRSM(rsm_matrix); } else if (irr_driver->hasARB_draw_indirect()) { - renderRSMShadow(std::vector < GLuint > { 0 }, ListInstancedMatDefault::getInstance()->RSM, rsm_matrix); - renderRSMShadow(std::vector < GLuint > { 0 }, ListInstancedMatAlphaRef::getInstance()->RSM, rsm_matrix); - renderRSMShadow(std::vector < GLuint > { 0 }, ListInstancedMatUnlit::getInstance()->RSM, rsm_matrix); - renderRSMShadow(std::vector < GLuint > { 0 }, ListInstancedMatNormalMap::getInstance()->RSM, rsm_matrix); - renderRSMShadow(std::vector < GLuint > { 0 }, ListInstancedMatDetails::getInstance()->RSM, rsm_matrix); + renderRSMShadow(std::vector < GLuint > { 0 }, ListInstancedMatDefault::getInstance()->RSM, rsm_matrix); + renderRSMShadow(std::vector < GLuint > { 0 }, ListInstancedMatAlphaRef::getInstance()->RSM, rsm_matrix); + renderRSMShadow(std::vector < GLuint > { 0 }, ListInstancedMatUnlit::getInstance()->RSM, rsm_matrix); + renderRSMShadow(std::vector < GLuint > { 0 }, ListInstancedMatNormalMap::getInstance()->RSM, rsm_matrix); + renderRSMShadow(std::vector < GLuint > { 0 }, ListInstancedMatDetails::getInstance()->RSM, rsm_matrix); } } diff --git a/src/graphics/stkanimatedmesh.cpp b/src/graphics/stkanimatedmesh.cpp index da07759f6..5b52251ef 100644 --- a/src/graphics/stkanimatedmesh.cpp +++ b/src/graphics/stkanimatedmesh.cpp @@ -45,7 +45,7 @@ void STKAnimatedMesh::cleanGLMeshes() glDeleteBuffers(1, &(mesh.index_buffer)); } GLmeshes.clear(); - for (unsigned i = 0; i < MAT_COUNT; i++) + for (unsigned i = 0; i < Material::SHADERTYPE_COUNT; i++) MeshSolidMaterial[i].clearWithoutDeleting(); for (unsigned i = 0; i < TM_COUNT; i++) TransparentMesh[i].clearWithoutDeleting(); @@ -105,7 +105,7 @@ void STKAnimatedMesh::updateNoGL() } else { - MeshMaterial MatType = MaterialTypeToMeshMaterial(type, mb->getVertexType(), material); + Material::ShaderType MatType = material->getShaderType();// MaterialTypeToMeshMaterial(type, mb->getVertexType(), material); MeshSolidMaterial[MatType].push_back(&mesh); } } @@ -142,7 +142,7 @@ void STKAnimatedMesh::updateGL() if (!rnd->isTransparent()) { Material* material = material_manager->getMaterialFor(mb->getMaterial().getTexture(0), mb); - MeshMaterial MatType = MaterialTypeToMeshMaterial(type, mb->getVertexType(), material); + Material::ShaderType MatType = material->getShaderType();// MaterialTypeToMeshMaterial(type, mb->getVertexType(), material); InitTextures(mesh, MatType); } diff --git a/src/graphics/stkmesh.cpp b/src/graphics/stkmesh.cpp index b073e1212..46ba030c1 100644 --- a/src/graphics/stkmesh.cpp +++ b/src/graphics/stkmesh.cpp @@ -10,6 +10,7 @@ #include "graphics/camera.hpp" #include "modes/world.hpp" +/* MeshMaterial MaterialTypeToMeshMaterial(video::E_MATERIAL_TYPE MaterialType, video::E_VERTEX_TYPE tp, Material* material) { switch (material->getShaderType()) @@ -31,8 +32,8 @@ MeshMaterial MaterialTypeToMeshMaterial(video::E_MATERIAL_TYPE MaterialType, vid return MAT_DETAIL; return MAT_DEFAULT; } - } +*/ TransparentMaterial MaterialTypeToTransparentMaterial(video::E_MATERIAL_TYPE type, f32 MaterialTypeParam, Material* material) { @@ -299,26 +300,26 @@ SetTexture(GLMesh &mesh, unsigned i, bool isSrgb) } } -void InitTextures(GLMesh &mesh, MeshMaterial Mat) +void InitTextures(GLMesh &mesh, Material::ShaderType Mat) { switch (Mat) { default: - case MAT_DEFAULT: - case MAT_ALPHA_REF: - case MAT_GRASS: - case MAT_SPHEREMAP: - case MAT_UNLIT: + case Material::SHADERTYPE_SOLID: + case Material::SHADERTYPE_ALPHA_TEST: + case Material::SHADERTYPE_VEGETATION: + case Material::SHADERTYPE_SPHERE_MAP: + case Material::SHADERTYPE_SOLID_UNLIT: SetTexture(mesh, 0, true); SetTexture(mesh, 1, false); break; - case MAT_DETAIL: - case MAT_NORMAL_MAP: + case Material::SHADERTYPE_DETAIL_MAP: + case Material::SHADERTYPE_NORMAL_MAP: SetTexture(mesh, 0, true); SetTexture(mesh, 1, false); SetTexture(mesh, 2, false); break; - case MAT_SPLATTING: + case Material::SHADERTYPE_SPLATTING: SetTexture(mesh, 0, true); SetTexture(mesh, 1, false); SetTexture(mesh, 2, true); diff --git a/src/graphics/stkmesh.hpp b/src/graphics/stkmesh.hpp index e9e111033..346ffe9fb 100644 --- a/src/graphics/stkmesh.hpp +++ b/src/graphics/stkmesh.hpp @@ -9,22 +9,10 @@ #include "../lib/irrlicht/source/Irrlicht/CMeshSceneNode.h" #include +#include "material.hpp" class Material; -enum MeshMaterial -{ - MAT_DEFAULT, - MAT_ALPHA_REF, - MAT_NORMAL_MAP, - MAT_GRASS, - MAT_SPHEREMAP, - MAT_SPLATTING, - MAT_UNLIT, - MAT_DETAIL, - MAT_COUNT -}; - enum TransparentMaterial { TM_DEFAULT, @@ -67,7 +55,7 @@ protected: bool m_culledForShadowCam[4]; bool m_culledForRSMCam; public: - PtrVector MeshSolidMaterial[MAT_COUNT]; + PtrVector MeshSolidMaterial[Material::SHADERTYPE_COUNT]; PtrVector TransparentMesh[TM_COUNT]; virtual void updateNoGL() = 0; virtual void updateGL() = 0; @@ -186,9 +174,8 @@ class ListDisplacement : public MiscList, public std::vector {}; -MeshMaterial MaterialTypeToMeshMaterial(video::E_MATERIAL_TYPE, video::E_VERTEX_TYPE, Material* material); TransparentMaterial MaterialTypeToTransparentMaterial(video::E_MATERIAL_TYPE, f32 MaterialTypeParam, Material* material); -void InitTextures(GLMesh &mesh, MeshMaterial); +void InitTextures(GLMesh &mesh, Material::ShaderType); #endif // STKMESH_H diff --git a/src/graphics/stkmeshscenenode.cpp b/src/graphics/stkmeshscenenode.cpp index d63420aef..1e7d5da19 100644 --- a/src/graphics/stkmeshscenenode.cpp +++ b/src/graphics/stkmeshscenenode.cpp @@ -62,7 +62,7 @@ void STKMeshSceneNode::cleanGLMeshes() glDeleteBuffers(1, &(mesh.index_buffer)); } GLmeshes.clear(); - for (unsigned i = 0; i < MAT_COUNT; i++) + for (unsigned i = 0; i < Material::SHADERTYPE_COUNT; i++) MeshSolidMaterial[i].clearWithoutDeleting(); for (unsigned i = 0; i < TM_COUNT; i++) TransparentMesh[i].clearWithoutDeleting(); @@ -143,7 +143,7 @@ void STKMeshSceneNode::updateNoGL() else { assert(!isDisplacement); - MeshMaterial MatType = MaterialTypeToMeshMaterial(type, mb->getVertexType(), material); + Material::ShaderType MatType = material->getShaderType();// MaterialTypeToMeshMaterial(type, mb->getVertexType(), material); if (!immediate_draw) MeshSolidMaterial[MatType].push_back(&mesh); } @@ -179,7 +179,7 @@ void STKMeshSceneNode::updateGL() if (!rnd->isTransparent()) { Material* material = material_manager->getMaterialFor(mb->getMaterial().getTexture(0), mb); - MeshMaterial MatType = MaterialTypeToMeshMaterial(type, mb->getVertexType(), material); + Material::ShaderType MatType = material->getShaderType();// MaterialTypeToMeshMaterial(type, mb->getVertexType(), material); if (!immediate_draw) InitTextures(mesh, MatType); } diff --git a/src/graphics/stkscenemanager.cpp b/src/graphics/stkscenemanager.cpp index 4798e92d4..1f6784757 100644 --- a/src/graphics/stkscenemanager.cpp +++ b/src/graphics/stkscenemanager.cpp @@ -150,7 +150,7 @@ void FillInstances(const std::unordered_map > > MeshForSolidPass[MAT_COUNT]; +static std::unordered_map > > MeshForSolidPass[Material::SHADERTYPE_COUNT]; static std::unordered_map > > MeshForGlowPass; static std::vector DeferredUpdate; @@ -248,7 +248,7 @@ handleSTKCommon(scene::ISceneNode *Node, std::vector *Immed for_in(mesh, node->TransparentMesh[TM_DISPLACEMENT]) pushVector(ListDisplacement::getInstance(), mesh, Node->getAbsoluteTransformation()); - for (unsigned Mat = 0; Mat < MAT_COUNT; ++Mat) + for (unsigned Mat = 0; Mat < Material::SHADERTYPE_COUNT; ++Mat) { if (irr_driver->hasARB_draw_indirect()) { @@ -257,7 +257,7 @@ handleSTKCommon(scene::ISceneNode *Node, std::vector *Immed if (node->glow()) MeshForGlowPass[mesh->mb].emplace_back(mesh, Node); - if (Mat != MAT_SPLATTING && mesh->TextureMatrix.isIdentity()) + if (Mat != Material::SHADERTYPE_SPLATTING && mesh->TextureMatrix.isIdentity()) MeshForSolidPass[Mat][mesh->mb].emplace_back(mesh, Node); else { @@ -265,16 +265,16 @@ handleSTKCommon(scene::ISceneNode *Node, std::vector *Immed ModelMatrix.getInverse(InvModelMatrix); switch (Mat) { - case MAT_DEFAULT: + case Material::SHADERTYPE_SOLID: ListMatDefault::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; - case MAT_ALPHA_REF: + case Material::SHADERTYPE_ALPHA_TEST: ListMatAlphaRef::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; - case MAT_UNLIT: + case Material::SHADERTYPE_SOLID_UNLIT: ListMatUnlit::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; - case MAT_SPLATTING: + case Material::SHADERTYPE_SPLATTING: ListMatSplatting::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix); break; } @@ -292,28 +292,28 @@ handleSTKCommon(scene::ISceneNode *Node, std::vector *Immed { switch (Mat) { - case MAT_DEFAULT: + case Material::SHADERTYPE_SOLID: ListMatDefault::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; - case MAT_ALPHA_REF: + case Material::SHADERTYPE_ALPHA_TEST: ListMatAlphaRef::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; - case MAT_NORMAL_MAP: + case Material::SHADERTYPE_NORMAL_MAP: ListMatNormalMap::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; - case MAT_DETAIL: + case Material::SHADERTYPE_DETAIL_MAP: ListMatDetails::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; - case MAT_UNLIT: + case Material::SHADERTYPE_SOLID_UNLIT: ListMatUnlit::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; - case MAT_SPHEREMAP: + case Material::SHADERTYPE_SPHERE_MAP: ListMatSphereMap::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; - case MAT_SPLATTING: + case Material::SHADERTYPE_SPLATTING: ListMatSplatting::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix); break; - case MAT_GRASS: + case Material::SHADERTYPE_VEGETATION: ListMatGrass::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, windDir); break; } @@ -322,7 +322,7 @@ handleSTKCommon(scene::ISceneNode *Node, std::vector *Immed } if (!UserConfigParams::m_shadows) return; - for (unsigned Mat = 0; Mat < MAT_COUNT; ++Mat) + for (unsigned Mat = 0; Mat < Material::SHADERTYPE_COUNT; ++Mat) { for (unsigned cascade = 0; cascade < 4; ++cascade) { @@ -337,28 +337,28 @@ handleSTKCommon(scene::ISceneNode *Node, std::vector *Immed { switch (Mat) { - case MAT_DEFAULT: + case Material::SHADERTYPE_SOLID: ListMatDefault::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; - case MAT_ALPHA_REF: + case Material::SHADERTYPE_ALPHA_TEST: ListMatAlphaRef::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; - case MAT_NORMAL_MAP: + case Material::SHADERTYPE_NORMAL_MAP: ListMatNormalMap::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; - case MAT_DETAIL: + case Material::SHADERTYPE_DETAIL_MAP: ListMatDetails::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; - case MAT_UNLIT: + case Material::SHADERTYPE_SOLID_UNLIT: ListMatUnlit::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; - case MAT_SPHEREMAP: + case Material::SHADERTYPE_SPHERE_MAP: ListMatSphereMap::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; - case MAT_SPLATTING: + case Material::SHADERTYPE_SPLATTING: ListMatSplatting::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix); break; - case MAT_GRASS: + case Material::SHADERTYPE_VEGETATION: ListMatGrass::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, windDir); } } @@ -367,11 +367,11 @@ handleSTKCommon(scene::ISceneNode *Node, std::vector *Immed } if (!UserConfigParams::m_gi) return; - for (unsigned Mat = 0; Mat < MAT_COUNT; ++Mat) + for (unsigned Mat = 0; Mat < Material::SHADERTYPE_COUNT; ++Mat) { if (irr_driver->hasARB_draw_indirect()) { - if (Mat == MAT_SPLATTING) + if (Mat == Material::SHADERTYPE_SPLATTING) for_in(mesh, node->MeshSolidMaterial[Mat]) { core::matrix4 ModelMatrix = Node->getAbsoluteTransformation(), InvModelMatrix; @@ -390,28 +390,28 @@ handleSTKCommon(scene::ISceneNode *Node, std::vector *Immed { switch (Mat) { - case MAT_DEFAULT: + case Material::SHADERTYPE_SOLID: ListMatDefault::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; - case MAT_ALPHA_REF: + case Material::SHADERTYPE_ALPHA_TEST: ListMatAlphaRef::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; - case MAT_NORMAL_MAP: + case Material::SHADERTYPE_NORMAL_MAP: ListMatNormalMap::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; - case MAT_DETAIL: + case Material::SHADERTYPE_DETAIL_MAP: ListMatDetails::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; - case MAT_UNLIT: + case Material::SHADERTYPE_SOLID_UNLIT: ListMatUnlit::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; - case MAT_SPHEREMAP: + case Material::SHADERTYPE_SPHERE_MAP: ListMatSphereMap::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; - case MAT_SPLATTING: + case Material::SHADERTYPE_SPLATTING: ListMatSplatting::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix); break; - case MAT_GRASS: + case Material::SHADERTYPE_VEGETATION: ListMatGrass::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, windDir); break; } @@ -453,7 +453,7 @@ parseSceneManager(core::list List, std::vector static void +template static void GenDrawCalls(unsigned cascade, std::vector &InstancedList, T *InstanceBuffer, DrawElementsIndirectCommand *CommandBuffer, size_t &InstanceBufferOffset, size_t &CommandBufferOffset, size_t &PolyCount) { @@ -490,7 +490,7 @@ void IrrDriver::PrepareDrawCalls(scene::ICameraSceneNode *camnode) ParticlesList::getInstance()->clear(); ListInstancedGlow::getInstance()->clear(); - for (unsigned Mat = 0; Mat < MAT_COUNT; ++Mat) + for (unsigned Mat = 0; Mat < Material::SHADERTYPE_COUNT; ++Mat) MeshForSolidPass[Mat].clear(); MeshForGlowPass.clear(); DeferredUpdate.clear(); @@ -595,25 +595,25 @@ void IrrDriver::PrepareDrawCalls(scene::ICameraSceneNode *camnode) // Default Material - SolidPassCmd::getInstance()->Offset[MAT_DEFAULT] = current_cmd; - FillInstances(MeshForSolidPass[MAT_DEFAULT], ListInstancedMatDefault::getInstance()->SolidPass, InstanceBufferDualTex, CmdBuffer, offset, current_cmd, SolidPoly, playercamculling); - SolidPassCmd::getInstance()->Size[MAT_DEFAULT] = current_cmd - SolidPassCmd::getInstance()->Offset[MAT_DEFAULT]; + SolidPassCmd::getInstance()->Offset[Material::SHADERTYPE_SOLID] = current_cmd; + FillInstances(MeshForSolidPass[Material::SHADERTYPE_SOLID], ListInstancedMatDefault::getInstance()->SolidPass, InstanceBufferDualTex, CmdBuffer, offset, current_cmd, SolidPoly, playercamculling); + SolidPassCmd::getInstance()->Size[Material::SHADERTYPE_SOLID] = current_cmd - SolidPassCmd::getInstance()->Offset[Material::SHADERTYPE_SOLID]; // Alpha Ref - SolidPassCmd::getInstance()->Offset[MAT_ALPHA_REF] = current_cmd; - FillInstances(MeshForSolidPass[MAT_ALPHA_REF], ListInstancedMatAlphaRef::getInstance()->SolidPass, InstanceBufferDualTex, CmdBuffer, offset, current_cmd, SolidPoly, playercamculling); - SolidPassCmd::getInstance()->Size[MAT_ALPHA_REF] = current_cmd - SolidPassCmd::getInstance()->Offset[MAT_ALPHA_REF]; + SolidPassCmd::getInstance()->Offset[Material::SHADERTYPE_ALPHA_TEST] = current_cmd; + FillInstances(MeshForSolidPass[Material::SHADERTYPE_ALPHA_TEST], ListInstancedMatAlphaRef::getInstance()->SolidPass, InstanceBufferDualTex, CmdBuffer, offset, current_cmd, SolidPoly, playercamculling); + SolidPassCmd::getInstance()->Size[Material::SHADERTYPE_ALPHA_TEST] = current_cmd - SolidPassCmd::getInstance()->Offset[Material::SHADERTYPE_ALPHA_TEST]; // Unlit - SolidPassCmd::getInstance()->Offset[MAT_UNLIT] = current_cmd; - FillInstances(MeshForSolidPass[MAT_UNLIT], ListInstancedMatUnlit::getInstance()->SolidPass, InstanceBufferDualTex, CmdBuffer, offset, current_cmd, SolidPoly, playercamculling); - SolidPassCmd::getInstance()->Size[MAT_UNLIT] = current_cmd - SolidPassCmd::getInstance()->Offset[MAT_UNLIT]; + SolidPassCmd::getInstance()->Offset[Material::SHADERTYPE_SOLID_UNLIT] = current_cmd; + FillInstances(MeshForSolidPass[Material::SHADERTYPE_SOLID_UNLIT], ListInstancedMatUnlit::getInstance()->SolidPass, InstanceBufferDualTex, CmdBuffer, offset, current_cmd, SolidPoly, playercamculling); + SolidPassCmd::getInstance()->Size[Material::SHADERTYPE_SOLID_UNLIT] = current_cmd - SolidPassCmd::getInstance()->Offset[Material::SHADERTYPE_SOLID_UNLIT]; // Spheremap - SolidPassCmd::getInstance()->Offset[MAT_SPHEREMAP] = current_cmd; - FillInstances(MeshForSolidPass[MAT_SPHEREMAP], ListInstancedMatSphereMap::getInstance()->SolidPass, InstanceBufferDualTex, CmdBuffer, offset, current_cmd, SolidPoly, playercamculling); - SolidPassCmd::getInstance()->Size[MAT_SPHEREMAP] = current_cmd - SolidPassCmd::getInstance()->Offset[MAT_SPHEREMAP]; + SolidPassCmd::getInstance()->Offset[Material::SHADERTYPE_SPHERE_MAP] = current_cmd; + FillInstances(MeshForSolidPass[Material::SHADERTYPE_SPHERE_MAP], ListInstancedMatSphereMap::getInstance()->SolidPass, InstanceBufferDualTex, CmdBuffer, offset, current_cmd, SolidPoly, playercamculling); + SolidPassCmd::getInstance()->Size[Material::SHADERTYPE_SPHERE_MAP] = current_cmd - SolidPassCmd::getInstance()->Offset[Material::SHADERTYPE_SPHERE_MAP]; // Grass - SolidPassCmd::getInstance()->Offset[MAT_GRASS] = current_cmd; - FillInstances(MeshForSolidPass[MAT_GRASS], ListInstancedMatGrass::getInstance()->SolidPass, InstanceBufferDualTex, CmdBuffer, offset, current_cmd, SolidPoly, playercamculling); - SolidPassCmd::getInstance()->Size[MAT_GRASS] = current_cmd - SolidPassCmd::getInstance()->Offset[MAT_GRASS]; + SolidPassCmd::getInstance()->Offset[Material::SHADERTYPE_VEGETATION] = current_cmd; + FillInstances(MeshForSolidPass[Material::SHADERTYPE_VEGETATION], ListInstancedMatGrass::getInstance()->SolidPass, InstanceBufferDualTex, CmdBuffer, offset, current_cmd, SolidPoly, playercamculling); + SolidPassCmd::getInstance()->Size[Material::SHADERTYPE_VEGETATION] = current_cmd - SolidPassCmd::getInstance()->Offset[Material::SHADERTYPE_VEGETATION]; if (!irr_driver->hasBufferStorageExtension()) { @@ -624,13 +624,13 @@ void IrrDriver::PrepareDrawCalls(scene::ICameraSceneNode *camnode) } // Detail - SolidPassCmd::getInstance()->Offset[MAT_DETAIL] = current_cmd; - FillInstances(MeshForSolidPass[MAT_DETAIL], ListInstancedMatDetails::getInstance()->SolidPass, InstanceBufferThreeTex, CmdBuffer, offset, current_cmd, SolidPoly, playercamculling); - SolidPassCmd::getInstance()->Size[MAT_DETAIL] = current_cmd - SolidPassCmd::getInstance()->Offset[MAT_DETAIL]; + SolidPassCmd::getInstance()->Offset[Material::SHADERTYPE_DETAIL_MAP] = current_cmd; + FillInstances(MeshForSolidPass[Material::SHADERTYPE_DETAIL_MAP], ListInstancedMatDetails::getInstance()->SolidPass, InstanceBufferThreeTex, CmdBuffer, offset, current_cmd, SolidPoly, playercamculling); + SolidPassCmd::getInstance()->Size[Material::SHADERTYPE_DETAIL_MAP] = current_cmd - SolidPassCmd::getInstance()->Offset[Material::SHADERTYPE_DETAIL_MAP]; // Normal Map - SolidPassCmd::getInstance()->Offset[MAT_NORMAL_MAP] = current_cmd; - FillInstances(MeshForSolidPass[MAT_NORMAL_MAP], ListInstancedMatNormalMap::getInstance()->SolidPass, InstanceBufferThreeTex, CmdBuffer, offset, current_cmd, SolidPoly, playercamculling); - SolidPassCmd::getInstance()->Size[MAT_NORMAL_MAP] = current_cmd - SolidPassCmd::getInstance()->Offset[MAT_NORMAL_MAP]; + SolidPassCmd::getInstance()->Offset[Material::SHADERTYPE_NORMAL_MAP] = current_cmd; + FillInstances(MeshForSolidPass[Material::SHADERTYPE_NORMAL_MAP], ListInstancedMatNormalMap::getInstance()->SolidPass, InstanceBufferThreeTex, CmdBuffer, offset, current_cmd, SolidPoly, playercamculling); + SolidPassCmd::getInstance()->Size[Material::SHADERTYPE_NORMAL_MAP] = current_cmd - SolidPassCmd::getInstance()->Offset[Material::SHADERTYPE_NORMAL_MAP]; if (!irr_driver->hasBufferStorageExtension()) @@ -689,19 +689,19 @@ void IrrDriver::PrepareDrawCalls(scene::ICameraSceneNode *camnode) for (unsigned i = 0; i < 4; i++) { // Mat default - GenDrawCalls(i, ListInstancedMatDefault::getInstance()->Shadows[i], ShadowInstanceBuffer, ShadowCmdBuffer, offset, current_cmd, ShadowPoly); + GenDrawCalls(i, ListInstancedMatDefault::getInstance()->Shadows[i], ShadowInstanceBuffer, ShadowCmdBuffer, offset, current_cmd, ShadowPoly); // Mat AlphaRef - GenDrawCalls(i, ListInstancedMatAlphaRef::getInstance()->Shadows[i], ShadowInstanceBuffer, ShadowCmdBuffer, offset, current_cmd, ShadowPoly); + GenDrawCalls(i, ListInstancedMatAlphaRef::getInstance()->Shadows[i], ShadowInstanceBuffer, ShadowCmdBuffer, offset, current_cmd, ShadowPoly); // Mat Unlit - GenDrawCalls(i, ListInstancedMatUnlit::getInstance()->Shadows[i], ShadowInstanceBuffer, ShadowCmdBuffer, offset, current_cmd, ShadowPoly); + GenDrawCalls(i, ListInstancedMatUnlit::getInstance()->Shadows[i], ShadowInstanceBuffer, ShadowCmdBuffer, offset, current_cmd, ShadowPoly); // Mat NormalMap - GenDrawCalls(i, ListInstancedMatNormalMap::getInstance()->Shadows[i], ShadowInstanceBuffer, ShadowCmdBuffer, offset, current_cmd, ShadowPoly); + GenDrawCalls(i, ListInstancedMatNormalMap::getInstance()->Shadows[i], ShadowInstanceBuffer, ShadowCmdBuffer, offset, current_cmd, ShadowPoly); // Mat Spheremap - GenDrawCalls(i, ListInstancedMatSphereMap::getInstance()->Shadows[i], ShadowInstanceBuffer, ShadowCmdBuffer, offset, current_cmd, ShadowPoly); + GenDrawCalls(i, ListInstancedMatSphereMap::getInstance()->Shadows[i], ShadowInstanceBuffer, ShadowCmdBuffer, offset, current_cmd, ShadowPoly); // Mat Detail - GenDrawCalls(i, ListInstancedMatDetails::getInstance()->Shadows[i], ShadowInstanceBuffer, ShadowCmdBuffer, offset, current_cmd, ShadowPoly); + GenDrawCalls(i, ListInstancedMatDetails::getInstance()->Shadows[i], ShadowInstanceBuffer, ShadowCmdBuffer, offset, current_cmd, ShadowPoly); // Mat Grass - GenDrawCalls(i, ListInstancedMatGrass::getInstance()->Shadows[i], ShadowInstanceBuffer, ShadowCmdBuffer, offset, current_cmd, ShadowPoly); + GenDrawCalls(i, ListInstancedMatGrass::getInstance()->Shadows[i], ShadowInstanceBuffer, ShadowCmdBuffer, offset, current_cmd, ShadowPoly); } if (!irr_driver->hasBufferStorageExtension()) { @@ -722,25 +722,25 @@ void IrrDriver::PrepareDrawCalls(scene::ICameraSceneNode *camnode) } // Default Material - RSMPassCmd::getInstance()->Offset[MAT_DEFAULT] = current_cmd; - FillInstances(MeshForSolidPass[MAT_DEFAULT], ListInstancedMatDefault::getInstance()->RSM, RSMInstanceBuffer, RSMCmdBuffer, offset, current_cmd, MiscPoly, rsmcamculling); - RSMPassCmd::getInstance()->Size[MAT_DEFAULT] = current_cmd - RSMPassCmd::getInstance()->Offset[MAT_DEFAULT]; + RSMPassCmd::getInstance()->Offset[Material::SHADERTYPE_SOLID] = current_cmd; + FillInstances(MeshForSolidPass[Material::SHADERTYPE_SOLID], ListInstancedMatDefault::getInstance()->RSM, RSMInstanceBuffer, RSMCmdBuffer, offset, current_cmd, MiscPoly, rsmcamculling); + RSMPassCmd::getInstance()->Size[Material::SHADERTYPE_SOLID] = current_cmd - RSMPassCmd::getInstance()->Offset[Material::SHADERTYPE_SOLID]; // Alpha Ref - RSMPassCmd::getInstance()->Offset[MAT_ALPHA_REF] = current_cmd; - FillInstances(MeshForSolidPass[MAT_ALPHA_REF], ListInstancedMatAlphaRef::getInstance()->RSM, RSMInstanceBuffer, RSMCmdBuffer, offset, current_cmd, MiscPoly, rsmcamculling); - RSMPassCmd::getInstance()->Size[MAT_ALPHA_REF] = current_cmd - RSMPassCmd::getInstance()->Offset[MAT_ALPHA_REF]; + RSMPassCmd::getInstance()->Offset[Material::SHADERTYPE_ALPHA_TEST] = current_cmd; + FillInstances(MeshForSolidPass[Material::SHADERTYPE_ALPHA_TEST], ListInstancedMatAlphaRef::getInstance()->RSM, RSMInstanceBuffer, RSMCmdBuffer, offset, current_cmd, MiscPoly, rsmcamculling); + RSMPassCmd::getInstance()->Size[Material::SHADERTYPE_ALPHA_TEST] = current_cmd - RSMPassCmd::getInstance()->Offset[Material::SHADERTYPE_ALPHA_TEST]; // Unlit - RSMPassCmd::getInstance()->Offset[MAT_UNLIT] = current_cmd; - FillInstances(MeshForSolidPass[MAT_UNLIT], ListInstancedMatUnlit::getInstance()->RSM, RSMInstanceBuffer, RSMCmdBuffer, offset, current_cmd, MiscPoly, rsmcamculling); - RSMPassCmd::getInstance()->Size[MAT_UNLIT] = current_cmd - RSMPassCmd::getInstance()->Offset[MAT_UNLIT]; + RSMPassCmd::getInstance()->Offset[Material::SHADERTYPE_SOLID_UNLIT] = current_cmd; + FillInstances(MeshForSolidPass[Material::SHADERTYPE_SOLID_UNLIT], ListInstancedMatUnlit::getInstance()->RSM, RSMInstanceBuffer, RSMCmdBuffer, offset, current_cmd, MiscPoly, rsmcamculling); + RSMPassCmd::getInstance()->Size[Material::SHADERTYPE_SOLID_UNLIT] = current_cmd - RSMPassCmd::getInstance()->Offset[Material::SHADERTYPE_SOLID_UNLIT]; // Detail - RSMPassCmd::getInstance()->Offset[MAT_DETAIL] = current_cmd; - FillInstances(MeshForSolidPass[MAT_DETAIL], ListInstancedMatDetails::getInstance()->RSM, RSMInstanceBuffer, RSMCmdBuffer, offset, current_cmd, MiscPoly, rsmcamculling); - RSMPassCmd::getInstance()->Size[MAT_DETAIL] = current_cmd - RSMPassCmd::getInstance()->Offset[MAT_DETAIL]; + RSMPassCmd::getInstance()->Offset[Material::SHADERTYPE_DETAIL_MAP] = current_cmd; + FillInstances(MeshForSolidPass[Material::SHADERTYPE_DETAIL_MAP], ListInstancedMatDetails::getInstance()->RSM, RSMInstanceBuffer, RSMCmdBuffer, offset, current_cmd, MiscPoly, rsmcamculling); + RSMPassCmd::getInstance()->Size[Material::SHADERTYPE_DETAIL_MAP] = current_cmd - RSMPassCmd::getInstance()->Offset[Material::SHADERTYPE_DETAIL_MAP]; // Normal Map - RSMPassCmd::getInstance()->Offset[MAT_NORMAL_MAP] = current_cmd; - FillInstances(MeshForSolidPass[MAT_NORMAL_MAP], ListInstancedMatNormalMap::getInstance()->RSM, RSMInstanceBuffer, RSMCmdBuffer, offset, current_cmd, MiscPoly, rsmcamculling); - RSMPassCmd::getInstance()->Size[MAT_NORMAL_MAP] = current_cmd - RSMPassCmd::getInstance()->Offset[MAT_NORMAL_MAP]; + RSMPassCmd::getInstance()->Offset[Material::SHADERTYPE_NORMAL_MAP] = current_cmd; + FillInstances(MeshForSolidPass[Material::SHADERTYPE_NORMAL_MAP], ListInstancedMatNormalMap::getInstance()->RSM, RSMInstanceBuffer, RSMCmdBuffer, offset, current_cmd, MiscPoly, rsmcamculling); + RSMPassCmd::getInstance()->Size[Material::SHADERTYPE_NORMAL_MAP] = current_cmd - RSMPassCmd::getInstance()->Offset[Material::SHADERTYPE_NORMAL_MAP]; if (!irr_driver->hasBufferStorageExtension()) { diff --git a/src/graphics/stkscenemanager.hpp b/src/graphics/stkscenemanager.hpp index 9d68c955f..51877ae71 100644 --- a/src/graphics/stkscenemanager.hpp +++ b/src/graphics/stkscenemanager.hpp @@ -45,19 +45,19 @@ class ParticlesList : public Singleton, public std::vector { public: - size_t Offset[MAT_COUNT], Size[MAT_COUNT]; + size_t Offset[Material::SHADERTYPE_COUNT], Size[Material::SHADERTYPE_COUNT]; }; class ShadowPassCmd : public CommandBuffer { public: - size_t Offset[4][MAT_COUNT], Size[4][MAT_COUNT]; + size_t Offset[4][Material::SHADERTYPE_COUNT], Size[4][Material::SHADERTYPE_COUNT]; }; class RSMPassCmd : public CommandBuffer { public: - size_t Offset[MAT_COUNT], Size[MAT_COUNT]; + size_t Offset[Material::SHADERTYPE_COUNT], Size[Material::SHADERTYPE_COUNT]; }; class GlowPassCmd : public CommandBuffer