Allow using animated texture with displace shader
Plus some clean-up
This commit is contained in:
parent
6a03f147f6
commit
850afc8620
@ -6,7 +6,6 @@ uniform vec2 dir;
|
|||||||
uniform vec2 dir2;
|
uniform vec2 dir2;
|
||||||
|
|
||||||
in vec2 uv;
|
in vec2 uv;
|
||||||
in vec2 uv_bis;
|
|
||||||
in float camdist;
|
in float camdist;
|
||||||
|
|
||||||
out vec4 FragColor;
|
out vec4 FragColor;
|
||||||
|
@ -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.));
|
|
||||||
}
|
|
@ -41,7 +41,7 @@ out vec3 bitangent;
|
|||||||
out vec2 uv;
|
out vec2 uv;
|
||||||
out vec2 uv_bis;
|
out vec2 uv_bis;
|
||||||
out vec4 color;
|
out vec4 color;
|
||||||
|
out float camdist;
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
@ -56,4 +56,5 @@ void main(void)
|
|||||||
bitangent = (ViewMatrix * ModelMatrix * vec4(Bitangent, 0.)).xyz;
|
bitangent = (ViewMatrix * ModelMatrix * vec4(Bitangent, 0.)).xyz;
|
||||||
uv = vec2(Texcoord.x + texture_trans.x, Texcoord.y + texture_trans.y);
|
uv = vec2(Texcoord.x + texture_trans.x, Texcoord.y + texture_trans.y);
|
||||||
uv_bis = SecondTexcoord;
|
uv_bis = SecondTexcoord;
|
||||||
|
camdist = length(ViewMatrix * ModelMatrix * vec4(Position, 1.));
|
||||||
}
|
}
|
||||||
|
@ -384,6 +384,7 @@ void AbstractGeometryPasses::renderTransparent(const DrawCalls& draw_calls,
|
|||||||
mesh.textures[0]->getOpenGLTextureName());
|
mesh.textures[0]->getOpenGLTextureName());
|
||||||
DisplaceShader::getInstance()->use();
|
DisplaceShader::getInstance()->use();
|
||||||
DisplaceShader::getInstance()->setUniforms(AbsoluteTransformation,
|
DisplaceShader::getInstance()->setUniforms(AbsoluteTransformation,
|
||||||
|
mesh.texture_trans,
|
||||||
core::vector2df(cb->getDirX(), cb->getDirY()),
|
core::vector2df(cb->getDirX(), cb->getDirY()),
|
||||||
core::vector2df(cb->getDir2X(), cb->getDir2Y()));
|
core::vector2df(cb->getDir2X(), cb->getDir2Y()));
|
||||||
|
|
||||||
|
@ -329,7 +329,7 @@ InstancedRefShadowShader::InstancedRefShadowShader()
|
|||||||
// ============================================================================
|
// ============================================================================
|
||||||
DisplaceMaskShader::DisplaceMaskShader()
|
DisplaceMaskShader::DisplaceMaskShader()
|
||||||
{
|
{
|
||||||
loadProgram(OBJECT, GL_VERTEX_SHADER, "displace.vert",
|
loadProgram(OBJECT, GL_VERTEX_SHADER, "object_pass.vert",
|
||||||
GL_FRAGMENT_SHADER, "white.frag");
|
GL_FRAGMENT_SHADER, "white.frag");
|
||||||
assignUniforms("ModelMatrix");
|
assignUniforms("ModelMatrix");
|
||||||
} // DisplaceMaskShader
|
} // DisplaceMaskShader
|
||||||
@ -337,9 +337,9 @@ DisplaceMaskShader::DisplaceMaskShader()
|
|||||||
// ============================================================================
|
// ============================================================================
|
||||||
DisplaceShader::DisplaceShader()
|
DisplaceShader::DisplaceShader()
|
||||||
{
|
{
|
||||||
loadProgram(OBJECT, GL_VERTEX_SHADER, "displace.vert",
|
loadProgram(OBJECT, GL_VERTEX_SHADER, "object_pass.vert",
|
||||||
GL_FRAGMENT_SHADER, "displace.frag");
|
GL_FRAGMENT_SHADER, "displace.frag");
|
||||||
assignUniforms("ModelMatrix", "dir", "dir2");
|
assignUniforms("ModelMatrix", "texture_trans", "dir", "dir2");
|
||||||
assignSamplerNames(0, "displacement_tex", ST_BILINEAR_FILTERED,
|
assignSamplerNames(0, "displacement_tex", ST_BILINEAR_FILTERED,
|
||||||
1, "color_tex", ST_BILINEAR_FILTERED,
|
1, "color_tex", ST_BILINEAR_FILTERED,
|
||||||
2, "mask_tex", ST_BILINEAR_FILTERED,
|
2, "mask_tex", ST_BILINEAR_FILTERED,
|
||||||
|
@ -212,7 +212,8 @@ public:
|
|||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
class DisplaceShader : public TextureShader<DisplaceShader, 4, core::matrix4,
|
class DisplaceShader : public TextureShader<DisplaceShader, 4, core::matrix4,
|
||||||
core::vector2df, core::vector2df>
|
core::vector2df, core::vector2df,
|
||||||
|
core::vector2df>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DisplaceShader();
|
DisplaceShader();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user