Simplify material

This commit is contained in:
vlj 2014-07-16 23:15:07 +02:00
parent 27020c0c92
commit 1d0fb9ca68
10 changed files with 240 additions and 276 deletions

View File

@ -266,10 +266,6 @@ void IrrDriver::renderScene(scene::ICameraSceneNode * const camnode, unsigned po
{
glBindBufferBase(GL_UNIFORM_BUFFER, 0, SharedObject::ViewProjectionMatrixesUBO);
PROFILER_PUSH_CPU_MARKER("- Solid Pass 1", 0xFF, 0x00, 0x00);
renderSolidFirstPass();
PROFILER_POP_CPU_MARKER();
// Shadows
{
PROFILER_PUSH_CPU_MARKER("- Shadow", 0x30, 0x6F, 0x90);
@ -283,6 +279,12 @@ void IrrDriver::renderScene(scene::ICameraSceneNode * const camnode, unsigned po
PROFILER_POP_CPU_MARKER();
}
PROFILER_PUSH_CPU_MARKER("- Solid Pass 1", 0xFF, 0x00, 0x00);
renderSolidFirstPass();
PROFILER_POP_CPU_MARKER();
// Lights
{
PROFILER_PUSH_CPU_MARKER("- Light", 0x00, 0xFF, 0x00);

View File

@ -83,7 +83,31 @@ void apply_instance(const T *Shader, const std::tuple<TupleType...> &arg)
unroll_args_instance<std::tuple_size<std::tuple<TupleType...> >::value >::template exec<T>(Shader, arg);
}
template<typename Shader, enum E_VERTEX_TYPE VertexType, typename... TupleType>
template<int...List>
struct custom_unroll_args;
template<>
struct custom_unroll_args<>
{
template<typename T, typename ...TupleTypes, typename ...Args>
static void exec(const T *Shader, const std::tuple<TupleTypes...> &t, Args... args)
{
draw<T>(Shader, std::get<0>(t), args...);
}
};
template<int N, int...List>
struct custom_unroll_args<N, List...>
{
template<typename T, typename ...TupleTypes, typename ...Args>
static void exec(const T *Shader, const std::tuple<TupleTypes...> &t, Args... args)
{
custom_unroll_args<List...>::template exec<T>(Shader, t, std::get<N>(t), args...);
}
};
template<typename Shader, enum E_VERTEX_TYPE VertexType, int ...List, typename... TupleType>
void renderMeshes1stPass(const std::vector<GLuint> &TexUnits, std::vector<std::tuple<TupleType...> > &meshes)
{
glUseProgram(Shader::template getInstance<Shader>()->Program);
@ -105,7 +129,7 @@ void renderMeshes1stPass(const std::vector<GLuint> &TexUnits, std::vector<std::t
#endif
continue;
}
apply_instance(Shader::template getInstance<Shader>(), meshes[i]);
custom_unroll_args<List...>::template exec(Shader::template getInstance<Shader>(), meshes[i]);
}
}
@ -122,11 +146,14 @@ void IrrDriver::renderSolidFirstPass()
glDisable(GL_BLEND);
glEnable(GL_CULL_FACE);
irr_driver->setPhase(SOLID_NORMAL_AND_DEPTH_PASS);
ListDefaultStandardG::Arguments.clear();
ListDefault2TCoordG::Arguments.clear();
ListAlphaRefG::Arguments.clear();
ListNormalG::Arguments.clear();
ListGrassG::Arguments.clear();
ListMatDefault::Arguments.clear();
ListMatAlphaRef::Arguments.clear();
ListMatSphereMap::Arguments.clear();
ListMatDetails::Arguments.clear();
ListMatUnlit::Arguments.clear();
ListMatNormalMap::Arguments.clear();
ListMatGrass::Arguments.clear();
ListMatSplatting::Arguments.clear();
m_scene_manager->drawAll(scene::ESNRP_SOLID);
if (!UserConfigParams::m_dynamic_lights)
@ -134,15 +161,18 @@ void IrrDriver::renderSolidFirstPass()
{
ScopedGPUTimer Timer(getGPUTimer(Q_SOLID_PASS1));
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_STANDARD>({ MeshShader::ObjectPass1Shader::getInstance<MeshShader::ObjectPass1Shader>()->TU_tex }, ListDefaultStandardG::Arguments);
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_2TCOORDS>({ MeshShader::ObjectPass1Shader::getInstance<MeshShader::ObjectPass1Shader>()->TU_tex }, ListDefault2TCoordG::Arguments);
renderMeshes1stPass<MeshShader::ObjectRefPass1Shader, video::EVT_STANDARD>({ MeshShader::ObjectRefPass1Shader::getInstance<MeshShader::ObjectRefPass1Shader>()->TU_tex }, ListAlphaRefG::Arguments);
renderMeshes1stPass<MeshShader::NormalMapShader, video::EVT_TANGENTS>({ MeshShader::NormalMapShader::getInstance<MeshShader::NormalMapShader>()->TU_glossy, MeshShader::NormalMapShader::getInstance<MeshShader::NormalMapShader>()->TU_normalmap }, ListNormalG::Arguments);
renderMeshes1stPass<MeshShader::GrassPass1Shader, video::EVT_STANDARD>({ MeshShader::GrassPass1Shader::getInstance<MeshShader::GrassPass1Shader>()->TU_tex }, ListGrassG::Arguments);
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_STANDARD, 2, 1>({ MeshShader::ObjectPass1Shader::getInstance<MeshShader::ObjectPass1Shader>()->TU_tex }, ListMatDefault::Arguments);
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_STANDARD, 2, 1>({ MeshShader::ObjectPass1Shader::getInstance<MeshShader::ObjectPass1Shader>()->TU_tex }, ListMatSphereMap::Arguments);
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_STANDARD, 2, 1>({ MeshShader::ObjectPass1Shader::getInstance<MeshShader::ObjectPass1Shader>()->TU_tex }, ListMatUnlit::Arguments);
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_2TCOORDS, 2, 1>({ MeshShader::ObjectPass1Shader::getInstance<MeshShader::ObjectPass1Shader>()->TU_tex }, ListMatDetails::Arguments);
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_2TCOORDS, 2, 1>({ MeshShader::ObjectPass1Shader::getInstance<MeshShader::ObjectPass1Shader>()->TU_tex }, ListMatSplatting::Arguments);
renderMeshes1stPass<MeshShader::ObjectRefPass1Shader, video::EVT_STANDARD, 3, 2, 1>({ MeshShader::ObjectRefPass1Shader::getInstance<MeshShader::ObjectRefPass1Shader>()->TU_tex }, ListMatAlphaRef::Arguments);
renderMeshes1stPass<MeshShader::GrassPass1Shader, video::EVT_STANDARD, 3, 2, 1>({ MeshShader::GrassPass1Shader::getInstance<MeshShader::GrassPass1Shader>()->TU_tex }, ListMatGrass::Arguments);
// renderMeshes1stPass<MeshShader::NormalMapShader, video::EVT_TANGENTS>({ MeshShader::NormalMapShader::getInstance<MeshShader::NormalMapShader>()->TU_glossy, MeshShader::NormalMapShader::getInstance<MeshShader::NormalMapShader>()->TU_normalmap }, ListNormalG::Arguments);
}
}
template<typename Shader, enum E_VERTEX_TYPE VertexType, typename... TupleType>
template<typename Shader, enum E_VERTEX_TYPE VertexType, int...List, typename... TupleType>
void renderMeshes2ndPass(const std::vector<GLuint> &TexUnits, std::vector<std::tuple<TupleType...> > &meshes)
{
glUseProgram(Shader::template getInstance<Shader>()->Program);
@ -175,7 +205,7 @@ void renderMeshes2ndPass(const std::vector<GLuint> &TexUnits, std::vector<std::t
#endif
continue;
}
apply_instance(Shader::template getInstance<Shader>(), meshes[i]);
custom_unroll_args<List...>::template exec(Shader::template getInstance<Shader>(), meshes[i]);
}
}
@ -201,14 +231,6 @@ void IrrDriver::renderSolidSecondPass()
glEnable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);
glDisable(GL_BLEND);
ListDefaultStandardSM::Arguments.clear();
ListDefaultTangentSM::Arguments.clear();
ListAlphaRefSM::Arguments.clear();
ListSphereMapSM::Arguments.clear();
ListUnlitSM::Arguments.clear();
ListDetailSM::Arguments.clear();
ListSplattingSM::Arguments.clear();
ListGrassSM::Arguments.clear();
setTexture(0, m_rtts->getRenderTarget(RTT_TMP1), GL_NEAREST, GL_NEAREST);
setTexture(1, m_rtts->getRenderTarget(RTT_TMP2), GL_NEAREST, GL_NEAREST);
setTexture(2, m_rtts->getRenderTarget(RTT_HALF1_R), GL_LINEAR, GL_LINEAR);
@ -218,14 +240,13 @@ void IrrDriver::renderSolidSecondPass()
m_scene_manager->drawAll(scene::ESNRP_SOLID);
renderMeshes2ndPass<MeshShader::ObjectPass2Shader, video::EVT_STANDARD>({ MeshShader::ObjectPass2Shader::getInstance<MeshShader::ObjectPass2Shader>()->TU_Albedo }, ListDefaultStandardSM::Arguments);
renderMeshes2ndPass<MeshShader::ObjectPass2Shader, video::EVT_TANGENTS>({ MeshShader::ObjectPass2Shader::getInstance<MeshShader::ObjectPass2Shader>()->TU_Albedo }, ListDefaultTangentSM::Arguments);
renderMeshes2ndPass<MeshShader::ObjectRefPass2Shader, video::EVT_STANDARD>({ MeshShader::ObjectRefPass2Shader::getInstance<MeshShader::ObjectRefPass2Shader>()->TU_Albedo }, ListAlphaRefSM::Arguments);
renderMeshes2ndPass<MeshShader::SphereMapShader, video::EVT_STANDARD>({ MeshShader::SphereMapShader::getInstance<MeshShader::SphereMapShader>()->TU_tex }, ListSphereMapSM::Arguments);
renderMeshes2ndPass<MeshShader::ObjectUnlitShader, video::EVT_STANDARD>({ MeshShader::ObjectUnlitShader::getInstance<MeshShader::ObjectUnlitShader>()->TU_tex }, ListUnlitSM::Arguments);
renderMeshes2ndPass<MeshShader::DetailledObjectPass2Shader, video::EVT_2TCOORDS>({ MeshShader::DetailledObjectPass2Shader::getInstance<MeshShader::DetailledObjectPass2Shader>()->TU_Albedo, MeshShader::DetailledObjectPass2Shader::getInstance<MeshShader::DetailledObjectPass2Shader>()->TU_detail }, ListDetailSM::Arguments);
renderMeshes2ndPass<MeshShader::SplattingShader, video::EVT_2TCOORDS>({ 8, MeshShader::SplattingShader::getInstance<MeshShader::SplattingShader>()->TU_tex_layout, MeshShader::SplattingShader::getInstance<MeshShader::SplattingShader>()->TU_tex_detail0, MeshShader::SplattingShader::getInstance<MeshShader::SplattingShader>()->TU_tex_detail1, MeshShader::SplattingShader::getInstance<MeshShader::SplattingShader>()->TU_tex_detail2, MeshShader::SplattingShader::getInstance<MeshShader::SplattingShader>()->TU_tex_detail3 }, ListSplattingSM::Arguments);
renderMeshes2ndPass<MeshShader::GrassPass2Shader, video::EVT_STANDARD>({ MeshShader::GrassPass2Shader::getInstance<MeshShader::GrassPass2Shader>()->TU_Albedo }, ListGrassSM::Arguments);
renderMeshes2ndPass<MeshShader::ObjectPass2Shader, video::EVT_STANDARD, 4, 3, 1>({ MeshShader::ObjectPass2Shader::getInstance<MeshShader::ObjectPass2Shader>()->TU_Albedo }, ListMatDefault::Arguments);
renderMeshes2ndPass<MeshShader::ObjectRefPass2Shader, video::EVT_STANDARD, 4, 3, 1 >({ MeshShader::ObjectRefPass2Shader::getInstance<MeshShader::ObjectRefPass2Shader>()->TU_Albedo }, ListMatAlphaRef::Arguments);
renderMeshes2ndPass<MeshShader::SphereMapShader, video::EVT_STANDARD, 4, 2, 1>({ MeshShader::SphereMapShader::getInstance<MeshShader::SphereMapShader>()->TU_tex }, ListMatSphereMap::Arguments);
renderMeshes2ndPass<MeshShader::DetailledObjectPass2Shader, video::EVT_2TCOORDS, 4, 1>({ MeshShader::DetailledObjectPass2Shader::getInstance<MeshShader::DetailledObjectPass2Shader>()->TU_Albedo, MeshShader::DetailledObjectPass2Shader::getInstance<MeshShader::DetailledObjectPass2Shader>()->TU_detail }, ListMatDetails::Arguments);
renderMeshes2ndPass<MeshShader::GrassPass2Shader, video::EVT_STANDARD, 4, 3, 1>({ MeshShader::GrassPass2Shader::getInstance<MeshShader::GrassPass2Shader>()->TU_Albedo }, ListMatGrass::Arguments);
renderMeshes2ndPass<MeshShader::ObjectUnlitShader, video::EVT_STANDARD, 1>({ MeshShader::ObjectUnlitShader::getInstance<MeshShader::ObjectUnlitShader>()->TU_tex }, ListMatUnlit::Arguments);
renderMeshes2ndPass<MeshShader::SplattingShader, video::EVT_2TCOORDS, 3, 1>({ 8, MeshShader::SplattingShader::getInstance<MeshShader::SplattingShader>()->TU_tex_layout, MeshShader::SplattingShader::getInstance<MeshShader::SplattingShader>()->TU_tex_detail0, MeshShader::SplattingShader::getInstance<MeshShader::SplattingShader>()->TU_tex_detail1, MeshShader::SplattingShader::getInstance<MeshShader::SplattingShader>()->TU_tex_detail2, MeshShader::SplattingShader::getInstance<MeshShader::SplattingShader>()->TU_tex_detail3 }, ListMatSplatting::Arguments);
}
}
@ -252,16 +273,16 @@ void IrrDriver::renderTransparent()
if (World::getWorld() && World::getWorld()->isFogEnabled())
{
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
renderMeshes2ndPass<MeshShader::TransparentFogShader, video::EVT_STANDARD>({ MeshShader::TransparentFogShader::getInstance<MeshShader::TransparentFogShader>()->TU_tex }, ListBlendTransparentFog::Arguments);
renderMeshes2ndPass<MeshShader::TransparentFogShader, video::EVT_STANDARD, 8, 7, 6, 5, 4, 3, 2, 1>({ MeshShader::TransparentFogShader::getInstance<MeshShader::TransparentFogShader>()->TU_tex }, ListBlendTransparentFog::Arguments);
glBlendFunc(GL_ONE, GL_ONE);
renderMeshes2ndPass<MeshShader::TransparentFogShader, video::EVT_STANDARD>({ MeshShader::TransparentFogShader::getInstance<MeshShader::TransparentFogShader>()->TU_tex }, ListAdditiveTransparentFog::Arguments);
renderMeshes2ndPass<MeshShader::TransparentFogShader, video::EVT_STANDARD, 8, 7, 6, 5, 4, 3, 2, 1>({ MeshShader::TransparentFogShader::getInstance<MeshShader::TransparentFogShader>()->TU_tex }, ListAdditiveTransparentFog::Arguments);
}
else
{
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
renderMeshes2ndPass<MeshShader::TransparentShader, video::EVT_STANDARD>({ MeshShader::TransparentShader::getInstance<MeshShader::TransparentShader>()->TU_tex }, ListBlendTransparent::Arguments);
renderMeshes2ndPass<MeshShader::TransparentShader, video::EVT_STANDARD, 2, 1>({ MeshShader::TransparentShader::getInstance<MeshShader::TransparentShader>()->TU_tex }, ListBlendTransparent::Arguments);
glBlendFunc(GL_ONE, GL_ONE);
renderMeshes2ndPass<MeshShader::TransparentShader, video::EVT_STANDARD>({ MeshShader::TransparentShader::getInstance<MeshShader::TransparentShader>()->TU_tex }, ListAdditiveTransparent::Arguments);
renderMeshes2ndPass<MeshShader::TransparentShader, video::EVT_STANDARD, 2, 1>({ MeshShader::TransparentShader::getInstance<MeshShader::TransparentShader>()->TU_tex }, ListAdditiveTransparent::Arguments);
}
if (!UserConfigParams::m_dynamic_lights)
@ -285,7 +306,7 @@ void IrrDriver::renderTransparent()
glStencilFunc(GL_ALWAYS, 1, 0xFF);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
glBindVertexArray(getVAO(EVT_2TCOORDS));
/* glBindVertexArray(getVAO(EVT_2TCOORDS));
// Generate displace mask
// Use RTT_TMP4 as displace mask
irr_driver->getFBO(FBO_TMP1_WITH_DS).Bind();
@ -339,7 +360,7 @@ void IrrDriver::renderTransparent()
irr_driver->getFBO(FBO_COLORS).Bind();
glStencilFunc(GL_EQUAL, 1, 0xFF);
m_post_processing->renderPassThrough(m_rtts->getRenderTarget(RTT_DISPLACE));
glDisable(GL_STENCIL_TEST);
glDisable(GL_STENCIL_TEST);*/
}
@ -356,10 +377,10 @@ void drawShadow(const T *Shader, const GLMesh *mesh, uniforms... Args)
}
template<int...List>
struct custom_unroll_args;
struct shadow_custom_unroll_args;
template<>
struct custom_unroll_args<>
struct shadow_custom_unroll_args<>
{
template<typename T, typename ...TupleTypes, typename ...Args>
static void exec(const T *Shader, const std::tuple<TupleTypes...> &t, Args... args)
@ -369,18 +390,17 @@ struct custom_unroll_args<>
};
template<int N, int...List>
struct custom_unroll_args<N, List...>
struct shadow_custom_unroll_args<N, List...>
{
template<typename T, typename ...TupleTypes, typename ...Args>
static void exec(const T *Shader, const std::tuple<TupleTypes...> &t, Args... args)
{
custom_unroll_args<List...>::template exec<T>(Shader, t, std::get<N>(t), args...);
shadow_custom_unroll_args<List...>::template exec<T>(Shader, t, std::get<N>(t), args...);
}
};
template<typename T, enum E_VERTEX_TYPE VertexType, int...List, typename... Args>
void drawShadow(const T *Shader, const std::vector<GLuint> TextureUnits, const std::vector<std::tuple<GLMesh *, core::matrix4, Args...> >&t)
void renderShadow(const T *Shader, const std::vector<GLuint> TextureUnits, const std::vector<std::tuple<GLMesh *, core::matrix4, Args...> >&t)
{
glUseProgram(Shader->Program);
glBindVertexArray(getVAO(VertexType));
@ -393,7 +413,7 @@ void drawShadow(const T *Shader, const std::vector<GLuint> TextureUnits, const s
setTexture(TextureUnits[j], getTextureGLuint(mesh->textures[j]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
}
custom_unroll_args<List...>::template exec<T>(Shader, t[i]);
shadow_custom_unroll_args<List...>::template exec<T>(Shader, t[i]);
}
}
@ -416,7 +436,9 @@ void drawRSM(const core::matrix4 & rsm_matrix, const std::vector<GLuint> Texture
void IrrDriver::renderShadows()
{
irr_driver->setPhase(SHADOW_PASS);
glDepthFunc(GL_LEQUAL);
glDepthMask(GL_TRUE);
glEnable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(1.5, 0.);
@ -426,13 +448,24 @@ void IrrDriver::renderShadows()
glBindBufferBase(GL_UNIFORM_BUFFER, 0, SharedObject::ViewProjectionMatrixesUBO);
irr_driver->setPhase(SHADOW_PASS);
ListMatDefault::Arguments.clear();
ListMatAlphaRef::Arguments.clear();
ListMatSphereMap::Arguments.clear();
ListMatDetails::Arguments.clear();
ListMatUnlit::Arguments.clear();
ListMatNormalMap::Arguments.clear();
ListMatGrass::Arguments.clear();
ListMatSplatting::Arguments.clear();
m_scene_manager->drawAll(scene::ESNRP_SOLID);
drawShadow<MeshShader::ShadowShader, EVT_STANDARD, 1>(MeshShader::ShadowShaderInstance, {}, ListDefaultStandardG::Arguments);
drawShadow<MeshShader::ShadowShader, EVT_2TCOORDS, 1>(MeshShader::ShadowShaderInstance, {}, ListDefault2TCoordG::Arguments);
drawShadow<MeshShader::ShadowShader, EVT_TANGENTS, 1>(MeshShader::ShadowShaderInstance, {}, ListNormalG::Arguments);
drawShadow<MeshShader::RefShadowShader, EVT_STANDARD, 1>(MeshShader::RefShadowShaderInstance, { MeshShader::RefShadowShaderInstance->TU_tex }, ListAlphaRefG::Arguments);
drawShadow<MeshShader::GrassShadowShader, EVT_STANDARD, 3, 1>(MeshShader::GrassShadowShaderInstance, { MeshShader::GrassShadowShaderInstance->TU_tex }, ListGrassG::Arguments);
renderShadow<MeshShader::ShadowShader, EVT_STANDARD, 1>(MeshShader::ShadowShaderInstance, {}, ListMatDefault::Arguments);
renderShadow<MeshShader::ShadowShader, EVT_STANDARD, 1>(MeshShader::ShadowShaderInstance, {}, ListMatSphereMap::Arguments);
renderShadow<MeshShader::ShadowShader, EVT_STANDARD, 1>(MeshShader::ShadowShaderInstance, {}, ListMatUnlit::Arguments);
renderShadow<MeshShader::ShadowShader, EVT_2TCOORDS, 1>(MeshShader::ShadowShaderInstance, {}, ListMatDetails::Arguments);
renderShadow<MeshShader::ShadowShader, EVT_2TCOORDS, 1>(MeshShader::ShadowShaderInstance, {}, ListMatSplatting::Arguments);
renderShadow<MeshShader::RefShadowShader, EVT_STANDARD, 1>(MeshShader::RefShadowShaderInstance, { MeshShader::RefShadowShaderInstance->TU_tex }, ListMatAlphaRef::Arguments);
renderShadow<MeshShader::GrassShadowShader, EVT_STANDARD, 3, 1>(MeshShader::GrassShadowShaderInstance, { MeshShader::GrassShadowShaderInstance->TU_tex }, ListMatGrass::Arguments);
glDisable(GL_POLYGON_OFFSET_FILL);
@ -442,6 +475,6 @@ void IrrDriver::renderShadows()
m_rtts->getRSM().Bind();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
drawRSM<EVT_STANDARD>(rsm_matrix, { MeshShader::RSMShader::TU_tex }, ListDefaultStandardG::Arguments);
drawRSM<EVT_2TCOORDS>(rsm_matrix, { MeshShader::RSMShader::TU_tex }, ListDefault2TCoordG::Arguments);
// drawRSM<EVT_STANDARD>(rsm_matrix, { MeshShader::RSMShader::TU_tex }, ListDefaultStandardG::Arguments);
// drawRSM<EVT_2TCOORDS>(rsm_matrix, { MeshShader::RSMShader::TU_tex }, ListDefault2TCoordG::Arguments);
}

View File

@ -39,10 +39,8 @@ void STKAnimatedMesh::setMesh(scene::IAnimatedMesh* mesh)
{
firstTime = true;
GLmeshes.clear();
for (unsigned i = 0; i < FPSM_COUNT; i++)
GeometricMesh[i].clearWithoutDeleting();
for (unsigned i = 0; i < SM_COUNT; i++)
ShadedMesh[i].clearWithoutDeleting();
for (unsigned i = 0; i < MAT_COUNT; i++)
MeshSolidMaterial[i].clearWithoutDeleting();
CAnimatedMeshSceneNode::setMesh(mesh);
}
@ -98,10 +96,8 @@ void STKAnimatedMesh::render()
}
else
{
GeometricMaterial GeometricType = MaterialTypeToGeometricMaterial(type, mb->getVertexType());
ShadedMaterial ShadedType = MaterialTypeToShadedMaterial(type, mesh.textures, mb->getVertexType());
GeometricMesh[GeometricType].push_back(&mesh);
ShadedMesh[ShadedType].push_back(&mesh);
MeshMaterial MatType = MaterialTypeToMeshMaterial(type, mb->getVertexType());
MeshSolidMaterial[MatType].push_back(&mesh);
}
std::pair<unsigned, unsigned> p = getVAOOffsetAndBase(mb);
mesh.vaoBaseVertex = p.first;
@ -117,7 +113,7 @@ void STKAnimatedMesh::render()
const video::SMaterial& material = ReadOnlyMaterials ? mb->getMaterial() : Materials[i];
if (isObject(material.MaterialType))
{
if (irr_driver->getPhase() == SOLID_NORMAL_AND_DEPTH_PASS || irr_driver->getPhase() == TRANSPARENT_PASS)
if (irr_driver->getPhase() == SOLID_NORMAL_AND_DEPTH_PASS || irr_driver->getPhase() == TRANSPARENT_PASS || irr_driver->getPhase() == SHADOW_PASS)
{
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, getVBO(mb->getVertexType()));
@ -137,45 +133,24 @@ void STKAnimatedMesh::render()
continue;
}
if (irr_driver->getPhase() == SOLID_NORMAL_AND_DEPTH_PASS)
if (irr_driver->getPhase() == SOLID_NORMAL_AND_DEPTH_PASS || irr_driver->getPhase() == SHADOW_PASS)
{
ModelViewProjectionMatrix = computeMVP(AbsoluteTransformation);
core::matrix4 invmodel;
AbsoluteTransformation.getInverse(invmodel);
GLMesh* mesh;
for_in(mesh, GeometricMesh[FPSM_DEFAULT_STANDARD])
ListDefaultStandardG::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, invmodel));
for_in(mesh, MeshSolidMaterial[MAT_DEFAULT])
ListMatDefault::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix, irr_driver->getSceneManager()->getAmbientLight()));
for_in(mesh, GeometricMesh[FPSM_DEFAULT_2TCOORD])
ListDefault2TCoordG::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, invmodel));
for_in(mesh, MeshSolidMaterial[MAT_ALPHA_REF])
ListMatAlphaRef::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix, irr_driver->getSceneManager()->getAmbientLight()));
for_in(mesh, GeometricMesh[FPSM_ALPHA_REF_TEXTURE])
ListAlphaRefG::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix));
for_in(mesh, MeshSolidMaterial[MAT_DETAIL])
ListMatDetails::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix, irr_driver->getSceneManager()->getAmbientLight()));
return;
}
if (irr_driver->getPhase() == SOLID_LIT_PASS)
{
core::matrix4 invmodel;
AbsoluteTransformation.getInverse(invmodel);
GLMesh* mesh;
for_in(mesh, ShadedMesh[SM_DEFAULT_STANDARD])
ListDefaultStandardSM::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, mesh->TextureMatrix, irr_driver->getSceneManager()->getAmbientLight()));
for_in(mesh, ShadedMesh[SM_DEFAULT_TANGENT])
ListDefaultTangentSM::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, mesh->TextureMatrix, irr_driver->getSceneManager()->getAmbientLight()));
for_in(mesh, ShadedMesh[SM_ALPHA_REF_TEXTURE])
ListAlphaRefSM::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, mesh->TextureMatrix, irr_driver->getSceneManager()->getAmbientLight()));
for_in (mesh, ShadedMesh[SM_UNLIT])
ListUnlitSM::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation));
for_in(mesh, ShadedMesh[SM_DETAILS])
ListDetailSM::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, irr_driver->getSceneManager()->getAmbientLight()));
for_in(mesh, MeshSolidMaterial[MAT_UNLIT])
ListMatUnlit::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, core::matrix4::EM4CONST_IDENTITY));
return;
}

