Merge branch 'refactor_shaders' of github.com:supertuxkart/stk-code into refactor_shaders
This commit is contained in:
commit
ba957ca0dc
@ -1,5 +1,5 @@
|
||||
# Modify this file to change the last-modified date when you add/remove a file.
|
||||
# This will then trigger a new cmake run automatically.
|
||||
# This will then trigger a new cmake run automatically.
|
||||
file(GLOB_RECURSE STK_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.hpp")
|
||||
file(GLOB_RECURSE STK_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp")
|
||||
file(GLOB_RECURSE STK_SHADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/shaders/*")
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "graphics/glwrap.hpp"
|
||||
#include "graphics/shaders_util.hpp"
|
||||
#include "gpuparticles.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
@ -33,7 +32,7 @@
|
||||
/** Transform feedback shader that simulates the particles on GPU.
|
||||
*/
|
||||
class PointEmitterShader : public Shader
|
||||
< PointEmitterShader, core::matrix4, int, int, float >
|
||||
< PointEmitterShader, core::matrix4, int, int, float >
|
||||
{
|
||||
public:
|
||||
PointEmitterShader()
|
||||
@ -52,8 +51,8 @@ public:
|
||||
*/
|
||||
class SimpleParticleRender : public Shader<SimpleParticleRender, video::SColorf,
|
||||
video::SColorf>,
|
||||
public TextureRead<Trilinear_Anisotropic_Filtered,
|
||||
Nearest_Filtered>
|
||||
public TextureReadNew<ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
ST_NEAREST_FILTERED>
|
||||
{
|
||||
public:
|
||||
SimpleParticleRender()
|
||||
@ -64,7 +63,8 @@ public:
|
||||
GL_FRAGMENT_SHADER, "particle.frag");
|
||||
|
||||
assignUniforms("color_from", "color_to");
|
||||
assignSamplerNames(m_program, 0, "tex", 1, "dtex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
1, "dtex", ST_NEAREST_FILTERED);
|
||||
} // SimpleParticleRender
|
||||
|
||||
}; // SimpleParticleRender
|
||||
@ -72,8 +72,8 @@ public:
|
||||
// ============================================================================
|
||||
|
||||
class FlipParticleRender : public Shader<FlipParticleRender>,
|
||||
public TextureRead < Trilinear_Anisotropic_Filtered,
|
||||
Nearest_Filtered >
|
||||
public TextureReadNew < ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
ST_NEAREST_FILTERED >
|
||||
{
|
||||
public:
|
||||
FlipParticleRender()
|
||||
@ -83,7 +83,8 @@ public:
|
||||
GL_FRAGMENT_SHADER, "utils/getPosFromUVDepth.frag",
|
||||
GL_FRAGMENT_SHADER, "particle.frag");
|
||||
assignUniforms();
|
||||
assignSamplerNames(m_program, 0, "tex", 1, "dtex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
1, "dtex", ST_NEAREST_FILTERED);
|
||||
}
|
||||
|
||||
}; // FlipParticleShader
|
||||
|
@ -54,8 +54,8 @@ protected:
|
||||
|
||||
void bypassUBO() const;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Ends vararg template
|
||||
// ========================================================================
|
||||
/** Ends recursion. */
|
||||
template<typename ... Types>
|
||||
void loadAndAttachShader()
|
||||
{
|
||||
@ -72,6 +72,7 @@ protected:
|
||||
loadAndAttachShader(args...);
|
||||
} // loadAndAttachShader
|
||||
// ------------------------------------------------------------------------
|
||||
/** Convenience interface using const char. */
|
||||
template<typename ... Types>
|
||||
void loadAndAttachShader(GLint shader_type, const char *name,
|
||||
Types ... args)
|
||||
@ -109,6 +110,22 @@ private:
|
||||
if (block_index != GL_INVALID_INDEX)
|
||||
glUniformBlockBinding(m_program, block_index, index);
|
||||
} // bindPoint
|
||||
|
||||
|
||||
// ========================================================================
|
||||
// assignUniforms: Variadic Template
|
||||
protected:
|
||||
/** This variadic template collects all names of uniforms in
|
||||
* a std::vector. It used assignUnfiromsImpl for the actual recursive
|
||||
* implementation. */
|
||||
template<typename... U>
|
||||
void assignUniforms(U... rest)
|
||||
{
|
||||
static_assert(sizeof...(rest) == sizeof...(Args),
|
||||
"Count of Uniform's name mismatch");
|
||||
assignUniformsImpl(rest...);
|
||||
} // assignUniforms
|
||||
private:
|
||||
// ------------------------------------------------------------------------
|
||||
/** End of recursive implementation of assignUniforms. */
|
||||
void assignUniformsImpl()
|
||||
@ -129,6 +146,28 @@ private:
|
||||
assignUniformsImpl(rest...);
|
||||
} // assignUniformsImpl
|
||||
|
||||
|
||||
// ==============================================
|
||||
// setUniforms: Variadic template implementation.
|
||||
|
||||
public:
|
||||
/** Sets the uniforms for this shader. */
|
||||
void setUniforms(const Args & ... args) const
|
||||
{
|
||||
if (!CVS->isARBUniformBufferObjectUsable())
|
||||
bypassUBO();
|
||||
setUniformsImpl(args...);
|
||||
} // setUniforms
|
||||
// ------------------------------------------------------------------------
|
||||
private:
|
||||
/** Implementation for setUniforms for a vector<float> uniform. */
|
||||
template<unsigned N = 0, typename... Args1>
|
||||
void setUniformsImpl(const std::vector<float> &v, Args1... arg) const
|
||||
{
|
||||
glUniform1fv(m_uniforms[N], (int)v.size(), v.data());
|
||||
setUniformsImpl<N + 1>(arg...);
|
||||
} // setUniformsImpl
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** End of recursion for setUniforms implementation.
|
||||
*/
|
||||
@ -136,6 +175,7 @@ private:
|
||||
void setUniformsImpl() const
|
||||
{
|
||||
} // setUniformImpl
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Implementation for setUniforms for a matrix uniform. */
|
||||
template<unsigned N = 0, typename... Args1>
|
||||
@ -209,59 +249,60 @@ private:
|
||||
setUniformsImpl<N + 1>(arg...);
|
||||
} // setUniformsImpl
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Implementation for setUniforms for a vector<float> uniform. */
|
||||
template<unsigned N = 0, typename... Args1>
|
||||
void setUniformsImpl(const std::vector<float> &v, Args1... arg) const
|
||||
{
|
||||
glUniform1fv(m_uniforms[N], (int)v.size(), v.data());
|
||||
setUniformsImpl<N + 1>(arg...);
|
||||
} // setUniformsImpl
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** End recursion for variadic template. */
|
||||
template<typename ...Types>
|
||||
void printFileList()
|
||||
{
|
||||
return;
|
||||
} // printFileList
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// printFileList: Variadic template for printing a list of shader filenames
|
||||
// ========================================================================
|
||||
/** Variadic template to print a list of file names.
|
||||
* \param shader_type Ignored (used since the variadic calling function
|
||||
* has this parameter).
|
||||
* \param filepath Name of the file to print.
|
||||
*/
|
||||
* \param shader_type Ignored (used since the variadic calling function
|
||||
* has this parameter).
|
||||
* \param filepath Name of the file to print.
|
||||
*/
|
||||
protected:
|
||||
template<typename ...Types>
|
||||
void printFileList(GLint shader_type, const char *filepath, Types ... args)
|
||||
{
|
||||
Log::error("shader", filepath);
|
||||
printFileList(args...);
|
||||
} // printFileList
|
||||
protected:
|
||||
|
||||
// ========================================================================
|
||||
void assignTextureUnit(GLuint index, const char* uniform)
|
||||
{
|
||||
glUseProgram(m_program);
|
||||
GLuint uniform_loc = glGetUniformLocation(m_program, uniform);
|
||||
glUniform1i(uniform_loc, index);
|
||||
glUseProgram(0);
|
||||
} // assignTextureUnit
|
||||
// ------------------------------------------------------------------------
|
||||
/** End recursion for variadic template. */
|
||||
private:
|
||||
template<typename ...Types>
|
||||
void printFileList()
|
||||
{
|
||||
return;
|
||||
} // printFileList
|
||||
|
||||
|
||||
// Variadic template implementation of assignTextureUnig
|
||||
// ========================================================================
|
||||
public:
|
||||
/** Variadic top level/public interface. It does the calls to glUseProgram
|
||||
* and uses assignTextureUnitNoUse() in recursion to avoid unnecessary
|
||||
* calls to glUseProgram.
|
||||
* \param index Index of the texture.
|
||||
* \param uniform Uniform name.
|
||||
*/
|
||||
template<typename... T1>
|
||||
void assignTextureUnit(GLuint index, const char* uniform, T1... rest)
|
||||
{
|
||||
glUseProgram(m_program);
|
||||
GLuint uniform_loc = glGetUniformLocation(m_program, uniform);
|
||||
glUniform1i(uniform_loc, index);
|
||||
// Avoid doing any additional glUseProgram for the remaining calls
|
||||
assignTextureUnitNoUse(rest...);
|
||||
glUseProgram(0);
|
||||
} // assignTextureUnit
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
void assignTextureUnitNoUse() {}
|
||||
private:
|
||||
// ------------------------------------------------------------------------
|
||||
/** End of recursion. */
|
||||
void assignTextureUnitNoUse() {}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Recursive implementation of assignTextureUnit, but without the call
|
||||
* to gluseProgram (which is done by the public interface). */
|
||||
template<typename... T1>
|
||||
void assignTextureUnitNoUse(GLuint index, const char* uniform, T1... rest)
|
||||
{
|
||||
@ -270,14 +311,22 @@ protected:
|
||||
assignTextureUnitNoUse(rest...);
|
||||
} // assignTextureUnitNoUse
|
||||
|
||||
// ========================================================================
|
||||
|
||||
public:
|
||||
|
||||
/** Constructor. Adds the static kill function of this shader to the list
|
||||
* of all kill function, which is used for the debugging feature of
|
||||
* reloading all shaders.
|
||||
*/
|
||||
Shader()
|
||||
{
|
||||
m_all_kill_functions.push_back(this->kill);
|
||||
}
|
||||
} // Shader
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Load a list of shaders and links them all together.
|
||||
*/
|
||||
template<typename ... Types>
|
||||
void loadProgram(AttributeType type, Types ... args)
|
||||
{
|
||||
@ -301,26 +350,6 @@ public:
|
||||
}
|
||||
} // loadProgram
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** This variadic template collects all names of uniforms in
|
||||
* a std::vector. */
|
||||
template<typename... U>
|
||||
void assignUniforms(U... rest)
|
||||
{
|
||||
static_assert(sizeof...(rest) == sizeof...(Args),
|
||||
"Count of Uniform's name mismatch");
|
||||
assignUniformsImpl(rest...);
|
||||
} // assignUniforms
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets the uniforms for this shader. */
|
||||
void setUniforms(const Args & ... args) const
|
||||
{
|
||||
if (!CVS->isARBUniformBufferObjectUsable())
|
||||
bypassUBO();
|
||||
setUniformsImpl(args...);
|
||||
} // setUniforms
|
||||
|
||||
|
||||
}; // Shader
|
||||
|
||||
|
@ -97,7 +97,6 @@
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "graphics/gpuparticles.hpp"
|
||||
#include "graphics/shaders.hpp"
|
||||
#include "graphics/shaders_util.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "graphics/glwrap.hpp"
|
||||
@ -521,231 +520,8 @@ namespace UtilShader
|
||||
using namespace UtilShader;
|
||||
|
||||
|
||||
void setTextureSampler(GLenum tp, GLuint texunit, GLuint tid, GLuint sid)
|
||||
{
|
||||
#ifdef GL_VERSION_3_3
|
||||
glActiveTexture(GL_TEXTURE0 + texunit);
|
||||
glBindTexture(tp, tid);
|
||||
glBindSampler(texunit, sid);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
GLuint createNearestSampler()
|
||||
{
|
||||
#ifdef GL_VERSION_3_3
|
||||
unsigned id;
|
||||
glGenSamplers(1, &id);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glSamplerParameterf(id, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.);
|
||||
return id;
|
||||
#endif
|
||||
}
|
||||
|
||||
void BindTextureNearest(GLuint TU, GLuint tex)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + TU);
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.);
|
||||
}
|
||||
|
||||
GLuint createBilinearSampler()
|
||||
{
|
||||
#ifdef GL_VERSION_3_3
|
||||
unsigned id;
|
||||
glGenSamplers(1, &id);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glSamplerParameterf(id, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.);
|
||||
return id;
|
||||
#endif
|
||||
}
|
||||
|
||||
void BindTextureBilinear(GLuint TU, GLuint tex)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + TU);
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.);
|
||||
}
|
||||
|
||||
GLuint createBilinearClampedSampler()
|
||||
{
|
||||
#ifdef GL_VERSION_3_3
|
||||
unsigned id;
|
||||
glGenSamplers(1, &id);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameterf(id, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.);
|
||||
return id;
|
||||
#endif
|
||||
}
|
||||
|
||||
void BindTextureBilinearClamped(GLuint TU, GLuint tex)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + TU);
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.);
|
||||
}
|
||||
|
||||
GLuint createSemiTrilinearSampler()
|
||||
{
|
||||
#ifdef GL_VERSION_3_3
|
||||
unsigned id;
|
||||
glGenSamplers(1, &id);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameterf(id, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.);
|
||||
return id;
|
||||
#endif
|
||||
}
|
||||
|
||||
void BindTextureSemiTrilinear(GLuint TU, GLuint tex)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + TU);
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.);
|
||||
}
|
||||
|
||||
GLuint createTrilinearSampler()
|
||||
{
|
||||
#ifdef GL_VERSION_3_3
|
||||
unsigned id;
|
||||
glGenSamplers(1, &id);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
|
||||
int aniso = UserConfigParams::m_anisotropic;
|
||||
if (aniso == 0) aniso = 1;
|
||||
glSamplerParameterf(id, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)aniso);
|
||||
return id;
|
||||
#endif
|
||||
}
|
||||
|
||||
void BindTextureTrilinearAnisotropic(GLuint TU, GLuint tex)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + TU);
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
|
||||
int aniso = UserConfigParams::m_anisotropic;
|
||||
if (aniso == 0) aniso = 1;
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)aniso);
|
||||
}
|
||||
|
||||
void BindCubemapTrilinear(unsigned TU, unsigned tex)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + TU);
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
|
||||
int aniso = UserConfigParams::m_anisotropic;
|
||||
if (aniso == 0) aniso = 1;
|
||||
glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)aniso);
|
||||
}
|
||||
|
||||
GLuint createShadowSampler()
|
||||
{
|
||||
#ifdef GL_VERSION_3_3
|
||||
unsigned id;
|
||||
glGenSamplers(1, &id);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameterf(id, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
|
||||
glSamplerParameterf(id, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
|
||||
return id;
|
||||
#endif
|
||||
}
|
||||
|
||||
void BindTextureShadow(GLuint TU, GLuint tex)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + TU);
|
||||
glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
|
||||
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
|
||||
}
|
||||
|
||||
|
||||
GLuint createTrilinearClampedArray()
|
||||
{
|
||||
#ifdef GL_VERSION_3_3
|
||||
unsigned id;
|
||||
glGenSamplers(1, &id);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
int aniso = UserConfigParams::m_anisotropic;
|
||||
if (aniso == 0) aniso = 1;
|
||||
glSamplerParameterf(id, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)aniso);
|
||||
return id;
|
||||
#endif
|
||||
}
|
||||
|
||||
void BindTrilinearClampedArrayTexture(unsigned TU, unsigned tex)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + TU);
|
||||
glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
int aniso = UserConfigParams::m_anisotropic;
|
||||
if (aniso == 0) aniso = 1;
|
||||
glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)aniso);
|
||||
}
|
||||
|
||||
void BindTextureVolume(GLuint TU, GLuint tex)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + TU);
|
||||
glBindTexture(GL_TEXTURE_3D, tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.);
|
||||
}
|
||||
|
||||
unsigned getGLSLVersion()
|
||||
{
|
||||
return CVS->getGLSLVersion();
|
||||
@ -760,7 +536,7 @@ namespace UtilShader
|
||||
GL_FRAGMENT_SHADER, "importance_sampling_specular.frag");
|
||||
assignUniforms("PermutationMatrix", "ViewportSize");
|
||||
TU_Samples = 1;
|
||||
assignSamplerNames(m_program, 0, "tex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_TRILINEAR_CUBEMAP);
|
||||
assignTextureUnit(TU_Samples, "samples");
|
||||
}
|
||||
}
|
||||
@ -775,7 +551,7 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, "utils/encode_normal.frag",
|
||||
GL_FRAGMENT_SHADER, "object_pass1.frag");
|
||||
assignUniforms("ModelMatrix", "InverseModelMatrix");
|
||||
assignSamplerNames(m_program, 0, "tex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
}
|
||||
|
||||
ObjectRefPass1Shader::ObjectRefPass1Shader()
|
||||
@ -785,7 +561,8 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, "utils/encode_normal.frag",
|
||||
GL_FRAGMENT_SHADER, "objectref_pass1.frag");
|
||||
assignUniforms("ModelMatrix", "InverseModelMatrix", "TextureMatrix");
|
||||
assignSamplerNames(m_program, 0, "tex", 1, "glosstex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
1, "glosstex",ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
}
|
||||
|
||||
GrassPass1Shader::GrassPass1Shader()
|
||||
@ -795,7 +572,8 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, "utils/encode_normal.frag",
|
||||
GL_FRAGMENT_SHADER, "objectref_pass1.frag");
|
||||
assignUniforms("ModelMatrix", "InverseModelMatrix", "windDir");
|
||||
assignSamplerNames(m_program, 0, "tex", 1, "glosstex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
1, "glosstex", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
}
|
||||
|
||||
NormalMapShader::NormalMapShader()
|
||||
@ -805,7 +583,8 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, "utils/encode_normal.frag",
|
||||
GL_FRAGMENT_SHADER, "normalmap.frag");
|
||||
assignUniforms("ModelMatrix", "InverseModelMatrix");
|
||||
assignSamplerNames(m_program, 1, "normalMap", 0, "DiffuseForAlpha");
|
||||
assignSamplerNames(m_program, 1, "normalMap", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
0, "DiffuseForAlpha", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
}
|
||||
|
||||
InstancedObjectPass1Shader::InstancedObjectPass1Shader()
|
||||
@ -817,7 +596,7 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, "instanced_object_pass1.frag");
|
||||
|
||||
assignUniforms();
|
||||
assignSamplerNames(m_program, 0, "glosstex");
|
||||
assignSamplerNames(m_program, 0, "glosstex", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
}
|
||||
|
||||
InstancedObjectRefPass1Shader::InstancedObjectRefPass1Shader()
|
||||
@ -829,7 +608,8 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, "instanced_objectref_pass1.frag");
|
||||
|
||||
assignUniforms();
|
||||
assignSamplerNames(m_program, 0, "tex", 1, "glosstex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
1, "glosstex", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
}
|
||||
|
||||
InstancedGrassPass1Shader::InstancedGrassPass1Shader()
|
||||
@ -840,7 +620,8 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, "utils/encode_normal.frag",
|
||||
GL_FRAGMENT_SHADER, "instanced_objectref_pass1.frag");
|
||||
assignUniforms("windDir");
|
||||
assignSamplerNames(m_program, 0, "tex", 1, "glosstex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
1, "glosstex", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
}
|
||||
|
||||
InstancedNormalMapShader::InstancedNormalMapShader()
|
||||
@ -851,7 +632,8 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, "utils/encode_normal.frag",
|
||||
GL_FRAGMENT_SHADER, "instanced_normalmap.frag");
|
||||
assignUniforms();
|
||||
assignSamplerNames(m_program, 0, "normalMap", 1, "glossMap");
|
||||
assignSamplerNames(m_program, 0, "normalMap", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
1, "glossMap", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
}
|
||||
|
||||
// Solid Lit pass shaders
|
||||
@ -862,7 +644,11 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, "utils/getLightFactor.frag",
|
||||
GL_FRAGMENT_SHADER, "object_pass2.frag");
|
||||
assignUniforms("ModelMatrix", "TextureMatrix");
|
||||
assignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "SpecMap");
|
||||
assignSamplerNames(m_program, 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);
|
||||
}
|
||||
|
||||
InstancedObjectPass2Shader::InstancedObjectPass2Shader()
|
||||
@ -873,7 +659,11 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, "utils/getLightFactor.frag",
|
||||
GL_FRAGMENT_SHADER, "instanced_object_pass2.frag");
|
||||
assignUniforms();
|
||||
assignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "SpecMap");
|
||||
assignSamplerNames(m_program, 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);
|
||||
}
|
||||
|
||||
InstancedObjectRefPass2Shader::InstancedObjectRefPass2Shader()
|
||||
@ -884,7 +674,11 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, "utils/getLightFactor.frag",
|
||||
GL_FRAGMENT_SHADER, "instanced_objectref_pass2.frag");
|
||||
assignUniforms();
|
||||
assignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "SpecMap");
|
||||
assignSamplerNames(m_program, 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);
|
||||
}
|
||||
|
||||
DetailledObjectPass2Shader::DetailledObjectPass2Shader()
|
||||
@ -894,7 +688,12 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, "utils/getLightFactor.frag",
|
||||
GL_FRAGMENT_SHADER, "detailledobject_pass2.frag");
|
||||
assignUniforms("ModelMatrix");
|
||||
assignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "Detail", 5, "SpecMap");
|
||||
assignSamplerNames(m_program, 0, "DiffuseMap", ST_NEAREST_FILTERED,
|
||||
1, "SpecularMap", ST_NEAREST_FILTERED,
|
||||
2, "SSAO", ST_BILINEAR_FILTERED,
|
||||
3, "Albedo", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
4, "Detail", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
5, "SpecMap", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
}
|
||||
|
||||
InstancedDetailledObjectPass2Shader::InstancedDetailledObjectPass2Shader()
|
||||
@ -905,7 +704,12 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, "utils/getLightFactor.frag",
|
||||
GL_FRAGMENT_SHADER, "instanced_detailledobject_pass2.frag");
|
||||
assignUniforms();
|
||||
assignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "Detail", 5, "SpecMap");
|
||||
assignSamplerNames(m_program, 0, "DiffuseMap", ST_NEAREST_FILTERED,
|
||||
1, "SpecularMap", ST_NEAREST_FILTERED,
|
||||
2, "SSAO", ST_BILINEAR_FILTERED,
|
||||
3, "Albedo", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
4, "Detail", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
5, "SpecMap", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
}
|
||||
|
||||
ObjectUnlitShader::ObjectUnlitShader()
|
||||
@ -914,7 +718,10 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, "object_pass.vert",
|
||||
GL_FRAGMENT_SHADER, "object_unlit.frag");
|
||||
assignUniforms("ModelMatrix", "TextureMatrix");
|
||||
assignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "tex");
|
||||
assignSamplerNames(m_program, 0, "DiffuseMap", ST_NEAREST_FILTERED,
|
||||
1, "SpecularMap", ST_NEAREST_FILTERED,
|
||||
2, "SSAO", ST_BILINEAR_FILTERED,
|
||||
3, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
}
|
||||
|
||||
InstancedObjectUnlitShader::InstancedObjectUnlitShader()
|
||||
@ -924,7 +731,10 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, "instanced_object_pass.vert",
|
||||
GL_FRAGMENT_SHADER, "instanced_object_unlit.frag");
|
||||
assignUniforms();
|
||||
assignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "tex");
|
||||
assignSamplerNames(m_program, 0, "DiffuseMap", ST_NEAREST_FILTERED,
|
||||
1, "SpecularMap", ST_NEAREST_FILTERED,
|
||||
2, "SSAO", ST_BILINEAR_FILTERED,
|
||||
3, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
}
|
||||
|
||||
ObjectRefPass2Shader::ObjectRefPass2Shader()
|
||||
@ -934,7 +744,11 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, "utils/getLightFactor.frag",
|
||||
GL_FRAGMENT_SHADER, "objectref_pass2.frag");
|
||||
assignUniforms("ModelMatrix", "TextureMatrix");
|
||||
assignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "SpecMap");
|
||||
assignSamplerNames(m_program, 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);
|
||||
}
|
||||
|
||||
GrassPass2Shader::GrassPass2Shader()
|
||||
@ -944,7 +758,11 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, "utils/getLightFactor.frag",
|
||||
GL_FRAGMENT_SHADER, "grass_pass2.frag");
|
||||
assignUniforms("ModelMatrix", "windDir");
|
||||
assignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "SpecMap");
|
||||
assignSamplerNames(m_program, 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);
|
||||
}
|
||||
|
||||
InstancedGrassPass2Shader::InstancedGrassPass2Shader()
|
||||
@ -955,7 +773,12 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, "utils/getLightFactor.frag",
|
||||
GL_FRAGMENT_SHADER, "instanced_grass_pass2.frag");
|
||||
assignUniforms("windDir", "SunDir");
|
||||
assignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "dtex", 4, "Albedo", 5, "SpecMap");
|
||||
assignSamplerNames(m_program, 0, "DiffuseMap", ST_NEAREST_FILTERED,
|
||||
1, "SpecularMap", ST_NEAREST_FILTERED,
|
||||
2, "SSAO", ST_BILINEAR_FILTERED,
|
||||
3, "dtex", ST_NEAREST_FILTERED,
|
||||
4, "Albedo", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
5, "SpecMap", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
}
|
||||
|
||||
SphereMapShader::SphereMapShader()
|
||||
@ -966,7 +789,10 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, "utils/getPosFromUVDepth.frag",
|
||||
GL_FRAGMENT_SHADER, "objectpass_spheremap.frag");
|
||||
assignUniforms("ModelMatrix", "InverseModelMatrix");
|
||||
assignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "tex");
|
||||
assignSamplerNames(m_program, 0, "DiffuseMap", ST_NEAREST_FILTERED,
|
||||
1, "SpecularMap", ST_NEAREST_FILTERED,
|
||||
2, "SSAO", ST_BILINEAR_FILTERED,
|
||||
3, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
}
|
||||
|
||||
InstancedSphereMapShader::InstancedSphereMapShader()
|
||||
@ -978,7 +804,10 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, "utils/getPosFromUVDepth.frag",
|
||||
GL_FRAGMENT_SHADER, "instanced_objectpass_spheremap.frag");
|
||||
assignUniforms();
|
||||
assignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "tex");
|
||||
assignSamplerNames(m_program, 0, "DiffuseMap", ST_NEAREST_FILTERED,
|
||||
1, "SpecularMap", ST_NEAREST_FILTERED,
|
||||
2, "SSAO", ST_BILINEAR_FILTERED,
|
||||
3, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
}
|
||||
|
||||
SplattingShader::SplattingShader()
|
||||
@ -990,14 +819,14 @@ namespace MeshShader
|
||||
assignUniforms("ModelMatrix");
|
||||
|
||||
assignSamplerNames(m_program,
|
||||
0, "DiffuseMap",
|
||||
1, "SpecularMap",
|
||||
2, "SSAO",
|
||||
3, "tex_layout",
|
||||
4, "tex_detail0",
|
||||
5, "tex_detail1",
|
||||
6, "tex_detail2",
|
||||
7, "tex_detail3");
|
||||
0, "DiffuseMap", ST_NEAREST_FILTERED,
|
||||
1, "SpecularMap", ST_NEAREST_FILTERED,
|
||||
2, "SSAO", ST_BILINEAR_FILTERED,
|
||||
3, "tex_layout", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
4, "tex_detail0", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
5, "tex_detail1", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
6, "tex_detail2", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
7, "tex_detail3", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
}
|
||||
|
||||
TransparentShader::TransparentShader()
|
||||
@ -1006,7 +835,7 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, "object_pass.vert",
|
||||
GL_FRAGMENT_SHADER, "transparent.frag");
|
||||
assignUniforms("ModelMatrix", "TextureMatrix");
|
||||
assignSamplerNames(m_program, 0, "tex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
}
|
||||
|
||||
TransparentFogShader::TransparentFogShader()
|
||||
@ -1014,8 +843,9 @@ namespace MeshShader
|
||||
loadProgram(OBJECT,
|
||||
GL_VERTEX_SHADER, "object_pass.vert",
|
||||
GL_FRAGMENT_SHADER, "transparentfog.frag");
|
||||
assignUniforms("ModelMatrix", "TextureMatrix", "fogmax", "startH", "endH", "start", "end", "col");
|
||||
assignSamplerNames(m_program, 0, "tex");
|
||||
assignUniforms("ModelMatrix", "TextureMatrix", "fogmax", "startH",
|
||||
"endH", "start", "end", "col");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
}
|
||||
|
||||
BillboardShader::BillboardShader()
|
||||
@ -1025,7 +855,7 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, "billboard.frag");
|
||||
|
||||
assignUniforms("ModelViewMatrix", "ProjectionMatrix", "Position", "Size");
|
||||
assignSamplerNames(m_program, 0, "tex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
}
|
||||
|
||||
ColorizeShader::ColorizeShader()
|
||||
@ -1073,7 +903,7 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, "rsm.frag");
|
||||
|
||||
assignUniforms("RSMMatrix", "ModelMatrix", "TextureMatrix");
|
||||
assignSamplerNames(m_program, 0, "tex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
}
|
||||
|
||||
InstancedRSMShader::InstancedRSMShader()
|
||||
@ -1084,7 +914,7 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, "instanced_rsm.frag");
|
||||
|
||||
assignUniforms("RSMMatrix");
|
||||
assignSamplerNames(m_program, 0, "tex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
}
|
||||
|
||||
SplattingRSMShader::SplattingRSMShader()
|
||||
@ -1094,7 +924,11 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, "splatting_rsm.frag");
|
||||
|
||||
assignUniforms("RSMMatrix", "ModelMatrix");
|
||||
assignSamplerNames(m_program, 0, "tex_layout", 1, "tex_detail0", 2, "tex_detail1", 3, "tex_detail2", 4, "tex_detail3");
|
||||
assignSamplerNames(m_program, 0, "tex_layout", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
1, "tex_detail0", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
2, "tex_detail1", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
3, "tex_detail2", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
4, "tex_detail3", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
}
|
||||
|
||||
InstancedShadowShader::InstancedShadowShader()
|
||||
@ -1139,7 +973,7 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, "shadowref.frag");
|
||||
}
|
||||
assignUniforms("layer", "ModelMatrix");
|
||||
assignSamplerNames(m_program, 0, "tex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
}
|
||||
|
||||
InstancedRefShadowShader::InstancedRefShadowShader()
|
||||
@ -1163,7 +997,7 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, "instanced_shadowref.frag");
|
||||
}
|
||||
assignUniforms("layer");
|
||||
assignSamplerNames(m_program, 0, "tex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
}
|
||||
|
||||
GrassShadowShader::GrassShadowShader()
|
||||
@ -1185,7 +1019,7 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, "instanced_shadowref.frag");
|
||||
}
|
||||
assignUniforms("layer", "ModelMatrix", "windDir");
|
||||
assignSamplerNames(m_program, 0, "tex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
}
|
||||
|
||||
InstancedGrassShadowShader::InstancedGrassShadowShader()
|
||||
@ -1209,7 +1043,7 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, "instanced_shadowref.frag");
|
||||
}
|
||||
|
||||
assignSamplerNames(m_program, 0, "tex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
assignUniforms("layer", "windDir");
|
||||
}
|
||||
|
||||
@ -1230,10 +1064,10 @@ namespace MeshShader
|
||||
assignUniforms("ModelMatrix", "dir", "dir2");
|
||||
|
||||
assignSamplerNames(m_program,
|
||||
0, "displacement_tex",
|
||||
1, "color_tex",
|
||||
2, "mask_tex",
|
||||
3, "tex");
|
||||
0, "displacement_tex", ST_BILINEAR_FILTERED,
|
||||
1, "color_tex", ST_BILINEAR_FILTERED,
|
||||
2, "mask_tex", ST_BILINEAR_FILTERED,
|
||||
3, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
}
|
||||
|
||||
SkyboxShader::SkyboxShader()
|
||||
@ -1242,7 +1076,7 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, "sky.vert",
|
||||
GL_FRAGMENT_SHADER, "sky.frag");
|
||||
assignUniforms();
|
||||
assignSamplerNames(m_program, 0, "tex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_TRILINEAR_CUBEMAP);
|
||||
|
||||
glGenVertexArrays(1, &vao);
|
||||
glBindVertexArray(vao);
|
||||
@ -1293,8 +1127,8 @@ namespace LightShader
|
||||
GL_FRAGMENT_SHADER, "pointlight.frag");
|
||||
|
||||
assignUniforms();
|
||||
assignSamplerNames(m_program, 0, "ntex", 1, "dtex");
|
||||
|
||||
assignSamplerNames(m_program, 0, "ntex", ST_NEAREST_FILTERED,
|
||||
1, "dtex", ST_NEAREST_FILTERED);
|
||||
glGenVertexArrays(1, &vao);
|
||||
glBindVertexArray(vao);
|
||||
|
||||
@ -1330,7 +1164,7 @@ namespace LightShader
|
||||
GL_FRAGMENT_SHADER, "pointlightscatter.frag");
|
||||
|
||||
assignUniforms("density", "fogcol");
|
||||
assignSamplerNames(m_program, 0, "dtex");
|
||||
assignSamplerNames(m_program, 0, "dtex", ST_NEAREST_FILTERED);
|
||||
|
||||
glGenVertexArrays(1, &vao);
|
||||
glBindVertexArray(vao);
|
||||
@ -1387,7 +1221,7 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "bloom.frag");
|
||||
assignUniforms();
|
||||
|
||||
assignSamplerNames(m_program, 0, "tex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_NEAREST_FILTERED);
|
||||
}
|
||||
|
||||
BloomBlendShader::BloomBlendShader()
|
||||
@ -1397,7 +1231,9 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "bloomblend.frag");
|
||||
assignUniforms();
|
||||
|
||||
assignSamplerNames(m_program, 0, "tex_128", 1, "tex_256", 2, "tex_512");
|
||||
assignSamplerNames(m_program, 0, "tex_128", ST_BILINEAR_FILTERED,
|
||||
1, "tex_256", ST_BILINEAR_FILTERED,
|
||||
2, "tex_512", ST_BILINEAR_FILTERED);
|
||||
}
|
||||
|
||||
LensBlendShader::LensBlendShader()
|
||||
@ -1407,7 +1243,9 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "lensblend.frag");
|
||||
assignUniforms();
|
||||
|
||||
assignSamplerNames(m_program, 0, "tex_128", 1, "tex_256", 2, "tex_512");
|
||||
assignSamplerNames(m_program, 0, "tex_128", ST_BILINEAR_FILTERED,
|
||||
1, "tex_256", ST_BILINEAR_FILTERED,
|
||||
2, "tex_512", ST_BILINEAR_FILTERED);
|
||||
}
|
||||
|
||||
ToneMapShader::ToneMapShader()
|
||||
@ -1419,7 +1257,7 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "tonemap.frag");
|
||||
assignUniforms("vignette_weight");
|
||||
|
||||
assignSamplerNames(m_program, 0, "text");
|
||||
assignSamplerNames(m_program, 0, "text", ST_NEAREST_FILTERED);
|
||||
}
|
||||
|
||||
DepthOfFieldShader::DepthOfFieldShader()
|
||||
@ -1429,7 +1267,8 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "dof.frag");
|
||||
|
||||
assignUniforms();
|
||||
assignSamplerNames(m_program, 0, "tex", 1, "dtex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_BILINEAR_FILTERED,
|
||||
1, "dtex", ST_NEAREST_FILTERED);
|
||||
}
|
||||
|
||||
SunLightShader::SunLightShader()
|
||||
@ -1443,7 +1282,8 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "utils/SunMRP.frag",
|
||||
GL_FRAGMENT_SHADER, "sunlight.frag");
|
||||
|
||||
assignSamplerNames(m_program, 0, "ntex", 1, "dtex");
|
||||
assignSamplerNames(m_program, 0, "ntex", ST_NEAREST_FILTERED,
|
||||
1, "dtex", ST_NEAREST_FILTERED);
|
||||
assignUniforms("direction", "col");
|
||||
}
|
||||
|
||||
@ -1457,7 +1297,9 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "utils/SpecularIBL.frag",
|
||||
GL_FRAGMENT_SHADER, "IBL.frag");
|
||||
assignUniforms();
|
||||
assignSamplerNames(m_program, 0, "ntex", 1, "dtex", 2, "probe");
|
||||
assignSamplerNames(m_program, 0, "ntex", ST_NEAREST_FILTERED,
|
||||
1, "dtex", ST_NEAREST_FILTERED,
|
||||
2, "probe", ST_TRILINEAR_CUBEMAP);
|
||||
}
|
||||
|
||||
DegradedIBLShader::DegradedIBLShader()
|
||||
@ -1470,7 +1312,7 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "utils/SpecularIBL.frag",
|
||||
GL_FRAGMENT_SHADER, "degraded_ibl.frag");
|
||||
assignUniforms();
|
||||
assignSamplerNames(m_program, 0, "ntex");
|
||||
assignSamplerNames(m_program, 0, "ntex", ST_NEAREST_FILTERED);
|
||||
}
|
||||
|
||||
ShadowedSunLightShaderPCF::ShadowedSunLightShaderPCF()
|
||||
@ -1485,7 +1327,9 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "sunlightshadow.frag");
|
||||
|
||||
// Use 8 to circumvent a catalyst bug when binding sampler
|
||||
assignSamplerNames(m_program, 0, "ntex", 1, "dtex", 8, "shadowtex");
|
||||
assignSamplerNames(m_program, 0, "ntex", ST_NEAREST_FILTERED,
|
||||
1, "dtex", ST_NEAREST_FILTERED,
|
||||
8, "shadowtex", ST_SHADOW_SAMPLER);
|
||||
assignUniforms("split0", "split1", "split2", "splitmax", "shadow_res");
|
||||
}
|
||||
|
||||
@ -1501,7 +1345,10 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "sunlightshadowesm.frag");
|
||||
|
||||
// Use 8 to circumvent a catalyst bug when binding sampler
|
||||
assignSamplerNames(m_program, 0, "ntex", 1, "dtex", 8, "shadowtex");
|
||||
assignSamplerNames(m_program, 0, "ntex", ST_NEAREST_FILTERED,
|
||||
1, "dtex", ST_NEAREST_FILTERED,
|
||||
8, "shadowtex", ST_TRILINEAR_CLAMPED_ARRAY2D);
|
||||
|
||||
assignUniforms("split0", "split1", "split2", "splitmax");
|
||||
}
|
||||
|
||||
@ -1522,7 +1369,9 @@ namespace FullScreenShader
|
||||
}
|
||||
|
||||
assignUniforms("RSMMatrix", "RHMatrix", "extents", "suncol");
|
||||
assignSamplerNames(m_program, 0, "ctex", 1, "ntex", 2, "dtex");
|
||||
assignSamplerNames(m_program, 0, "ctex", ST_BILINEAR_FILTERED,
|
||||
1, "ntex", ST_BILINEAR_FILTERED,
|
||||
2, "dtex", ST_BILINEAR_FILTERED);
|
||||
}
|
||||
|
||||
NVWorkaroundRadianceHintsConstructionShader::NVWorkaroundRadianceHintsConstructionShader()
|
||||
@ -1534,7 +1383,9 @@ namespace FullScreenShader
|
||||
|
||||
assignUniforms("RSMMatrix", "RHMatrix", "extents", "slice", "suncol");
|
||||
|
||||
assignSamplerNames(m_program, 0, "ctex", 1, "ntex", 2, "dtex");
|
||||
assignSamplerNames(m_program, 0, "ctex", ST_BILINEAR_FILTERED,
|
||||
1, "ntex", ST_BILINEAR_FILTERED,
|
||||
2, "dtex", ST_BILINEAR_FILTERED);
|
||||
}
|
||||
|
||||
RHDebug::RHDebug()
|
||||
@ -1558,7 +1409,11 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "gi.frag");
|
||||
|
||||
assignUniforms("RHMatrix", "InvRHMatrix", "extents");
|
||||
assignSamplerNames(m_program, 0, "ntex", 1, "dtex", 2, "SHR", 3, "SHG", 4, "SHB");
|
||||
assignSamplerNames(m_program, 0, "ntex", ST_NEAREST_FILTERED,
|
||||
1, "dtex", ST_NEAREST_FILTERED,
|
||||
2, "SHR", ST_VOLUME_LINEAR_FILTERED,
|
||||
3, "SHG", ST_VOLUME_LINEAR_FILTERED,
|
||||
4, "SHB", ST_VOLUME_LINEAR_FILTERED);
|
||||
}
|
||||
|
||||
Gaussian17TapHShader::Gaussian17TapHShader()
|
||||
@ -1567,7 +1422,8 @@ namespace FullScreenShader
|
||||
GL_VERTEX_SHADER, "screenquad.vert",
|
||||
GL_FRAGMENT_SHADER, "bilateralH.frag");
|
||||
assignUniforms("pixel");
|
||||
assignSamplerNames(m_program, 0, "tex", 1, "depth");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_BILINEAR_CLAMPED_FILTERED,
|
||||
1, "depth", ST_BILINEAR_CLAMPED_FILTERED);
|
||||
}
|
||||
|
||||
ComputeGaussian17TapHShader::ComputeGaussian17TapHShader()
|
||||
@ -1575,7 +1431,8 @@ namespace FullScreenShader
|
||||
loadProgram(OBJECT, GL_COMPUTE_SHADER, "bilateralH.comp");
|
||||
TU_dest = 2;
|
||||
assignUniforms("pixel");
|
||||
assignSamplerNames(m_program, 0, "source", 1, "depth");
|
||||
assignSamplerNames(m_program, 0, "source", ST_NEARED_CLAMPED_FILTERED,
|
||||
1, "depth", ST_NEARED_CLAMPED_FILTERED);
|
||||
assignTextureUnit(TU_dest, "dest");
|
||||
}
|
||||
|
||||
@ -1585,7 +1442,7 @@ namespace FullScreenShader
|
||||
GL_COMPUTE_SHADER, "gaussian6h.comp");
|
||||
TU_dest = 1;
|
||||
assignUniforms("pixel", "weights");
|
||||
assignSamplerNames(m_program, 0, "source");
|
||||
assignSamplerNames(m_program, 0, "source", ST_BILINEAR_CLAMPED_FILTERED);
|
||||
assignTextureUnit(TU_dest, "dest");
|
||||
}
|
||||
|
||||
@ -1595,7 +1452,7 @@ namespace FullScreenShader
|
||||
GL_COMPUTE_SHADER, "blurshadowH.comp");
|
||||
TU_dest = 1;
|
||||
assignUniforms("pixel", "weights");
|
||||
assignSamplerNames(m_program, 0, "source");
|
||||
assignSamplerNames(m_program, 0, "source", ST_NEARED_CLAMPED_FILTERED);
|
||||
assignTextureUnit(TU_dest, "dest");
|
||||
}
|
||||
|
||||
@ -1606,7 +1463,7 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "gaussian6h.frag");
|
||||
assignUniforms("pixel", "sigma");
|
||||
|
||||
assignSamplerNames(m_program, 0, "tex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_BILINEAR_CLAMPED_FILTERED);
|
||||
}
|
||||
|
||||
HorizontalBlurShader::HorizontalBlurShader()
|
||||
@ -1616,7 +1473,7 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "gaussian6h.frag");
|
||||
assignUniforms("pixel");
|
||||
|
||||
assignSamplerNames(m_program, 0, "tex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_BILINEAR_CLAMPED_FILTERED);
|
||||
}
|
||||
|
||||
Gaussian3HBlurShader::Gaussian3HBlurShader()
|
||||
@ -1626,7 +1483,7 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "gaussian3h.frag");
|
||||
assignUniforms("pixel");
|
||||
|
||||
assignSamplerNames(m_program, 0, "tex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_BILINEAR_CLAMPED_FILTERED);
|
||||
}
|
||||
|
||||
Gaussian17TapVShader::Gaussian17TapVShader()
|
||||
@ -1636,7 +1493,8 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "bilateralV.frag");
|
||||
assignUniforms("pixel");
|
||||
|
||||
assignSamplerNames(m_program, 0, "tex", 1, "depth");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_BILINEAR_CLAMPED_FILTERED,
|
||||
1, "depth", ST_BILINEAR_CLAMPED_FILTERED);
|
||||
}
|
||||
|
||||
ComputeGaussian17TapVShader::ComputeGaussian17TapVShader()
|
||||
@ -1645,7 +1503,8 @@ namespace FullScreenShader
|
||||
GL_COMPUTE_SHADER, "bilateralV.comp");
|
||||
TU_dest = 2;
|
||||
assignUniforms("pixel");
|
||||
assignSamplerNames(m_program, 0, "source", 1, "depth");
|
||||
assignSamplerNames(m_program, 0, "source", ST_NEARED_CLAMPED_FILTERED,
|
||||
1, "depth", ST_NEARED_CLAMPED_FILTERED);
|
||||
assignTextureUnit(TU_dest, "dest");
|
||||
}
|
||||
|
||||
@ -1655,7 +1514,7 @@ namespace FullScreenShader
|
||||
GL_COMPUTE_SHADER, "gaussian6v.comp");
|
||||
TU_dest = 1;
|
||||
assignUniforms("pixel", "weights");
|
||||
assignSamplerNames(m_program, 0, "source");
|
||||
assignSamplerNames(m_program, 0, "source", ST_BILINEAR_CLAMPED_FILTERED);
|
||||
assignTextureUnit(TU_dest, "dest");
|
||||
}
|
||||
|
||||
@ -1665,7 +1524,7 @@ namespace FullScreenShader
|
||||
GL_COMPUTE_SHADER, "blurshadowV.comp");
|
||||
TU_dest = 1;
|
||||
assignUniforms("pixel", "weights");
|
||||
assignSamplerNames(m_program, 0, "source");
|
||||
assignSamplerNames(m_program, 0, "source", ST_NEARED_CLAMPED_FILTERED);
|
||||
assignTextureUnit(TU_dest, "dest");
|
||||
}
|
||||
|
||||
@ -1676,7 +1535,7 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "gaussian6v.frag");
|
||||
assignUniforms("pixel", "sigma");
|
||||
|
||||
assignSamplerNames(m_program, 0, "tex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_BILINEAR_CLAMPED_FILTERED);
|
||||
}
|
||||
|
||||
Gaussian3VBlurShader::Gaussian3VBlurShader()
|
||||
@ -1686,7 +1545,7 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "gaussian3v.frag");
|
||||
assignUniforms("pixel");
|
||||
|
||||
assignSamplerNames(m_program, 0, "tex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_BILINEAR_CLAMPED_FILTERED);
|
||||
}
|
||||
|
||||
PassThroughShader::PassThroughShader()
|
||||
@ -1696,7 +1555,7 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "passthrough.frag");
|
||||
|
||||
assignUniforms("width", "height");
|
||||
assignSamplerNames(m_program, 0, "tex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_BILINEAR_FILTERED);
|
||||
}
|
||||
|
||||
LayerPassThroughShader::LayerPassThroughShader()
|
||||
@ -1717,7 +1576,7 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "linearizedepth.frag");
|
||||
assignUniforms("zn", "zf");
|
||||
|
||||
assignSamplerNames(m_program, 0, "texture");
|
||||
assignSamplerNames(m_program, 0, "texture", ST_BILINEAR_FILTERED);
|
||||
}
|
||||
|
||||
|
||||
@ -1726,7 +1585,7 @@ namespace FullScreenShader
|
||||
loadProgram(OBJECT,
|
||||
GL_COMPUTE_SHADER, "Lightspaceboundingbox.comp",
|
||||
GL_COMPUTE_SHADER, "utils/getPosFromUVDepth.frag");
|
||||
assignSamplerNames(m_program, 0, "depth");
|
||||
assignSamplerNames(m_program, 0, "depth", ST_NEAREST_FILTERED);
|
||||
assignUniforms("SunCamMatrix", "split0", "split1", "split2", "splitmax");
|
||||
GLuint block_idx = glGetProgramResourceIndex(m_program, GL_SHADER_STORAGE_BLOCK, "BoundingBoxes");
|
||||
glShaderStorageBlockBinding(m_program, block_idx, 2);
|
||||
@ -1748,7 +1607,7 @@ namespace FullScreenShader
|
||||
loadProgram(OBJECT,
|
||||
GL_COMPUTE_SHADER, "depthhistogram.comp",
|
||||
GL_COMPUTE_SHADER, "utils/getPosFromUVDepth.frag");
|
||||
assignSamplerNames(m_program, 0, "depth");
|
||||
assignSamplerNames(m_program, 0, "depth", ST_NEAREST_FILTERED);
|
||||
|
||||
GLuint block_idx = glGetProgramResourceIndex(m_program, GL_SHADER_STORAGE_BLOCK, "Histogram");
|
||||
glShaderStorageBlockBinding(m_program, block_idx, 1);
|
||||
@ -1761,7 +1620,7 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "glow.frag");
|
||||
assignUniforms();
|
||||
|
||||
assignSamplerNames(m_program, 0, "tex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_BILINEAR_FILTERED);
|
||||
vao = createVAO(m_program);
|
||||
}
|
||||
|
||||
@ -1774,7 +1633,7 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "ssao.frag");
|
||||
|
||||
assignUniforms("radius", "k", "sigma");
|
||||
assignSamplerNames(m_program, 0, "dtex");
|
||||
assignSamplerNames(m_program, 0, "dtex", ST_SEMI_TRILINEAR);
|
||||
}
|
||||
|
||||
FogShader::FogShader()
|
||||
@ -1785,7 +1644,7 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "fog.frag");
|
||||
|
||||
assignUniforms("density", "col");
|
||||
assignSamplerNames(m_program, 0, "tex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_NEAREST_FILTERED);
|
||||
}
|
||||
|
||||
MotionBlurShader::MotionBlurShader()
|
||||
@ -1795,7 +1654,8 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "utils/getPosFromUVDepth.frag",
|
||||
GL_FRAGMENT_SHADER, "motion_blur.frag");
|
||||
assignUniforms("previous_viewproj", "center", "boost_amount", "mask_radius");
|
||||
assignSamplerNames(m_program, 0, "color_buffer", 1, "dtex");
|
||||
assignSamplerNames(m_program, 0, "color_buffer", ST_BILINEAR_CLAMPED_FILTERED,
|
||||
1, "dtex", ST_NEAREST_FILTERED);
|
||||
}
|
||||
|
||||
GodFadeShader::GodFadeShader()
|
||||
@ -1805,7 +1665,7 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "godfade.frag");
|
||||
assignUniforms("col");
|
||||
|
||||
assignSamplerNames(m_program, 0, "tex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_BILINEAR_FILTERED);
|
||||
}
|
||||
|
||||
GodRayShader::GodRayShader()
|
||||
@ -1815,7 +1675,7 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "godray.frag");
|
||||
|
||||
assignUniforms("sunpos");
|
||||
assignSamplerNames(m_program, 0, "tex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_BILINEAR_FILTERED);
|
||||
}
|
||||
|
||||
MLAAColorEdgeDetectionSHader::MLAAColorEdgeDetectionSHader()
|
||||
@ -1825,7 +1685,7 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "mlaa_color1.frag");
|
||||
assignUniforms("PIXEL_SIZE");
|
||||
|
||||
assignSamplerNames(m_program, 0, "colorMapG");
|
||||
assignSamplerNames(m_program, 0, "colorMapG", ST_NEAREST_FILTERED);
|
||||
}
|
||||
|
||||
MLAABlendWeightSHader::MLAABlendWeightSHader()
|
||||
@ -1835,7 +1695,8 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "mlaa_blend2.frag");
|
||||
assignUniforms("PIXEL_SIZE");
|
||||
|
||||
assignSamplerNames(m_program, 0, "edgesMap", 1, "areaMap");
|
||||
assignSamplerNames(m_program, 0, "edgesMap", ST_BILINEAR_FILTERED,
|
||||
1, "areaMap", ST_NEAREST_FILTERED);
|
||||
}
|
||||
|
||||
MLAAGatherSHader::MLAAGatherSHader()
|
||||
@ -1845,7 +1706,8 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, "mlaa_neigh3.frag");
|
||||
assignUniforms("PIXEL_SIZE");
|
||||
|
||||
assignSamplerNames(m_program, 0, "blendMap", 1, "colorMap");
|
||||
assignSamplerNames(m_program, 0, "blendMap", ST_NEAREST_FILTERED,
|
||||
1, "colorMap", ST_NEAREST_FILTERED);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1858,7 +1720,7 @@ namespace UIShader
|
||||
GL_VERTEX_SHADER, "primitive2dlist.vert",
|
||||
GL_FRAGMENT_SHADER, "transparent.frag");
|
||||
assignUniforms();
|
||||
assignSamplerNames(m_program, 0, "tex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_BILINEAR_FILTERED);
|
||||
}
|
||||
|
||||
TextureRectShader::TextureRectShader()
|
||||
@ -1868,7 +1730,7 @@ namespace UIShader
|
||||
GL_FRAGMENT_SHADER, "texturedquad.frag");
|
||||
assignUniforms("center", "size", "texcenter", "texsize");
|
||||
|
||||
assignSamplerNames(m_program, 0, "tex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_BILINEAR_FILTERED);
|
||||
}
|
||||
|
||||
UniformColoredTextureRectShader::UniformColoredTextureRectShader()
|
||||
@ -1879,7 +1741,7 @@ namespace UIShader
|
||||
|
||||
assignUniforms("center", "size", "texcenter", "texsize", "color");
|
||||
|
||||
assignSamplerNames(m_program, 0, "tex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_BILINEAR_FILTERED);
|
||||
}
|
||||
|
||||
ColoredTextureRectShader::ColoredTextureRectShader()
|
||||
@ -1889,7 +1751,7 @@ namespace UIShader
|
||||
GL_FRAGMENT_SHADER, "colortexturedquad.frag");
|
||||
assignUniforms("center", "size", "texcenter", "texsize");
|
||||
|
||||
assignSamplerNames(m_program, 0, "tex");
|
||||
assignSamplerNames(m_program, 0, "tex", ST_BILINEAR_FILTERED);
|
||||
|
||||
glGenVertexArrays(1, &vao);
|
||||
glBindVertexArray(vao);
|
||||
|
@ -20,7 +20,6 @@
|
||||
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/shader.hpp"
|
||||
#include "graphics/shaders_util.hpp"
|
||||
#include "graphics/texture_read.hpp"
|
||||
|
||||
#include <IMeshSceneNode.h>
|
||||
@ -50,7 +49,7 @@ public:
|
||||
};
|
||||
|
||||
class SpecularIBLGenerator : public Shader<SpecularIBLGenerator, core::matrix4, float >,
|
||||
public TextureRead<Trilinear_cubemap>
|
||||
public TextureReadNew<ST_TRILINEAR_CUBEMAP>
|
||||
{
|
||||
public:
|
||||
GLuint TU_Samples;
|
||||
@ -62,146 +61,188 @@ public:
|
||||
namespace MeshShader
|
||||
{
|
||||
class ObjectPass1Shader : public Shader<ObjectPass1Shader, core::matrix4, core::matrix4>,
|
||||
public TextureRead<Trilinear_Anisotropic_Filtered>
|
||||
public TextureReadNew<ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
ObjectPass1Shader();
|
||||
};
|
||||
|
||||
class ObjectRefPass1Shader : public Shader<ObjectRefPass1Shader, core::matrix4, core::matrix4, core::matrix4>,
|
||||
public TextureRead<Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered>
|
||||
public TextureReadNew<ST_TRILINEAR_ANISOTROPIC_FILTERED, ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
ObjectRefPass1Shader();
|
||||
};
|
||||
|
||||
class GrassPass1Shader : public Shader<GrassPass1Shader, core::matrix4, core::matrix4, core::vector3df>, public TextureRead<Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered>
|
||||
class GrassPass1Shader : public Shader<GrassPass1Shader, core::matrix4, core::matrix4, core::vector3df>,
|
||||
public TextureReadNew<ST_TRILINEAR_ANISOTROPIC_FILTERED, ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
GrassPass1Shader();
|
||||
};
|
||||
|
||||
class NormalMapShader : public Shader<NormalMapShader, core::matrix4, core::matrix4>, public TextureRead<Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered>
|
||||
class NormalMapShader : public Shader<NormalMapShader, core::matrix4, core::matrix4>,
|
||||
public TextureReadNew<ST_TRILINEAR_ANISOTROPIC_FILTERED, ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
NormalMapShader();
|
||||
};
|
||||
|
||||
class InstancedObjectPass1Shader : public Shader<InstancedObjectPass1Shader>, public TextureRead<Trilinear_Anisotropic_Filtered>
|
||||
class InstancedObjectPass1Shader : public Shader<InstancedObjectPass1Shader>,
|
||||
public TextureReadNew<ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
InstancedObjectPass1Shader();
|
||||
};
|
||||
|
||||
class InstancedObjectRefPass1Shader : public Shader<InstancedObjectRefPass1Shader>, public TextureRead<Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered>
|
||||
class InstancedObjectRefPass1Shader : public Shader<InstancedObjectRefPass1Shader>,
|
||||
public TextureReadNew<ST_TRILINEAR_ANISOTROPIC_FILTERED, ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
InstancedObjectRefPass1Shader();
|
||||
};
|
||||
|
||||
class InstancedGrassPass1Shader : public Shader<InstancedGrassPass1Shader, core::vector3df>, public TextureRead<Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered>
|
||||
class InstancedGrassPass1Shader : public Shader<InstancedGrassPass1Shader, core::vector3df>,
|
||||
public TextureReadNew<ST_TRILINEAR_ANISOTROPIC_FILTERED, ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
InstancedGrassPass1Shader();
|
||||
};
|
||||
|
||||
class InstancedNormalMapShader : public Shader<InstancedNormalMapShader>, public TextureRead<Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered>
|
||||
class InstancedNormalMapShader : public Shader<InstancedNormalMapShader>,
|
||||
public TextureReadNew<ST_TRILINEAR_ANISOTROPIC_FILTERED, ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
InstancedNormalMapShader();
|
||||
};
|
||||
|
||||
class ObjectPass2Shader : public Shader<ObjectPass2Shader, core::matrix4, core::matrix4>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered>
|
||||
class ObjectPass2Shader : public Shader<ObjectPass2Shader, core::matrix4, core::matrix4>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED, ST_NEAREST_FILTERED, ST_BILINEAR_FILTERED,
|
||||
ST_TRILINEAR_ANISOTROPIC_FILTERED, ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
ObjectPass2Shader();
|
||||
};
|
||||
|
||||
class InstancedObjectPass2Shader : public Shader<InstancedObjectPass2Shader>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered>
|
||||
class InstancedObjectPass2Shader : public Shader<InstancedObjectPass2Shader>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED, ST_NEAREST_FILTERED, ST_BILINEAR_FILTERED,
|
||||
ST_TRILINEAR_ANISOTROPIC_FILTERED, ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
InstancedObjectPass2Shader();
|
||||
};
|
||||
|
||||
class InstancedObjectRefPass2Shader : public Shader<InstancedObjectRefPass2Shader>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered>
|
||||
class InstancedObjectRefPass2Shader : public Shader<InstancedObjectRefPass2Shader>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED, ST_NEAREST_FILTERED, ST_BILINEAR_FILTERED,
|
||||
ST_TRILINEAR_ANISOTROPIC_FILTERED, ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
InstancedObjectRefPass2Shader();
|
||||
};
|
||||
|
||||
class DetailledObjectPass2Shader : public Shader<DetailledObjectPass2Shader, core::matrix4>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered>
|
||||
class DetailledObjectPass2Shader : public Shader<DetailledObjectPass2Shader, core::matrix4>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED, ST_NEAREST_FILTERED, ST_BILINEAR_FILTERED,
|
||||
ST_TRILINEAR_ANISOTROPIC_FILTERED, ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
DetailledObjectPass2Shader();
|
||||
};
|
||||
|
||||
class InstancedDetailledObjectPass2Shader : public Shader<InstancedDetailledObjectPass2Shader>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered>
|
||||
class InstancedDetailledObjectPass2Shader : public Shader<InstancedDetailledObjectPass2Shader>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED, ST_NEAREST_FILTERED, ST_BILINEAR_FILTERED,
|
||||
ST_TRILINEAR_ANISOTROPIC_FILTERED, ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
ST_TRILINEAR_ANISOTROPIC_FILTERED >
|
||||
{
|
||||
public:
|
||||
InstancedDetailledObjectPass2Shader();
|
||||
};
|
||||
|
||||
class ObjectUnlitShader : public Shader<ObjectUnlitShader, core::matrix4, core::matrix4>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered>
|
||||
class ObjectUnlitShader : public Shader<ObjectUnlitShader, core::matrix4, core::matrix4>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED, ST_NEAREST_FILTERED,
|
||||
ST_BILINEAR_FILTERED, ST_TRILINEAR_ANISOTROPIC_FILTERED >
|
||||
{
|
||||
public:
|
||||
ObjectUnlitShader();
|
||||
};
|
||||
|
||||
class InstancedObjectUnlitShader : public Shader<InstancedObjectUnlitShader>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered>
|
||||
class InstancedObjectUnlitShader : public Shader<InstancedObjectUnlitShader>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED, ST_NEAREST_FILTERED,
|
||||
ST_BILINEAR_FILTERED, ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
InstancedObjectUnlitShader();
|
||||
};
|
||||
|
||||
class ObjectRefPass2Shader : public Shader<ObjectRefPass2Shader, core::matrix4, core::matrix4>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered>
|
||||
class ObjectRefPass2Shader : public Shader<ObjectRefPass2Shader, core::matrix4, core::matrix4>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED, ST_NEAREST_FILTERED, ST_BILINEAR_FILTERED,
|
||||
ST_TRILINEAR_ANISOTROPIC_FILTERED, ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
ObjectRefPass2Shader();
|
||||
};
|
||||
|
||||
class GrassPass2Shader : public Shader<GrassPass2Shader, core::matrix4, core::vector3df>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered>
|
||||
class GrassPass2Shader : public Shader<GrassPass2Shader, core::matrix4, core::vector3df>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED, ST_NEAREST_FILTERED, ST_BILINEAR_FILTERED,
|
||||
ST_TRILINEAR_ANISOTROPIC_FILTERED, ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
GrassPass2Shader();
|
||||
};
|
||||
|
||||
class InstancedGrassPass2Shader : public Shader<InstancedGrassPass2Shader, core::vector3df, core::vector3df>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Nearest_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered>
|
||||
class InstancedGrassPass2Shader : public Shader<InstancedGrassPass2Shader, core::vector3df, core::vector3df>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED, ST_NEAREST_FILTERED, ST_BILINEAR_FILTERED,
|
||||
ST_NEAREST_FILTERED, ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
InstancedGrassPass2Shader();
|
||||
};
|
||||
|
||||
class SphereMapShader : public Shader<SphereMapShader, core::matrix4, core::matrix4>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered>
|
||||
class SphereMapShader : public Shader<SphereMapShader, core::matrix4, core::matrix4>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED, ST_NEAREST_FILTERED,
|
||||
ST_BILINEAR_FILTERED, ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
SphereMapShader();
|
||||
};
|
||||
|
||||
class InstancedSphereMapShader : public Shader<InstancedSphereMapShader>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered>
|
||||
class InstancedSphereMapShader : public Shader<InstancedSphereMapShader>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED, ST_NEAREST_FILTERED,
|
||||
ST_BILINEAR_FILTERED, ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
InstancedSphereMapShader();
|
||||
};
|
||||
|
||||
class SplattingShader : public Shader<SplattingShader, core::matrix4>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered>
|
||||
class SplattingShader : public Shader<SplattingShader, core::matrix4>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED, ST_NEAREST_FILTERED, ST_BILINEAR_FILTERED,
|
||||
ST_TRILINEAR_ANISOTROPIC_FILTERED, ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
ST_TRILINEAR_ANISOTROPIC_FILTERED, ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
SplattingShader();
|
||||
};
|
||||
|
||||
class TransparentShader : public Shader<TransparentShader, core::matrix4, core::matrix4>, public TextureRead<Trilinear_Anisotropic_Filtered>
|
||||
class TransparentShader : public Shader<TransparentShader, core::matrix4, core::matrix4>,
|
||||
public TextureReadNew<ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
TransparentShader();
|
||||
};
|
||||
|
||||
class TransparentFogShader : public Shader<TransparentFogShader, core::matrix4, core::matrix4, float, float, float, float, float, video::SColorf>, public TextureRead<Trilinear_Anisotropic_Filtered>
|
||||
class TransparentFogShader : public Shader<TransparentFogShader, core::matrix4, core::matrix4, float, float,
|
||||
float, float, float, video::SColorf>,
|
||||
public TextureReadNew<ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
TransparentFogShader();
|
||||
};
|
||||
|
||||
class BillboardShader : public Shader<BillboardShader, core::matrix4, core::matrix4, core::vector3df, core::dimension2df>, public TextureRead<Trilinear_Anisotropic_Filtered>
|
||||
class BillboardShader : public Shader<BillboardShader, core::matrix4, core::matrix4,
|
||||
core::vector3df, core::dimension2df>,
|
||||
public TextureReadNew<ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
BillboardShader();
|
||||
@ -220,56 +261,64 @@ public:
|
||||
InstancedColorizeShader();
|
||||
};
|
||||
|
||||
class ShadowShader : public Shader<ShadowShader, int, core::matrix4>, public TextureRead<>
|
||||
class ShadowShader : public Shader<ShadowShader, int, core::matrix4>, public TextureReadNew<>
|
||||
{
|
||||
public:
|
||||
ShadowShader();
|
||||
};
|
||||
|
||||
class RSMShader : public Shader<RSMShader, core::matrix4, core::matrix4, core::matrix4>, public TextureRead<Trilinear_Anisotropic_Filtered>
|
||||
class RSMShader : public Shader<RSMShader, core::matrix4, core::matrix4, core::matrix4>,
|
||||
public TextureReadNew<ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
RSMShader();
|
||||
};
|
||||
|
||||
class InstancedRSMShader : public Shader<InstancedRSMShader, core::matrix4>, public TextureRead<Trilinear_Anisotropic_Filtered>
|
||||
class InstancedRSMShader : public Shader<InstancedRSMShader, core::matrix4>,
|
||||
public TextureReadNew<ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
InstancedRSMShader();
|
||||
};
|
||||
|
||||
class SplattingRSMShader : public Shader<SplattingRSMShader, core::matrix4, core::matrix4>,
|
||||
public TextureRead<Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered>
|
||||
public TextureReadNew<ST_TRILINEAR_ANISOTROPIC_FILTERED, ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
ST_TRILINEAR_ANISOTROPIC_FILTERED, ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
SplattingRSMShader();
|
||||
};
|
||||
|
||||
class InstancedShadowShader : public Shader<InstancedShadowShader, int>, public TextureRead<>
|
||||
class InstancedShadowShader : public Shader<InstancedShadowShader, int>, public TextureReadNew<>
|
||||
{
|
||||
public:
|
||||
InstancedShadowShader();
|
||||
};
|
||||
|
||||
class RefShadowShader : public Shader<RefShadowShader, int, core::matrix4>, public TextureRead<Trilinear_Anisotropic_Filtered>
|
||||
class RefShadowShader : public Shader<RefShadowShader, int, core::matrix4>,
|
||||
public TextureReadNew<ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
RefShadowShader();
|
||||
};
|
||||
|
||||
class InstancedRefShadowShader : public Shader<InstancedRefShadowShader, int>, public TextureRead<Trilinear_Anisotropic_Filtered>
|
||||
class InstancedRefShadowShader : public Shader<InstancedRefShadowShader, int>,
|
||||
public TextureReadNew<ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
InstancedRefShadowShader();
|
||||
};
|
||||
|
||||
class GrassShadowShader : public Shader<GrassShadowShader, int, core::matrix4, core::vector3df>, public TextureRead<Trilinear_Anisotropic_Filtered>
|
||||
class GrassShadowShader : public Shader<GrassShadowShader, int, core::matrix4, core::vector3df>,
|
||||
public TextureReadNew<ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
GrassShadowShader();
|
||||
};
|
||||
|
||||
class InstancedGrassShadowShader : public Shader<InstancedGrassShadowShader, int, core::vector3df>, public TextureRead<Trilinear_Anisotropic_Filtered>
|
||||
class InstancedGrassShadowShader : public Shader<InstancedGrassShadowShader, int, core::vector3df>,
|
||||
public TextureReadNew<ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
InstancedGrassShadowShader();
|
||||
@ -281,13 +330,16 @@ public:
|
||||
DisplaceMaskShader();
|
||||
};
|
||||
|
||||
class DisplaceShader : public Shader<DisplaceShader, core::matrix4, core::vector2df, core::vector2df>, public TextureRead<Bilinear_Filtered, Bilinear_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered>
|
||||
class DisplaceShader : public Shader<DisplaceShader, core::matrix4, core::vector2df, core::vector2df>,
|
||||
public TextureReadNew<ST_BILINEAR_FILTERED, ST_BILINEAR_FILTERED,
|
||||
ST_BILINEAR_FILTERED, ST_TRILINEAR_ANISOTROPIC_FILTERED>
|
||||
{
|
||||
public:
|
||||
DisplaceShader();
|
||||
};
|
||||
|
||||
class SkyboxShader : public Shader<SkyboxShader>, public TextureRead<Trilinear_cubemap>
|
||||
class SkyboxShader : public Shader<SkyboxShader>,
|
||||
public TextureReadNew<ST_TRILINEAR_CUBEMAP>
|
||||
{
|
||||
public:
|
||||
SkyboxShader();
|
||||
@ -327,7 +379,8 @@ namespace LightShader
|
||||
};
|
||||
|
||||
|
||||
class PointLightShader : public Shader<PointLightShader>, public TextureRead<Nearest_Filtered, Nearest_Filtered>
|
||||
class PointLightShader : public Shader<PointLightShader>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED, ST_NEAREST_FILTERED>
|
||||
{
|
||||
public:
|
||||
GLuint vbo;
|
||||
@ -335,7 +388,8 @@ namespace LightShader
|
||||
PointLightShader();
|
||||
};
|
||||
|
||||
class PointLightScatterShader : public Shader<PointLightScatterShader, float, core::vector3df>, public TextureRead<Nearest_Filtered>
|
||||
class PointLightScatterShader : public Shader<PointLightScatterShader, float, core::vector3df>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED>
|
||||
{
|
||||
public:
|
||||
GLuint vbo;
|
||||
@ -357,76 +411,96 @@ static void DrawFullScreenEffect(Args...args)
|
||||
namespace FullScreenShader
|
||||
{
|
||||
|
||||
class BloomShader : public Shader<BloomShader>, public TextureRead<Nearest_Filtered>
|
||||
class BloomShader : public Shader<BloomShader>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED>
|
||||
{
|
||||
public:
|
||||
BloomShader();
|
||||
};
|
||||
|
||||
class BloomBlendShader : public Shader<BloomBlendShader>, public TextureRead<Bilinear_Filtered, Bilinear_Filtered, Bilinear_Filtered>
|
||||
class BloomBlendShader : public Shader<BloomBlendShader>,
|
||||
public TextureReadNew<ST_BILINEAR_FILTERED, ST_BILINEAR_FILTERED,
|
||||
ST_BILINEAR_FILTERED>
|
||||
{
|
||||
public:
|
||||
BloomBlendShader();
|
||||
};
|
||||
|
||||
class LensBlendShader : public Shader<LensBlendShader>, public TextureRead<Bilinear_Filtered, Bilinear_Filtered, Bilinear_Filtered>
|
||||
class LensBlendShader : public Shader<LensBlendShader>,
|
||||
public TextureReadNew<ST_BILINEAR_FILTERED, ST_BILINEAR_FILTERED,
|
||||
ST_BILINEAR_FILTERED>
|
||||
{
|
||||
public:
|
||||
LensBlendShader();
|
||||
};
|
||||
|
||||
|
||||
class ToneMapShader : public Shader<ToneMapShader, float>, public TextureRead<Nearest_Filtered>
|
||||
class ToneMapShader : public Shader<ToneMapShader, float>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED>
|
||||
{
|
||||
public:
|
||||
|
||||
ToneMapShader();
|
||||
};
|
||||
|
||||
class DepthOfFieldShader : public Shader<DepthOfFieldShader>, public TextureRead<Bilinear_Filtered, Nearest_Filtered>
|
||||
class DepthOfFieldShader : public Shader<DepthOfFieldShader>,
|
||||
public TextureReadNew<ST_BILINEAR_FILTERED, ST_NEAREST_FILTERED>
|
||||
{
|
||||
public:
|
||||
DepthOfFieldShader();
|
||||
};
|
||||
|
||||
class SunLightShader : public Shader<SunLightShader, core::vector3df, video::SColorf>, public TextureRead<Nearest_Filtered, Nearest_Filtered>
|
||||
class SunLightShader : public Shader<SunLightShader, core::vector3df, video::SColorf>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED, ST_NEAREST_FILTERED>
|
||||
{
|
||||
public:
|
||||
SunLightShader();
|
||||
};
|
||||
|
||||
class IBLShader : public Shader<IBLShader>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Trilinear_cubemap>
|
||||
class IBLShader : public Shader<IBLShader>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED, ST_NEAREST_FILTERED, ST_TRILINEAR_CUBEMAP>
|
||||
{
|
||||
public:
|
||||
IBLShader();
|
||||
};
|
||||
|
||||
class DegradedIBLShader : public Shader<DegradedIBLShader>, public TextureRead<Nearest_Filtered>
|
||||
class DegradedIBLShader : public Shader<DegradedIBLShader>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED>
|
||||
{
|
||||
public:
|
||||
DegradedIBLShader();
|
||||
};
|
||||
|
||||
class ShadowedSunLightShaderPCF : public Shader<ShadowedSunLightShaderPCF, float, float, float, float, float>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Shadow_Sampler>
|
||||
class ShadowedSunLightShaderPCF : public Shader<ShadowedSunLightShaderPCF, float, float, float, float, float>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED, ST_NEAREST_FILTERED, ST_SHADOW_SAMPLER>
|
||||
{
|
||||
public:
|
||||
ShadowedSunLightShaderPCF();
|
||||
};
|
||||
|
||||
class ShadowedSunLightShaderESM : public Shader<ShadowedSunLightShaderESM, float, float, float, float>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Trilinear_Clamped_Array2D>
|
||||
class ShadowedSunLightShaderESM : public Shader<ShadowedSunLightShaderESM, float, float, float, float>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED, ST_NEAREST_FILTERED,
|
||||
ST_TRILINEAR_CLAMPED_ARRAY2D>
|
||||
{
|
||||
public:
|
||||
ShadowedSunLightShaderESM();
|
||||
};
|
||||
|
||||
class RadianceHintsConstructionShader : public Shader<RadianceHintsConstructionShader, core::matrix4, core::matrix4, core::vector3df, video::SColorf>, public TextureRead<Bilinear_Filtered, Bilinear_Filtered, Bilinear_Filtered>
|
||||
class RadianceHintsConstructionShader : public Shader<RadianceHintsConstructionShader, core::matrix4,
|
||||
core::matrix4, core::vector3df, video::SColorf>,
|
||||
public TextureReadNew<ST_BILINEAR_FILTERED, ST_BILINEAR_FILTERED, ST_BILINEAR_FILTERED>
|
||||
{
|
||||
public:
|
||||
RadianceHintsConstructionShader();
|
||||
};
|
||||
|
||||
// Workaround for a bug found in kepler nvidia linux and fermi nvidia windows
|
||||
class NVWorkaroundRadianceHintsConstructionShader : public Shader<NVWorkaroundRadianceHintsConstructionShader, core::matrix4, core::matrix4, core::vector3df, int, video::SColorf>, public TextureRead<Bilinear_Filtered, Bilinear_Filtered, Bilinear_Filtered>
|
||||
class NVWorkaroundRadianceHintsConstructionShader : public Shader<NVWorkaroundRadianceHintsConstructionShader,
|
||||
core::matrix4, core::matrix4, core::vector3df,
|
||||
int, video::SColorf>,
|
||||
public TextureReadNew<ST_BILINEAR_FILTERED,
|
||||
ST_BILINEAR_FILTERED,
|
||||
ST_BILINEAR_FILTERED>
|
||||
{
|
||||
public:
|
||||
NVWorkaroundRadianceHintsConstructionShader();
|
||||
@ -440,65 +514,80 @@ public:
|
||||
RHDebug();
|
||||
};
|
||||
|
||||
class GlobalIlluminationReconstructionShader : public Shader<GlobalIlluminationReconstructionShader, core::matrix4, core::matrix4, core::vector3df>,
|
||||
public TextureRead<Nearest_Filtered, Nearest_Filtered, Volume_Linear_Filtered, Volume_Linear_Filtered, Volume_Linear_Filtered>
|
||||
class GlobalIlluminationReconstructionShader : public Shader<GlobalIlluminationReconstructionShader,
|
||||
core::matrix4, core::matrix4, core::vector3df>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED, ST_NEAREST_FILTERED,
|
||||
ST_VOLUME_LINEAR_FILTERED,
|
||||
ST_VOLUME_LINEAR_FILTERED,
|
||||
ST_VOLUME_LINEAR_FILTERED>
|
||||
{
|
||||
public:
|
||||
GlobalIlluminationReconstructionShader();
|
||||
};
|
||||
|
||||
class Gaussian17TapHShader : public Shader<Gaussian17TapHShader, core::vector2df>, public TextureRead<Bilinear_Clamped_Filtered, Bilinear_Clamped_Filtered>
|
||||
class Gaussian17TapHShader : public Shader<Gaussian17TapHShader, core::vector2df>,
|
||||
public TextureReadNew<ST_BILINEAR_CLAMPED_FILTERED,
|
||||
ST_BILINEAR_CLAMPED_FILTERED>
|
||||
{
|
||||
public:
|
||||
Gaussian17TapHShader();
|
||||
};
|
||||
|
||||
class ComputeGaussian17TapHShader : public Shader<ComputeGaussian17TapHShader, core::vector2df>, public TextureRead<Neared_Clamped_Filtered, Neared_Clamped_Filtered>
|
||||
class ComputeGaussian17TapHShader : public Shader<ComputeGaussian17TapHShader, core::vector2df>,
|
||||
public TextureReadNew<ST_NEARED_CLAMPED_FILTERED,
|
||||
ST_NEARED_CLAMPED_FILTERED>
|
||||
{
|
||||
public:
|
||||
GLuint TU_dest;
|
||||
ComputeGaussian17TapHShader();
|
||||
};
|
||||
|
||||
class ComputeGaussian6HBlurShader : public Shader<ComputeGaussian6HBlurShader, core::vector2df, std::vector<float> >, public TextureRead<Bilinear_Clamped_Filtered>
|
||||
class ComputeGaussian6HBlurShader : public Shader<ComputeGaussian6HBlurShader, core::vector2df, std::vector<float> >,
|
||||
public TextureReadNew<ST_BILINEAR_CLAMPED_FILTERED>
|
||||
{
|
||||
public:
|
||||
GLuint TU_dest;
|
||||
ComputeGaussian6HBlurShader();
|
||||
};
|
||||
|
||||
class ComputeShadowBlurHShader : public Shader<ComputeShadowBlurHShader, core::vector2df, std::vector<float> >, public TextureRead<Neared_Clamped_Filtered>
|
||||
class ComputeShadowBlurHShader : public Shader<ComputeShadowBlurHShader, core::vector2df, std::vector<float> >,
|
||||
public TextureReadNew<ST_NEARED_CLAMPED_FILTERED>
|
||||
{
|
||||
public:
|
||||
GLuint TU_dest;
|
||||
ComputeShadowBlurHShader();
|
||||
};
|
||||
|
||||
class Gaussian6HBlurShader : public Shader<Gaussian6HBlurShader, core::vector2df, float>, public TextureRead<Bilinear_Clamped_Filtered>
|
||||
class Gaussian6HBlurShader : public Shader<Gaussian6HBlurShader, core::vector2df, float>,
|
||||
public TextureReadNew<ST_BILINEAR_CLAMPED_FILTERED>
|
||||
{
|
||||
public:
|
||||
Gaussian6HBlurShader();
|
||||
};
|
||||
|
||||
class HorizontalBlurShader : public Shader<HorizontalBlurShader, core::vector2df>, public TextureRead<Bilinear_Clamped_Filtered>
|
||||
class HorizontalBlurShader : public Shader<HorizontalBlurShader, core::vector2df>,
|
||||
public TextureReadNew<ST_BILINEAR_CLAMPED_FILTERED>
|
||||
{
|
||||
public:
|
||||
HorizontalBlurShader();
|
||||
};
|
||||
|
||||
class Gaussian3HBlurShader : public Shader<Gaussian3HBlurShader, core::vector2df>, public TextureRead<Bilinear_Clamped_Filtered>
|
||||
class Gaussian3HBlurShader : public Shader<Gaussian3HBlurShader, core::vector2df>,
|
||||
public TextureReadNew<ST_BILINEAR_CLAMPED_FILTERED>
|
||||
{
|
||||
public:
|
||||
Gaussian3HBlurShader();
|
||||
};
|
||||
|
||||
class Gaussian17TapVShader : public Shader<Gaussian17TapVShader, core::vector2df>, public TextureRead<Bilinear_Clamped_Filtered, Bilinear_Clamped_Filtered>
|
||||
class Gaussian17TapVShader : public Shader<Gaussian17TapVShader, core::vector2df>,
|
||||
public TextureReadNew<ST_BILINEAR_CLAMPED_FILTERED, ST_BILINEAR_CLAMPED_FILTERED>
|
||||
{
|
||||
public:
|
||||
Gaussian17TapVShader();
|
||||
};
|
||||
|
||||
class ComputeGaussian17TapVShader : public Shader<ComputeGaussian17TapVShader, core::vector2df>, public TextureRead<Neared_Clamped_Filtered, Neared_Clamped_Filtered>
|
||||
class ComputeGaussian17TapVShader : public Shader<ComputeGaussian17TapVShader, core::vector2df>,
|
||||
public TextureReadNew<ST_NEARED_CLAMPED_FILTERED, ST_NEARED_CLAMPED_FILTERED>
|
||||
{
|
||||
public:
|
||||
GLuint TU_dest;
|
||||
@ -506,33 +595,38 @@ public:
|
||||
ComputeGaussian17TapVShader();
|
||||
};
|
||||
|
||||
class ComputeGaussian6VBlurShader : public Shader<ComputeGaussian6VBlurShader, core::vector2df, std::vector<float> >, public TextureRead<Bilinear_Clamped_Filtered>
|
||||
class ComputeGaussian6VBlurShader : public Shader<ComputeGaussian6VBlurShader, core::vector2df, std::vector<float> >,
|
||||
public TextureReadNew<ST_BILINEAR_CLAMPED_FILTERED>
|
||||
{
|
||||
public:
|
||||
GLuint TU_dest;
|
||||
ComputeGaussian6VBlurShader();
|
||||
};
|
||||
|
||||
class ComputeShadowBlurVShader : public Shader<ComputeShadowBlurVShader, core::vector2df, std::vector<float> >, public TextureRead<Neared_Clamped_Filtered>
|
||||
class ComputeShadowBlurVShader : public Shader<ComputeShadowBlurVShader, core::vector2df, std::vector<float> >,
|
||||
public TextureReadNew<ST_NEARED_CLAMPED_FILTERED>
|
||||
{
|
||||
public:
|
||||
GLuint TU_dest;
|
||||
ComputeShadowBlurVShader();
|
||||
};
|
||||
|
||||
class Gaussian6VBlurShader : public Shader<Gaussian6VBlurShader, core::vector2df, float>, public TextureRead<Bilinear_Clamped_Filtered>
|
||||
class Gaussian6VBlurShader : public Shader<Gaussian6VBlurShader, core::vector2df, float>,
|
||||
public TextureReadNew<ST_BILINEAR_CLAMPED_FILTERED>
|
||||
{
|
||||
public:
|
||||
Gaussian6VBlurShader();
|
||||
};
|
||||
|
||||
class Gaussian3VBlurShader : public Shader<Gaussian3VBlurShader, core::vector2df>, public TextureRead<Bilinear_Clamped_Filtered>
|
||||
class Gaussian3VBlurShader : public Shader<Gaussian3VBlurShader, core::vector2df>,
|
||||
public TextureReadNew<ST_BILINEAR_CLAMPED_FILTERED>
|
||||
{
|
||||
public:
|
||||
Gaussian3VBlurShader();
|
||||
};
|
||||
|
||||
class PassThroughShader : public Shader<PassThroughShader, int, int>, public TextureRead<Bilinear_Filtered>
|
||||
class PassThroughShader : public Shader<PassThroughShader, int, int>,
|
||||
public TextureReadNew<ST_BILINEAR_FILTERED>
|
||||
{
|
||||
public:
|
||||
PassThroughShader();
|
||||
@ -547,13 +641,17 @@ public:
|
||||
LayerPassThroughShader();
|
||||
};
|
||||
|
||||
class LinearizeDepthShader : public Shader<LinearizeDepthShader, float, float>, public TextureRead<Bilinear_Filtered>
|
||||
class LinearizeDepthShader : public Shader<LinearizeDepthShader, float, float>,
|
||||
public TextureReadNew<ST_BILINEAR_FILTERED>
|
||||
{
|
||||
public:
|
||||
LinearizeDepthShader();
|
||||
};
|
||||
|
||||
class LightspaceBoundingBoxShader : public Shader<LightspaceBoundingBoxShader, core::matrix4, float, float, float, float>, public TextureRead < Nearest_Filtered >
|
||||
class LightspaceBoundingBoxShader : public Shader<LightspaceBoundingBoxShader,
|
||||
core::matrix4, float, float,
|
||||
float, float>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED >
|
||||
{
|
||||
public:
|
||||
LightspaceBoundingBoxShader();
|
||||
@ -565,13 +663,15 @@ public:
|
||||
ShadowMatrixesGenerationShader();
|
||||
};
|
||||
|
||||
class DepthHistogramShader : public Shader<DepthHistogramShader>, public TextureRead <Nearest_Filtered>
|
||||
class DepthHistogramShader : public Shader<DepthHistogramShader>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED>
|
||||
{
|
||||
public:
|
||||
DepthHistogramShader();
|
||||
};
|
||||
|
||||
class GlowShader : public Shader<GlowShader>, public TextureRead<Bilinear_Filtered>
|
||||
class GlowShader : public Shader<GlowShader>,
|
||||
public TextureReadNew<ST_BILINEAR_FILTERED>
|
||||
{
|
||||
public:
|
||||
GLuint vao;
|
||||
@ -579,49 +679,57 @@ public:
|
||||
GlowShader();
|
||||
};
|
||||
|
||||
class SSAOShader : public Shader<SSAOShader, float, float, float>, public TextureRead<Semi_trilinear>
|
||||
class SSAOShader : public Shader<SSAOShader, float, float, float>,
|
||||
public TextureReadNew<ST_SEMI_TRILINEAR>
|
||||
{
|
||||
public:
|
||||
SSAOShader();
|
||||
};
|
||||
|
||||
class FogShader : public Shader<FogShader, float, core::vector3df>, public TextureRead<Nearest_Filtered>
|
||||
class FogShader : public Shader<FogShader, float, core::vector3df>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED>
|
||||
{
|
||||
public:
|
||||
FogShader();
|
||||
};
|
||||
|
||||
class MotionBlurShader : public Shader<MotionBlurShader, core::matrix4, core::vector2df, float, float>, public TextureRead<Bilinear_Clamped_Filtered, Nearest_Filtered>
|
||||
class MotionBlurShader : public Shader<MotionBlurShader, core::matrix4, core::vector2df, float, float>,
|
||||
public TextureReadNew<ST_BILINEAR_CLAMPED_FILTERED, ST_NEAREST_FILTERED>
|
||||
{
|
||||
public:
|
||||
MotionBlurShader();
|
||||
};
|
||||
|
||||
class GodFadeShader : public Shader<GodFadeShader, video::SColorf>, public TextureRead<Bilinear_Filtered>
|
||||
class GodFadeShader : public Shader<GodFadeShader, video::SColorf>,
|
||||
public TextureReadNew<ST_BILINEAR_FILTERED>
|
||||
{
|
||||
public:
|
||||
GodFadeShader();
|
||||
};
|
||||
|
||||
class GodRayShader : public Shader<GodRayShader, core::vector2df>, public TextureRead<Bilinear_Filtered>
|
||||
class GodRayShader : public Shader<GodRayShader, core::vector2df>,
|
||||
public TextureReadNew<ST_BILINEAR_FILTERED>
|
||||
{
|
||||
public:
|
||||
GodRayShader();
|
||||
};
|
||||
|
||||
class MLAAColorEdgeDetectionSHader : public Shader<MLAAColorEdgeDetectionSHader, core::vector2df>, public TextureRead<Nearest_Filtered>
|
||||
class MLAAColorEdgeDetectionSHader : public Shader<MLAAColorEdgeDetectionSHader, core::vector2df>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED>
|
||||
{
|
||||
public:
|
||||
MLAAColorEdgeDetectionSHader();
|
||||
};
|
||||
|
||||
class MLAABlendWeightSHader : public Shader<MLAABlendWeightSHader, core::vector2df>, public TextureRead<Bilinear_Filtered, Nearest_Filtered>
|
||||
class MLAABlendWeightSHader : public Shader<MLAABlendWeightSHader, core::vector2df>,
|
||||
public TextureReadNew<ST_BILINEAR_FILTERED, ST_NEAREST_FILTERED>
|
||||
{
|
||||
public:
|
||||
MLAABlendWeightSHader();
|
||||
};
|
||||
|
||||
class MLAAGatherSHader : public Shader<MLAAGatherSHader, core::vector2df>, public TextureRead<Nearest_Filtered, Nearest_Filtered>
|
||||
class MLAAGatherSHader : public Shader<MLAAGatherSHader, core::vector2df>,
|
||||
public TextureReadNew<ST_NEAREST_FILTERED, ST_NEAREST_FILTERED>
|
||||
{
|
||||
public:
|
||||
MLAAGatherSHader();
|
||||
@ -632,25 +740,36 @@ public:
|
||||
namespace UIShader
|
||||
{
|
||||
|
||||
class Primitive2DList : public Shader<Primitive2DList>, public TextureRead < Bilinear_Filtered >
|
||||
class Primitive2DList : public Shader<Primitive2DList>,
|
||||
public TextureReadNew<ST_BILINEAR_FILTERED >
|
||||
{
|
||||
public:
|
||||
Primitive2DList();
|
||||
};
|
||||
|
||||
class TextureRectShader : public Shader<TextureRectShader, core::vector2df, core::vector2df, core::vector2df, core::vector2df>, public TextureRead<Bilinear_Filtered>
|
||||
class TextureRectShader : public Shader<TextureRectShader, core::vector2df,
|
||||
core::vector2df, core::vector2df,
|
||||
core::vector2df>,
|
||||
public TextureReadNew<ST_BILINEAR_FILTERED>
|
||||
{
|
||||
public:
|
||||
TextureRectShader();
|
||||
};
|
||||
|
||||
class UniformColoredTextureRectShader : public Shader<UniformColoredTextureRectShader, core::vector2df, core::vector2df, core::vector2df, core::vector2df, video::SColor>, public TextureRead<Bilinear_Filtered>
|
||||
class UniformColoredTextureRectShader : public Shader<UniformColoredTextureRectShader,
|
||||
core::vector2df, core::vector2df,
|
||||
core::vector2df, core::vector2df,
|
||||
video::SColor>,
|
||||
public TextureReadNew<ST_BILINEAR_FILTERED>
|
||||
{
|
||||
public:
|
||||
UniformColoredTextureRectShader();
|
||||
};
|
||||
|
||||
class ColoredTextureRectShader : public Shader<ColoredTextureRectShader, core::vector2df, core::vector2df, core::vector2df, core::vector2df>, public TextureRead<Bilinear_Filtered>
|
||||
class ColoredTextureRectShader : public Shader<ColoredTextureRectShader, core::vector2df,
|
||||
core::vector2df, core::vector2df,
|
||||
core::vector2df>,
|
||||
public TextureReadNew<ST_BILINEAR_FILTERED>
|
||||
{
|
||||
public:
|
||||
GLuint colorvbo;
|
||||
@ -659,7 +778,8 @@ public:
|
||||
ColoredTextureRectShader();
|
||||
};
|
||||
|
||||
class ColoredRectShader : public Shader<ColoredRectShader, core::vector2df, core::vector2df, video::SColor>
|
||||
class ColoredRectShader : public Shader<ColoredRectShader, core::vector2df,
|
||||
core::vector2df, video::SColor>
|
||||
{
|
||||
public:
|
||||
ColoredRectShader();
|
||||
|
@ -1,347 +0,0 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2014-2015 SuperTuxKart-Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef SHADERS_UTIL_HPP
|
||||
#define SHADERS_UTIL_HPP
|
||||
|
||||
#include "graphics/central_settings.hpp"
|
||||
#include "utils/singleton.hpp"
|
||||
#include <vector>
|
||||
#include <matrix4.h>
|
||||
#include <SColor.h>
|
||||
#include <vector3d.h>
|
||||
#include "gl_headers.hpp"
|
||||
|
||||
bool needsUBO();
|
||||
|
||||
unsigned getGLSLVersion();
|
||||
|
||||
|
||||
enum AttributeType
|
||||
{
|
||||
OBJECT,
|
||||
PARTICLES_SIM,
|
||||
PARTICLES_RENDERING,
|
||||
};
|
||||
|
||||
void setAttribute(AttributeType Tp, GLuint ProgramID);
|
||||
|
||||
void bypassUBO(GLuint Program);
|
||||
|
||||
enum SamplerType {
|
||||
Trilinear_Anisotropic_Filtered,
|
||||
Semi_trilinear,
|
||||
Bilinear_Filtered,
|
||||
Bilinear_Clamped_Filtered,
|
||||
Neared_Clamped_Filtered,
|
||||
Nearest_Filtered,
|
||||
Shadow_Sampler,
|
||||
Volume_Linear_Filtered,
|
||||
Trilinear_cubemap,
|
||||
Trilinear_Clamped_Array2D,
|
||||
};
|
||||
|
||||
void setTextureSampler(GLenum, GLuint, GLuint, GLuint);
|
||||
|
||||
template<SamplerType...tp>
|
||||
struct CreateSamplers;
|
||||
|
||||
template<SamplerType...tp>
|
||||
struct BindTexture;
|
||||
|
||||
template<>
|
||||
struct CreateSamplers<>
|
||||
{
|
||||
static void exec(std::vector<unsigned> &, std::vector<GLenum> &e)
|
||||
{}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct BindTexture<>
|
||||
{
|
||||
template<int N>
|
||||
static void exec(const std::vector<unsigned> &TU)
|
||||
{}
|
||||
};
|
||||
|
||||
GLuint createNearestSampler();
|
||||
|
||||
template<SamplerType...tp>
|
||||
struct CreateSamplers<Nearest_Filtered, tp...>
|
||||
{
|
||||
static void exec(std::vector<unsigned> &v, std::vector<GLenum> &e)
|
||||
{
|
||||
v.push_back(createNearestSampler());
|
||||
e.push_back(GL_TEXTURE_2D);
|
||||
CreateSamplers<tp...>::exec(v, e);
|
||||
}
|
||||
};
|
||||
|
||||
void BindTextureNearest(unsigned TU, unsigned tid);
|
||||
|
||||
template<SamplerType...tp>
|
||||
struct BindTexture<Nearest_Filtered, tp...>
|
||||
{
|
||||
template<int N, typename...Args>
|
||||
static void exec(const std::vector<unsigned> &TU, GLuint TexId, Args... args)
|
||||
{
|
||||
BindTextureNearest(TU[N], TexId);
|
||||
BindTexture<tp...>::template exec<N + 1>(TU, args...);
|
||||
}
|
||||
};
|
||||
|
||||
template<SamplerType...tp>
|
||||
struct CreateSamplers<Neared_Clamped_Filtered, tp...>
|
||||
{
|
||||
static void exec(std::vector<unsigned> &v, std::vector<GLenum> &e)
|
||||
{
|
||||
unsigned id;
|
||||
glGenSamplers(1, &id);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameterf(id, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.);
|
||||
|
||||
v.push_back(createNearestSampler());
|
||||
e.push_back(GL_TEXTURE_2D);
|
||||
CreateSamplers<tp...>::exec(v, e);
|
||||
}
|
||||
};
|
||||
|
||||
template<SamplerType...tp>
|
||||
struct BindTexture<Neared_Clamped_Filtered, tp...>
|
||||
{
|
||||
template<int N, typename...Args>
|
||||
static void exec(const std::vector<unsigned> &TU, GLuint TexId, Args... args)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + TU[N]);
|
||||
glBindTexture(GL_TEXTURE_2D, TexId);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.);
|
||||
BindTexture<tp...>::template exec<N + 1>(TU, args...);
|
||||
}
|
||||
};
|
||||
|
||||
GLuint createBilinearSampler();
|
||||
|
||||
template<SamplerType...tp>
|
||||
struct CreateSamplers<Bilinear_Filtered, tp...>
|
||||
{
|
||||
static void exec(std::vector<unsigned> &v, std::vector<GLenum> &e)
|
||||
{
|
||||
v.push_back(createBilinearSampler());
|
||||
e.push_back(GL_TEXTURE_2D);
|
||||
CreateSamplers<tp...>::exec(v, e);
|
||||
}
|
||||
};
|
||||
|
||||
void BindTextureBilinear(unsigned TU, unsigned tex);
|
||||
|
||||
template<SamplerType...tp>
|
||||
struct BindTexture<Bilinear_Filtered, tp...>
|
||||
{
|
||||
template<int N, typename...Args>
|
||||
static void exec(const std::vector<unsigned> &TU, GLuint TexId, Args... args)
|
||||
{
|
||||
BindTextureBilinear(TU[N], TexId);
|
||||
BindTexture<tp...>::template exec<N + 1>(TU, args...);
|
||||
}
|
||||
};
|
||||
|
||||
GLuint createBilinearClampedSampler();
|
||||
|
||||
template<SamplerType...tp>
|
||||
struct CreateSamplers<Bilinear_Clamped_Filtered, tp...>
|
||||
{
|
||||
static void exec(std::vector<unsigned> &v, std::vector<GLenum> &e)
|
||||
{
|
||||
v.push_back(createBilinearClampedSampler());
|
||||
e.push_back(GL_TEXTURE_2D);
|
||||
CreateSamplers<tp...>::exec(v, e);
|
||||
}
|
||||
};
|
||||
|
||||
void BindTextureBilinearClamped(unsigned TU, unsigned tex);
|
||||
|
||||
template<SamplerType...tp>
|
||||
struct BindTexture<Bilinear_Clamped_Filtered, tp...>
|
||||
{
|
||||
template<int N, typename...Args>
|
||||
static void exec(const std::vector<unsigned> &TU, GLuint TexId, Args... args)
|
||||
{
|
||||
BindTextureBilinearClamped(TU[N], TexId);
|
||||
BindTexture<tp...>::template exec<N + 1>(TU, args...);
|
||||
}
|
||||
};
|
||||
|
||||
GLuint createSemiTrilinearSampler();
|
||||
|
||||
template<SamplerType...tp>
|
||||
struct CreateSamplers<Semi_trilinear, tp...>
|
||||
{
|
||||
static void exec(std::vector<unsigned> &v, std::vector<GLenum> &e)
|
||||
{
|
||||
v.push_back(createSemiTrilinearSampler());
|
||||
e.push_back(GL_TEXTURE_2D);
|
||||
CreateSamplers<tp...>::exec(v, e);
|
||||
}
|
||||
};
|
||||
|
||||
void BindTextureSemiTrilinear(unsigned TU, unsigned tex);
|
||||
|
||||
template<SamplerType...tp>
|
||||
struct BindTexture<Semi_trilinear, tp...>
|
||||
{
|
||||
template<int N, typename...Args>
|
||||
static void exec(const std::vector<unsigned> &TU, GLuint TexId, Args... args)
|
||||
{
|
||||
BindTextureSemiTrilinear(TU[N], TexId);
|
||||
BindTexture<tp...>::template exec<N + 1>(TU, args...);
|
||||
}
|
||||
};
|
||||
|
||||
GLuint createTrilinearSampler();
|
||||
|
||||
template<SamplerType...tp>
|
||||
struct CreateSamplers<Trilinear_Anisotropic_Filtered, tp...>
|
||||
{
|
||||
static void exec(std::vector<unsigned> &v, std::vector<GLenum> &e)
|
||||
{
|
||||
v.push_back(createTrilinearSampler());
|
||||
e.push_back(GL_TEXTURE_2D);
|
||||
CreateSamplers<tp...>::exec(v, e);
|
||||
}
|
||||
};
|
||||
|
||||
void BindTextureTrilinearAnisotropic(unsigned TU, unsigned tex);
|
||||
|
||||
template<SamplerType...tp>
|
||||
struct CreateSamplers<Trilinear_cubemap, tp...>
|
||||
{
|
||||
static void exec(std::vector<unsigned> &v, std::vector<GLenum> &e)
|
||||
{
|
||||
v.push_back(createTrilinearSampler());
|
||||
e.push_back(GL_TEXTURE_CUBE_MAP);
|
||||
CreateSamplers<tp...>::exec(v, e);
|
||||
}
|
||||
};
|
||||
|
||||
void BindCubemapTrilinear(unsigned TU, unsigned tex);
|
||||
|
||||
template<SamplerType...tp>
|
||||
struct BindTexture<Trilinear_cubemap, tp...>
|
||||
{
|
||||
template<int N, typename...Args>
|
||||
static void exec(const std::vector<unsigned> &TU, GLuint TexId, Args... args)
|
||||
{
|
||||
BindCubemapTrilinear(TU[N], TexId);
|
||||
BindTexture<tp...>::template exec<N + 1>(TU, args...);
|
||||
}
|
||||
};
|
||||
|
||||
template<SamplerType...tp>
|
||||
struct BindTexture<Trilinear_Anisotropic_Filtered, tp...>
|
||||
{
|
||||
template<int N, typename...Args>
|
||||
static void exec(const std::vector<unsigned> &TU, GLuint TexId, Args... args)
|
||||
{
|
||||
BindTextureTrilinearAnisotropic(TU[N], TexId);
|
||||
BindTexture<tp...>::template exec<N + 1>(TU, args...);
|
||||
}
|
||||
};
|
||||
|
||||
template<SamplerType...tp>
|
||||
struct CreateSamplers<Volume_Linear_Filtered, tp...>
|
||||
{
|
||||
static void exec(std::vector<unsigned> &v, std::vector<GLenum> &e)
|
||||
{
|
||||
v.push_back(createBilinearSampler());
|
||||
e.push_back(GL_TEXTURE_3D);
|
||||
CreateSamplers<tp...>::exec(v, e);
|
||||
}
|
||||
};
|
||||
|
||||
void BindTextureVolume(unsigned TU, unsigned tex);
|
||||
|
||||
template<SamplerType...tp>
|
||||
struct BindTexture<Volume_Linear_Filtered, tp...>
|
||||
{
|
||||
template<int N, typename...Args>
|
||||
static void exec(const std::vector<unsigned> &TU, GLuint TexId, Args... args)
|
||||
{
|
||||
BindTextureVolume(TU[N], TexId);
|
||||
BindTexture<tp...>::template exec<N + 1>(TU, args...);
|
||||
}
|
||||
};
|
||||
|
||||
GLuint createShadowSampler();
|
||||
|
||||
template<SamplerType...tp>
|
||||
struct CreateSamplers<Shadow_Sampler, tp...>
|
||||
{
|
||||
static void exec(std::vector<unsigned> &v, std::vector<GLenum> &e)
|
||||
{
|
||||
v.push_back(createShadowSampler());
|
||||
e.push_back(GL_TEXTURE_2D_ARRAY);
|
||||
CreateSamplers<tp...>::exec(v, e);
|
||||
}
|
||||
};
|
||||
|
||||
void BindTextureShadow(unsigned TU, unsigned tex);
|
||||
|
||||
template<SamplerType...tp>
|
||||
struct BindTexture<Shadow_Sampler, tp...>
|
||||
{
|
||||
template <int N, typename...Args>
|
||||
static void exec(const std::vector<unsigned> &TU, GLuint TexId, Args... args)
|
||||
{
|
||||
BindTextureShadow(TU[N], TexId);
|
||||
BindTexture<tp...>::template exec<N + 1>(TU, args...);
|
||||
}
|
||||
};
|
||||
|
||||
GLuint createTrilinearClampedArray();
|
||||
|
||||
template<SamplerType...tp>
|
||||
struct CreateSamplers<Trilinear_Clamped_Array2D, tp...>
|
||||
{
|
||||
static void exec(std::vector<unsigned> &v, std::vector<GLenum> &e)
|
||||
{
|
||||
v.push_back(createTrilinearClampedArray());
|
||||
e.push_back(GL_TEXTURE_2D_ARRAY);
|
||||
CreateSamplers<tp...>::exec(v, e);
|
||||
}
|
||||
};
|
||||
|
||||
void BindTrilinearClampedArrayTexture(unsigned TU, unsigned tex);
|
||||
|
||||
template<SamplerType...tp>
|
||||
struct BindTexture<Trilinear_Clamped_Array2D, tp...>
|
||||
{
|
||||
template <int N, typename...Args>
|
||||
static void exec(const std::vector<unsigned> &TU, GLuint TexId, Args... args)
|
||||
{
|
||||
BindTrilinearClampedArrayTexture(TU[N], TexId);
|
||||
BindTexture<tp...>::template exec<N + 1>(TU, args...);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
339
src/graphics/texture_read.cpp
Normal file
339
src/graphics/texture_read.cpp
Normal file
@ -0,0 +1,339 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2014-2015 SuperTuxKart-Team
|
||||
// (C) 2015 Joerg Henrichs
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "graphics/texture_read.hpp"
|
||||
|
||||
#include "config/user_config.hpp"
|
||||
|
||||
TextureReadBaseNew::BindFunction TextureReadBaseNew::m_all_bind_functions[] =
|
||||
{ /* ST_NEAREST_FILTERED */ &TextureReadBaseNew::bindTextureNearest,
|
||||
/* ST_TRILINEAR_ANISOTROPIC_FILTERED */ &TextureReadBaseNew::bindTextureTrilinearAnisotropic,
|
||||
/* ST_TRILINEAR_CUBEMAP */ &TextureReadBaseNew::bindCubemapTrilinear,
|
||||
/* ST_BILINEAR_FILTERED */ &TextureReadBaseNew::bindTextureBilinear,
|
||||
/* ST_SHADOW_SAMPLER */ &TextureReadBaseNew::bindTextureShadow,
|
||||
/* ST_TRILINEAR_CLAMPED_ARRAY2D */ &TextureReadBaseNew::bindTrilinearClampedArrayTexture,
|
||||
/* ST_VOLUME_LINEAR_FILTERED */ &TextureReadBaseNew::bindTextureVolume,
|
||||
/* ST_NEARED_CLAMPED_FILTERED */ &TextureReadBaseNew::bindTextureNearestClamped,
|
||||
/* ST_BILINEAR_CLAMPED_FILTERED */ &TextureReadBaseNew::bindTextureBilinearClamped,
|
||||
/* ST_SEMI_TRILINEAR */ &TextureReadBaseNew::bindTextureSemiTrilinear
|
||||
};
|
||||
|
||||
GLuint TextureReadBaseNew::m_all_texture_types[] =
|
||||
{ /* ST_NEAREST_FILTERED */ GL_TEXTURE_2D,
|
||||
/* ST_TRILINEAR_ANISOTROPIC_FILTERED */ GL_TEXTURE_2D,
|
||||
/* ST_TRILINEAR_CUBEMAP */ GL_TEXTURE_CUBE_MAP,
|
||||
/* ST_BILINEAR_FILTERED */ GL_TEXTURE_2D ,
|
||||
/* ST_SHADOW_SAMPLER */ GL_TEXTURE_2D_ARRAY,
|
||||
/* ST_TRILINEAR_CLAMPED_ARRAY2D */ GL_TEXTURE_2D_ARRAY,
|
||||
/* ST_VOLUME_LINEAR_FILTERED */ GL_TEXTURE_3D,
|
||||
/* ST_NEARED_CLAMPED_FILTERED */ GL_TEXTURE_2D,
|
||||
/* ST_BILINEAR_CLAMPED_FILTERED */ GL_TEXTURE_2D,
|
||||
/* ST_SEMI_TRILINEAR */ GL_TEXTURE_2D
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void TextureReadBaseNew::bindTextureNearest(GLuint texture_unit, GLuint tex)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + texture_unit);
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.);
|
||||
|
||||
} // bindTextureNearest
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void TextureReadBaseNew::bindTextureTrilinearAnisotropic(GLuint tex_unit, GLuint tex)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + tex_unit);
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
|
||||
int aniso = UserConfigParams::m_anisotropic;
|
||||
if (aniso == 0) aniso = 1;
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)aniso);
|
||||
} // bindTextureTrilinearAnisotropic
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void TextureReadBaseNew::bindCubemapTrilinear(unsigned tex_unit, unsigned tex)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + tex_unit);
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
|
||||
int aniso = UserConfigParams::m_anisotropic;
|
||||
if (aniso == 0) aniso = 1;
|
||||
glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_ANISOTROPY_EXT,
|
||||
(float)aniso);
|
||||
} // bindCubemapTrilinear
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void TextureReadBaseNew::bindTextureNearestClamped(GLuint texture_unit,
|
||||
GLuint tex_id)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + texture_unit);
|
||||
glBindTexture(GL_TEXTURE_2D, tex_id);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.);
|
||||
} // bindTextureNearestClamped
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void TextureReadBaseNew::bindTextureBilinear(GLuint texture_unit, GLuint tex)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + texture_unit);
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.);
|
||||
} // bindTextureBilinear
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void TextureReadBaseNew::bindTextureBilinearClamped(GLuint tex_unit, GLuint tex)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + tex_unit);
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.);
|
||||
} // bindTextureBilinearClamped
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void TextureReadBaseNew::bindTextureSemiTrilinear(GLuint tex_unit, GLuint tex_id)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + tex_unit);
|
||||
glBindTexture(GL_TEXTURE_2D, tex_id);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.);
|
||||
} // bindTextureSemiTrilinear
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void TextureReadBaseNew::bindTextureShadow(GLuint tex_unit, GLuint tex_id)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + tex_unit);
|
||||
glBindTexture(GL_TEXTURE_2D_ARRAY, tex_id);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
|
||||
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
|
||||
} // bindTextureShadow
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void TextureReadBaseNew::bindTrilinearClampedArrayTexture(unsigned tex_unit,
|
||||
unsigned tex_id)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + tex_unit);
|
||||
glBindTexture(GL_TEXTURE_2D_ARRAY, tex_id);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
int aniso = UserConfigParams::m_anisotropic;
|
||||
if (aniso == 0) aniso = 1;
|
||||
glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)aniso);
|
||||
} // bindTrilinearClampedArrayTexture
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void TextureReadBaseNew::bindTextureVolume(unsigned tex_unit, unsigned tex_id)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + tex_unit);
|
||||
glBindTexture(GL_TEXTURE_3D, tex_id);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.);
|
||||
} // bindTextureVolume
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
GLuint TextureReadBaseNew::createSamplers(SamplerTypeNew sampler_type)
|
||||
{
|
||||
switch (sampler_type)
|
||||
{
|
||||
case ST_NEAREST_FILTERED:
|
||||
return createNearestSampler();
|
||||
case ST_TRILINEAR_ANISOTROPIC_FILTERED:
|
||||
return createTrilinearSampler();
|
||||
case ST_TRILINEAR_CUBEMAP:
|
||||
return createTrilinearSampler();
|
||||
case ST_BILINEAR_FILTERED:
|
||||
return createBilinearSampler();
|
||||
case ST_SHADOW_SAMPLER:
|
||||
return createShadowSampler();
|
||||
case ST_TRILINEAR_CLAMPED_ARRAY2D:
|
||||
return createTrilinearClampedArray();
|
||||
case ST_VOLUME_LINEAR_FILTERED:
|
||||
return createBilinearSampler();
|
||||
case ST_NEARED_CLAMPED_FILTERED:
|
||||
{
|
||||
// WHAT'S THAT??????????????????
|
||||
unsigned id;
|
||||
glGenSamplers(1, &id);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameterf(id, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.);
|
||||
return createNearestSampler();
|
||||
}
|
||||
case ST_BILINEAR_CLAMPED_FILTERED:
|
||||
return createBilinearClampedSampler();
|
||||
case ST_SEMI_TRILINEAR:
|
||||
return createSemiTrilinearSampler();
|
||||
default:
|
||||
assert(false);
|
||||
return 0;
|
||||
} // switch
|
||||
} // createSamplers
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
GLuint TextureReadBaseNew::createNearestSampler()
|
||||
{
|
||||
#ifdef GL_VERSION_3_3
|
||||
unsigned id;
|
||||
glGenSamplers(1, &id);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glSamplerParameterf(id, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.);
|
||||
return id;
|
||||
#endif
|
||||
} // createNearestSampler
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
GLuint TextureReadBaseNew::createTrilinearSampler()
|
||||
{
|
||||
#ifdef GL_VERSION_3_3
|
||||
unsigned id;
|
||||
glGenSamplers(1, &id);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
|
||||
int aniso = UserConfigParams::m_anisotropic;
|
||||
if (aniso == 0) aniso = 1;
|
||||
glSamplerParameterf(id, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)aniso);
|
||||
return id;
|
||||
#endif
|
||||
} // createTrilinearSampler
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
GLuint TextureReadBaseNew::createBilinearSampler()
|
||||
{
|
||||
#ifdef GL_VERSION_3_3
|
||||
unsigned id;
|
||||
glGenSamplers(1, &id);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glSamplerParameterf(id, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.);
|
||||
return id;
|
||||
#endif
|
||||
} // createBilinearSampler
|
||||
// ----------------------------------------------------------------------------
|
||||
GLuint TextureReadBaseNew::createShadowSampler()
|
||||
{
|
||||
#ifdef GL_VERSION_3_3
|
||||
unsigned id;
|
||||
glGenSamplers(1, &id);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameterf(id, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
|
||||
glSamplerParameterf(id, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
|
||||
return id;
|
||||
#endif
|
||||
} // createShadowSampler
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
GLuint TextureReadBaseNew::createBilinearClampedSampler()
|
||||
{
|
||||
#ifdef GL_VERSION_3_3
|
||||
unsigned id;
|
||||
glGenSamplers(1, &id);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameterf(id, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.);
|
||||
return id;
|
||||
#endif
|
||||
} // createBilinearClampedSampler
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
GLuint TextureReadBaseNew::createTrilinearClampedArray()
|
||||
{
|
||||
#ifdef GL_VERSION_3_3
|
||||
unsigned id;
|
||||
glGenSamplers(1, &id);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
int aniso = UserConfigParams::m_anisotropic;
|
||||
if (aniso == 0) aniso = 1;
|
||||
glSamplerParameterf(id, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)aniso);
|
||||
return id;
|
||||
#endif
|
||||
} // createTrilinearClampedArray
|
||||
// ----------------------------------------------------------------------------
|
||||
GLuint TextureReadBaseNew::createSemiTrilinearSampler()
|
||||
{
|
||||
#ifdef GL_VERSION_3_3
|
||||
unsigned id;
|
||||
glGenSamplers(1, &id);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameteri(id, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameterf(id, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.);
|
||||
return id;
|
||||
#endif
|
||||
} // createSemiTrilinearSampler
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
@ -18,12 +18,69 @@
|
||||
#ifndef HEADER_TEXTURE_READ_HPP
|
||||
#define HEADER_TEXTURE_READ_HPP
|
||||
|
||||
#include "shaders_util.hpp"
|
||||
#include "graphics/gl_headers.hpp"
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
template<SamplerType...tp>
|
||||
class TextureRead
|
||||
|
||||
enum SamplerTypeNew
|
||||
{
|
||||
ST_MIN,
|
||||
ST_NEAREST_FILTERED = ST_MIN,
|
||||
ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
ST_TRILINEAR_CUBEMAP,
|
||||
ST_BILINEAR_FILTERED,
|
||||
ST_SHADOW_SAMPLER,
|
||||
ST_TRILINEAR_CLAMPED_ARRAY2D,
|
||||
ST_VOLUME_LINEAR_FILTERED,
|
||||
ST_NEARED_CLAMPED_FILTERED,
|
||||
ST_BILINEAR_CLAMPED_FILTERED,
|
||||
ST_SEMI_TRILINEAR,
|
||||
ST_MAX = ST_SEMI_TRILINEAR
|
||||
}; // SamplerTypeNew
|
||||
|
||||
|
||||
class TextureReadBaseNew
|
||||
{
|
||||
public:
|
||||
typedef std::function<void(GLuint, GLuint)> BindFunction;
|
||||
|
||||
protected:
|
||||
static void bindTextureNearest(GLuint tex_unit, GLuint tex_id);
|
||||
static void bindTextureBilinear(GLuint texture_unit, GLuint tex_id);
|
||||
static void bindTextureBilinearClamped(GLuint tex_unit, GLuint tex_id);
|
||||
static void bindTextureNearestClamped(GLuint tex_unit, GLuint tex_id);
|
||||
static void bindTextureTrilinearAnisotropic(GLuint tex_unit, GLuint tex_id);
|
||||
static void bindTextureSemiTrilinear(GLuint tex_unit, GLuint tex_id);
|
||||
static void bindCubemapTrilinear(GLuint tex_unit, GLuint tex_id);
|
||||
static void bindTextureShadow(GLuint tex_unit, GLuint tex_id);
|
||||
static void bindTrilinearClampedArrayTexture(GLuint tex_unit, GLuint tex_id);
|
||||
static void bindTextureVolume(GLuint tex_unit, GLuint tex_id);
|
||||
|
||||
GLuint createSamplers(SamplerTypeNew sampler_type);
|
||||
private:
|
||||
|
||||
static GLuint createNearestSampler();
|
||||
static GLuint createTrilinearSampler();
|
||||
static GLuint createBilinearSampler();
|
||||
static GLuint createShadowSampler();
|
||||
static GLuint createTrilinearClampedArray();
|
||||
static GLuint createBilinearClampedSampler();
|
||||
static GLuint createSemiTrilinearSampler();
|
||||
protected:
|
||||
static BindFunction m_all_bind_functions[];
|
||||
std::vector<BindFunction> m_bind_functions;
|
||||
static GLuint m_all_texture_types[];
|
||||
}; // TextureReadBaseNew
|
||||
|
||||
// ============================================================================
|
||||
|
||||
template<SamplerTypeNew...tp>
|
||||
class TextureReadNew : public TextureReadBaseNew
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
std::vector<GLuint> m_texture_units;
|
||||
std::vector<GLenum> m_texture_type;
|
||||
std::vector<GLenum> m_texture_location;
|
||||
@ -47,26 +104,36 @@ private:
|
||||
* list of arguments.
|
||||
*/
|
||||
template<unsigned N, typename...Args>
|
||||
void assignTextureNamesImpl(GLuint program, GLuint tex_unit,
|
||||
const char *name, Args...args)
|
||||
void assignTextureNamesImpl(GLuint program, GLuint tex_unit,
|
||||
const char *name, SamplerTypeNew sampler_type,
|
||||
Args...args)
|
||||
{
|
||||
|
||||
m_sampler_ids.push_back(createSamplers(sampler_type));
|
||||
|
||||
assert(sampler_type >= ST_MIN && sampler_type <= ST_MAX);
|
||||
m_texture_type.push_back(m_all_texture_types[sampler_type]);
|
||||
|
||||
GLuint location = glGetUniformLocation(program, name);
|
||||
m_texture_location.push_back(location);
|
||||
glUniform1i(location, tex_unit);
|
||||
m_texture_units.push_back(tex_unit);
|
||||
|
||||
// Duplicated assert
|
||||
assert(sampler_type >= ST_MIN && sampler_type <= ST_MAX);
|
||||
m_bind_functions.push_back( m_all_bind_functions[sampler_type]);
|
||||
|
||||
assignTextureNamesImpl<N + 1>(program, args...);
|
||||
} // assignTextureNamesImpl
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
protected:
|
||||
public:
|
||||
/** The protected interface for setting sampler names - it is only called
|
||||
* from instances.
|
||||
*/
|
||||
template<typename...Args>
|
||||
void assignSamplerNames(GLuint program, Args...args)
|
||||
{
|
||||
CreateSamplers<tp...>::exec(m_sampler_ids, m_texture_type);
|
||||
|
||||
glUseProgram(program);
|
||||
assignTextureNamesImpl<0>(program, args...);
|
||||
glUseProgram(0);
|
||||
@ -86,10 +153,20 @@ protected:
|
||||
/** The recursive implementation.
|
||||
*/
|
||||
template<int N, typename... TexIds>
|
||||
void setTextureUnitsImpl(GLuint texid, TexIds... args)
|
||||
void setTextureUnitsImpl(GLuint tex_id, TexIds... args)
|
||||
{
|
||||
setTextureSampler(m_texture_type[N], m_texture_units[N], texid,
|
||||
m_sampler_ids[N]);
|
||||
if (CVS->getGLSLVersion() >= 330)
|
||||
{
|
||||
#ifdef GL_VERSION_3_3
|
||||
glActiveTexture(GL_TEXTURE0 + m_texture_units[N]);
|
||||
glBindTexture(m_texture_type[N], tex_id);
|
||||
glBindSampler(m_texture_units[N], m_sampler_ids[N]);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bind_functions[N](m_texture_units[N], tex_id);
|
||||
}
|
||||
setTextureUnitsImpl<N + 1>(args...);
|
||||
} // setTextureUnitsImpl
|
||||
|
||||
@ -100,11 +177,8 @@ public:
|
||||
template<typename... TexIds>
|
||||
void setTextureUnits(TexIds... args)
|
||||
{
|
||||
if (getGLSLVersion() >= 330)
|
||||
setTextureUnitsImpl<0>(args...);
|
||||
else
|
||||
BindTexture<tp...>::template exec<0>(m_texture_units, args...);
|
||||
} // SetTextureUnits
|
||||
setTextureUnitsImpl<0>(args...);
|
||||
} // setTextureUnits
|
||||
|
||||
|
||||
// ========================================================================
|
||||
@ -148,13 +222,14 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
/** Destructor which frees al lsampler ids.
|
||||
*/
|
||||
~TextureRead()
|
||||
~TextureReadNew()
|
||||
{
|
||||
for (unsigned i = 0; i < m_sampler_ids.size(); i++)
|
||||
glDeleteSamplers(1, &m_sampler_ids[i]);
|
||||
} // ~TextureRead
|
||||
} // ~TextureReadNew
|
||||
|
||||
|
||||
}; // class TextureRead
|
||||
}; // class TextureReadNew
|
||||
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user