diff --git a/data/shaders/instanced_object_pass2.frag b/data/shaders/instanced_object_pass2.frag index caa7f3311..73fb7999e 100644 --- a/data/shaders/instanced_object_pass2.frag +++ b/data/shaders/instanced_object_pass2.frag @@ -7,11 +7,16 @@ uniform sampler2D SpecMap; flat in sampler2D handle; flat in sampler2D secondhandle; #endif + +uniform vec2 color_change; + in vec2 uv; in vec4 color; out vec4 FragColor; vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue); +float rgbToValue(vec3 c); +vec3 hsvToRgb(vec3 c); void main(void) { @@ -27,7 +32,14 @@ void main(void) float specmap = texture(SpecMap, uv).g; float emitmap = texture(SpecMap, uv).b; #endif + + if (color_change.x > 0) + { + vec3 new_color = hsvToRgb(vec3(color_change.x, color_change.y, rgbToValue(col.rgb))); + col = vec4(new_color.b, new_color.g, new_color.r, col.a); + } + col.xyz *= pow(color.xyz, vec3(2.2)); - + FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, emitmap) , 1.); } diff --git a/data/shaders/instanced_object_pass2_blue.frag b/data/shaders/instanced_object_pass2_blue.frag deleted file mode 100644 index 5593c30c5..000000000 --- a/data/shaders/instanced_object_pass2_blue.frag +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef Use_Bindless_Texture -uniform sampler2D Albedo; -uniform sampler2D SpecMap; -#endif - -#ifdef Use_Bindless_Texture -flat in sampler2D handle; -flat in sampler2D secondhandle; -#endif -in vec2 uv; -in vec4 color; -out vec4 FragColor; - -vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue); -vec3 rgbToHsv(vec3 c); -vec3 hsvToRgb(vec3 c); - -void main(void) -{ -#ifdef Use_Bindless_Texture - vec4 col = texture(handle, uv); - float specmap = texture(secondhandle, uv).g; - float emitmap = texture(secondhandle, uv).b; -#ifdef SRGBBindlessFix - col.xyz = pow(col.xyz, vec3(2.2)); -#endif -#else - vec4 col = texture(Albedo, uv); - float specmap = texture(SpecMap, uv).g; - float emitmap = texture(SpecMap, uv).b; -#endif - - vec3 old_color = rgbToHsv(col.rgb); - vec3 new_color = hsvToRgb(vec3(0.1,0.5,old_color.z)); - col = vec4(new_color.b, new_color.g, new_color.r, col.a); - col.xyz *= pow(color.xyz, vec3(2.2)); - - FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, emitmap) , 1.); -} diff --git a/data/shaders/instanced_object_pass2_red.frag b/data/shaders/instanced_object_pass2_red.frag deleted file mode 100644 index dcdb0c549..000000000 --- a/data/shaders/instanced_object_pass2_red.frag +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef Use_Bindless_Texture -uniform sampler2D Albedo; -uniform sampler2D SpecMap; -#endif - -#ifdef Use_Bindless_Texture -flat in sampler2D handle; -flat in sampler2D secondhandle; -#endif -in vec2 uv; -in vec4 color; -out vec4 FragColor; - -vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue); -vec3 rgbToHsv(vec3 c); -vec3 hsvToRgb(vec3 c); - -void main(void) -{ -#ifdef Use_Bindless_Texture - vec4 col = texture(handle, uv); - float specmap = texture(secondhandle, uv).g; - float emitmap = texture(secondhandle, uv).b; -#ifdef SRGBBindlessFix - col.xyz = pow(col.xyz, vec3(2.2)); -#endif -#else - vec4 col = texture(Albedo, uv); - float specmap = texture(SpecMap, uv).g; - float emitmap = texture(SpecMap, uv).b; -#endif - - vec3 old_color = rgbToHsv(col.rgb); - vec3 new_color = hsvToRgb(vec3(0.7,0.7,old_color.z)); - col = vec4(new_color.b, new_color.g, new_color.r, col.a); - col.xyz *= pow(color.xyz, vec3(2.2)); - - FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, emitmap) , 1.); -} diff --git a/data/shaders/object_pass2_blue.frag b/data/shaders/object_pass2_blue.frag deleted file mode 100644 index 45e9b7278..000000000 --- a/data/shaders/object_pass2_blue.frag +++ /dev/null @@ -1,35 +0,0 @@ -#ifdef Use_Bindless_Texture -layout(bindless_sampler) uniform sampler2D Albedo; -layout(bindless_sampler) uniform sampler2D SpecMap; -#else -uniform sampler2D Albedo; -uniform sampler2D SpecMap; -#endif - -in vec2 uv; -in vec4 color; -out vec4 FragColor; - -vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue); -vec3 rgbToHsv(vec3 c); -vec3 hsvToRgb(vec3 c); - -void main(void) -{ -#ifdef Use_Bindless_Texture - vec4 col = texture(Albedo, uv); -#ifdef SRGBBindlessFix - col.xyz = pow(col.xyz, vec3(2.2)); -#endif -#else - vec4 col = texture(Albedo, uv); -#endif - - vec3 old_color = rgbToHsv(col.rgb); - vec3 new_color = hsvToRgb(vec3(0.1,0.5,old_color.z)); - col = vec4(new_color.b, new_color.g, new_color.r, col.a); - col.xyz *= pow(color.xyz, vec3(2.2)); - float specmap = texture(SpecMap, uv).g; - float emitmap = texture(SpecMap, uv).b; - FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, emitmap), 1.); -} diff --git a/data/shaders/object_pass2_red.frag b/data/shaders/object_pass2_red.frag deleted file mode 100644 index 18f9f91c5..000000000 --- a/data/shaders/object_pass2_red.frag +++ /dev/null @@ -1,35 +0,0 @@ -#ifdef Use_Bindless_Texture -layout(bindless_sampler) uniform sampler2D Albedo; -layout(bindless_sampler) uniform sampler2D SpecMap; -#else -uniform sampler2D Albedo; -uniform sampler2D SpecMap; -#endif - -in vec2 uv; -in vec4 color; -out vec4 FragColor; - -vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue); -vec3 rgbToHsv(vec3 c); -vec3 hsvToRgb(vec3 c); - -void main(void) -{ -#ifdef Use_Bindless_Texture - vec4 col = texture(Albedo, uv); -#ifdef SRGBBindlessFix - col.xyz = pow(col.xyz, vec3(2.2)); -#endif -#else - vec4 col = texture(Albedo, uv); -#endif - - vec3 old_color = rgbToHsv(col.rgb); - vec3 new_color = hsvToRgb(vec3(0.7,0.7,old_color.z)); - col = vec4(new_color.b, new_color.g, new_color.r, col.a); - col.xyz *= pow(color.xyz, vec3(2.2)); - float specmap = texture(SpecMap, uv).g; - float emitmap = texture(SpecMap, uv).b; - FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, emitmap), 1.); -} diff --git a/data/shaders/utils/rgb_conversion.frag b/data/shaders/utils/rgb_conversion.frag index 6e944a611..ad1838013 100644 --- a/data/shaders/utils/rgb_conversion.frag +++ b/data/shaders/utils/rgb_conversion.frag @@ -9,6 +9,15 @@ vec3 rgbToHsv(vec3 c) return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } +float rgbToValue(vec3 c) +{ + vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); + vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); + vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); + + return q.x; +} + vec3 hsvToRgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); diff --git a/src/graphics/material.hpp b/src/graphics/material.hpp index cf6d8c9ce..9870ec599 100644 --- a/src/graphics/material.hpp +++ b/src/graphics/material.hpp @@ -47,8 +47,6 @@ public: enum ShaderType { SHADERTYPE_SOLID, - SHADERTYPE_SOLID_RED, - SHADERTYPE_SOLID_BLUE, SHADERTYPE_ALPHA_TEST, SHADERTYPE_ALPHA_BLEND, SHADERTYPE_ADDITIVE, diff --git a/src/graphics/render_geometry.cpp b/src/graphics/render_geometry.cpp index 7aa028b3b..616d6c5b2 100644 --- a/src/graphics/render_geometry.cpp +++ b/src/graphics/render_geometry.cpp @@ -133,13 +133,18 @@ public: // ============================================================================ class InstancedObjectPass2Shader : public TextureShader { +private: + GLint m_color_change_location; + public: InstancedObjectPass2Shader() { loadProgram(OBJECT, GL_VERTEX_SHADER, "utils/getworldmatrix.vert", GL_VERTEX_SHADER, "instanced_object_pass.vert", GL_FRAGMENT_SHADER, "utils/getLightFactor.frag", + GL_FRAGMENT_SHADER, "utils/rgb_conversion.frag", GL_FRAGMENT_SHADER, "instanced_object_pass2.frag"); + m_color_change_location = glGetUniformLocation(m_program, "color_change"); assignUniforms(); assignSamplerNames(0, "DiffuseMap", ST_NEAREST_FILTERED, 1, "SpecularMap", ST_NEAREST_FILTERED, @@ -147,48 +152,13 @@ public: 3, "Albedo", ST_TRILINEAR_ANISOTROPIC_FILTERED, 4, "SpecMap", ST_TRILINEAR_ANISOTROPIC_FILTERED); } // InstancedObjectPass2Shader + + void setHueSaturation(float hue, float saturation) const + { + glUniform2f(m_color_change_location, hue, saturation); + } // setHueSaturation }; // InstancedObjectPass2Shader -// ============================================================================ -class InstancedObjectPass2ShaderRed : public TextureShader -{ -public: - InstancedObjectPass2ShaderRed() - { - loadProgram(OBJECT, GL_VERTEX_SHADER, "utils/getworldmatrix.vert", - GL_VERTEX_SHADER, "instanced_object_pass.vert", - GL_FRAGMENT_SHADER, "utils/getLightFactor.frag", - GL_FRAGMENT_SHADER, "utils/rgb_conversion.frag", - GL_FRAGMENT_SHADER, "instanced_object_pass2_red.frag"); - assignUniforms(); - assignSamplerNames(0, "DiffuseMap", ST_NEAREST_FILTERED, - 1, "SpecularMap", ST_NEAREST_FILTERED, - 2, "SSAO", ST_BILINEAR_FILTERED, - 3, "Albedo", ST_TRILINEAR_ANISOTROPIC_FILTERED, - 4, "SpecMap", ST_TRILINEAR_ANISOTROPIC_FILTERED); - } // InstancedObjectPass2ShaderRed -}; // InstancedObjectPass2ShaderRed - -// ============================================================================ -class InstancedObjectPass2ShaderBlue : public TextureShader -{ -public: - InstancedObjectPass2ShaderBlue() - { - loadProgram(OBJECT, GL_VERTEX_SHADER, "utils/getworldmatrix.vert", - GL_VERTEX_SHADER, "instanced_object_pass.vert", - GL_FRAGMENT_SHADER, "utils/getLightFactor.frag", - GL_FRAGMENT_SHADER, "utils/rgb_conversion.frag", - GL_FRAGMENT_SHADER, "instanced_object_pass2_blue.frag"); - assignUniforms(); - assignSamplerNames(0, "DiffuseMap", ST_NEAREST_FILTERED, - 1, "SpecularMap", ST_NEAREST_FILTERED, - 2, "SSAO", ST_BILINEAR_FILTERED, - 3, "Albedo", ST_TRILINEAR_ANISOTROPIC_FILTERED, - 4, "SpecMap", ST_TRILINEAR_ANISOTROPIC_FILTERED); - } // InstancedObjectPass2ShaderBlue -}; // InstancedObjectPass2ShaderBlue - // ============================================================================ class InstancedObjectRefPass2Shader : public TextureShader { @@ -582,66 +552,6 @@ const STK::Tuple DefaultMaterial::SecondPassTextures const STK::Tuple<> DefaultMaterial::ShadowTextures; const STK::Tuple DefaultMaterial::RSMTextures = STK::Tuple(0); -// ============================================================================ -struct RedMaterial -{ - typedef InstancedObjectPass1Shader InstancedFirstPassShader; - typedef InstancedObjectPass2ShaderRed InstancedSecondPassShader; - typedef InstancedShadowShader InstancedShadowPassShader; - typedef CInstancedRSMShader InstancedRSMShader; - typedef ListInstancedMatRed InstancedList; - typedef Shaders::ObjectPass1Shader FirstPassShader; - typedef Shaders::ObjectPass2ShaderRed SecondPassShader; - typedef ShadowShader ShadowPassShader; - typedef CRSMShader RSMShader; - typedef ListMatRed List; - static const enum video::E_VERTEX_TYPE VertexType = video::EVT_STANDARD; - static const enum Material::ShaderType MaterialType - = Material::SHADERTYPE_SOLID_RED; - static const enum InstanceType Instance = InstanceTypeDualTex; - static const STK::Tuple FirstPassTextures; - static const STK::Tuple SecondPassTextures; - static const STK::Tuple<> ShadowTextures; - static const STK::Tuple RSMTextures; -}; // struct RedMaterial - -const STK::Tuple RedMaterial::FirstPassTextures - = STK::Tuple(1); -const STK::Tuple RedMaterial::SecondPassTextures - = STK::Tuple(0, 1); -const STK::Tuple<> RedMaterial::ShadowTextures; -const STK::Tuple RedMaterial::RSMTextures = STK::Tuple(0); - -// ============================================================================ -struct BlueMaterial -{ - typedef InstancedObjectPass1Shader InstancedFirstPassShader; - typedef InstancedObjectPass2ShaderBlue InstancedSecondPassShader; - typedef InstancedShadowShader InstancedShadowPassShader; - typedef CInstancedRSMShader InstancedRSMShader; - typedef ListInstancedMatBlue InstancedList; - typedef Shaders::ObjectPass1Shader FirstPassShader; - typedef Shaders::ObjectPass2ShaderBlue SecondPassShader; - typedef ShadowShader ShadowPassShader; - typedef CRSMShader RSMShader; - typedef ListMatBlue List; - static const enum video::E_VERTEX_TYPE VertexType = video::EVT_STANDARD; - static const enum Material::ShaderType MaterialType - = Material::SHADERTYPE_SOLID_BLUE; - static const enum InstanceType Instance = InstanceTypeDualTex; - static const STK::Tuple FirstPassTextures; - static const STK::Tuple SecondPassTextures; - static const STK::Tuple<> ShadowTextures; - static const STK::Tuple RSMTextures; -}; // struct BlueMaterial - -const STK::Tuple BlueMaterial::FirstPassTextures - = STK::Tuple(1); -const STK::Tuple BlueMaterial::SecondPassTextures - = STK::Tuple(0, 1); -const STK::Tuple<> BlueMaterial::ShadowTextures; -const STK::Tuple BlueMaterial::RSMTextures = STK::Tuple(0); - // ---------------------------------------------------------------------------- struct AlphaRef { @@ -1087,6 +997,26 @@ void draw(const T *Shader, const GLMesh *mesh, uniforms... Args) GLenum itype = mesh->IndexType; size_t count = mesh->IndexCount; + const Shaders::ObjectPass2Shader* op2s = dynamic_cast + (Shader); + if (op2s) + { + const video::E_RENDER_TYPE rt = mesh->mb->getRenderType(); + if (rt == video::ERT_RED) + { + op2s->setHueSaturation(0.7f, 0.7f); + } + else if (rt == video::ERT_BLUE) + { + op2s->setHueSaturation(0.1f, 0.5f); + } + else + { + // Reset if not using custom render type + op2s->setHueSaturation(-1, -1); + } + } + Shader->setUniforms(Args...); glDrawElementsBaseVertex(ptype, (int)count, itype, (GLvoid *)mesh->vaoOffset, @@ -1287,8 +1217,6 @@ void IrrDriver::renderSolidFirstPass() ImmediateDrawList::getInstance()->at(i)->render(); renderMeshes1stPass(); - renderMeshes1stPass(); - renderMeshes1stPass(); renderMeshes1stPass(); renderMeshes1stPass(); renderMeshes1stPass(); @@ -1300,8 +1228,6 @@ void IrrDriver::renderSolidFirstPass() if (CVS->isAZDOEnabled()) { multidraw1stPass(); - multidraw1stPass(); - multidraw1stPass(); multidraw1stPass(); multidraw1stPass(); multidraw1stPass(); @@ -1313,8 +1239,6 @@ void IrrDriver::renderSolidFirstPass() else if (CVS->supportsIndirectInstancingRendering()) { renderInstancedMeshes1stPass(); - renderInstancedMeshes1stPass(); - renderInstancedMeshes1stPass(); renderInstancedMeshes1stPass(); renderInstancedMeshes1stPass(); renderInstancedMeshes1stPass(); @@ -1372,12 +1296,32 @@ void renderInstancedMeshes2ndPass(const std::vector &Prefilled_tex, Args T::InstancedSecondPassShader::getInstance()->use(); glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(T::VertexType, T::Instance)); + InstancedObjectPass2Shader* iop2s = dynamic_cast + (T::InstancedSecondPassShader::getInstance()); for (unsigned i = 0; i < meshes.size(); i++) { GLMesh *mesh = meshes[i]; TexExpander::template ExpandTex(*mesh, T::SecondPassTextures, Prefilled_tex[0], Prefilled_tex[1], Prefilled_tex[2]); + if (iop2s) + { + const video::E_RENDER_TYPE rt = mesh->mb->getRenderType(); + if (rt == video::ERT_RED) + { + iop2s->setHueSaturation(0.7f, 0.7f); + } + else if (rt == video::ERT_BLUE) + { + iop2s->setHueSaturation(0.1f, 0.5f); + } + else + { + // Reset if not using custom render type + iop2s->setHueSaturation(-1, -1); + } + } + T::InstancedSecondPassShader::getInstance()->setUniforms(args...); glDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, (const void*)((SolidPassCmd::getInstance()->Offset[T::MaterialType] + i) @@ -1457,8 +1401,6 @@ void IrrDriver::renderSolidSecondPass() m_rtts->getRenderTarget(RTT_HALF1_R)); renderMeshes2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex); - renderMeshes2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex); - renderMeshes2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex); renderMeshes2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex); renderMeshes2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex); renderMeshes2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex); @@ -1470,8 +1412,6 @@ void IrrDriver::renderSolidSecondPass() if (CVS->isAZDOEnabled()) { multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0)); - multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0)); - multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0)); multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0)); multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0)); multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0)); @@ -1502,8 +1442,6 @@ void IrrDriver::renderSolidSecondPass() else if (CVS->supportsIndirectInstancingRendering()) { renderInstancedMeshes2ndPass(DiffSpecSSAOTex); - renderInstancedMeshes2ndPass(DiffSpecSSAOTex); - renderInstancedMeshes2ndPass(DiffSpecSSAOTex); renderInstancedMeshes2ndPass(DiffSpecSSAOTex); renderInstancedMeshes2ndPass(DiffSpecSSAOTex); renderInstancedMeshes2ndPass(DiffSpecSSAOTex); @@ -1571,8 +1509,6 @@ void IrrDriver::renderNormalsVisualisation() { if (CVS->isAZDOEnabled()) { renderMultiMeshNormals(); - renderMultiMeshNormals(); - renderMultiMeshNormals(); renderMultiMeshNormals(); renderMultiMeshNormals(); renderMultiMeshNormals(); @@ -1582,8 +1518,6 @@ void IrrDriver::renderNormalsVisualisation() else if (CVS->supportsIndirectInstancingRendering()) { renderInstancedMeshNormals(); - renderInstancedMeshNormals(); - renderInstancedMeshNormals(); renderInstancedMeshNormals(); renderInstancedMeshNormals(); renderInstancedMeshNormals(); @@ -1893,8 +1827,6 @@ void IrrDriver::renderShadows() ScopedGPUTimer Timer(getGPUTimer(Q_SHADOWS_CASCADE0 + cascade)); renderShadow(cascade); - renderShadow(cascade); - renderShadow(cascade); renderShadow(cascade); renderShadow(cascade); renderShadow(cascade); @@ -1909,8 +1841,6 @@ void IrrDriver::renderShadows() if (CVS->isAZDOEnabled()) { multidrawShadow(cascade); - multidrawShadow(cascade); - multidrawShadow(cascade); multidrawShadow(cascade); multidrawShadow(cascade); multidrawShadow(cascade); @@ -1920,8 +1850,6 @@ void IrrDriver::renderShadows() else if (CVS->supportsIndirectInstancingRendering()) { renderInstancedShadow(cascade); - renderInstancedShadow(cascade); - renderInstancedShadow(cascade); renderInstancedShadow(cascade); renderInstancedShadow(cascade); renderInstancedShadow(cascade); @@ -2054,8 +1982,6 @@ void IrrDriver::renderRSM() const core::matrix4 &rsm_matrix = getShadowMatrices()->getRSMMatrix(); drawRSM(rsm_matrix); - drawRSM(rsm_matrix); - drawRSM(rsm_matrix); drawRSM(rsm_matrix); drawRSM(rsm_matrix); drawRSM(rsm_matrix); @@ -2069,8 +1995,6 @@ void IrrDriver::renderRSM() if (CVS->isAZDOEnabled()) { multidrawRSM(rsm_matrix); - multidrawRSM(rsm_matrix); - multidrawRSM(rsm_matrix); multidrawRSM(rsm_matrix); multidrawRSM(rsm_matrix); multidrawRSM(rsm_matrix); @@ -2079,8 +2003,6 @@ void IrrDriver::renderRSM() else if (CVS->supportsIndirectInstancingRendering()) { renderRSMShadow(rsm_matrix); - renderRSMShadow(rsm_matrix); - renderRSMShadow(rsm_matrix); renderRSMShadow(rsm_matrix); renderRSMShadow(rsm_matrix); renderRSMShadow(rsm_matrix); diff --git a/src/graphics/shaders.cpp b/src/graphics/shaders.cpp index a62c74cd8..796ec8122 100644 --- a/src/graphics/shaders.cpp +++ b/src/graphics/shaders.cpp @@ -340,7 +340,9 @@ Shaders::ObjectPass2Shader::ObjectPass2Shader() { loadProgram(OBJECT, GL_VERTEX_SHADER, "object_pass.vert", GL_FRAGMENT_SHADER, "utils/getLightFactor.frag", + GL_FRAGMENT_SHADER, "utils/rgb_conversion.frag", GL_FRAGMENT_SHADER, "object_pass2.frag"); + m_color_change_location = glGetUniformLocation(m_program, "color_change"); assignUniforms("ModelMatrix", "TextureMatrix"); assignSamplerNames(0, "DiffuseMap", ST_NEAREST_FILTERED, 1, "SpecularMap", ST_NEAREST_FILTERED, @@ -349,38 +351,6 @@ Shaders::ObjectPass2Shader::ObjectPass2Shader() 4, "SpecMap", ST_TRILINEAR_ANISOTROPIC_FILTERED); } // ObjectPass2Shader -// ============================================================================ -// Solid Lit pass shaders (red version) -Shaders::ObjectPass2ShaderRed::ObjectPass2ShaderRed() -{ - loadProgram(OBJECT, GL_VERTEX_SHADER, "object_pass.vert", - GL_FRAGMENT_SHADER, "utils/getLightFactor.frag", - GL_FRAGMENT_SHADER, "utils/rgb_conversion.frag", - GL_FRAGMENT_SHADER, "object_pass2_red.frag"); - assignUniforms("ModelMatrix", "TextureMatrix"); - assignSamplerNames(0, "DiffuseMap", ST_NEAREST_FILTERED, - 1, "SpecularMap", ST_NEAREST_FILTERED, - 2, "SSAO", ST_BILINEAR_FILTERED, - 3, "Albedo", ST_TRILINEAR_ANISOTROPIC_FILTERED, - 4, "SpecMap", ST_TRILINEAR_ANISOTROPIC_FILTERED); -} // ObjectPass2ShaderRed - -// ============================================================================ -// Solid Lit pass shaders (blue version) -Shaders::ObjectPass2ShaderBlue::ObjectPass2ShaderBlue() -{ - loadProgram(OBJECT, GL_VERTEX_SHADER, "object_pass.vert", - GL_FRAGMENT_SHADER, "utils/getLightFactor.frag", - GL_FRAGMENT_SHADER, "utils/rgb_conversion.frag", - GL_FRAGMENT_SHADER, "object_pass2_blue.frag"); - assignUniforms("ModelMatrix", "TextureMatrix"); - assignSamplerNames(0, "DiffuseMap", ST_NEAREST_FILTERED, - 1, "SpecularMap", ST_NEAREST_FILTERED, - 2, "SSAO", ST_BILINEAR_FILTERED, - 3, "Albedo", ST_TRILINEAR_ANISOTROPIC_FILTERED, - 4, "SpecMap", ST_TRILINEAR_ANISOTROPIC_FILTERED); -} // ObjectPass2ShaderBlue - // ============================================================================ Shaders::TransparentShader::TransparentShader() { diff --git a/src/graphics/shaders.hpp b/src/graphics/shaders.hpp index e2b219a6f..ea4cada42 100644 --- a/src/graphics/shaders.hpp +++ b/src/graphics/shaders.hpp @@ -146,27 +146,17 @@ public: class ObjectPass2Shader : public TextureShader < ObjectPass2Shader, 5, core::matrix4, core::matrix4 > { + private: + GLint m_color_change_location; public: ObjectPass2Shader(); + void setHueSaturation(float hue, float saturation) const + { + glUniform2f(m_color_change_location, hue, saturation); + } // setHueSaturation }; // ObjectPass2Shader // ======================================================================== - class ObjectPass2ShaderRed : public TextureShader < ObjectPass2ShaderRed, 5, - core::matrix4, core::matrix4 > - { - public: - ObjectPass2ShaderRed(); - }; // ObjectPass2ShaderRed - - // ======================================================================== - class ObjectPass2ShaderBlue : public TextureShader < ObjectPass2ShaderBlue, 5, - core::matrix4, core::matrix4 > - { - public: - ObjectPass2ShaderBlue(); - }; // ObjectPass2ShaderBlue - - // ======================================================================== }; // class Shaders diff --git a/src/graphics/stk_animated_mesh.cpp b/src/graphics/stk_animated_mesh.cpp index fcf997687..dbf951af4 100644 --- a/src/graphics/stk_animated_mesh.cpp +++ b/src/graphics/stk_animated_mesh.cpp @@ -132,11 +132,11 @@ void STKAnimatedMesh::updateNoGL() } else if (mb->getRenderType() == video::ERT_RED) { - MeshSolidMaterial[Material::SHADERTYPE_SOLID_RED].push_back(&mesh); + MeshSolidMaterial[Material::SHADERTYPE_SOLID].push_back(&mesh); } else if (mb->getRenderType() == video::ERT_BLUE) { - MeshSolidMaterial[Material::SHADERTYPE_SOLID_BLUE].push_back(&mesh); + MeshSolidMaterial[Material::SHADERTYPE_SOLID].push_back(&mesh); } else { diff --git a/src/graphics/stk_mesh.hpp b/src/graphics/stk_mesh.hpp index 1324fbefb..44504baff 100644 --- a/src/graphics/stk_mesh.hpp +++ b/src/graphics/stk_mesh.hpp @@ -122,28 +122,10 @@ class ListMatDefault : public MeshList {}; -// ---------------------------------------------------------------------------- -class ListMatRed : public MeshList -{}; - -// ---------------------------------------------------------------------------- -class ListMatBlue : public MeshList -{}; - // ---------------------------------------------------------------------------- class ListInstancedMatDefault : public InstancedMeshList {}; -// ---------------------------------------------------------------------------- -class ListInstancedMatRed : public InstancedMeshList -{}; - -// ---------------------------------------------------------------------------- -class ListInstancedMatBlue : public InstancedMeshList -{}; - // ---------------------------------------------------------------------------- class ListMatAlphaRef : public MeshList diff --git a/src/graphics/stk_mesh_scene_node.cpp b/src/graphics/stk_mesh_scene_node.cpp index b0af12339..93f1620ec 100644 --- a/src/graphics/stk_mesh_scene_node.cpp +++ b/src/graphics/stk_mesh_scene_node.cpp @@ -191,12 +191,12 @@ void STKMeshSceneNode::updateNoGL() else if (mb->getRenderType() == video::ERT_RED) { if (!immediate_draw) - MeshSolidMaterial[Material::SHADERTYPE_SOLID_RED].push_back(&mesh); + MeshSolidMaterial[Material::SHADERTYPE_SOLID].push_back(&mesh); } else if (mb->getRenderType() == video::ERT_BLUE) { if (!immediate_draw) - MeshSolidMaterial[Material::SHADERTYPE_SOLID_BLUE].push_back(&mesh); + MeshSolidMaterial[Material::SHADERTYPE_SOLID].push_back(&mesh); } else { diff --git a/src/graphics/stk_scene_manager.cpp b/src/graphics/stk_scene_manager.cpp index f7af8a7ef..5358ffd00 100644 --- a/src/graphics/stk_scene_manager.cpp +++ b/src/graphics/stk_scene_manager.cpp @@ -331,12 +331,6 @@ handleSTKCommon(scene::ISceneNode *Node, std::vector *Immed case Material::SHADERTYPE_SOLID: ListMatDefault::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; - case Material::SHADERTYPE_SOLID_RED: - ListMatRed::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); - break; - case Material::SHADERTYPE_SOLID_BLUE: - ListMatBlue::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); - break; case Material::SHADERTYPE_ALPHA_TEST: ListMatAlphaRef::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; @@ -362,12 +356,6 @@ handleSTKCommon(scene::ISceneNode *Node, std::vector *Immed case Material::SHADERTYPE_SOLID: ListMatDefault::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; - case Material::SHADERTYPE_SOLID_RED: - ListMatRed::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); - break; - case Material::SHADERTYPE_SOLID_BLUE: - ListMatBlue::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); - break; case Material::SHADERTYPE_ALPHA_TEST: ListMatAlphaRef::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; @@ -428,12 +416,6 @@ handleSTKCommon(scene::ISceneNode *Node, std::vector *Immed case Material::SHADERTYPE_SOLID: ListMatDefault::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; - case Material::SHADERTYPE_SOLID_RED: - ListMatRed::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); - break; - case Material::SHADERTYPE_SOLID_BLUE: - ListMatBlue::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); - break; case Material::SHADERTYPE_ALPHA_TEST: ListMatAlphaRef::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; @@ -493,12 +475,6 @@ handleSTKCommon(scene::ISceneNode *Node, std::vector *Immed case Material::SHADERTYPE_SOLID: ListMatDefault::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; - case Material::SHADERTYPE_SOLID_RED: - ListMatRed::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); - break; - case Material::SHADERTYPE_SOLID_BLUE: - ListMatBlue::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); - break; case Material::SHADERTYPE_ALPHA_TEST: ListMatAlphaRef::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); break; @@ -597,8 +573,6 @@ void IrrDriver::PrepareDrawCalls(scene::ICameraSceneNode *camnode) ListDisplacement::getInstance()->clear(); ListMatDefault::getInstance()->clear(); - ListMatRed::getInstance()->clear(); - ListMatBlue::getInstance()->clear(); ListMatAlphaRef::getInstance()->clear(); ListMatSphereMap::getInstance()->clear(); ListMatDetails::getInstance()->clear(); @@ -700,8 +674,6 @@ PROFILER_POP_CPU_MARKER(); enableOpenMP = 0; ListInstancedMatDefault::getInstance()->clear(); - ListInstancedMatRed::getInstance()->clear(); - ListInstancedMatBlue::getInstance()->clear(); ListInstancedMatAlphaRef::getInstance()->clear(); ListInstancedMatGrass::getInstance()->clear(); ListInstancedMatNormalMap::getInstance()->clear(); @@ -731,14 +703,6 @@ PROFILER_POP_CPU_MARKER(); SolidPassCmd::getInstance()->Offset[Material::SHADERTYPE_SOLID] = current_cmd; FillInstances(MeshForSolidPass[Material::SHADERTYPE_SOLID], ListInstancedMatDefault::getInstance()->SolidPass, InstanceBufferDualTex, CmdBuffer, offset, current_cmd, SolidPoly); SolidPassCmd::getInstance()->Size[Material::SHADERTYPE_SOLID] = current_cmd - SolidPassCmd::getInstance()->Offset[Material::SHADERTYPE_SOLID]; - // Red Material - SolidPassCmd::getInstance()->Offset[Material::SHADERTYPE_SOLID_RED] = current_cmd; - FillInstances(MeshForSolidPass[Material::SHADERTYPE_SOLID_RED], ListInstancedMatRed::getInstance()->SolidPass, InstanceBufferDualTex, CmdBuffer, offset, current_cmd, SolidPoly); - SolidPassCmd::getInstance()->Size[Material::SHADERTYPE_SOLID_RED] = current_cmd - SolidPassCmd::getInstance()->Offset[Material::SHADERTYPE_SOLID_RED]; - // Blue Material - SolidPassCmd::getInstance()->Offset[Material::SHADERTYPE_SOLID_BLUE] = current_cmd; - FillInstances(MeshForSolidPass[Material::SHADERTYPE_SOLID_BLUE], ListInstancedMatBlue::getInstance()->SolidPass, InstanceBufferDualTex, CmdBuffer, offset, current_cmd, SolidPoly); - SolidPassCmd::getInstance()->Size[Material::SHADERTYPE_SOLID_BLUE] = current_cmd - SolidPassCmd::getInstance()->Offset[Material::SHADERTYPE_SOLID_BLUE]; // Alpha Ref SolidPassCmd::getInstance()->Offset[Material::SHADERTYPE_ALPHA_TEST] = current_cmd; FillInstances(MeshForSolidPass[Material::SHADERTYPE_ALPHA_TEST], ListInstancedMatAlphaRef::getInstance()->SolidPass, InstanceBufferDualTex, CmdBuffer, offset, current_cmd, SolidPoly);