Added image-based lighting with HDR images.

This commit is contained in:
Miguel Angel Astor Romero
2017-01-17 17:09:25 -04:00
parent 04618e518e
commit 8d341b9a25
12 changed files with 177 additions and 77 deletions

37
environment.hpp Normal file
View File

@@ -0,0 +1,37 @@
#pragma once
#ifndef ENVIRONMENT_HPP
#define ENVIRONMENT_HPP
#include <FreeImage.h>
#include <glm/vec3.hpp>
#include "ray.hpp"
using glm::vec3;
class Environment {
public:
Environment(const char * tex_file = NULL, bool light_probe = false, vec3 bckg = vec3(1.0f)): m_bckg_color(bckg), m_probe(light_probe) {
FREE_IMAGE_FORMAT fif;
if (tex_file != NULL) {
fif = FreeImage_GetFIFFromFilename(tex_file);
m_texture = FreeImage_Load(fif, tex_file, 0);
} else
m_texture = NULL;
}
~Environment() {
if (m_texture != NULL)
FreeImage_Unload(m_texture);
}
vec3 get_color(Ray & r);
private:
vec3 m_bckg_color;
FIBITMAP * m_texture;
bool m_probe;
};
#endif