Moved more shaders.

This commit is contained in:
hiker 2015-05-18 16:52:42 +10:00
parent 90d7fac6c4
commit 6def0c752c
4 changed files with 51 additions and 49 deletions

View File

@ -57,6 +57,36 @@ public:
} // InstancedColorizeShader
}; // InstancedColorizeShader
// ============================================================================
class ViewFrustrumShader : public Shader<ViewFrustrumShader, video::SColor, int>
{
private:
GLuint m_frustrum_vao;
public: ViewFrustrumShader()
{
loadProgram(OBJECT, GL_VERTEX_SHADER, "frustrum.vert",
GL_FRAGMENT_SHADER, "coloredquad.frag");
assignUniforms("color", "idx");
glGenVertexArrays(1, &m_frustrum_vao);
glBindVertexArray(m_frustrum_vao);
glBindBuffer(GL_ARRAY_BUFFER, SharedGPUObjects::getFrustrumVBO());
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,
SharedGPUObjects::getFrustrumIndices());
glBindVertexArray(0);
} // ViewFrustrumShader
// ------------------------------------------------------------------------
void bindVertexArray()
{
glBindVertexArray(m_frustrum_vao);
} // bindVertexArray
}; // ViewFrustrumShader
// ============================================================================
extern std::vector<float> BoundingBoxes;
@ -646,12 +676,12 @@ void IrrDriver::renderParticles()
static void renderWireFrameFrustrum(float *tmp, unsigned i)
{
MeshShader::ViewFrustrumShader::getInstance()->use();
glBindVertexArray(MeshShader::ViewFrustrumShader::getInstance()->frustrumvao);
ViewFrustrumShader::getInstance()->use();
ViewFrustrumShader::getInstance()->bindVertexArray();
glBindBuffer(GL_ARRAY_BUFFER, SharedGPUObjects::getFrustrumVBO());
glBufferSubData(GL_ARRAY_BUFFER, 0, 8 * 3 * sizeof(float), (void *)tmp);
MeshShader::ViewFrustrumShader::getInstance()->setUniforms(video::SColor(255, 0, 255, 0), i);
ViewFrustrumShader::getInstance()->setUniforms(video::SColor(255, 0, 255, 0), i);
glDrawElements(GL_LINES, 24, GL_UNSIGNED_INT, 0);
}

View File

@ -497,6 +497,20 @@ public:
} // DisplaceShader
}; // DisplaceShader
// ============================================================================
class NormalVisualizer : public Shader<NormalVisualizer, video::SColor>
{
public:
NormalVisualizer()
{
loadProgram(OBJECT, GL_VERTEX_SHADER, "utils/getworldmatrix.vert",
GL_VERTEX_SHADER, "instanced_object_pass.vert",
GL_GEOMETRY_SHADER, "normal_visualizer.geom",
GL_FRAGMENT_SHADER, "coloredquad.frag");
assignUniforms("color");
} // NormalVisualizer
}; // NormalVisualizer
// ============================================================================
struct DefaultMaterial
{
@ -1412,11 +1426,11 @@ template<typename T>
static void renderInstancedMeshNormals()
{
std::vector<GLMesh *> &meshes = T::InstancedList::getInstance()->SolidPass;
MeshShader::NormalVisualizer::getInstance()->use();
NormalVisualizer::getInstance()->use();
glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(T::VertexType, T::Instance));
for (unsigned i = 0; i < meshes.size(); i++)
{
MeshShader::NormalVisualizer::getInstance()->setUniforms(video::SColor(255, 0, 255, 0));
NormalVisualizer::getInstance()->setUniforms(video::SColor(255, 0, 255, 0));
glDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT,
(const void*)((SolidPassCmd::getInstance()->Offset[T::MaterialType] + i)
* sizeof(DrawElementsIndirectCommand)));
@ -1427,11 +1441,11 @@ static void renderInstancedMeshNormals()
template<typename T>
static void renderMultiMeshNormals()
{
MeshShader::NormalVisualizer::getInstance()->use();
NormalVisualizer::getInstance()->use();
glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(T::VertexType, T::Instance));
if (SolidPassCmd::getInstance()->Size[T::MaterialType])
{
MeshShader::NormalVisualizer::getInstance()->setUniforms(video::SColor(255, 0, 255, 0));
NormalVisualizer::getInstance()->setUniforms(video::SColor(255, 0, 255, 0));
glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT,
(const void*)(SolidPassCmd::getInstance()->Offset[T::MaterialType] * sizeof(DrawElementsIndirectCommand)),
(int)SolidPassCmd::getInstance()->Size[T::MaterialType],

View File

@ -441,33 +441,6 @@ namespace MeshShader
assignSamplerNames(0, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED);
}
NormalVisualizer::NormalVisualizer()
{
loadProgram(OBJECT,
GL_VERTEX_SHADER, "utils/getworldmatrix.vert",
GL_VERTEX_SHADER, "instanced_object_pass.vert",
GL_GEOMETRY_SHADER, "normal_visualizer.geom",
GL_FRAGMENT_SHADER, "coloredquad.frag");
assignUniforms("color");
}
ViewFrustrumShader::ViewFrustrumShader()
{
loadProgram(OBJECT,
GL_VERTEX_SHADER, "frustrum.vert",
GL_FRAGMENT_SHADER, "coloredquad.frag");
assignUniforms("color", "idx");
glGenVertexArrays(1, &frustrumvao);
glBindVertexArray(frustrumvao);
glBindBuffer(GL_ARRAY_BUFFER, SharedGPUObjects::getFrustrumVBO());
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,
SharedGPUObjects::getFrustrumIndices());
glBindVertexArray(0);
}
}
namespace LightShader

View File

@ -65,21 +65,6 @@ public:
TransparentFogShader();
};
class NormalVisualizer : public Shader<NormalVisualizer, video::SColor>
{
public:
NormalVisualizer();
};
class ViewFrustrumShader : public Shader<ViewFrustrumShader, video::SColor, int>
{
public:
GLuint frustrumvao;
ViewFrustrumShader();
};
}
#define MAXLIGHT 32