Check for nan in camera setting (closes #1686), add tracy zones to atmosphere rendering

This commit is contained in:
Alexander Bock
2021-07-23 14:17:16 +02:00
parent d38968a5ad
commit 817621617e
2 changed files with 34 additions and 11 deletions
@@ -525,6 +525,8 @@ void AtmosphereDeferredcaster::setHardShadows(bool enabled) {
}
void AtmosphereDeferredcaster::calculateTransmittance() {
ZoneScoped
glFramebufferTexture(
GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT0,
@@ -560,6 +562,8 @@ void AtmosphereDeferredcaster::calculateTransmittance() {
}
GLuint AtmosphereDeferredcaster::calculateDeltaE() {
ZoneScoped
GLuint deltaE = createTexture(_deltaETableSize, "DeltaE");
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, deltaE, 0);
glViewport(0, 0, _deltaETableSize.x, _deltaETableSize.y);
@@ -587,6 +591,8 @@ GLuint AtmosphereDeferredcaster::calculateDeltaE() {
}
std::pair<GLuint, GLuint> AtmosphereDeferredcaster::calculateDeltaS() {
ZoneScoped
GLuint deltaSRayleigh = createTexture(_textureSize, "DeltaS Rayleigh", 3);
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, deltaSRayleigh, 0);
GLuint deltaSMie = createTexture(_textureSize, "DeltaS Mie", 3);
@@ -639,6 +645,8 @@ std::pair<GLuint, GLuint> AtmosphereDeferredcaster::calculateDeltaS() {
}
void AtmosphereDeferredcaster::calculateIrradiance() {
ZoneScoped
glFramebufferTexture(
GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT0,
@@ -666,6 +674,8 @@ void AtmosphereDeferredcaster::calculateIrradiance() {
void AtmosphereDeferredcaster::calculateInscattering(GLuint deltaSRayleigh,
GLuint deltaSMie)
{
ZoneScoped
glFramebufferTexture(
GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT0,
@@ -712,6 +722,8 @@ void AtmosphereDeferredcaster::calculateDeltaJ(int scatteringOrder,
GLuint deltaJ, GLuint deltaE,
GLuint deltaSRayleigh, GLuint deltaSMie)
{
ZoneScoped
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, deltaJ, 0);
glViewport(0, 0, _textureSize.x, _textureSize.y);
program.activate();
@@ -768,6 +780,8 @@ void AtmosphereDeferredcaster::calculateDeltaE(int scatteringOrder,
GLuint deltaE, GLuint deltaSRayleigh,
GLuint deltaSMie)
{
ZoneScoped
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, deltaE, 0);
glViewport(0, 0, _deltaETableSize.x, _deltaETableSize.y);
program.activate();
@@ -805,6 +819,8 @@ void AtmosphereDeferredcaster::calculateDeltaS(int scatteringOrder,
ghoul::opengl::ProgramObject& program,
GLuint deltaSRayleigh, GLuint deltaJ)
{
ZoneScoped
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, deltaSRayleigh, 0);
glViewport(0, 0, _textureSize.x, _textureSize.y);
program.activate();
@@ -843,6 +859,8 @@ void AtmosphereDeferredcaster::calculateIrradiance(int scatteringOrder,
ghoul::opengl::ProgramObject& program,
GLuint deltaE)
{
ZoneScoped
glFramebufferTexture(
GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT0,
@@ -873,6 +891,8 @@ void AtmosphereDeferredcaster::calculateInscattering(int scatteringOrder,
GLuint deltaSRayleigh)
{
ZoneScoped
glFramebufferTexture(
GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT0,
@@ -904,6 +924,8 @@ void AtmosphereDeferredcaster::calculateInscattering(int scatteringOrder,
}
void AtmosphereDeferredcaster::calculateAtmosphereParameters() {
ZoneScoped
using ProgramObject = ghoul::opengl::ProgramObject;
std::unique_ptr<ProgramObject> deltaJProgram = ProgramObject::Build(
"DeltaJ Program",
+12 -11
View File
@@ -42,14 +42,15 @@ Camera::Camera(const Camera& o)
{}
void Camera::setPositionVec3(glm::dvec3 pos) {
std::lock_guard<std::mutex> _lock(_mutex);
_position = std::move(pos);
_cachedCombinedViewMatrix.isDirty = true;
if (!glm::any(glm::isnan(pos))) {
std::lock_guard _lock(_mutex);
_position = std::move(pos);
_cachedCombinedViewMatrix.isDirty = true;
}
}
void Camera::setRotation(glm::dquat rotation) {
std::lock_guard<std::mutex> _lock(_mutex);
std::lock_guard _lock(_mutex);
_rotation = std::move(rotation);
_cachedViewDirection.isDirty = true;
_cachedLookupVector.isDirty = true;
@@ -58,14 +59,14 @@ void Camera::setRotation(glm::dquat rotation) {
}
void Camera::setScaling(float scaling) {
std::lock_guard<std::mutex> _lock(_mutex);
std::lock_guard _lock(_mutex);
_scaling = scaling;
_cachedViewScaleMatrix.isDirty = true;
_cachedCombinedViewMatrix.isDirty = true;
}
void Camera::setMaxFov(float fov) {
std::lock_guard<std::mutex> _lock(_mutex);
std::lock_guard _lock(_mutex);
_maxFov = fov;
_cachedSinMaxFov.isDirty = true;
}
@@ -75,7 +76,7 @@ void Camera::setParent(SceneGraphNode* parent) {
}
void Camera::rotate(glm::dquat rotation) {
std::lock_guard<std::mutex> _lock(_mutex);
std::lock_guard _lock(_mutex);
_rotation = std::move(rotation) * static_cast<glm::dquat>(_rotation);
_cachedViewDirection.isDirty = true;
@@ -224,20 +225,20 @@ Camera::SgctInternal::SgctInternal(const SgctInternal& o)
{}
void Camera::SgctInternal::setSceneMatrix(glm::mat4 sceneMatrix) {
std::lock_guard<std::mutex> _lock(_mutex);
std::lock_guard _lock(_mutex);
_sceneMatrix = std::move(sceneMatrix);
}
void Camera::SgctInternal::setViewMatrix(glm::mat4 viewMatrix) {
std::lock_guard<std::mutex> _lock(_mutex);
std::lock_guard _lock(_mutex);
_viewMatrix = std::move(viewMatrix);
_cachedViewProjectionMatrix.isDirty = true;
}
void Camera::SgctInternal::setProjectionMatrix(glm::mat4 projectionMatrix) {
std::lock_guard<std::mutex> _lock(_mutex);
std::lock_guard _lock(_mutex);
_projectionMatrix = std::move(projectionMatrix);
_cachedViewProjectionMatrix.isDirty = true;