Started scene reader. Added libjson-spirit dependency.

This commit is contained in:
Miguel Angel Astor Romero
2017-01-18 17:26:09 -04:00
parent 965b04ca39
commit 5edccd4d30
10 changed files with 351 additions and 32 deletions

View File

@@ -9,6 +9,7 @@ using glm::mat3;
using glm::abs;
using glm::normalize;
using glm::cross;
using glm::radians;
using glm::pi;
const float PDF = (1.0f / (2.0f * pi<float>()));
@@ -17,6 +18,20 @@ float random01() {
return static_cast<float>(rand()) / static_cast<float>(RAND_MAX);
}
vec2 sample_pixel(int i, int j, float w, float h, float a_ratio, float fov) {
float pxNDC;
float pyNDC;
float pxS;
float pyS;
pyNDC = (static_cast<float>(i) + random01()) / h;
pyS = (1.0f - (2.0f * pyNDC)) * glm::tan(radians(fov / 2.0f));
pxNDC = (static_cast<float>(j) + random01()) / w;
pxS = (2.0f * pxNDC) - 1.0f;
pxS *= a_ratio * glm::tan(radians(fov / 2.0f));
return vec2(pxS, pyS);
}
/* Sampling functions pretty much taken from scratchapixel.com */
void create_coords_system(const vec3 &n, vec3 &nt, vec3 &nb) {
if (abs(n.x) > abs(n.y))