Mix texture for displace.
This commit is contained in:
parent
25b5134881
commit
4c3db6ca59
@ -1,6 +1,7 @@
|
||||
uniform sampler2D displacement_tex;
|
||||
uniform sampler2D mask_tex;
|
||||
uniform sampler2D color_tex;
|
||||
uniform sampler2D tex;
|
||||
uniform vec2 dir;
|
||||
uniform vec2 dir2;
|
||||
|
||||
@ -64,5 +65,8 @@ void main()
|
||||
float mask = texture(mask_tex, tc + shift).x;
|
||||
tc += (mask < 1.) ? vec2(0.) : shift;
|
||||
|
||||
FragColor = texture(color_tex, tc);
|
||||
vec4 col = texture(color_tex, tc);
|
||||
vec4 blend_tex = texture(tex, uv);
|
||||
col.rgb = blend_tex.rgb * blend_tex.a + (1. - blend_tex.a) * col.rgb;
|
||||
FragColor = vec4(col.rgb, 1.);
|
||||
}
|
||||
|
@ -1537,6 +1537,7 @@ namespace MeshShader
|
||||
GLuint DisplaceShader::uniform_displacement_tex;
|
||||
GLuint DisplaceShader::uniform_mask_tex;
|
||||
GLuint DisplaceShader::uniform_color_tex;
|
||||
GLuint DisplaceShader::uniform_tex;
|
||||
GLuint DisplaceShader::uniform_dir;
|
||||
GLuint DisplaceShader::uniform_dir2;
|
||||
|
||||
@ -1551,11 +1552,12 @@ namespace MeshShader
|
||||
uniform_mask_tex = glGetUniformLocation(Program, "mask_tex");
|
||||
uniform_dir = glGetUniformLocation(Program, "dir");
|
||||
uniform_dir2 = glGetUniformLocation(Program, "dir2");
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
void DisplaceShader::setUniforms(const core::matrix4 &ModelMatrix, const core::vector2df &dir, const core::vector2df &dir2, const core::vector2df &screen, unsigned TU_displacement_tex, unsigned TU_mask_tex, unsigned TU_color_tex)
|
||||
void DisplaceShader::setUniforms(const core::matrix4 &ModelMatrix, const core::vector2df &dir, const core::vector2df &dir2, const core::vector2df &screen, unsigned TU_displacement_tex, unsigned TU_mask_tex, unsigned TU_color_tex, unsigned TU_tex)
|
||||
{
|
||||
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelMatrix.pointer());
|
||||
glUniform2f(uniform_dir, dir.X, dir.Y);
|
||||
@ -1563,6 +1565,7 @@ namespace MeshShader
|
||||
glUniform1i(uniform_displacement_tex, TU_displacement_tex);
|
||||
glUniform1i(uniform_mask_tex, TU_mask_tex);
|
||||
glUniform1i(uniform_color_tex, TU_color_tex);
|
||||
glUniform1i(uniform_tex, TU_tex);
|
||||
}
|
||||
|
||||
GLuint SkyboxShader::Program;
|
||||
|
@ -375,10 +375,10 @@ class DisplaceShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_MVP, uniform_displacement_tex, uniform_mask_tex, uniform_color_tex, uniform_dir, uniform_dir2;
|
||||
static GLuint uniform_MVP, uniform_displacement_tex, uniform_mask_tex, uniform_color_tex, uniform_tex, uniform_dir, uniform_dir2;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelMatrix, const core::vector2df &dir, const core::vector2df &dir2, const core::vector2df &screen, unsigned TU_displacement_tex, unsigned TU_mask_tex, unsigned TU_color_tex);
|
||||
static void setUniforms(const core::matrix4 &ModelMatrix, const core::vector2df &dir, const core::vector2df &dir2, const core::vector2df &screen, unsigned TU_displacement_tex, unsigned TU_mask_tex, unsigned TU_color_tex, unsigned TU_tex);
|
||||
};
|
||||
|
||||
class SkyboxShader
|
||||
|
@ -141,7 +141,7 @@ void STKMeshSceneNode::drawGlow(const GLMesh &mesh)
|
||||
size_t count = mesh.IndexCount;
|
||||
|
||||
MeshShader::ColorizeShader::setUniforms(AbsoluteTransformation, cb->getRed(), cb->getGreen(), cb->getBlue());
|
||||
glDrawElementsInstancedBaseVertex(ptype, count, itype, (GLvoid *)mesh.vaoOffset, 4, mesh.vaoBaseVertex);
|
||||
glDrawElementsBaseVertex(ptype, count, itype, (GLvoid *)mesh.vaoOffset, mesh.vaoBaseVertex);
|
||||
}
|
||||
|
||||
static video::ITexture *displaceTex = 0;
|
||||
@ -166,7 +166,7 @@ void STKMeshSceneNode::drawDisplace(const GLMesh &mesh)
|
||||
|
||||
glUseProgram(MeshShader::DisplaceMaskShader::Program);
|
||||
MeshShader::DisplaceMaskShader::setUniforms(AbsoluteTransformation);
|
||||
glDrawElementsInstancedBaseVertex(ptype, count, itype, (GLvoid *)mesh.vaoOffset, 4, mesh.vaoBaseVertex);
|
||||
glDrawElementsBaseVertex(ptype, count, itype, (GLvoid *)mesh.vaoOffset, mesh.vaoBaseVertex);
|
||||
|
||||
// Render the effect
|
||||
if (!displaceTex)
|
||||
@ -175,15 +175,16 @@ void STKMeshSceneNode::drawDisplace(const GLMesh &mesh)
|
||||
setTexture(0, getTextureGLuint(displaceTex), GL_LINEAR, GL_LINEAR, true);
|
||||
setTexture(1, irr_driver->getRenderTargetTexture(RTT_TMP1), GL_LINEAR, GL_LINEAR, true);
|
||||
setTexture(2, irr_driver->getRenderTargetTexture(RTT_COLOR), GL_LINEAR, GL_LINEAR, true);
|
||||
setTexture(3, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR, true);
|
||||
glUseProgram(MeshShader::DisplaceShader::Program);
|
||||
MeshShader::DisplaceShader::setUniforms(AbsoluteTransformation,
|
||||
core::vector2df(cb->getDirX(), cb->getDirY()),
|
||||
core::vector2df(cb->getDir2X(), cb->getDir2Y()),
|
||||
core::vector2df(float(UserConfigParams::m_width),
|
||||
float(UserConfigParams::m_height)),
|
||||
0, 1, 2);
|
||||
0, 1, 2, 3);
|
||||
|
||||
glDrawElementsInstancedBaseVertex(ptype, count, itype, (GLvoid *)mesh.vaoOffset, 4, mesh.vaoBaseVertex);
|
||||
glDrawElementsBaseVertex(ptype, count, itype, (GLvoid *)mesh.vaoOffset, mesh.vaoBaseVertex);
|
||||
}
|
||||
|
||||
void STKMeshSceneNode::drawTransparent(const GLMesh &mesh, video::E_MATERIAL_TYPE type)
|
||||
|
Loading…
Reference in New Issue
Block a user