Add manual depth test between models

This commit is contained in:
Malin E
2022-12-07 14:19:12 +01:00
parent eafbb89e1e
commit 560c58e499
6 changed files with 99 additions and 8 deletions

View File

@@ -77,11 +77,11 @@ namespace {
"Enable or disable the animation for the model if it has any"
};
constexpr std::array<const char*, 10> UniformNames = {
constexpr std::array<const char*, 11> UniformNames = {
"nLightSources", "lightDirectionsViewSpace", "lightIntensities",
"modelViewTransform", "normalTransform", "projectionTransform",
"performShading", "ambientIntensity", "diffuseIntensity",
"specularIntensity"
"specularIntensity", "gBufferDepthTexture"
};
constexpr std::array<const char*, 5> UniformOpacityNames = {
@@ -740,6 +740,18 @@ void RenderableModel::render(const RenderData& data, RendererTasks&) {
_program->setUniform(_uniformCache.specularIntensity, _specularIntensity);
_program->setUniform(_uniformCache.performShading, _performShading);
// Bind the G-buffer depth texture for a manual depth test for the second pass
ghoul::opengl::TextureUnit gBufferDepthTextureUnit;
gBufferDepthTextureUnit.activate();
glBindTexture(
GL_TEXTURE_2D,
global::renderEngine->renderer()->gBufferDepthTexture()
);
_program->setUniform(
_uniformCache.gBufferDepthTexture,
gBufferDepthTextureUnit
);
// Configure blending
glEnablei(GL_BLEND, 0);
switch (_blendingFuncOption) {