mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 14:53:01 +02:00
FIx the problem with cauterizedClusterMatrices in the case rear view mirror is used. Clean the way to define the depth stencil format for texture
This commit is contained in:
parent
6c75daa027
commit
0a351a8a0c
5 changed files with 32 additions and 22 deletions
|
@ -50,6 +50,11 @@ public:
|
||||||
case gpu::DEPTH:
|
case gpu::DEPTH:
|
||||||
texel.internalFormat = GL_DEPTH_COMPONENT;
|
texel.internalFormat = GL_DEPTH_COMPONENT;
|
||||||
break;
|
break;
|
||||||
|
case gpu::DEPTH_STENCIL:
|
||||||
|
texel.type = GL_UNSIGNED_INT_24_8;
|
||||||
|
texel.format = GL_DEPTH_STENCIL;
|
||||||
|
texel.internalFormat = GL_DEPTH24_STENCIL8;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
qCDebug(gpulogging) << "Unknown combination of texel format";
|
qCDebug(gpulogging) << "Unknown combination of texel format";
|
||||||
}
|
}
|
||||||
|
@ -65,11 +70,6 @@ public:
|
||||||
case gpu::RGBA:
|
case gpu::RGBA:
|
||||||
texel.internalFormat = GL_RG;
|
texel.internalFormat = GL_RG;
|
||||||
break;
|
break;
|
||||||
case gpu::DEPTH_STENCIL:
|
|
||||||
texel.type = GL_UNSIGNED_INT_24_8;
|
|
||||||
texel.format = GL_DEPTH_STENCIL;
|
|
||||||
texel.internalFormat = GL_DEPTH24_STENCIL8;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
qCDebug(gpulogging) << "Unknown combination of texel format";
|
qCDebug(gpulogging) << "Unknown combination of texel format";
|
||||||
}
|
}
|
||||||
|
@ -182,6 +182,11 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case gpu::DEPTH_STENCIL:
|
||||||
|
texel.type = GL_UNSIGNED_INT_24_8;
|
||||||
|
texel.format = GL_DEPTH_STENCIL;
|
||||||
|
texel.internalFormat = GL_DEPTH24_STENCIL8;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
qCDebug(gpulogging) << "Unknown combination of texel format";
|
qCDebug(gpulogging) << "Unknown combination of texel format";
|
||||||
}
|
}
|
||||||
|
@ -198,11 +203,6 @@ public:
|
||||||
case gpu::RGBA:
|
case gpu::RGBA:
|
||||||
texel.internalFormat = GL_RG;
|
texel.internalFormat = GL_RG;
|
||||||
break;
|
break;
|
||||||
case gpu::DEPTH_STENCIL:
|
|
||||||
texel.type = GL_UNSIGNED_INT_24_8;
|
|
||||||
texel.format = GL_DEPTH_STENCIL;
|
|
||||||
texel.internalFormat = GL_DEPTH24_STENCIL8;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
qCDebug(gpulogging) << "Unknown combination of texel format";
|
qCDebug(gpulogging) << "Unknown combination of texel format";
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ void FramebufferCache::createPrimaryFramebuffer() {
|
||||||
auto depthFormat = gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::DEPTH);
|
auto depthFormat = gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::DEPTH);
|
||||||
_primaryDepthTexture = gpu::TexturePointer(gpu::Texture::create2D(depthFormat, width, height, defaultSampler));
|
_primaryDepthTexture = gpu::TexturePointer(gpu::Texture::create2D(depthFormat, width, height, defaultSampler));
|
||||||
|
|
||||||
auto stencilFormat = gpu::Element(gpu::VEC2, gpu::UINT32, gpu::DEPTH_STENCIL);
|
auto stencilFormat = gpu::Element(gpu::SCALAR, gpu::UINT32, gpu::DEPTH_STENCIL); // Depth24_Stencil8 texel format
|
||||||
_primaryStencilTexture = gpu::TexturePointer(gpu::Texture::create2D(stencilFormat, width, height, defaultSampler));
|
_primaryStencilTexture = gpu::TexturePointer(gpu::Texture::create2D(stencilFormat, width, height, defaultSampler));
|
||||||
|
|
||||||
_primaryFramebufferFull->setDepthStencilBuffer(_primaryDepthTexture, depthFormat);
|
_primaryFramebufferFull->setDepthStencilBuffer(_primaryDepthTexture, depthFormat);
|
||||||
|
|
|
@ -212,7 +212,11 @@ void MeshPartPayload::bindTransform(gpu::Batch& batch, const ModelRender::Locati
|
||||||
|
|
||||||
Transform transform;
|
Transform transform;
|
||||||
if (state.clusterBuffer) {
|
if (state.clusterBuffer) {
|
||||||
batch.setUniformBuffer(ModelRender::SKINNING_GPU_SLOT, state.clusterBuffer);
|
if (model->_cauterizeBones) {
|
||||||
|
batch.setUniformBuffer(ModelRender::SKINNING_GPU_SLOT, state.cauterizedClusterBuffer);
|
||||||
|
} else {
|
||||||
|
batch.setUniformBuffer(ModelRender::SKINNING_GPU_SLOT, state.clusterBuffer);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (model->_cauterizeBones) {
|
if (model->_cauterizeBones) {
|
||||||
transform = Transform(state.cauterizedClusterMatrices[0]);
|
transform = Transform(state.cauterizedClusterMatrices[0]);
|
||||||
|
|
|
@ -167,9 +167,7 @@ bool Model::updateGeometry() {
|
||||||
MeshState state;
|
MeshState state;
|
||||||
state.clusterMatrices.resize(mesh.clusters.size());
|
state.clusterMatrices.resize(mesh.clusters.size());
|
||||||
state.cauterizedClusterMatrices.resize(mesh.clusters.size());
|
state.cauterizedClusterMatrices.resize(mesh.clusters.size());
|
||||||
if (mesh.clusters.size() > 1) {
|
|
||||||
state.clusterBuffer = std::make_shared<gpu::Buffer>(mesh.clusters.size() * sizeof(glm::mat4), nullptr);
|
|
||||||
}
|
|
||||||
_meshStates.append(state);
|
_meshStates.append(state);
|
||||||
|
|
||||||
auto buffer = std::make_shared<gpu::Buffer>();
|
auto buffer = std::make_shared<gpu::Buffer>();
|
||||||
|
@ -1006,15 +1004,21 @@ void Model::updateClusterMatrices() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Once computed the cluster matrices, update the buffer
|
// Once computed the cluster matrices, update the buffer(s)
|
||||||
if (state.clusterBuffer) {
|
if (mesh.clusters.size() > 1) {
|
||||||
const float* bones;
|
if (!state.clusterBuffer) {
|
||||||
if (_cauterizeBones) {
|
state.clusterBuffer = std::make_shared<gpu::Buffer>(state.clusterMatrices.size() * sizeof(glm::mat4), (const gpu::Byte*) state.clusterMatrices.constData());
|
||||||
bones = (const float*)state.cauterizedClusterMatrices.constData();
|
|
||||||
} else {
|
} else {
|
||||||
bones = (const float*)state.clusterMatrices.constData();
|
state.clusterBuffer->setSubData(0, state.clusterMatrices.size() * sizeof(glm::mat4), (const gpu::Byte*) state.clusterMatrices.constData());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_cauterizeBoneSet.empty() && (state.cauterizedClusterMatrices.size() > 1)) {
|
||||||
|
if (!state.cauterizedClusterBuffer) {
|
||||||
|
state.cauterizedClusterBuffer = std::make_shared<gpu::Buffer>(state.cauterizedClusterMatrices.size() * sizeof(glm::mat4), (const gpu::Byte*) state.cauterizedClusterMatrices.constData());
|
||||||
|
} else {
|
||||||
|
state.cauterizedClusterBuffer->setSubData(0, state.cauterizedClusterMatrices.size() * sizeof(glm::mat4), (const gpu::Byte*) state.cauterizedClusterMatrices.constData());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
state.clusterBuffer->setSubData(0, state.clusterMatrices.size() * sizeof(glm::mat4), (const gpu::Byte*) bones);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -256,6 +256,8 @@ protected:
|
||||||
QVector<glm::mat4> clusterMatrices;
|
QVector<glm::mat4> clusterMatrices;
|
||||||
QVector<glm::mat4> cauterizedClusterMatrices;
|
QVector<glm::mat4> cauterizedClusterMatrices;
|
||||||
gpu::BufferPointer clusterBuffer;
|
gpu::BufferPointer clusterBuffer;
|
||||||
|
gpu::BufferPointer cauterizedClusterBuffer;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QVector<MeshState> _meshStates;
|
QVector<MeshState> _meshStates;
|
||||||
|
|
Loading…
Reference in a new issue