Skip to content

Commit

Permalink
Camera copy operator with ismoving check
Browse files Browse the repository at this point in the history
get progress value for progressive rendering
  • Loading branch information
CedricGuillemet committed Jan 6, 2019
1 parent 8b9d7de commit 771d19b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
14 changes: 14 additions & 0 deletions PathTracer/src/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ namespace GLSLPathTracer
focalDist = 0.1f;
aperture = 0.0;
updateCamera();

}

Camera::Camera(const Camera& other)
{
*this = other;
}

Camera& Camera::operator = (const Camera& other)
{
ptrdiff_t l = (unsigned char*)&isMoving - (unsigned char*)&position.x;
isMoving = memcmp(&position.x, &other.position.x, l) != 0;
memcpy(&position.x, &other.position.x, l);
return *this;
}

void Camera::offsetOrientation(float x, float y)
Expand Down
2 changes: 2 additions & 0 deletions PathTracer/src/Camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ namespace GLSLPathTracer
{
public:
Camera(glm::vec3 pos, glm::vec3 lookAt, float fov);
Camera(const Camera& other);
Camera& operator = (const Camera& other);

void offsetOrientation(float x, float y);
void offsetPosition(glm::vec3 val);
Expand Down
7 changes: 7 additions & 0 deletions PathTracer/src/ProgressiveRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ namespace GLSLPathTracer
}
}

float ProgressiveRenderer::getProgress() const
{
if (lowRes || fadeIn)
return 0.f;
return 1.f;
}

void ProgressiveRenderer::present() const
{
if (!initialized)
Expand Down
2 changes: 1 addition & 1 deletion PathTracer/src/ProgressiveRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace GLSLPathTracer
void render();
void present() const;
void update(float secondsElapsed);
float getProgress() const { return 1.f; }
float getProgress() const;
RendererType getType() const { return Renderer_Progressive; }
};
}
6 changes: 3 additions & 3 deletions PathTracer/src/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ namespace GLSLPathTracer
glGenTextures(1, &albedoTextures);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D_ARRAY, albedoTextures);
glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_RGB, scene->texData.albedoTextureSize.x, scene->texData.albedoTextureSize.y, scene->texData.albedoTexCount);
glTexStorage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB, scene->texData.albedoTextureSize.x, scene->texData.albedoTextureSize.y, scene->texData.albedoTexCount);
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB8, scene->texData.albedoTextureSize.x, scene->texData.albedoTextureSize.y, scene->texData.albedoTexCount, 0, GL_RGB, GL_UNSIGNED_BYTE, scene->texData.albedoTextures);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
Expand All @@ -124,7 +124,7 @@ namespace GLSLPathTracer
{
glGenTextures(1, &metallicRoughnessTextures);
glBindTexture(GL_TEXTURE_2D_ARRAY, metallicRoughnessTextures);
glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_RGB, scene->texData.metallicRoughnessTextureSize.x, scene->texData.metallicRoughnessTextureSize.y, scene->texData.metallicRoughnessTexCount);
glTexStorage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB, scene->texData.metallicRoughnessTextureSize.x, scene->texData.metallicRoughnessTextureSize.y, scene->texData.metallicRoughnessTexCount);
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB8, scene->texData.metallicRoughnessTextureSize.x, scene->texData.metallicRoughnessTextureSize.y, scene->texData.metallicRoughnessTexCount, 0, GL_RGB, GL_UNSIGNED_BYTE, scene->texData.metallicRoughnessTextures);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
Expand All @@ -136,7 +136,7 @@ namespace GLSLPathTracer
{
glGenTextures(1, &normalTextures);
glBindTexture(GL_TEXTURE_2D_ARRAY, normalTextures);
glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_RGB, scene->texData.normalTextureSize.x, scene->texData.normalTextureSize.y, scene->texData.normalTexCount);
glTexStorage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB, scene->texData.normalTextureSize.x, scene->texData.normalTextureSize.y, scene->texData.normalTexCount);
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB8, scene->texData.normalTextureSize.x, scene->texData.normalTextureSize.y, scene->texData.normalTexCount, 0, GL_RGB, GL_UNSIGNED_BYTE, scene->texData.normalTextures);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
Expand Down

0 comments on commit 771d19b

Please sign in to comment.