Merge branch 'TupleTest'
This commit is contained in:
commit
9478adbd8c
@ -28,9 +28,55 @@
|
||||
#include "utils/helpers.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/profiler.hpp"
|
||||
#include "utils/tuple.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace RenderGeometry
|
||||
{
|
||||
struct TexUnit
|
||||
{
|
||||
GLuint m_id;
|
||||
bool m_premul_alpha;
|
||||
|
||||
TexUnit(GLuint id, bool premul_alpha)
|
||||
{
|
||||
m_id = id;
|
||||
m_premul_alpha = premul_alpha;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
std::vector<TexUnit> TexUnits(T curr) // required on older clang versions
|
||||
{
|
||||
std::vector<TexUnit> v;
|
||||
v.push_back(curr);
|
||||
return v;
|
||||
}
|
||||
|
||||
template <typename T, typename... R>
|
||||
std::vector<TexUnit> TexUnits(T curr, R... rest) // required on older clang versions
|
||||
{
|
||||
std::vector<TexUnit> v;
|
||||
v.push_back(curr);
|
||||
VTexUnits(v, rest...);
|
||||
return v;
|
||||
}
|
||||
|
||||
template <typename T, typename... R>
|
||||
void VTexUnits(std::vector<TexUnit>& v, T curr, R... rest) // required on older clang versions
|
||||
{
|
||||
v.push_back(curr);
|
||||
VTexUnits(v, rest...);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void VTexUnits(std::vector<TexUnit>& v, T curr)
|
||||
{
|
||||
v.push_back(curr);
|
||||
}
|
||||
}
|
||||
using namespace RenderGeometry;
|
||||
|
||||
template<typename Shader, typename...uniforms>
|
||||
void draw(const GLMesh *mesh, uniforms... Args)
|
||||
@ -61,9 +107,9 @@ template<unsigned N>
|
||||
struct unroll_args_instance
|
||||
{
|
||||
template<typename T, typename ...TupleTypes, typename ...Args>
|
||||
static void exec(const T *Shader, const std::tuple<TupleTypes...> &t, Args... args)
|
||||
static void exec(const T *Shader, const STK::Tuple<TupleTypes...> &t, Args... args)
|
||||
{
|
||||
unroll_args_instance<N - 1>::template exec<T>(Shader, t, std::get<N - 1>(t), args...);
|
||||
unroll_args_instance<N - 1>::template exec<T>(Shader, t, STK::tuple_get<N - 1>(t), args...);
|
||||
}
|
||||
};
|
||||
|
||||
@ -71,16 +117,17 @@ template<>
|
||||
struct unroll_args_instance<0>
|
||||
{
|
||||
template<typename T, typename ...TupleTypes, typename ...Args>
|
||||
static void exec(const T *Shader, const std::tuple<TupleTypes...> &t, Args... args)
|
||||
static void exec(const T *Shader, const STK::Tuple<TupleTypes...> &t, Args... args)
|
||||
{
|
||||
draw<T>(Shader, args...);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, typename... TupleType>
|
||||
void apply_instance(const T *Shader, const std::tuple<TupleType...> &arg)
|
||||
void apply_instance(const T *Shader, const STK::Tuple<TupleType...> &arg)
|
||||
{
|
||||
unroll_args_instance<std::tuple_size<std::tuple<TupleType...> >::value >::template exec<T>(Shader, arg);
|
||||
unroll_args_instance<sizeof...(TupleType)>::template exec<T>(Shader, arg);
|
||||
//unroll_args_instance<STK::TupleSize<STK::Tuple<TupleType...> >::value >::template exec<T>(Shader, arg);
|
||||
}
|
||||
|
||||
template<int...List>
|
||||
@ -90,9 +137,9 @@ 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)
|
||||
static void exec(const T *Shader, const STK::Tuple<TupleTypes...> &t, Args... args)
|
||||
{
|
||||
draw<T>(Shader, std::get<0>(t), args...);
|
||||
draw<T>(Shader, STK::tuple_get<0>(t), args...);
|
||||
}
|
||||
};
|
||||
|
||||
@ -100,27 +147,27 @@ 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)
|
||||
static void exec(const T *Shader, const STK::Tuple<TupleTypes...> &t, Args... args)
|
||||
{
|
||||
custom_unroll_args<List...>::template exec<T>(Shader, t, std::get<N>(t), args...);
|
||||
custom_unroll_args<List...>::template exec<T>(Shader, t, STK::tuple_get<N>(t), args...);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename Shader, enum E_VERTEX_TYPE VertexType, int ...List, typename... TupleType>
|
||||
void renderMeshes1stPass(const std::vector<std::pair<GLuint, bool> > &TexUnits, std::vector<std::tuple<TupleType...> > &meshes)
|
||||
void renderMeshes1stPass(const std::vector<TexUnit> &TexUnits, std::vector<STK::Tuple<TupleType...> > &meshes)
|
||||
{
|
||||
glUseProgram(Shader::getInstance()->Program);
|
||||
glBindVertexArray(getVAO(VertexType));
|
||||
for (unsigned i = 0; i < meshes.size(); i++)
|
||||
{
|
||||
GLMesh &mesh = *(std::get<0>(meshes[i]));
|
||||
GLMesh &mesh = *(STK::tuple_get<0>(meshes[i]));
|
||||
for (unsigned j = 0; j < TexUnits.size(); j++)
|
||||
{
|
||||
if (!mesh.textures[j])
|
||||
mesh.textures[j] = getUnicolorTexture(video::SColor(255, 255, 255, 255));
|
||||
compressTexture(mesh.textures[j], TexUnits[j].second);
|
||||
setTexture(TexUnits[j].first, getTextureGLuint(mesh.textures[j]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
compressTexture(mesh.textures[j], TexUnits[j].m_premul_alpha);
|
||||
setTexture(TexUnits[j].m_id, getTextureGLuint(mesh.textures[j]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
}
|
||||
if (mesh.VAOType != VertexType)
|
||||
{
|
||||
@ -161,31 +208,36 @@ void IrrDriver::renderSolidFirstPass()
|
||||
|
||||
{
|
||||
ScopedGPUTimer Timer(getGPUTimer(Q_SOLID_PASS1));
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_STANDARD, 2, 1>({ { MeshShader::ObjectPass1Shader::getInstance()->TU_tex, true } }, ListMatDefault::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_STANDARD, 2, 1>({ { MeshShader::ObjectPass1Shader::getInstance()->TU_tex, true } }, ListMatSphereMap::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_STANDARD, 2, 1>({ { MeshShader::ObjectPass1Shader::getInstance()->TU_tex, true } }, ListMatUnlit::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_2TCOORDS, 2, 1>({ { MeshShader::ObjectPass1Shader::getInstance()->TU_tex, true } }, ListMatDetails::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_2TCOORDS, 2, 1>({ { MeshShader::ObjectPass1Shader::getInstance()->TU_tex, true } }, ListMatSplatting::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectRefPass1Shader, video::EVT_STANDARD, 3, 2, 1>({ { MeshShader::ObjectRefPass1Shader::getInstance()->TU_tex, true } }, ListMatAlphaRef::Arguments);
|
||||
renderMeshes1stPass<MeshShader::GrassPass1Shader, video::EVT_STANDARD, 3, 2, 1>({ { MeshShader::GrassPass1Shader::getInstance()->TU_tex, true } }, ListMatGrass::Arguments);
|
||||
renderMeshes1stPass<MeshShader::NormalMapShader, video::EVT_TANGENTS, 2, 1>({ { MeshShader::NormalMapShader::getInstance()->TU_glossy, true }, { MeshShader::NormalMapShader::getInstance()->TU_normalmap, false } }, ListMatNormalMap::Arguments);
|
||||
|
||||
std::vector<TexUnit> object_pass1_texunits = TexUnits(TexUnit(MeshShader::ObjectPass1Shader::getInstance()->TU_tex, true) );
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_STANDARD, 2, 1>(object_pass1_texunits, ListMatDefault::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_STANDARD, 2, 1>(object_pass1_texunits, ListMatSphereMap::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_STANDARD, 2, 1>(object_pass1_texunits, ListMatUnlit::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_2TCOORDS, 2, 1>(object_pass1_texunits, ListMatDetails::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_2TCOORDS, 2, 1>(object_pass1_texunits, ListMatSplatting::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectRefPass1Shader, video::EVT_STANDARD, 3, 2, 1>(TexUnits(TexUnit(MeshShader::ObjectRefPass1Shader::getInstance()->TU_tex, true)), ListMatAlphaRef::Arguments);
|
||||
renderMeshes1stPass<MeshShader::GrassPass1Shader, video::EVT_STANDARD, 3, 2, 1>(TexUnits(TexUnit(MeshShader::GrassPass1Shader::getInstance()->TU_tex, true)), ListMatGrass::Arguments);
|
||||
renderMeshes1stPass<MeshShader::NormalMapShader, video::EVT_TANGENTS, 2, 1>(TexUnits(
|
||||
TexUnit(MeshShader::NormalMapShader::getInstance()->TU_glossy, true),
|
||||
TexUnit(MeshShader::NormalMapShader::getInstance()->TU_normalmap, false)
|
||||
), ListMatNormalMap::Arguments);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Shader, enum E_VERTEX_TYPE VertexType, int...List, typename... TupleType>
|
||||
void renderMeshes2ndPass(const std::vector<std::pair<GLuint, bool> > &TexUnits, std::vector<std::tuple<TupleType...> > &meshes)
|
||||
void renderMeshes2ndPass(const std::vector<TexUnit> &TexUnits, std::vector<STK::Tuple<TupleType...> > &meshes)
|
||||
{
|
||||
glUseProgram(Shader::getInstance()->Program);
|
||||
glBindVertexArray(getVAO(VertexType));
|
||||
for (unsigned i = 0; i < meshes.size(); i++)
|
||||
{
|
||||
GLMesh &mesh = *(std::get<0>(meshes[i]));
|
||||
GLMesh &mesh = *(STK::tuple_get<0>(meshes[i]));
|
||||
for (unsigned j = 0; j < TexUnits.size(); j++)
|
||||
{
|
||||
if (!mesh.textures[j])
|
||||
mesh.textures[j] = getUnicolorTexture(video::SColor(255, 255, 255, 255));
|
||||
compressTexture(mesh.textures[j], TexUnits[j].second);
|
||||
setTexture(TexUnits[j].first, getTextureGLuint(mesh.textures[j]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
compressTexture(mesh.textures[j], TexUnits[j].m_premul_alpha);
|
||||
setTexture(TexUnits[j].m_id, getTextureGLuint(mesh.textures[j]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
if (irr_driver->getLightViz())
|
||||
{
|
||||
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
|
||||
@ -240,14 +292,43 @@ void IrrDriver::renderSolidSecondPass()
|
||||
|
||||
m_scene_manager->drawAll(scene::ESNRP_SOLID);
|
||||
|
||||
renderMeshes2ndPass<MeshShader::ObjectPass2Shader, video::EVT_STANDARD, 4, 3, 1>({ { MeshShader::ObjectPass2Shader::getInstance()->TU_Albedo, true } }, ListMatDefault::Arguments);
|
||||
renderMeshes2ndPass<MeshShader::ObjectRefPass2Shader, video::EVT_STANDARD, 4, 3, 1 >({ { MeshShader::ObjectRefPass2Shader::getInstance()->TU_Albedo, true } }, ListMatAlphaRef::Arguments);
|
||||
renderMeshes2ndPass<MeshShader::SphereMapShader, video::EVT_STANDARD, 4, 2, 1>({ { MeshShader::SphereMapShader::getInstance()->TU_tex, true } }, ListMatSphereMap::Arguments);
|
||||
renderMeshes2ndPass<MeshShader::DetailledObjectPass2Shader, video::EVT_2TCOORDS, 4, 1>({ { MeshShader::DetailledObjectPass2Shader::getInstance()->TU_Albedo, true }, { MeshShader::DetailledObjectPass2Shader::getInstance()->TU_detail, true } }, ListMatDetails::Arguments);
|
||||
renderMeshes2ndPass<MeshShader::GrassPass2Shader, video::EVT_STANDARD, 4, 3, 1>({ { MeshShader::GrassPass2Shader::getInstance()->TU_Albedo, true } }, ListMatGrass::Arguments);
|
||||
renderMeshes2ndPass<MeshShader::ObjectUnlitShader, video::EVT_STANDARD, 1>({ { MeshShader::ObjectUnlitShader::getInstance()->TU_tex, true } }, ListMatUnlit::Arguments);
|
||||
renderMeshes2ndPass<MeshShader::SplattingShader, video::EVT_2TCOORDS, 3, 1>({ { 8, true }, { MeshShader::SplattingShader::getInstance()->TU_tex_layout, false }, { MeshShader::SplattingShader::getInstance()->TU_tex_detail0, true }, { MeshShader::SplattingShader::getInstance()->TU_tex_detail1, true }, { MeshShader::SplattingShader::getInstance()->TU_tex_detail2, true }, { MeshShader::SplattingShader::getInstance()->TU_tex_detail3, true } }, ListMatSplatting::Arguments);
|
||||
renderMeshes2ndPass<MeshShader::ObjectPass2Shader, video::EVT_TANGENTS, 4, 3, 1>({ { MeshShader::ObjectPass2Shader::getInstance()->TU_Albedo, true } }, ListMatNormalMap::Arguments);
|
||||
renderMeshes2ndPass<MeshShader::ObjectPass2Shader, video::EVT_STANDARD, 4, 3, 1>(TexUnits(
|
||||
TexUnit(MeshShader::ObjectPass2Shader::getInstance()->TU_Albedo, true)
|
||||
), ListMatDefault::Arguments);
|
||||
|
||||
renderMeshes2ndPass<MeshShader::ObjectRefPass2Shader, video::EVT_STANDARD, 4, 3, 1 >(TexUnits(
|
||||
TexUnit(MeshShader::ObjectRefPass2Shader::getInstance()->TU_Albedo, true)
|
||||
), ListMatAlphaRef::Arguments);
|
||||
|
||||
renderMeshes2ndPass<MeshShader::SphereMapShader, video::EVT_STANDARD, 4, 2, 1>(TexUnits(
|
||||
TexUnit(MeshShader::SphereMapShader::getInstance()->TU_tex, true)
|
||||
), ListMatSphereMap::Arguments);
|
||||
|
||||
renderMeshes2ndPass<MeshShader::DetailledObjectPass2Shader, video::EVT_2TCOORDS, 4, 1>(TexUnits(
|
||||
TexUnit(MeshShader::DetailledObjectPass2Shader::getInstance()->TU_Albedo, true),
|
||||
TexUnit(MeshShader::DetailledObjectPass2Shader::getInstance()->TU_detail, true)
|
||||
), ListMatDetails::Arguments);
|
||||
|
||||
renderMeshes2ndPass<MeshShader::GrassPass2Shader, video::EVT_STANDARD, 4, 3, 1>(TexUnits(
|
||||
TexUnit(MeshShader::GrassPass2Shader::getInstance()->TU_Albedo, true)
|
||||
), ListMatGrass::Arguments);
|
||||
|
||||
renderMeshes2ndPass<MeshShader::ObjectUnlitShader, video::EVT_STANDARD, 1>(TexUnits(
|
||||
TexUnit(MeshShader::ObjectUnlitShader::getInstance()->TU_tex, true)
|
||||
), ListMatUnlit::Arguments);
|
||||
|
||||
renderMeshes2ndPass<MeshShader::SplattingShader, video::EVT_2TCOORDS, 3, 1>(TexUnits(
|
||||
TexUnit(8, true),
|
||||
TexUnit(MeshShader::SplattingShader::getInstance()->TU_tex_layout, false),
|
||||
TexUnit(MeshShader::SplattingShader::getInstance()->TU_tex_detail0, true),
|
||||
TexUnit(MeshShader::SplattingShader::getInstance()->TU_tex_detail1, true),
|
||||
TexUnit(MeshShader::SplattingShader::getInstance()->TU_tex_detail2, true),
|
||||
TexUnit(MeshShader::SplattingShader::getInstance()->TU_tex_detail3, true)
|
||||
), ListMatSplatting::Arguments);
|
||||
|
||||
renderMeshes2ndPass<MeshShader::ObjectPass2Shader, video::EVT_TANGENTS, 4, 3, 1>(TexUnits(
|
||||
TexUnit(MeshShader::ObjectPass2Shader::getInstance()->TU_Albedo, true)
|
||||
), ListMatNormalMap::Arguments);
|
||||
}
|
||||
}
|
||||
|
||||
@ -274,16 +355,24 @@ void IrrDriver::renderTransparent()
|
||||
if (World::getWorld() && World::getWorld()->isFogEnabled())
|
||||
{
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
renderMeshes2ndPass<MeshShader::TransparentFogShader, video::EVT_STANDARD, 8, 7, 6, 5, 4, 3, 2, 1>({ { MeshShader::TransparentFogShader::getInstance()->TU_tex, true } }, ListBlendTransparentFog::Arguments);
|
||||
renderMeshes2ndPass<MeshShader::TransparentFogShader, video::EVT_STANDARD, 8, 7, 6, 5, 4, 3, 2, 1>(TexUnits(
|
||||
TexUnit(MeshShader::TransparentFogShader::getInstance()->TU_tex, true)
|
||||
), ListBlendTransparentFog::Arguments);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
renderMeshes2ndPass<MeshShader::TransparentFogShader, video::EVT_STANDARD, 8, 7, 6, 5, 4, 3, 2, 1>({ { MeshShader::TransparentFogShader::getInstance()->TU_tex, true } }, ListAdditiveTransparentFog::Arguments);
|
||||
renderMeshes2ndPass<MeshShader::TransparentFogShader, video::EVT_STANDARD, 8, 7, 6, 5, 4, 3, 2, 1>(TexUnits(
|
||||
TexUnit(MeshShader::TransparentFogShader::getInstance()->TU_tex, true)
|
||||
), ListAdditiveTransparentFog::Arguments);
|
||||
}
|
||||
else
|
||||
{
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
renderMeshes2ndPass<MeshShader::TransparentShader, video::EVT_STANDARD, 2, 1>({ { MeshShader::TransparentShader::getInstance()->TU_tex, true } }, ListBlendTransparent::Arguments);
|
||||
renderMeshes2ndPass<MeshShader::TransparentShader, video::EVT_STANDARD, 2, 1>(TexUnits(
|
||||
TexUnit(MeshShader::TransparentShader::getInstance()->TU_tex, true)
|
||||
), ListBlendTransparent::Arguments);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
renderMeshes2ndPass<MeshShader::TransparentShader, video::EVT_STANDARD, 2, 1>({ { MeshShader::TransparentShader::getInstance()->TU_tex, true } }, ListAdditiveTransparent::Arguments);
|
||||
renderMeshes2ndPass<MeshShader::TransparentShader, video::EVT_STANDARD, 2, 1>(TexUnits(
|
||||
TexUnit(MeshShader::TransparentShader::getInstance()->TU_tex, true)
|
||||
), ListAdditiveTransparent::Arguments);
|
||||
}
|
||||
|
||||
if (!UserConfigParams::m_dynamic_lights)
|
||||
@ -313,8 +402,8 @@ void IrrDriver::renderTransparent()
|
||||
irr_driver->getFBO(FBO_TMP1_WITH_DS).Bind();
|
||||
for (unsigned i = 0; i < ListDisplacement::Arguments.size(); i++)
|
||||
{
|
||||
const GLMesh &mesh = *(std::get<0>(ListDisplacement::Arguments[i]));
|
||||
const core::matrix4 &AbsoluteTransformation = std::get<1>(ListDisplacement::Arguments[i]);
|
||||
const GLMesh &mesh = *(STK::tuple_get<0>(ListDisplacement::Arguments[i]));
|
||||
const core::matrix4 &AbsoluteTransformation = STK::tuple_get<1>(ListDisplacement::Arguments[i]);
|
||||
if (mesh.VAOType != video::EVT_2TCOORDS)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
@ -337,8 +426,8 @@ void IrrDriver::renderTransparent()
|
||||
displaceTex = irr_driver->getTexture(FileManager::TEXTURE, "displace.png");
|
||||
for (unsigned i = 0; i < ListDisplacement::Arguments.size(); i++)
|
||||
{
|
||||
const GLMesh &mesh = *(std::get<0>(ListDisplacement::Arguments[i]));
|
||||
const core::matrix4 &AbsoluteTransformation = std::get<1>(ListDisplacement::Arguments[i]);
|
||||
const GLMesh &mesh = *(STK::tuple_get<0>(ListDisplacement::Arguments[i]));
|
||||
const core::matrix4 &AbsoluteTransformation = STK::tuple_get<1>(ListDisplacement::Arguments[i]);
|
||||
if (mesh.VAOType != video::EVT_2TCOORDS)
|
||||
continue;
|
||||
|
||||
@ -384,9 +473,9 @@ template<>
|
||||
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)
|
||||
static void exec(const T *Shader, const STK::Tuple<TupleTypes...> &t, Args... args)
|
||||
{
|
||||
drawShadow<T>(Shader, std::get<0>(t), args...);
|
||||
drawShadow<T>(Shader, STK::tuple_get<0>(t), args...);
|
||||
}
|
||||
};
|
||||
|
||||
@ -394,20 +483,20 @@ template<int N, int...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)
|
||||
static void exec(const T *Shader, const STK::Tuple<TupleTypes...> &t, Args... args)
|
||||
{
|
||||
shadow_custom_unroll_args<List...>::template exec<T>(Shader, t, std::get<N>(t), args...);
|
||||
shadow_custom_unroll_args<List...>::template exec<T>(Shader, t, STK::tuple_get<N>(t), args...);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, enum E_VERTEX_TYPE VertexType, int...List, typename... Args>
|
||||
void renderShadow(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<STK::Tuple<GLMesh *, core::matrix4, Args...> >&t)
|
||||
{
|
||||
glUseProgram(Shader->Program);
|
||||
glBindVertexArray(getVAO(VertexType));
|
||||
for (unsigned i = 0; i < t.size(); i++)
|
||||
{
|
||||
const GLMesh *mesh = std::get<0>(t[i]);
|
||||
const GLMesh *mesh = STK::tuple_get<0>(t[i]);
|
||||
for (unsigned j = 0; j < TextureUnits.size(); j++)
|
||||
{
|
||||
compressTexture(mesh->textures[j], true);
|
||||
@ -419,13 +508,13 @@ void renderShadow(const T *Shader, const std::vector<GLuint> TextureUnits, const
|
||||
}
|
||||
|
||||
template<enum E_VERTEX_TYPE VertexType, typename... Args>
|
||||
void drawRSM(const core::matrix4 & rsm_matrix, const std::vector<GLuint> TextureUnits, const std::vector<std::tuple<GLMesh *, core::matrix4, Args...> >&t)
|
||||
void drawRSM(const core::matrix4 & rsm_matrix, const std::vector<GLuint> TextureUnits, const std::vector<STK::Tuple<GLMesh *, core::matrix4, Args...> >&t)
|
||||
{
|
||||
glUseProgram(MeshShader::RSMShader::Program);
|
||||
glBindVertexArray(getVAO(VertexType));
|
||||
for (unsigned i = 0; i < t.size(); i++)
|
||||
{
|
||||
GLMesh *mesh = std::get<0>(t[i]);
|
||||
GLMesh *mesh = STK::tuple_get<0>(t[i]);
|
||||
for (unsigned j = 0; j < TextureUnits.size(); j++)
|
||||
{
|
||||
if (!mesh->textures[j])
|
||||
@ -433,7 +522,7 @@ void drawRSM(const core::matrix4 & rsm_matrix, const std::vector<GLuint> Texture
|
||||
compressTexture(mesh->textures[j], true);
|
||||
setTexture(TextureUnits[j], getTextureGLuint(mesh->textures[j]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
}
|
||||
draw<MeshShader::RSMShader>(mesh, rsm_matrix, std::get<1>(t[i]));
|
||||
draw<MeshShader::RSMShader>(mesh, rsm_matrix, STK::tuple_get<1>(t[i]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -461,14 +550,15 @@ void IrrDriver::renderShadows()
|
||||
ListMatSplatting::Arguments.clear();
|
||||
m_scene_manager->drawAll(scene::ESNRP_SOLID);
|
||||
|
||||
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::ShadowShader, EVT_TANGENTS, 1>(MeshShader::ShadowShaderInstance, {}, ListMatNormalMap::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);
|
||||
std::vector<GLuint> noTexUnits;
|
||||
renderShadow<MeshShader::ShadowShader, EVT_STANDARD, 1>(MeshShader::ShadowShaderInstance, noTexUnits, ListMatDefault::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_STANDARD, 1>(MeshShader::ShadowShaderInstance, noTexUnits, ListMatSphereMap::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_STANDARD, 1>(MeshShader::ShadowShaderInstance, noTexUnits, ListMatUnlit::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_2TCOORDS, 1>(MeshShader::ShadowShaderInstance, noTexUnits, ListMatDetails::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_2TCOORDS, 1>(MeshShader::ShadowShaderInstance, noTexUnits, ListMatSplatting::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_TANGENTS, 1>(MeshShader::ShadowShaderInstance, noTexUnits, ListMatNormalMap::Arguments);
|
||||
renderShadow<MeshShader::RefShadowShader, EVT_STANDARD, 1>(MeshShader::RefShadowShaderInstance, std::vector<GLuint>{ MeshShader::RefShadowShaderInstance->TU_tex }, ListMatAlphaRef::Arguments);
|
||||
renderShadow<MeshShader::GrassShadowShader, EVT_STANDARD, 3, 1>(MeshShader::GrassShadowShaderInstance, std::vector<GLuint>{ MeshShader::GrassShadowShaderInstance->TU_tex }, ListMatGrass::Arguments);
|
||||
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
|
||||
@ -478,9 +568,9 @@ 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 }, ListMatDefault::Arguments);
|
||||
drawRSM<EVT_STANDARD>(rsm_matrix, { MeshShader::RSMShader::TU_tex }, ListMatSphereMap::Arguments);
|
||||
drawRSM<EVT_STANDARD>(rsm_matrix, { MeshShader::RSMShader::TU_tex }, ListMatUnlit::Arguments);
|
||||
drawRSM<EVT_2TCOORDS>(rsm_matrix, { MeshShader::RSMShader::TU_tex }, ListMatDetails::Arguments);
|
||||
drawRSM<EVT_2TCOORDS>(rsm_matrix, { MeshShader::RSMShader::TU_tex }, ListMatSplatting::Arguments);
|
||||
drawRSM<EVT_STANDARD>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::TU_tex }, ListMatDefault::Arguments);
|
||||
drawRSM<EVT_STANDARD>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::TU_tex }, ListMatSphereMap::Arguments);
|
||||
drawRSM<EVT_STANDARD>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::TU_tex }, ListMatUnlit::Arguments);
|
||||
drawRSM<EVT_2TCOORDS>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::TU_tex }, ListMatDetails::Arguments);
|
||||
drawRSM<EVT_2TCOORDS>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::TU_tex }, ListMatSplatting::Arguments);
|
||||
}
|
||||
|
@ -28,6 +28,11 @@
|
||||
|
||||
using namespace video;
|
||||
|
||||
GLuint getUniformLocation(GLuint program, const char* name)
|
||||
{
|
||||
return glGetUniformLocation(program, name);
|
||||
}
|
||||
|
||||
Shaders::Shaders()
|
||||
{
|
||||
// Callbacks
|
||||
@ -429,28 +434,79 @@ namespace UtilShader
|
||||
glUniform4i(uniform_color, col.getRed(), col.getGreen(), col.getBlue(), col.getAlpha());
|
||||
glUniformMatrix4fv(glGetUniformLocation(Program, "ModelMatrix"), 1, GL_FALSE, core::IdentityMatrix.pointer());
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
AssignTextureUnit(GLuint Program, const std::vector<std::pair<GLuint, const char*> > assoc)
|
||||
{
|
||||
glUseProgram(Program);
|
||||
for (unsigned i = 0; i < assoc.size(); i++)
|
||||
struct TexUnit
|
||||
{
|
||||
GLuint uniform = glGetUniformLocation(Program, assoc[i].second);
|
||||
glUniform1i(uniform, assoc[i].first);
|
||||
GLuint m_index;
|
||||
const char* m_uniform;
|
||||
|
||||
TexUnit(GLuint index, const char* uniform)
|
||||
{
|
||||
m_index = index;
|
||||
m_uniform = uniform;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
std::vector<TexUnit> TexUnits(T curr) // required on older clang versions
|
||||
{
|
||||
std::vector<TexUnit> v;
|
||||
v.push_back(curr);
|
||||
return v;
|
||||
}
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
static void
|
||||
AssignUniforms(GLuint Program, std::vector<GLuint> &uniforms, const std::vector<const char*> &name)
|
||||
{
|
||||
for (unsigned i = 0; i < name.size(); i++)
|
||||
template <typename T, typename... R>
|
||||
std::vector<TexUnit> TexUnits(T curr, R... rest) // required on older clang versions
|
||||
{
|
||||
uniforms.push_back(glGetUniformLocation(Program, name[i]));
|
||||
std::vector<TexUnit> v;
|
||||
v.push_back(curr);
|
||||
VTexUnits(v, rest...);
|
||||
return v;
|
||||
}
|
||||
|
||||
template <typename T, typename... R>
|
||||
void VTexUnits(std::vector<TexUnit>& v, T curr, R... rest) // required on older clang versions
|
||||
{
|
||||
v.push_back(curr);
|
||||
VTexUnits(v, rest...);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void VTexUnits(std::vector<TexUnit>& v, T curr)
|
||||
{
|
||||
v.push_back(curr);
|
||||
}
|
||||
|
||||
static void
|
||||
AssignTextureUnit(GLuint Program, TexUnit texUnit)
|
||||
{
|
||||
glUseProgram(Program);
|
||||
GLuint uniform = glGetUniformLocation(Program, texUnit.m_uniform);
|
||||
glUniform1i(uniform, texUnit.m_index);
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
template<typename... T>
|
||||
static void AssignTextureUnit(GLuint Program, TexUnit texUnit, T... rest)
|
||||
{
|
||||
glUseProgram(Program);
|
||||
GLuint uniform = glGetUniformLocation(Program, texUnit.m_uniform);
|
||||
glUniform1i(uniform, texUnit.m_index);
|
||||
AssignTextureUnit_Sub(Program, rest...);
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
static void AssignTextureUnit_Sub(GLuint Program) {}
|
||||
|
||||
template<typename... T>
|
||||
static void AssignTextureUnit_Sub(GLuint Program, TexUnit texUnit, T... rest)
|
||||
{
|
||||
GLuint uniform = glGetUniformLocation(Program, texUnit.m_uniform);
|
||||
glUniform1i(uniform, texUnit.m_index);
|
||||
AssignTextureUnit_Sub(Program, rest...);
|
||||
}
|
||||
}
|
||||
using namespace UtilShader;
|
||||
|
||||
void glUniformMatrix4fvWraper(GLuint a, size_t b, unsigned c, const float *d)
|
||||
{
|
||||
@ -474,7 +530,6 @@ void glUniform1fWrapper(GLuint a, float b)
|
||||
|
||||
namespace MeshShader
|
||||
{
|
||||
|
||||
// Solid Normal and depth pass shaders
|
||||
ObjectPass1Shader::ObjectPass1Shader()
|
||||
{
|
||||
@ -482,14 +537,14 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass1.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, {"ModelMatrix", "InverseModelMatrix"});
|
||||
AssignUniforms("ModelMatrix", "InverseModelMatrix");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
}
|
||||
|
||||
ObjectRefPass1Shader::ObjectRefPass1Shader()
|
||||
@ -498,14 +553,14 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass1.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix", "InverseModelMatrix", "TextureMatrix" });
|
||||
AssignUniforms("ModelMatrix", "InverseModelMatrix", "TextureMatrix");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
}
|
||||
|
||||
GrassPass1Shader::GrassPass1Shader()
|
||||
@ -514,9 +569,9 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/grass_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass1.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix", "InverseModelMatrix", "windDir" });
|
||||
AssignUniforms("ModelMatrix", "InverseModelMatrix", "windDir");
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
}
|
||||
|
||||
NormalMapShader::NormalMapShader()
|
||||
@ -525,7 +580,7 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/normalmap.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/normalmap.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, {"ModelMatrix", "InverseModelMatrix"});
|
||||
AssignUniforms("ModelMatrix", "InverseModelMatrix");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
@ -533,7 +588,7 @@ namespace MeshShader
|
||||
}
|
||||
TU_normalmap = 1;
|
||||
TU_glossy = 0;
|
||||
AssignTextureUnit(Program, { { TU_normalmap, "normalMap" }, { TU_glossy, "DiffuseForAlpha" } });
|
||||
AssignTextureUnit(Program, TexUnit(TU_normalmap, "normalMap"), TexUnit(TU_glossy, "DiffuseForAlpha"));
|
||||
}
|
||||
|
||||
InstancedObjectPass1Shader::InstancedObjectPass1Shader()
|
||||
@ -544,7 +599,7 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass1.frag").c_str());
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
@ -562,7 +617,7 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass1.frag").c_str());
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
@ -579,9 +634,9 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/instanced_grass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass1.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "windDir" });
|
||||
AssignUniforms("windDir");
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
@ -598,7 +653,7 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass2.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix", "TextureMatrix", "ambient" });
|
||||
AssignUniforms("ModelMatrix", "TextureMatrix", "ambient");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
@ -606,7 +661,12 @@ namespace MeshShader
|
||||
}
|
||||
TU_Albedo = 3;
|
||||
|
||||
AssignTextureUnit(Program, { { 0, "DiffuseMap" }, { 1, "SpecularMap" }, { 2, "SSAO" }, { TU_Albedo, "Albedo" } });
|
||||
AssignTextureUnit(Program,
|
||||
TexUnit(0, "DiffuseMap"),
|
||||
TexUnit(1, "SpecularMap"),
|
||||
TexUnit(2, "SSAO"),
|
||||
TexUnit(TU_Albedo, "Albedo")
|
||||
);
|
||||
}
|
||||
|
||||
ObjectPass2Shader *ObjectPass2ShaderInstance;
|
||||
@ -618,10 +678,15 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/instanced_object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass2.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "ambient" });
|
||||
AssignUniforms("ambient");
|
||||
TU_Albedo = 3;
|
||||
|
||||
AssignTextureUnit(Program, { { 0, "DiffuseMap" }, { 1, "SpecularMap" }, { 2, "SSAO" }, { TU_Albedo, "Albedo" } });
|
||||
AssignTextureUnit(Program,
|
||||
TexUnit(0, "DiffuseMap"),
|
||||
TexUnit(1, "SpecularMap"),
|
||||
TexUnit(2, "SSAO"),
|
||||
TexUnit(TU_Albedo, "Albedo")
|
||||
);
|
||||
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
@ -639,10 +704,15 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/instanced_object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass2.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "ambient" });
|
||||
AssignUniforms("ambient");
|
||||
TU_Albedo = 3;
|
||||
|
||||
AssignTextureUnit(Program, { { 0, "DiffuseMap" }, { 1, "SpecularMap" }, { 2, "SSAO" }, { TU_Albedo, "Albedo" } });
|
||||
AssignTextureUnit(Program,
|
||||
TexUnit(0, "DiffuseMap"),
|
||||
TexUnit(1, "SpecularMap"),
|
||||
TexUnit(2, "SSAO"),
|
||||
TexUnit(TU_Albedo, "Albedo")
|
||||
);
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
@ -656,13 +726,19 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/detailledobject_pass2.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix", "ambient" });
|
||||
AssignUniforms("ModelMatrix", "ambient");
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
TU_Albedo = 3;
|
||||
TU_detail = 4;
|
||||
|
||||
AssignTextureUnit(Program, { { 0, "DiffuseMap" }, { 1, "SpecularMap" }, { 2, "SSAO" }, { TU_Albedo, "Albedo" }, { TU_detail, "Detail" } });
|
||||
AssignTextureUnit(Program,
|
||||
TexUnit(0, "DiffuseMap"),
|
||||
TexUnit(1, "SpecularMap"),
|
||||
TexUnit(2, "SSAO"),
|
||||
TexUnit(TU_Albedo, "Albedo"),
|
||||
TexUnit(TU_detail, "Detail")
|
||||
);
|
||||
}
|
||||
|
||||
DetailledObjectPass2Shader *DetailledObjectPass2ShaderInstance;
|
||||
@ -672,7 +748,7 @@ namespace MeshShader
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_unlit.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix" });
|
||||
AssignUniforms("ModelMatrix");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
@ -680,7 +756,7 @@ namespace MeshShader
|
||||
}
|
||||
TU_tex = 3;
|
||||
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
}
|
||||
|
||||
ObjectUnlitShader *ObjectUnlitShaderInstance;
|
||||
@ -691,7 +767,7 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass2.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix", "TextureMatrix", "ambient" });
|
||||
AssignUniforms("ModelMatrix", "TextureMatrix", "ambient");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
@ -699,7 +775,12 @@ namespace MeshShader
|
||||
}
|
||||
TU_Albedo = 3;
|
||||
|
||||
AssignTextureUnit(Program, { { 0, "DiffuseMap" }, { 1, "SpecularMap" }, { 2, "SSAO" }, { TU_Albedo, "Albedo" } });
|
||||
AssignTextureUnit(Program,
|
||||
TexUnit(0, "DiffuseMap"),
|
||||
TexUnit(1, "SpecularMap"),
|
||||
TexUnit(2, "SSAO"),
|
||||
TexUnit(TU_Albedo, "Albedo")
|
||||
);
|
||||
}
|
||||
|
||||
ObjectRefPass2Shader *ObjectRefPass2ShaderInstance;
|
||||
@ -710,10 +791,15 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/grass_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/grass_pass2.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix", "windDir", "ambient" });
|
||||
AssignUniforms("ModelMatrix", "windDir", "ambient");
|
||||
TU_Albedo = 3;
|
||||
|
||||
AssignTextureUnit(Program, { { 0, "DiffuseMap" }, { 1, "SpecularMap" }, { 2, "SSAO" }, { TU_Albedo, "Albedo" } });
|
||||
AssignTextureUnit(Program,
|
||||
TexUnit(0, "DiffuseMap"),
|
||||
TexUnit(1, "SpecularMap"),
|
||||
TexUnit(2, "SSAO"),
|
||||
TexUnit(TU_Albedo, "Albedo")
|
||||
);
|
||||
}
|
||||
|
||||
GrassPass2Shader *GrassPass2ShaderInstance;
|
||||
@ -725,11 +811,17 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/instanced_grass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/grass_pass2.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "windDir", "SunDir", "ambient" });
|
||||
AssignUniforms("windDir", "SunDir", "ambient");
|
||||
TU_Albedo = 3;
|
||||
TU_dtex = 4;
|
||||
|
||||
AssignTextureUnit(Program, { { 0, "DiffuseMap" }, { 1, "SpecularMap" }, { 2, "SSAO" }, { TU_Albedo, "Albedo" }, { TU_dtex, "dtex" } });
|
||||
AssignTextureUnit(Program,
|
||||
TexUnit(0, "DiffuseMap"),
|
||||
TexUnit(1, "SpecularMap"),
|
||||
TexUnit(2, "SSAO"),
|
||||
TexUnit(TU_Albedo, "Albedo"),
|
||||
TexUnit(TU_dtex, "dtex")
|
||||
);
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
@ -744,7 +836,7 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getPosFromUVDepth.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectpass_spheremap.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix", "InverseModelMatrix", "ambient" });
|
||||
AssignUniforms("ModelMatrix", "InverseModelMatrix", "ambient");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
@ -752,7 +844,12 @@ namespace MeshShader
|
||||
}
|
||||
TU_tex = 3;
|
||||
|
||||
AssignTextureUnit(Program, { { 0, "DiffuseMap" }, { 1, "SpecularMap" }, { 2, "SSAO" }, { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program,
|
||||
TexUnit(0, "DiffuseMap"),
|
||||
TexUnit(1, "SpecularMap"),
|
||||
TexUnit(2, "SSAO"),
|
||||
TexUnit(TU_tex, "tex")
|
||||
);
|
||||
}
|
||||
|
||||
SphereMapShader *SphereMapShaderInstance;
|
||||
@ -762,15 +859,23 @@ namespace MeshShader
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/splatting.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, {"ModelMatrix", "ambient"});
|
||||
AssignUniforms("ModelMatrix", "ambient");
|
||||
TU_tex_layout = 3;
|
||||
TU_tex_detail0 = 4;
|
||||
TU_tex_detail1 = 5;
|
||||
TU_tex_detail2 = 6;
|
||||
TU_tex_detail3 = 7;
|
||||
|
||||
AssignTextureUnit(Program, { { 0, "DiffuseMap" }, { 1, "SpecularMap" }, { 2, "SSAO" }, { TU_tex_layout, "tex_layout" },
|
||||
{ TU_tex_detail0, "tex_detail0" }, { TU_tex_detail1, "tex_detail1" }, { TU_tex_detail2, "tex_detail2" }, { TU_tex_detail3, "tex_detail3" } });
|
||||
AssignTextureUnit(Program,
|
||||
TexUnit(0, "DiffuseMap"),
|
||||
TexUnit(1, "SpecularMap"),
|
||||
TexUnit(2, "SSAO"),
|
||||
TexUnit(TU_tex_layout, "tex_layout"),
|
||||
TexUnit(TU_tex_detail0, "tex_detail0"),
|
||||
TexUnit(TU_tex_detail1, "tex_detail1"),
|
||||
TexUnit(TU_tex_detail2, "tex_detail2"),
|
||||
TexUnit(TU_tex_detail3, "tex_detail3")
|
||||
);
|
||||
}
|
||||
|
||||
SplattingShader *SplattingShaderInstance;
|
||||
@ -804,7 +909,7 @@ namespace MeshShader
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/transparent.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, {"ModelMatrix", "TextureMatrix" });
|
||||
AssignUniforms("ModelMatrix", "TextureMatrix");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
@ -812,7 +917,7 @@ namespace MeshShader
|
||||
}
|
||||
TU_tex = 0;
|
||||
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
}
|
||||
|
||||
TransparentShader *TransparentShaderInstance;
|
||||
@ -822,7 +927,7 @@ namespace MeshShader
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/transparentfog.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix", "TextureMatrix", "fogmax", "startH", "endH", "start", "end", "col" });
|
||||
AssignUniforms("ModelMatrix", "TextureMatrix", "fogmax", "startH", "endH", "start", "end", "col");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
@ -830,7 +935,7 @@ namespace MeshShader
|
||||
}
|
||||
TU_tex = 0;
|
||||
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
}
|
||||
|
||||
TransparentFogShader *TransparentFogShaderInstance;
|
||||
@ -915,7 +1020,7 @@ namespace MeshShader
|
||||
GL_GEOMETRY_SHADER, file_manager->getAsset("shaders/shadow.geom").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/white.frag").c_str());
|
||||
}
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix" });
|
||||
AssignUniforms("ModelMatrix");
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
@ -936,7 +1041,7 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/rsm.frag").c_str());
|
||||
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
|
||||
uniform_RSMMatrix = glGetUniformLocation(Program, "RSMMatrix");
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, { TexUnit(TU_tex, "tex") });
|
||||
}
|
||||
|
||||
void RSMShader::setUniforms(const core::matrix4 &RSMMatrix, const core::matrix4 &ModelMatrix)
|
||||
@ -989,12 +1094,12 @@ namespace MeshShader
|
||||
GL_GEOMETRY_SHADER, file_manager->getAsset("shaders/shadow.geom").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_unlit.frag").c_str());
|
||||
}
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix" });
|
||||
AssignUniforms("ModelMatrix");
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
TU_tex = 0;
|
||||
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, { TexUnit(TU_tex, "tex") });
|
||||
}
|
||||
|
||||
RefShadowShader *RefShadowShaderInstance;
|
||||
@ -1020,7 +1125,7 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_unlit.frag").c_str());
|
||||
}
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, { TexUnit(TU_tex, "tex") });
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
@ -1045,12 +1150,12 @@ namespace MeshShader
|
||||
GL_GEOMETRY_SHADER, file_manager->getAsset("shaders/shadow.geom").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_unlit.frag").c_str());
|
||||
}
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix", "windDir" });
|
||||
AssignUniforms("ModelMatrix", "windDir");
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
TU_tex = 0;
|
||||
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, { TexUnit(TU_tex, "tex") });
|
||||
}
|
||||
|
||||
GrassShadowShader *GrassShadowShaderInstance;
|
||||
@ -1076,9 +1181,9 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_unlit.frag").c_str());
|
||||
}
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
|
||||
AssignUniforms(Program, uniforms, { "windDir" });
|
||||
AssignUniforms("windDir");
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
@ -1090,7 +1195,7 @@ namespace MeshShader
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/displace.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/white.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix"});
|
||||
AssignUniforms("ModelMatrix");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
@ -1106,12 +1211,17 @@ namespace MeshShader
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/displace.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/displace.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix", "dir", "dir2" });
|
||||
AssignUniforms("ModelMatrix", "dir", "dir2");
|
||||
TU_displacement_tex = 0;
|
||||
TU_color_tex = 1;
|
||||
TU_mask_tex = 2;
|
||||
TU_tex = 3;
|
||||
AssignTextureUnit(Program, { { TU_displacement_tex, "displacement_tex" }, { TU_color_tex, "color_tex" }, { TU_mask_tex, "mask_tex" }, { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program,
|
||||
TexUnit(TU_displacement_tex, "displacement_tex"),
|
||||
TexUnit(TU_color_tex, "color_tex"),
|
||||
TexUnit(TU_mask_tex, "mask_tex"),
|
||||
TexUnit(TU_tex, "tex")
|
||||
);
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
@ -103,12 +103,26 @@ struct UniformHelper
|
||||
};
|
||||
|
||||
void bypassUBO(GLuint Program);
|
||||
GLuint getUniformLocation(GLuint program, const char* name);
|
||||
|
||||
template<typename... Args>
|
||||
class ShaderHelper
|
||||
{
|
||||
protected:
|
||||
std::vector<GLuint> uniforms;
|
||||
|
||||
void AssignUniforms(const char* name)
|
||||
{
|
||||
uniforms.push_back(getUniformLocation(Program, name));
|
||||
}
|
||||
|
||||
template<typename... T>
|
||||
void AssignUniforms(const char* name, T... rest)
|
||||
{
|
||||
uniforms.push_back(getUniformLocation(Program, name));
|
||||
AssignUniforms(rest...);
|
||||
}
|
||||
|
||||
public:
|
||||
GLuint Program;
|
||||
|
||||
@ -125,6 +139,19 @@ class ShaderHelperSingleton : public Singleton<T>
|
||||
{
|
||||
protected:
|
||||
std::vector<GLuint> uniforms;
|
||||
|
||||
void AssignUniforms(const char* name)
|
||||
{
|
||||
uniforms.push_back(getUniformLocation(Program, name));
|
||||
}
|
||||
|
||||
template<typename... U>
|
||||
void AssignUniforms(const char* name, U... rest)
|
||||
{
|
||||
uniforms.push_back(getUniformLocation(Program, name));
|
||||
AssignUniforms(rest...);
|
||||
}
|
||||
|
||||
public:
|
||||
friend class Singleton<class ObjectPass1Shader>;
|
||||
GLuint Program;
|
||||
|
@ -181,11 +181,11 @@ void STKAnimatedMesh::render()
|
||||
|
||||
for_in(mesh, TransparentMesh[TM_DEFAULT])
|
||||
ListBlendTransparentFog::Arguments.push_back(
|
||||
std::make_tuple(mesh, AbsoluteTransformation, mesh->TextureMatrix,
|
||||
STK::make_tuple(mesh, AbsoluteTransformation, mesh->TextureMatrix,
|
||||
fogmax, startH, endH, start, end, col));
|
||||
for_in(mesh, TransparentMesh[TM_ADDITIVE])
|
||||
ListAdditiveTransparentFog::Arguments.push_back(
|
||||
std::make_tuple(mesh, AbsoluteTransformation, mesh->TextureMatrix,
|
||||
STK::make_tuple(mesh, AbsoluteTransformation, mesh->TextureMatrix,
|
||||
fogmax, startH, endH, start, end, col));
|
||||
}
|
||||
else
|
||||
|
@ -293,17 +293,17 @@ bool isObject(video::E_MATERIAL_TYPE type)
|
||||
return false;
|
||||
}
|
||||
|
||||
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, core::matrix4, video::SColorf> > ListMatNormalMap::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > ListMatDefault::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > ListMatAlphaRef::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > ListMatSphereMap::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > ListMatDetails::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::vector3df, video::SColorf> > ListMatGrass::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4> > ListMatUnlit::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, video::SColorf> > ListMatSplatting::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > ListMatNormalMap::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, 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> > ListDisplacement::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4> > ListBlendTransparent::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4> > ListAdditiveTransparent::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, float, float, float, float, float, video::SColorf> > ListBlendTransparentFog::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, float, float, float, float, float, video::SColorf> > ListAdditiveTransparentFog::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4> > ListDisplacement::Arguments;
|
@ -3,12 +3,12 @@
|
||||
|
||||
#include "graphics/glwrap.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "utils/tuple.hpp"
|
||||
|
||||
#include <IMeshSceneNode.h>
|
||||
#include <IMesh.h>
|
||||
#include "../lib/irrlicht/source/Irrlicht/CMeshSceneNode.h"
|
||||
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
enum MeshMaterial
|
||||
@ -62,80 +62,80 @@ core::vector3df getWind();
|
||||
class ListMatDefault
|
||||
{
|
||||
public:
|
||||
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > Arguments;
|
||||
static std::vector<STK::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;
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > Arguments;
|
||||
};
|
||||
|
||||
class ListMatNormalMap
|
||||
{
|
||||
public:
|
||||
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > Arguments;
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > Arguments;
|
||||
};
|
||||
|
||||
class ListMatGrass
|
||||
{
|
||||
public:
|
||||
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::vector3df, video::SColorf> > Arguments;
|
||||
static std::vector<STK::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;
|
||||
static std::vector<STK::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;
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, video::SColorf> > Arguments;
|
||||
};
|
||||
|
||||
class ListMatUnlit
|
||||
{
|
||||
public:
|
||||
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4> > Arguments;
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4> > Arguments;
|
||||
};
|
||||
|
||||
class ListMatDetails
|
||||
{
|
||||
public:
|
||||
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > Arguments;
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > Arguments;
|
||||
};
|
||||
|
||||
|
||||
class ListBlendTransparent
|
||||
{
|
||||
public:
|
||||
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4> > Arguments;
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4> > Arguments;
|
||||
};
|
||||
|
||||
class ListAdditiveTransparent
|
||||
{
|
||||
public:
|
||||
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4> > Arguments;
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4> > Arguments;
|
||||
};
|
||||
|
||||
class ListBlendTransparentFog
|
||||
{
|
||||
public:
|
||||
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, float, float, float, float, float, video::SColorf> > Arguments;
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, float, float, float, float, float, video::SColorf> > Arguments;
|
||||
};
|
||||
|
||||
class ListAdditiveTransparentFog
|
||||
{
|
||||
public:
|
||||
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, float, float, float, float, float, video::SColorf> > Arguments;
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, float, float, float, float, float, video::SColorf> > Arguments;
|
||||
};
|
||||
|
||||
class ListDisplacement
|
||||
{
|
||||
public:
|
||||
static std::vector<std::tuple<GLMesh *, core::matrix4> > Arguments;
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4> > Arguments;
|
||||
};
|
||||
|
||||
// Forward pass (for transparents meshes)
|
||||
|
@ -6,9 +6,10 @@
|
||||
#include <IMaterialRenderer.h>
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/callbacks.hpp"
|
||||
#include "utils/helpers.hpp"
|
||||
#include "graphics/camera.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "utils/helpers.hpp"
|
||||
#include "utils/tuple.hpp"
|
||||
|
||||
STKMeshSceneNode::STKMeshSceneNode(irr::scene::IMesh* mesh, ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id,
|
||||
const irr::core::vector3df& position,
|
||||
|
92
src/utils/tuple.hpp
Normal file
92
src/utils/tuple.hpp
Normal file
@ -0,0 +1,92 @@
|
||||
#ifndef __STK_TUPLE_HPP__
|
||||
#define __STK_TUPLE_HPP__
|
||||
|
||||
namespace STK {
|
||||
|
||||
|
||||
// tuple
|
||||
template<typename... _Types> class Tuple;
|
||||
|
||||
// empty tuple
|
||||
template<> class Tuple<> {};
|
||||
|
||||
// recursive tuple definition
|
||||
template<typename _This, typename... _Rest>
|
||||
class Tuple<_This, _Rest...> : private Tuple<_Rest...>
|
||||
{
|
||||
public:
|
||||
_This _Elem;
|
||||
|
||||
Tuple()
|
||||
{
|
||||
}
|
||||
|
||||
Tuple(_This val, _Rest... rest) : Tuple<_Rest...>(rest...)
|
||||
{
|
||||
_Elem = val;
|
||||
}
|
||||
};
|
||||
|
||||
// tuple_element
|
||||
template<size_t _Index, typename _Tuple> struct tuple_element;
|
||||
|
||||
// select first element
|
||||
template<typename _This, typename... _Rest>
|
||||
struct tuple_element<0, Tuple<_This, _Rest...>>
|
||||
{
|
||||
typedef _This& type;
|
||||
typedef Tuple<_This, _Rest...> _Ttype;
|
||||
};
|
||||
|
||||
// recursive tuple_element definition
|
||||
template <size_t _Index, typename _This, typename... _Rest>
|
||||
struct tuple_element<_Index, Tuple<_This, _Rest...>>
|
||||
: public tuple_element<_Index - 1, Tuple<_Rest...> >
|
||||
{
|
||||
};
|
||||
|
||||
template<size_t _Index, class... _Types> inline
|
||||
typename tuple_element<_Index, Tuple<_Types...>>::type
|
||||
tuple_get(Tuple<_Types...>& _Tuple)
|
||||
{
|
||||
typedef typename tuple_element<_Index, Tuple<_Types...>>::_Ttype _Ttype;
|
||||
return (((_Ttype&)_Tuple)._Elem);
|
||||
}
|
||||
|
||||
template<size_t _Index, class... _Types> inline
|
||||
typename tuple_element<_Index, Tuple<_Types...>>::type tuple_get(const Tuple<_Types...>& _Tuple)
|
||||
{
|
||||
typedef typename tuple_element<_Index, Tuple<_Types...>>::_Ttype _Ttype;
|
||||
return (((_Ttype&)_Tuple)._Elem);
|
||||
}
|
||||
|
||||
template<size_t Index, typename... T> inline
|
||||
Tuple<T...> make_tuple(T... values)
|
||||
{
|
||||
return Tuple<T...>(values...);
|
||||
}
|
||||
|
||||
template<typename... T> inline
|
||||
Tuple<T...> make_tuple(T... values)
|
||||
{
|
||||
return Tuple<T...>(values...);
|
||||
}
|
||||
|
||||
//template<typename... T>
|
||||
//int tuple_size(Tuple<T...> tuple)
|
||||
//{
|
||||
// return sizeof...(T);
|
||||
//}
|
||||
|
||||
template<typename... T>
|
||||
struct TupleSize
|
||||
{
|
||||
int value;
|
||||
TupleSize()
|
||||
{
|
||||
value = sizeof...(T);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user