View File

@ -11,8 +11,7 @@ class STKAnimatedMesh : public irr::scene::CAnimatedMeshSceneNode
{
protected:
bool firstTime;
PtrVector<GLMesh, REF> GeometricMesh[FPSM_COUNT];
PtrVector<GLMesh, REF> ShadedMesh[SM_COUNT];
PtrVector<GLMesh, REF> MeshSolidMaterial[FPSM_COUNT];
PtrVector<GLMesh, REF> TransparentMesh[TM_COUNT];
std::vector<GLMesh> GLmeshes;
core::matrix4 ModelViewProjectionMatrix;

View File

@ -55,7 +55,7 @@ void STKInstancedSceneNode::createGLMeshes()
isMaterialInitialized = false;
}
void STKInstancedSceneNode::initinstancedvaostate(GLMesh &mesh, GeometricMaterial GeoMat, ShadedMaterial ShadedMat)
void STKInstancedSceneNode::initinstancedvaostate(GLMesh &mesh)
{
mesh.vao = createVAO(mesh.vertex_buffer, mesh.index_buffer, getVTXTYPEFromStride(mesh.Stride));
glGenBuffers(1, &instances_vbo);
@ -99,9 +99,9 @@ void STKInstancedSceneNode::setFirstTimeMaterial()
video::E_MATERIAL_TYPE type = mb->getMaterial().MaterialType;
GLMesh &mesh = GLmeshes[i];
GeometricMaterial GeometricType = MaterialTypeToGeometricMaterial(type, mb->getVertexType());
ShadedMaterial ShadedType = MaterialTypeToShadedMaterial(type, mesh.textures, mb->getVertexType());
initinstancedvaostate(mesh, GeometricType, ShadedType);
GeometricMaterial GeometricType;// = MaterialTypeToGeometricMaterial(type, mb->getVertexType());
ShadedMaterial ShadedType;// = MaterialTypeToShadedMaterial(type, mesh.textures, mb->getVertexType());
initinstancedvaostate(mesh);
GeometricMesh[GeometricType].push_back(&mesh);
ShadedMesh[ShadedType].push_back(&mesh);
}

