Allow using animated texture with displace shader

Plus some clean-up
This commit is contained in:
Benau 2017-08-23 00:55:25 +08:00
parent 6a03f147f6
commit 850afc8620
6 changed files with 8 additions and 28 deletions

View File

@ -6,7 +6,6 @@ uniform vec2 dir;
uniform vec2 dir2;
in vec2 uv;
in vec2 uv_bis;
in float camdist;
out vec4 FragColor;

View File

@ -1,22 +0,0 @@
uniform mat4 ModelMatrix;
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
layout(location = 3) in vec2 Texcoord;
layout(location = 4) in vec2 SecondTexcoord;
#else
in vec3 Position;
in vec2 Texcoord;
in vec2 SecondTexcoord;
#endif
out vec2 uv;
out vec2 uv_bis;
out float camdist;
void main() {
gl_Position = ProjectionViewMatrix * ModelMatrix * vec4(Position, 1.);
uv = Texcoord;
uv_bis = SecondTexcoord;
camdist = length(ViewMatrix * ModelMatrix * vec4(Position, 1.));
}

View File

@ -41,7 +41,7 @@ out vec3 bitangent;
out vec2 uv;
out vec2 uv_bis;
out vec4 color;
out float camdist;
void main(void)
{
@ -56,4 +56,5 @@ void main(void)
bitangent = (ViewMatrix * ModelMatrix * vec4(Bitangent, 0.)).xyz;
uv = vec2(Texcoord.x + texture_trans.x, Texcoord.y + texture_trans.y);
uv_bis = SecondTexcoord;
camdist = length(ViewMatrix * ModelMatrix * vec4(Position, 1.));
}

View File

@ -384,6 +384,7 @@ void AbstractGeometryPasses::renderTransparent(const DrawCalls& draw_calls,
mesh.textures[0]->getOpenGLTextureName());
DisplaceShader::getInstance()->use();
DisplaceShader::getInstance()->setUniforms(AbsoluteTransformation,
mesh.texture_trans,
core::vector2df(cb->getDirX(), cb->getDirY()),
core::vector2df(cb->getDir2X(), cb->getDir2Y()));

View File

@ -329,7 +329,7 @@ InstancedRefShadowShader::InstancedRefShadowShader()
// ============================================================================
DisplaceMaskShader::DisplaceMaskShader()
{
loadProgram(OBJECT, GL_VERTEX_SHADER, "displace.vert",
loadProgram(OBJECT, GL_VERTEX_SHADER, "object_pass.vert",
GL_FRAGMENT_SHADER, "white.frag");
assignUniforms("ModelMatrix");
} // DisplaceMaskShader
@ -337,9 +337,9 @@ DisplaceMaskShader::DisplaceMaskShader()
// ============================================================================
DisplaceShader::DisplaceShader()
{
loadProgram(OBJECT, GL_VERTEX_SHADER, "displace.vert",
loadProgram(OBJECT, GL_VERTEX_SHADER, "object_pass.vert",
GL_FRAGMENT_SHADER, "displace.frag");
assignUniforms("ModelMatrix", "dir", "dir2");
assignUniforms("ModelMatrix", "texture_trans", "dir", "dir2");
assignSamplerNames(0, "displacement_tex", ST_BILINEAR_FILTERED,
1, "color_tex", ST_BILINEAR_FILTERED,
2, "mask_tex", ST_BILINEAR_FILTERED,

View File

@ -212,7 +212,8 @@ public:
// ============================================================================
class DisplaceShader : public TextureShader<DisplaceShader, 4, core::matrix4,
core::vector2df, core::vector2df>
core::vector2df, core::vector2df,
core::vector2df>
{
public:
DisplaceShader();