Fix hole cutting or side by side stereo

* And disable face culling for Orion model that is a one sided plane
This commit is contained in:
Malin E
2023-03-08 11:49:55 +01:00
parent a3b5300684
commit 184a8b59ac
5 changed files with 8 additions and 45 deletions

View File

@@ -73,12 +73,12 @@ namespace {
GL_COLOR_ATTACHMENT2,
};
constexpr std::array<const char*, 14> UniformNames = {
constexpr std::array<const char*, 13> UniformNames = {
"nLightSources", "lightDirectionsViewSpace", "lightIntensities",
"modelViewTransform", "normalTransform", "projectionTransform",
"performShading", "ambientIntensity", "diffuseIntensity",
"specularIntensity", "performManualDepthTest", "gBufferDepthTexture",
"viewport", "resolution"
"resolution"
};
constexpr std::array<const char*, 3> UniformOpacityNames = {
@@ -833,24 +833,13 @@ void RenderableModel::render(const RenderData& data, RendererTasks&) {
gBufferDepthTextureUnit
);
// Will also need the resolution and viewport to get a texture coordinate for the
// G-buffer depth texture
// Will also need the resolution to get a texture coordinate for the G-buffer
// depth texture
_program->setUniform(
_uniformCache.resolution,
glm::vec2(global::windowDelegate->currentDrawBufferResolution())
);
GLint vp[4] = { 0 };
global::renderEngine->openglStateCache().viewport(vp);
glm::ivec4 viewport = glm::ivec4(vp[0], vp[1], vp[2], vp[3]);
_program->setUniform(
_uniformCache.viewport,
static_cast<float>(viewport[0]),
static_cast<float>(viewport[1]),
static_cast<float>(viewport[2]),
static_cast<float>(viewport[3])
);
// Render Pass 1
// Render all parts of the model into the new framebuffer without opacity
_geometry->render(*_program);

View File

@@ -106,7 +106,7 @@ private:
modelViewTransform, normalTransform, projectionTransform,
performShading, ambientIntensity, diffuseIntensity,
specularIntensity, performManualDepthTest, gBufferDepthTexture,
viewport, resolution) _uniformCache;
resolution) _uniformCache;
std::vector<std::unique_ptr<LightSource>> _lightSources;

View File

@@ -55,7 +55,6 @@ uniform float lightIntensities[8];
uniform bool performManualDepthTest = false;
uniform sampler2D gBufferDepthTexture;
uniform vec4 viewport;
uniform vec2 resolution;
Fragment getFragment() {
@@ -73,20 +72,8 @@ Fragment getFragment() {
texCoord.x = texCoord.x / resolution.x;
texCoord.y = texCoord.y / resolution.y;
// Modify the texCoord based on the Viewport and Resolution. This modification is
// necessary in case of side-by-side stereo as we only want to access the part of the
// feeding texture that we are currently responsible for. Otherwise we would map the
// entire feeding texture into our half of the result texture, leading to a doubling
// of the "missing" half. If you don't believe me, load a configuration file with the
// side_by_side stereo mode enabled, disable FXAA, and remove this modification.
// The same calculation is done in the FXAA shader, the HDR resolving and the
// atmosphere shader
vec2 st = texCoord;
st.x = st.x / (resolution.x / viewport[2]) + (viewport[0] / resolution.x);
st.y = st.y / (resolution.y / viewport[3]) + (viewport[1] / resolution.y);
// Manual depth test
float gBufferDepth = denormalizeFloat(texture(gBufferDepthTexture, st).x);
float gBufferDepth = denormalizeFloat(texture(gBufferDepthTexture, texCoord).x);
if (vs_screenSpaceDepth > gBufferDepth) {
frag.color = vec4(0.0);
frag.depth = gBufferDepth;