View File

@ -17,7 +17,7 @@ protected:
void createGLMeshes();
bool isMaterialInitialized;
void setFirstTimeMaterial();
void initinstancedvaostate(GLMesh &mesh, GeometricMaterial GeoMat, ShadedMaterial ShadedMat);
void initinstancedvaostate(GLMesh &mesh);
void cleanGL();
core::vector3df windDir;
public:

View File

@ -9,37 +9,23 @@
#include "graphics/camera.hpp"
#include "modes/world.hpp"
GeometricMaterial MaterialTypeToGeometricMaterial(video::E_MATERIAL_TYPE MaterialType, video::E_VERTEX_TYPE tp)
MeshMaterial MaterialTypeToMeshMaterial(video::E_MATERIAL_TYPE MaterialType, video::E_VERTEX_TYPE tp)
{
if (tp == irr_driver->getShader(ES_SPHERE_MAP))
return MAT_SPHEREMAP;
if (MaterialType == irr_driver->getShader(ES_NORMAL_MAP))
return FPSM_NORMAL_MAP;
return MAT_NORMAL_MAP;
else if (MaterialType == irr_driver->getShader(ES_OBJECTPASS_REF) || MaterialType == video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF)
return FPSM_ALPHA_REF_TEXTURE;
return MAT_ALPHA_REF;
else if (MaterialType == irr_driver->getShader(ES_GRASS) || MaterialType == irr_driver->getShader(ES_GRASS_REF))
return FPSM_GRASS;
return MAT_GRASS;
else if (tp == irr_driver->getShader(ES_SPLATTING))
return MAT_SPLATTING;
else if (tp == irr_driver->getShader(ES_OBJECT_UNLIT))
return MAT_UNLIT;
else if (tp == video::EVT_2TCOORDS)
return FPSM_DEFAULT_2TCOORD;
assert(tp == video::EVT_STANDARD);
return FPSM_DEFAULT_STANDARD;
}
ShadedMaterial MaterialTypeToShadedMaterial(video::E_MATERIAL_TYPE type, video::ITexture **textures, video::E_VERTEX_TYPE tp)
{
if (type == irr_driver->getShader(ES_SPHERE_MAP))
return SM_SPHEREMAP;
else if (type == irr_driver->getShader(ES_SPLATTING))
return SM_SPLATTING;
else if (type == irr_driver->getShader(ES_OBJECTPASS_REF) || type == video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF)
return SM_ALPHA_REF_TEXTURE;
else if (type == irr_driver->getShader(ES_GRASS) || type == irr_driver->getShader(ES_GRASS_REF))
return SM_GRASS;
else if (type == irr_driver->getShader(ES_OBJECT_UNLIT))
return SM_UNLIT;
else if (tp == video::EVT_2TCOORDS)
return SM_DETAILS;
else if (tp == video::EVT_TANGENTS)
return SM_DEFAULT_TANGENT;
return SM_DEFAULT_STANDARD;
return MAT_DETAIL;
return MAT_DEFAULT;
}
TransparentMaterial MaterialTypeToTransparentMaterial(video::E_MATERIAL_TYPE type, f32 MaterialTypeParam)
@ -307,22 +293,17 @@ bool isObject(video::E_MATERIAL_TYPE type)
return false;
}
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4> > ListDefaultStandardG::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4> > ListDefault2TCoordG::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4> > ListAlphaRefG::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4> > ListNormalG::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::vector3df> > ListGrassG::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > ListMatDefault::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > ListMatAlphaRef::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > ListMatSphereMap::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > ListMatDetails::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::vector3df, video::SColorf> > ListMatGrass::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4> > ListMatUnlit::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, video::SColorf> > ListMatSplatting::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4> > ListMatNormalMap::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, video::SColorf> > ListDefaultStandardSM::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, video::SColorf> > ListDefaultTangentSM::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, video::SColorf> > ListAlphaRefSM::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4, video::SColorf> > ListSplattingSM::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, video::SColorf> > ListSphereMapSM::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4> > ListUnlitSM::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4, video::SColorf> > ListDetailSM::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4> > ListBlendTransparent::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4> > ListAdditiveTransparent::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4> > ListDisplacement::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, float, float, float, float, float, video::SColorf> > ListBlendTransparentFog::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, float, float, float, float, float, video::SColorf> > ListAdditiveTransparentFog::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4, core::vector3df, video::SColorf> > ListGrassSM::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4> > ListDisplacement::Arguments;

