Merge branch 'master' of github.com:supertuxkart/stk-code
This commit is contained in:
commit
49fad934cd
@ -12,6 +12,7 @@ uniform sampler3D SHB;
|
||||
uniform float R_wcs = 10.;
|
||||
uniform vec3 extents;
|
||||
uniform mat4 RHMatrix;
|
||||
uniform mat4 InvRHMatrix;
|
||||
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
@ -55,7 +56,7 @@ void main()
|
||||
if (depth==1.0) discard;
|
||||
|
||||
vec4 pos_screen_space = getPosFromUVDepth(vec3(uv, depth), InverseProjectionMatrix);
|
||||
vec4 tmp = (inverse(RHMatrix) * InverseViewMatrix * pos_screen_space);
|
||||
vec4 tmp = (InvRHMatrix * InverseViewMatrix * pos_screen_space);
|
||||
vec3 pos = tmp.xyz / tmp.w;
|
||||
vec3 normal_screen_space = normalize(DecodeNormal(2. * texture(ntex, uv).xy - 1.));
|
||||
vec3 normal = (transpose(ViewMatrix) * vec4(normal_screen_space, 0.)).xyz;
|
||||
|
@ -244,6 +244,8 @@ void PostProcessing::renderDiffuseEnvMap(const float *bSHCoeff, const float *gSH
|
||||
|
||||
void PostProcessing::renderGI(const core::matrix4 &RHMatrix, const core::vector3df &rh_extend, GLuint shr, GLuint shg, GLuint shb)
|
||||
{
|
||||
core::matrix4 InvRHMatrix;
|
||||
RHMatrix.getInverse(InvRHMatrix);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glUseProgram(FullScreenShader::GlobalIlluminationReconstructionShader::Program);
|
||||
glBindVertexArray(FullScreenShader::GlobalIlluminationReconstructionShader::vao);
|
||||
@ -267,7 +269,7 @@ void PostProcessing::renderGI(const core::matrix4 &RHMatrix, const core::vector3
|
||||
}
|
||||
setTexture(3, irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), GL_NEAREST, GL_NEAREST);
|
||||
setTexture(4, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::GlobalIlluminationReconstructionShader::setUniforms(RHMatrix, rh_extend, 3, 4, 0, 1, 2);
|
||||
FullScreenShader::GlobalIlluminationReconstructionShader::setUniforms(RHMatrix, InvRHMatrix, rh_extend, 3, 4, 0, 1, 2);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
}
|
||||
|
||||
|
@ -648,7 +648,30 @@ void IrrDriver::renderTransparent()
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glDisable(GL_CULL_FACE);
|
||||
TransparentMeshes<TM_DEFAULT>::reset();
|
||||
TransparentMeshes<TM_ADDITIVE>::reset();
|
||||
m_scene_manager->drawAll(scene::ESNRP_TRANSPARENT);
|
||||
|
||||
if (World::getWorld() && World::getWorld()->isFogEnabled())
|
||||
{
|
||||
glUseProgram(MeshShader::TransparentFogShader::Program);
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
for (unsigned i = 0; i < TransparentMeshes<TM_DEFAULT>::MeshSet.size(); i++)
|
||||
drawTransparentFogObject(*TransparentMeshes<TM_DEFAULT>::MeshSet[i], TransparentMeshes<TM_DEFAULT>::MVPSet[i], TransparentMeshes<TM_DEFAULT>::MeshSet[i]->TextureMatrix);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
for (unsigned i = 0; i < TransparentMeshes<TM_ADDITIVE>::MeshSet.size(); i++)
|
||||
drawTransparentFogObject(*TransparentMeshes<TM_ADDITIVE>::MeshSet[i], TransparentMeshes<TM_ADDITIVE>::MVPSet[i], TransparentMeshes<TM_ADDITIVE>::MeshSet[i]->TextureMatrix);
|
||||
}
|
||||
else
|
||||
{
|
||||
glUseProgram(MeshShader::TransparentShader::Program);
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
for (unsigned i = 0; i < TransparentMeshes<TM_DEFAULT>::MeshSet.size(); i++)
|
||||
drawTransparentObject(*TransparentMeshes<TM_DEFAULT>::MeshSet[i], TransparentMeshes<TM_DEFAULT>::MVPSet[i], TransparentMeshes<TM_DEFAULT>::MeshSet[i]->TextureMatrix);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
for (unsigned i = 0; i < TransparentMeshes<TM_ADDITIVE>::MeshSet.size(); i++)
|
||||
drawTransparentObject(*TransparentMeshes<TM_ADDITIVE>::MeshSet[i], TransparentMeshes<TM_ADDITIVE>::MVPSet[i], TransparentMeshes<TM_ADDITIVE>::MeshSet[i]->TextureMatrix);
|
||||
}
|
||||
}
|
||||
|
||||
void IrrDriver::renderParticles()
|
||||
|
@ -2400,6 +2400,7 @@ namespace FullScreenShader
|
||||
GLuint GlobalIlluminationReconstructionShader::uniform_SHB;
|
||||
GLuint GlobalIlluminationReconstructionShader::uniform_extents;
|
||||
GLuint GlobalIlluminationReconstructionShader::uniform_RHMatrix;
|
||||
GLuint GlobalIlluminationReconstructionShader::uniform_InvRHMatrix;
|
||||
GLuint GlobalIlluminationReconstructionShader::vao;
|
||||
|
||||
void GlobalIlluminationReconstructionShader::init()
|
||||
@ -2415,15 +2416,17 @@ namespace FullScreenShader
|
||||
uniform_SHG = glGetUniformLocation(Program, "SHG");
|
||||
uniform_SHB = glGetUniformLocation(Program, "SHB");
|
||||
uniform_RHMatrix = glGetUniformLocation(Program, "RHMatrix");
|
||||
uniform_InvRHMatrix = glGetUniformLocation(Program, "InvRHMatrix");
|
||||
uniform_extents = glGetUniformLocation(Program, "extents");
|
||||
vao = createFullScreenVAO(Program);
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
void GlobalIlluminationReconstructionShader::setUniforms(const core::matrix4 &RHMatrix, const core::vector3df &extents, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_SHR, unsigned TU_SHG, unsigned TU_SHB)
|
||||
void GlobalIlluminationReconstructionShader::setUniforms(const core::matrix4 &RHMatrix, const core::matrix4 &InvRHMatrix, const core::vector3df &extents, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_SHR, unsigned TU_SHG, unsigned TU_SHB)
|
||||
{
|
||||
glUniformMatrix4fv(uniform_RHMatrix, 1, GL_FALSE, RHMatrix.pointer());
|
||||
glUniformMatrix4fv(uniform_InvRHMatrix, 1, GL_FALSE, InvRHMatrix.pointer());
|
||||
glUniform1i(uniform_ntex, TU_ntex);
|
||||
glUniform1i(uniform_dtex, TU_dtex);
|
||||
glUniform1i(uniform_SHR, TU_SHR);
|
||||
|
@ -624,11 +624,11 @@ class GlobalIlluminationReconstructionShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_ntex, uniform_dtex, uniform_extents, uniform_SHR, uniform_SHG, uniform_SHB, uniform_RHMatrix;
|
||||
static GLuint uniform_ntex, uniform_dtex, uniform_extents, uniform_SHR, uniform_SHG, uniform_SHB, uniform_RHMatrix, uniform_InvRHMatrix;
|
||||
static GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &RHMatrix, const core::vector3df &extents, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_SHR, unsigned TU_SHG, unsigned TU_SHB);
|
||||
static void setUniforms(const core::matrix4 &RHMatrix, const core::matrix4 &InvRHMatrix, const core::vector3df &extents, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_SHR, unsigned TU_SHG, unsigned TU_SHB);
|
||||
};
|
||||
|
||||
class Gaussian17TapHShader
|
||||
|
@ -227,30 +227,16 @@ void STKAnimatedMesh::render()
|
||||
glUseProgram(MeshShader::BubbleShader::Program);
|
||||
|
||||
GLMesh* mesh;
|
||||
for_in(mesh, TransparentMesh[TM_BUBBLE])
|
||||
drawBubble(*mesh, ModelViewProjectionMatrix);
|
||||
|
||||
if (World::getWorld() != NULL && World::getWorld()->isFogEnabled())
|
||||
for_in(mesh, TransparentMesh[TM_DEFAULT])
|
||||
{
|
||||
if (!TransparentMesh[TM_DEFAULT].empty() || !TransparentMesh[TM_ADDITIVE].empty())
|
||||
glUseProgram(MeshShader::TransparentFogShader::Program);
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
for_in(mesh, TransparentMesh[TM_DEFAULT])
|
||||
drawTransparentFogObject(*mesh, ModelViewProjectionMatrix, mesh->TextureMatrix);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
for_in(mesh, TransparentMesh[TM_ADDITIVE])
|
||||
drawTransparentFogObject(*mesh, ModelViewProjectionMatrix, mesh->TextureMatrix);
|
||||
TransparentMeshes<TM_DEFAULT>::MeshSet.push_back(mesh);
|
||||
TransparentMeshes<TM_DEFAULT>::MVPSet.push_back(ModelViewProjectionMatrix);
|
||||
}
|
||||
else
|
||||
|
||||
for_in(mesh, TransparentMesh[TM_ADDITIVE])
|
||||
{
|
||||
if (!TransparentMesh[TM_DEFAULT].empty() || !TransparentMesh[TM_ADDITIVE].empty())
|
||||
glUseProgram(MeshShader::TransparentShader::Program);
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
for_in(mesh, TransparentMesh[TM_DEFAULT])
|
||||
drawTransparentObject(*mesh, ModelViewProjectionMatrix, mesh->TextureMatrix);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
for_in(mesh, TransparentMesh[TM_ADDITIVE])
|
||||
drawTransparentObject(*mesh, ModelViewProjectionMatrix, mesh->TextureMatrix);
|
||||
TransparentMeshes<TM_ADDITIVE>::MeshSet.push_back(mesh);
|
||||
TransparentMeshes<TM_ADDITIVE>::MVPSet.push_back(ModelViewProjectionMatrix);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -147,6 +147,25 @@ void drawObjectUnlit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectio
|
||||
void drawShadowRef(const GLMesh &mesh, const core::matrix4 &ModelMatrix);
|
||||
void drawShadow(const GLMesh &mesh, const core::matrix4 &ModelMatrix);
|
||||
|
||||
template<enum TransparentMaterial T>
|
||||
class TransparentMeshes
|
||||
{
|
||||
public:
|
||||
static std::vector<GLMesh *> MeshSet;
|
||||
static std::vector<core::matrix4> MVPSet;
|
||||
|
||||
static void reset()
|
||||
{
|
||||
MeshSet.clear();
|
||||
MVPSet.clear();
|
||||
}
|
||||
};
|
||||
|
||||
template<enum TransparentMaterial T>
|
||||
std::vector<GLMesh *> TransparentMeshes<T>::MeshSet;
|
||||
template<enum TransparentMaterial T>
|
||||
std::vector<core::matrix4> TransparentMeshes<T>::MVPSet;
|
||||
|
||||
// Forward pass (for transparents meshes)
|
||||
void drawTransparentObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix);
|
||||
void drawTransparentFogObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix);
|
||||
|
@ -209,33 +209,9 @@ void STKMeshSceneNode::drawSolidPass2(const GLMesh &mesh, ShadedMaterial type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case SM_SPHEREMAP:
|
||||
drawSphereMap(mesh, ModelViewProjectionMatrix, TransposeInverseModelView);
|
||||
break;
|
||||
case SM_SPLATTING:
|
||||
drawSplatting(mesh, ModelViewProjectionMatrix);
|
||||
break;
|
||||
case SM_ALPHA_REF_TEXTURE:
|
||||
drawObjectRefPass2(mesh, ModelViewProjectionMatrix, mesh.TextureMatrix);
|
||||
break;
|
||||
case SM_GRASS:
|
||||
drawGrassPass2(mesh, ModelViewProjectionMatrix, windDir);
|
||||
break;
|
||||
case SM_RIMLIT:
|
||||
drawObjectRimLimit(mesh, ModelViewProjectionMatrix, TransposeInverseModelView, core::matrix4::EM4CONST_IDENTITY);
|
||||
break;
|
||||
case SM_UNLIT:
|
||||
drawObjectUnlit(mesh, ModelViewProjectionMatrix);
|
||||
break;
|
||||
case SM_DETAILS:
|
||||
drawDetailledObjectPass2(mesh, ModelViewProjectionMatrix);
|
||||
break;
|
||||
case SM_UNTEXTURED:
|
||||
drawUntexturedObject(mesh, ModelViewProjectionMatrix);
|
||||
break;
|
||||
case SM_DEFAULT:
|
||||
drawObjectPass2(mesh, ModelViewProjectionMatrix, mesh.TextureMatrix);
|
||||
break;
|
||||
default:
|
||||
assert(0 && "Wrong shaded material");
|
||||
break;
|
||||
@ -440,33 +416,23 @@ void STKMeshSceneNode::render()
|
||||
ModelViewProjectionMatrix = computeMVP(AbsoluteTransformation);
|
||||
|
||||
GLMesh* mesh;
|
||||
|
||||
for_in(mesh, TransparentMesh[TM_DEFAULT])
|
||||
{
|
||||
TransparentMeshes<TM_DEFAULT>::MeshSet.push_back(mesh);
|
||||
TransparentMeshes<TM_DEFAULT>::MVPSet.push_back(ModelViewProjectionMatrix);
|
||||
}
|
||||
|
||||
for_in(mesh, TransparentMesh[TM_ADDITIVE])
|
||||
{
|
||||
TransparentMeshes<TM_ADDITIVE>::MeshSet.push_back(mesh);
|
||||
TransparentMeshes<TM_ADDITIVE>::MVPSet.push_back(ModelViewProjectionMatrix);
|
||||
}
|
||||
|
||||
if (!TransparentMesh[TM_BUBBLE].empty())
|
||||
glUseProgram(MeshShader::BubbleShader::Program);
|
||||
for_in(mesh, TransparentMesh[TM_BUBBLE])
|
||||
drawBubble(*mesh, ModelViewProjectionMatrix);
|
||||
|
||||
if (World::getWorld() ->isFogEnabled())
|
||||
{
|
||||
if (!TransparentMesh[TM_DEFAULT].empty() || !TransparentMesh[TM_ADDITIVE].empty())
|
||||
glUseProgram(MeshShader::TransparentFogShader::Program);
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
for_in(mesh, TransparentMesh[TM_DEFAULT])
|
||||
drawTransparentFogObject(*mesh, ModelViewProjectionMatrix, (*mesh).TextureMatrix);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
for_in(mesh, TransparentMesh[TM_ADDITIVE])
|
||||
drawTransparentFogObject(*mesh, ModelViewProjectionMatrix, (*mesh).TextureMatrix);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!TransparentMesh[TM_DEFAULT].empty() || !TransparentMesh[TM_ADDITIVE].empty())
|
||||
glUseProgram(MeshShader::TransparentShader::Program);
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
for_in(mesh, TransparentMesh[TM_DEFAULT])
|
||||
drawTransparentObject(*mesh, ModelViewProjectionMatrix, (*mesh).TextureMatrix);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
for_in(mesh, TransparentMesh[TM_ADDITIVE])
|
||||
drawTransparentObject(*mesh, ModelViewProjectionMatrix, (*mesh).TextureMatrix);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user