Factorize splatting shader.
This commit is contained in:
@@ -693,7 +693,7 @@ void IrrDriver::renderSolidSecondPass()
|
||||
renderMeshes2ndPass<MeshShader::SphereMapShader, video::EVT_STANDARD>(MeshShader::SphereMapShaderInstance, { MeshShader::SphereMapShaderInstance->TU_tex }, ListSphereMapSM::Arguments);
|
||||
renderMeshes2ndPass<MeshShader::ObjectUnlitShader, video::EVT_STANDARD>(MeshShader::ObjectUnlitShaderInstance, { MeshShader::ObjectUnlitShaderInstance->TU_tex }, ListUnlitSM::Arguments);
|
||||
renderMeshes2ndPass<MeshShader::DetailledObjectPass2Shader, video::EVT_2TCOORDS>(MeshShader::DetailledObjectPass2ShaderInstance, { MeshShader::DetailledObjectPass2ShaderInstance->TU_Albedo, MeshShader::DetailledObjectPass2ShaderInstance->TU_detail }, ListDetailSM::Arguments);
|
||||
// renderMeshes2ndPass<MeshShader::SplattingShader, video::EVT_2TCOORDS>({ 8, MeshShader::SplattingShader::TU_tex_layout, MeshShader::SplattingShader::TU_tex_detail0, MeshShader::SplattingShader::TU_tex_detail1, MeshShader::SplattingShader::TU_tex_detail2, MeshShader::SplattingShader::TU_tex_detail3 }, ListSplattingSM::Arguments);
|
||||
renderMeshes2ndPass<MeshShader::SplattingShader, video::EVT_2TCOORDS>(MeshShader::SplattingShaderInstance, { 8, MeshShader::SplattingShaderInstance->TU_tex_layout, MeshShader::SplattingShaderInstance->TU_tex_detail0, MeshShader::SplattingShaderInstance->TU_tex_detail1, MeshShader::SplattingShaderInstance->TU_tex_detail2, MeshShader::SplattingShaderInstance->TU_tex_detail3 }, ListSplattingSM::Arguments);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -339,7 +339,7 @@ void Shaders::loadShaders()
|
||||
MeshShader::ObjectRefPass2ShaderInstance = new MeshShader::ObjectRefPass2Shader();
|
||||
MeshShader::ObjectUnlitShaderInstance = new MeshShader::ObjectUnlitShader();
|
||||
MeshShader::SphereMapShaderInstance = new MeshShader::SphereMapShader();
|
||||
MeshShader::SplattingShader::init();
|
||||
MeshShader::SplattingShaderInstance = new MeshShader::SplattingShader();
|
||||
MeshShader::GrassPass1Shader::init();
|
||||
MeshShader::GrassPass2Shader::init();
|
||||
MeshShader::BubbleShader::init();
|
||||
@@ -879,22 +879,12 @@ namespace MeshShader
|
||||
|
||||
SphereMapShader *SphereMapShaderInstance;
|
||||
|
||||
GLuint SplattingShader::Program;
|
||||
GLuint SplattingShader::uniform_MM;
|
||||
GLuint SplattingShader::uniform_ambient;
|
||||
GLuint SplattingShader::TU_tex_layout;
|
||||
GLuint SplattingShader::TU_tex_detail0;
|
||||
GLuint SplattingShader::TU_tex_detail1;
|
||||
GLuint SplattingShader::TU_tex_detail2;
|
||||
GLuint SplattingShader::TU_tex_detail3;
|
||||
|
||||
void SplattingShader::init()
|
||||
SplattingShader::SplattingShader()
|
||||
{
|
||||
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());
|
||||
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
|
||||
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
||||
AssignUniforms(Program, uniforms, {"ModelMatrix", "ambient"});
|
||||
TU_tex_layout = 3;
|
||||
TU_tex_detail0 = 4;
|
||||
TU_tex_detail1 = 5;
|
||||
@@ -905,12 +895,7 @@ namespace MeshShader
|
||||
{ TU_tex_detail0, "tex_detail0" }, { TU_tex_detail1, "tex_detail1" }, { TU_tex_detail2, "tex_detail2" }, { TU_tex_detail3, "tex_detail3" } });
|
||||
}
|
||||
|
||||
void SplattingShader::setUniforms(const core::matrix4 &ModelMatrix)
|
||||
{
|
||||
glUniformMatrix4fv(uniform_MM, 1, GL_FALSE, ModelMatrix.pointer());
|
||||
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
||||
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
||||
}
|
||||
SplattingShader *SplattingShaderInstance;
|
||||
|
||||
GLuint BubbleShader::Program;
|
||||
GLuint BubbleShader::uniform_MVP;
|
||||
|
||||
@@ -265,17 +265,16 @@ public:
|
||||
|
||||
extern SphereMapShader *SphereMapShaderInstance;
|
||||
|
||||
class SplattingShader
|
||||
class SplattingShader : public ShaderHelper<core::matrix4, video::SColorf>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_MM, uniform_ambient;
|
||||
static GLuint TU_tex_layout, TU_tex_detail0, TU_tex_detail1, TU_tex_detail2, TU_tex_detail3;
|
||||
GLuint TU_tex_layout, TU_tex_detail0, TU_tex_detail1, TU_tex_detail2, TU_tex_detail3;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelMatrix);
|
||||
SplattingShader();
|
||||
};
|
||||
|
||||
extern SplattingShader *SplattingShaderInstance;
|
||||
|
||||
class BubbleShader
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -372,7 +372,7 @@ std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4> > ListNormalG::Ar
|
||||
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> > ListSplattingSM::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;
|
||||
|
||||
@@ -173,7 +173,7 @@ public:
|
||||
class ListSplattingSM
|
||||
{
|
||||
public:
|
||||
static std::vector<std::tuple<GLMesh *, core::matrix4> > Arguments;
|
||||
static std::vector<std::tuple<GLMesh *, core::matrix4, video::SColorf> > Arguments;
|
||||
};
|
||||
|
||||
class ListUnlitSM
|
||||
|
||||
@@ -349,7 +349,7 @@ void STKMeshSceneNode::render()
|
||||
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));
|
||||
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));
|
||||
|
||||
Reference in New Issue
Block a user