View File

@ -12,6 +12,7 @@
#include <vector>
enum GeometricMaterial
{
FPSM_DEFAULT_STANDARD,
FPSM_DEFAULT_2TCOORD,
@ -34,6 +35,19 @@ enum ShadedMaterial
SM_COUNT
};
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,
@ -69,85 +83,54 @@ bool isObject(video::E_MATERIAL_TYPE type);
core::vector3df getWind();
// Pass 1 shader (ie shaders that outputs normals and depth)
class ListDefaultStandardG
class ListMatDefault
{
public:
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > Arguments;
};
class ListMatAlphaRef
{
public:
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > Arguments;
};
class ListMatNormalMap
{
public:
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4> > Arguments;
};
class ListDefault2TCoordG
class ListMatGrass
{
public:
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::vector3df, video::SColorf> > Arguments;
};
class ListMatSphereMap
{
public:
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > Arguments;
};
class ListMatSplatting
{
public:
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, video::SColorf> > Arguments;
};
class ListMatUnlit
{
public:
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4> > Arguments;
};
class ListAlphaRefG
class ListMatDetails
{
public:
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4> > Arguments;
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > Arguments;
};
class ListNormalG
{
public:
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4> > Arguments;
};
class ListGrassG
{
public:
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::vector3df> > Arguments;
};
// Pass 2 shader (ie shaders that outputs final color)
class ListDefaultStandardSM
{
public:
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, video::SColorf> > Arguments;
};
class ListDefaultTangentSM
{
public:
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, video::SColorf> > Arguments;
};
class ListAlphaRefSM
{
public:
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, video::SColorf> > Arguments;
};
class ListSphereMapSM
{
public:
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, video::SColorf> > Arguments;
};
class ListSplattingSM
{
public:
static std::vector<std::tuple<GLMesh *, core::matrix4, video::SColorf> > Arguments;
};
class ListUnlitSM
{
public:
static std::vector<std::tuple<GLMesh *, core::matrix4> > Arguments;
};
class ListDetailSM
{
public:
static std::vector<std::tuple<GLMesh *, core::matrix4, video::SColorf> > Arguments;
};
class ListGrassSM
{
public:
static std::vector<std::tuple<GLMesh *, core::matrix4, core::vector3df, video::SColorf> > Arguments;
};
class ListBlendTransparent
{
@ -182,8 +165,7 @@ public:
// Forward pass (for transparents meshes)
void drawBubble(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix);
GeometricMaterial MaterialTypeToGeometricMaterial(video::E_MATERIAL_TYPE, video::E_VERTEX_TYPE);
ShadedMaterial MaterialTypeToShadedMaterial(video::E_MATERIAL_TYPE, irr::video::ITexture **textures, video::E_VERTEX_TYPE tp);
MeshMaterial MaterialTypeToMeshMaterial(video::E_MATERIAL_TYPE, video::E_VERTEX_TYPE);
TransparentMaterial MaterialTypeToTransparentMaterial(video::E_MATERIAL_TYPE, f32 MaterialTypeParam);
#endif // STKMESH_H

View File

@ -78,8 +78,7 @@ void STKMeshSceneNode::setFirstTimeMaterial()
else
{
assert(!isDisplacement);
GeometricMaterial GeometricType = MaterialTypeToGeometricMaterial(type, mb->getVertexType());
ShadedMaterial ShadedType = MaterialTypeToShadedMaterial(type, mesh.textures, mb->getVertexType());
MeshMaterial MatType = MaterialTypeToMeshMaterial(type, mb->getVertexType());
if (immediate_draw)
{
fillLocalBuffer(mesh, mb);
@ -87,10 +86,7 @@ void STKMeshSceneNode::setFirstTimeMaterial()
glBindVertexArray(0);
}
else
{
GeometricMesh[GeometricType].push_back(&mesh);
ShadedMesh[ShadedType].push_back(&mesh);
}
MeshSolidMaterials[MatType].push_back(&mesh);
}
if (!immediate_draw)
@ -117,10 +113,8 @@ void STKMeshSceneNode::cleanGLMeshes()
glDeleteBuffers(1, &(mesh.index_buffer));
}
GLmeshes.clear();
for (unsigned i = 0; i < FPSM_COUNT; i++)
GeometricMesh[i].clearWithoutDeleting();
for (unsigned i = 0; i < SM_COUNT; i++)
ShadedMesh[i].clearWithoutDeleting();
for (unsigned i = 0; i < MAT_COUNT; i++)
MeshSolidMaterials[i].clearWithoutDeleting();
}
void STKMeshSceneNode::setMesh(irr::scene::IMesh* mesh)
@ -215,53 +209,77 @@ void STKMeshSceneNode::render()
GLmeshes[i].TextureMatrix = getMaterial(i).getTextureMatrix(0);
}
if (irr_driver->getPhase() == SOLID_NORMAL_AND_DEPTH_PASS)
if (irr_driver->getPhase() == SOLID_NORMAL_AND_DEPTH_PASS && immediate_draw)
{
core::matrix4 invmodel;
AbsoluteTransformation.getInverse(invmodel);
if (immediate_draw)
glDisable(GL_CULL_FACE);
if (update_each_frame)
updatevbo();
glUseProgram(MeshShader::ObjectPass1Shader::getInstance<MeshShader::ObjectPass1Shader>()->Program);
// Only untextured
for (unsigned i = 0; i < GLmeshes.size(); i++)
{
glDisable(GL_CULL_FACE);
if (update_each_frame)
updatevbo();
glUseProgram(MeshShader::ObjectPass1Shader::getInstance<MeshShader::ObjectPass1Shader>()->Program);
// Only untextured
for (unsigned i = 0; i < GLmeshes.size(); i++)
{
irr_driver->IncreaseObjectCount();
GLMesh &mesh = GLmeshes[i];
GLenum ptype = mesh.PrimitiveType;
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
irr_driver->IncreaseObjectCount();
GLMesh &mesh = GLmeshes[i];
GLenum ptype = mesh.PrimitiveType;
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
MeshShader::ObjectPass1Shader::getInstance()->setUniforms(AbsoluteTransformation, invmodel);
assert(mesh.vao);
glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
glBindVertexArray(0);
}
glEnable(GL_CULL_FACE);
return;
MeshShader::ObjectPass1Shader::getInstance()->setUniforms(AbsoluteTransformation, invmodel);
assert(mesh.vao);
glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
glBindVertexArray(0);
}
glEnable(GL_CULL_FACE);
return;
}
if (irr_driver->getPhase() == SOLID_NORMAL_AND_DEPTH_PASS || irr_driver->getPhase() == SHADOW_PASS)
{
core::matrix4 invmodel;
AbsoluteTransformation.getInverse(invmodel);
GLMesh* mesh;
for_in(mesh, GeometricMesh[FPSM_DEFAULT_STANDARD])
ListDefaultStandardG::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, invmodel));
for_in(mesh, MeshSolidMaterials[MAT_DEFAULT])
ListMatDefault::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix, irr_driver->getSceneManager()->getAmbientLight()));
for_in(mesh, GeometricMesh[FPSM_DEFAULT_2TCOORD])
ListDefault2TCoordG::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, invmodel));
for_in(mesh, MeshSolidMaterials[MAT_ALPHA_REF])
ListMatAlphaRef::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix, irr_driver->getSceneManager()->getAmbientLight()));
for_in(mesh, GeometricMesh[FPSM_ALPHA_REF_TEXTURE])
ListAlphaRefG::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix));
for_in(mesh, MeshSolidMaterials[MAT_SPHEREMAP])
ListMatSphereMap::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix, irr_driver->getSceneManager()->getAmbientLight()));
for_in(mesh, MeshSolidMaterials[MAT_DETAIL])
ListMatDetails::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix, irr_driver->getSceneManager()->getAmbientLight()));
windDir = getWind();
for_in(mesh, MeshSolidMaterials[MAT_GRASS])
ListMatGrass::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, invmodel, windDir, irr_driver->getSceneManager()->getAmbientLight()));
for_in(mesh, MeshSolidMaterials[MAT_UNLIT])
ListMatUnlit::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, core::matrix4::EM4CONST_IDENTITY));
for_in(mesh, MeshSolidMaterials[MAT_SPLATTING])
ListMatSplatting::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, invmodel, irr_driver->getSceneManager()->getAmbientLight()));
/*
for_in(mesh, GeometricMesh[FPSM_NORMAL_MAP])
ListNormalG::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, invmodel));
windDir = getWind();
for_in(mesh, GeometricMesh[FPSM_GRASS])
ListGrassG::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, invmodel, windDir));
*/
/*
for_in(mesh, ShadedMesh[SM_DEFAULT_TANGENT])
ListDefaultTangentSM::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, mesh->TextureMatrix, irr_driver->getSceneManager()->getAmbientLight()));
*/
return;
}
@ -297,31 +315,6 @@ void STKMeshSceneNode::render()
return;
}
GLMesh* mesh;
for_in(mesh, ShadedMesh[SM_DEFAULT_STANDARD])
ListDefaultStandardSM::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, mesh->TextureMatrix, irr_driver->getSceneManager()->getAmbientLight()));
for_in(mesh, ShadedMesh[SM_DEFAULT_TANGENT])
ListDefaultTangentSM::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, mesh->TextureMatrix, irr_driver->getSceneManager()->getAmbientLight()));
for_in(mesh, ShadedMesh[SM_ALPHA_REF_TEXTURE])
ListAlphaRefSM::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, mesh->TextureMatrix, irr_driver->getSceneManager()->getAmbientLight()));
for_in(mesh, ShadedMesh[SM_SPHEREMAP])
ListSphereMapSM::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, invmodel, irr_driver->getSceneManager()->getAmbientLight()));
for_in(mesh, ShadedMesh[SM_SPLATTING])
ListSplattingSM::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, irr_driver->getSceneManager()->getAmbientLight()));
for_in(mesh, ShadedMesh[SM_UNLIT])
ListUnlitSM::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation));
for_in(mesh, ShadedMesh[SM_DETAILS])
ListDetailSM::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, irr_driver->getSceneManager()->getAmbientLight()));
for_in(mesh, ShadedMesh[SM_GRASS])
ListGrassSM::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation, windDir, irr_driver->getSceneManager()->getAmbientLight()));
return;
}

View File

@ -7,8 +7,7 @@
class STKMeshSceneNode : public irr::scene::CMeshSceneNode
{
protected:
PtrVector<GLMesh, REF> GeometricMesh[FPSM_COUNT];
PtrVector<GLMesh, REF> ShadedMesh[SM_COUNT];
PtrVector<GLMesh, REF> MeshSolidMaterials[MAT_COUNT];
PtrVector<GLMesh, REF> TransparentMesh[TM_COUNT];
std::vector<GLMesh> GLmeshes;
core::matrix4 ModelViewProjectionMatrix;