TDT4230_final_project/report/delivery_part5.md

7.2 KiB

Appendix

The seqmented pane with the cobble texture and normal map{#fig:img-base}

The plane from @fig:img-base with a perlin noise displacement map applied to it{#fig:img-perlin-displacement}

First rendering of the downloaded grass texture and normal map{#fig:img-wrong-handedness}

Rendering of the downloaded grass texture with flipped normal map handedness{#fig:img-flipped-handedness}

The field with grass texture, normal map and displacement map{#fig:img-fine-plane}

How a mirrored-on-repeat texture behaves{#fig:img-gl-mirror}

if (isDisplacementMapped) {
    float o = texture(displaceTex, UV).r * 2 - 1;
    float u = (texture(displaceTex, UV + vec2(0.0001, 0)).r*2-1 - o) / 0.0004; // magic numbers!
    float v = (texture(displaceTex, UV + vec2(0, 0.0001)).r*2-1 - o) / 0.0004; // magic numbers!
    TBN = mat3(
        normalize(tangent   + normal*u),
        normalize(bitangent + normal*v),
        normalize(cross(tangent + normal*u, bitangent + normal*v))
    );
}

The displaced field with the TBN matrix rotated along the slope of the displacement.{#fig:img-displacement-normals}

Car mesh loaded from car model, without transformations{#fig:img-car-meshes}

Car mesh loaded from car model with transformations applied.{#fig:img-car-transformations}

Car mesh loaded from car model with transformations applied, rotated to make z point skyward.{#fig:img-car-coordinate-system}

Diffuse colors loaded from car model{#fig:img-car-materials}

Diffuse, emissive and specular colors loaded from car model{#fig:img-material-colors}

Car model with all colors, with reflection mapping applied.{#fig:img-reflection}

The reflection map texture applied to the car{#fig:img-reflection-map}

Tree model loaded from model file, no texture support yet.{#fig:img-tree}

Tree model loaded from model file, textures applied.{#fig:img-tree-alpha}

Tree model with textures, transparent meshes rendered last in sorted order.{#fig:img-tree-sorted}

Tree model with textures, transparent meshes rendered last in sorted order, with depthbuffer in read-only mode.{#fig:img-tree-depth-readonly}

Grass model loaded, cloned and placed randomly throughout the scene{#fig:img-low-fps}

glUniformMatrix4fv(s->location("MVP")     , 1, GL_FALSE, glm::value_ptr(node->MVP));
glUniformMatrix4fv(s->location("MV")      , 1, GL_FALSE, glm::value_ptr(node->MV));
glUniformMatrix4fv(s->location("MVnormal"), 1, GL_FALSE, glm::value_ptr(node->MVnormal));
glUniform2fv(s->location("uvOffset")      , 1,           glm::value_ptr(node->uvOffset));
glUniform3fv(s->location("diffuse_color") , 1,           glm::value_ptr(node->diffuse_color));
glUniform3fv(s->location("emissive_color"), 1,           glm::value_ptr(node->emissive_color));
glUniform3fv(s->location("specular_color"), 1,           glm::value_ptr(node->specular_color));
glUniform1f( s->location("opacity"),                 node->opacity);
glUniform1f( s->location("shininess"),               node->shininess);
glUniform1f( s->location("reflexiveness"),           node->reflexiveness);
glUniform1f( s->location("displacementCoefficient"), node->displacementCoefficient);
glUniform1ui(s->location("isTextured"),              node->isTextured);
glUniform1ui(s->location("isVertexColored"),         node->isVertexColored);
glUniform1ui(s->location("isNormalMapped"),          node->isNormalMapped);
glUniform1ui(s->location("isDisplacementMapped"),    node->isDisplacementMapped);
glUniform1ui(s->location("isReflectionMapped"),      node->isReflectionMapped);
glUniform1ui(s->location("isIlluminated"),           node->isIlluminated);
glUniform1ui(s->location("isInverted"),              node->isInverted);
GLint inline Shader::location(std::string const& name) {
    //return  glGetUniformLocation(mProgram, name.c_str());
    auto it = this->cache.find(name);
    if (it == this->cache.end()) 
        return this->cache[name] = glGetUniformLocation(mProgram, name.c_str());
    return it->second;
}
bool shader_changed = s != prev_s;
#define cache(x) static decltype(node->x) cached_ ## x; \
    if (shader_changed || cached_ ## x != node->x) { cached_ ## x = node->x;
#define um4fv(x) cache(x) glUniformMatrix4fv(s->location(#x), 1, GL_FALSE, glm::value_ptr(node->x)); }
#define u2fv(x)  cache(x) glUniform2fv( s->location(#x), 1, glm::value_ptr(node->x)); }
#define u3fv(x)  cache(x) glUniform3fv( s->location(#x), 1, glm::value_ptr(node->x)); }
#define u1f(x)   cache(x) glUniform1f(  s->location(#x), node->x); }
#define u1ui(x)  cache(x) glUniform1ui( s->location(#x), node->x); }

Car, trees and grass combined into a night driving scene. Two yellow spot lights attached to the head lights, two yelllow point lights attached to the head lights, two red point lights attached to the read lights.{#fig:img-night-scene-lights}

A pink rim backlight applied to the car with strength of 0.3.{#fig:img-rim-lights}

Visualisation of the transformed depth buffer, transformed into a 'point of focus' buffer. z=0 at the depth of the car, tends toward 1 otherwise.{#fig:img-depth-map}

Depth of field applied to the scene{#fig:img-depth-of-field}

The vignette effect, applied to a white frame buffer{#fig:img-vingette}

The chromatic aberration effect. F is the point of focus. The transformed depthbuffer is centered around the vertical line crossing F.{#fig:img-what-is}

Chromatic aberration applied to the scene, where the aberration coefficients have been multiplied by 3.{#fig:img-chromatic-aberration}

Noise/grain applied to the frame buffer.{#fig:img-noise}

Noise/grain, multiplied by the depthbuffer/point of focus, applied to the frame buffer.{#fig:img-all-effects}

The same scene, during the day. Spotlights have been turned off.{#fig:img-day}