Use the drawing resolution in the case of non-linear projections correctly (closes #2745)

This commit is contained in:
Alexander Bock
2023-06-06 17:17:17 +02:00
parent 5a47b20983
commit c78b41c645
3 changed files with 17 additions and 12 deletions

View File

@@ -97,6 +97,7 @@ const BaseViewport* currentViewport = nullptr;
Frustum::Mode currentFrustumMode;
glm::mat4 currentModelViewProjectionMatrix;
glm::mat4 currentModelMatrix;
glm::ivec2 currentDrawResolution;
#ifdef OPENVR_SUPPORT
Window* FirstOpenVRWindow = nullptr;
@@ -449,6 +450,7 @@ void mainRenderFunc(const sgct::RenderData& data) {
currentWindow = &data.window;
currentViewport = &data.viewport;
currentFrustumMode = data.frustumMode;
currentDrawResolution = glm::ivec2(data.bufferSize.x, data.bufferSize.y);
glm::vec3 pos;
std::memcpy(
@@ -533,6 +535,7 @@ void mainDraw2DFunc(const sgct::RenderData& data) {
currentWindow = &data.window;
currentViewport = &data.viewport;
currentFrustumMode = data.frustumMode;
currentDrawResolution = glm::ivec2(data.bufferSize.x, data.bufferSize.y);
try {
global::openSpaceEngine->drawOverlays();
@@ -766,7 +769,7 @@ void setSgctDelegateFunctions() {
ZoneScoped;
const Viewport* viewport = dynamic_cast<const Viewport*>(currentViewport);
if (viewport != nullptr) {
if (viewport) {
if (viewport->hasSubViewports() && viewport->nonLinearProjection()) {
ivec2 dim = viewport->nonLinearProjection()->cubemapResolution();
return glm::ivec2(dim.x, dim.y);
@@ -776,7 +779,9 @@ void setSgctDelegateFunctions() {
return glm::ivec2(dim.x, dim.y);
}
}
return glm::ivec2(-1, -1);
else {
return currentDrawResolution;
}
};
sgctDelegate.currentViewportSize = []() {
ZoneScoped;

View File

@@ -231,6 +231,15 @@ void ShadowComponent::deinitializeGL() {
}
RenderData ShadowComponent::begin(const RenderData& data) {
glm::ivec2 renderingResolution = global::renderEngine->renderingResolution();
if (_dynamicDepthTextureRes && ((_shadowDepthTextureWidth != renderingResolution.x) ||
(_shadowDepthTextureHeight != renderingResolution.y)))
{
_shadowDepthTextureWidth = renderingResolution.x * 2;
_shadowDepthTextureHeight = renderingResolution.y * 2;
updateDepthTexture();
}
// ===========================================
// Builds light's ModelViewProjectionMatrix:
// ===========================================
@@ -375,15 +384,6 @@ void ShadowComponent::update(const UpdateData&) {
else {
_sunPosition = glm::dvec3(0.0);
}
glm::ivec2 renderingResolution = global::renderEngine->renderingResolution();
if (_dynamicDepthTextureRes && ((_shadowDepthTextureWidth != renderingResolution.x) ||
(_shadowDepthTextureHeight != renderingResolution.y)))
{
_shadowDepthTextureWidth = renderingResolution.x * 2;
_shadowDepthTextureHeight = renderingResolution.y * 2;
updateDepthTexture();
}
}
void ShadowComponent::createDepthTexture() {