diff options
Diffstat (limited to 'hw5/src/bumpMap.cpp')
-rw-r--r-- | hw5/src/bumpMap.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/hw5/src/bumpMap.cpp b/hw5/src/bumpMap.cpp new file mode 100644 index 0000000..4d756ee --- /dev/null +++ b/hw5/src/bumpMap.cpp @@ -0,0 +1,47 @@ +/******************************************************************/ +/* This file is part of the homework assignments for CSCI-427/527 */ +/* at The College of William & Mary and authored by Pieter Peers. */ +/* No part of this file, whether altered or in original form, can */ +/* be distributed or used outside the context of CSCI-427/527 */ +/* without consent of either the College of William & Mary or */ +/* Pieter Peers. */ +/******************************************************************/ +#include <cassert> +#include <algorithm> +#include "bumpMap.h" +#include "coordinateTransform.h" + +////////////////// +// Constructors // +////////////////// +bumpMap::bumpMap(const std::shared_ptr<const texture_base>& map, float scale, unsigned int channel, const std::shared_ptr<const shader_base>& shader) + : shadingFrameTransformation(shader) +{ + _map = map; + _scale = scale; + _channel = std::max(channel, 2u); +} + +///////////// +// Methods // +///////////// +transformation3d bumpMap::_transformation(const vec2d& textureCoord) const +{ + // HW5-BONUS: Implement a bump map. The bump map specifies a 'bump' as a an offset in the + // Z direction (i.e., which aligns to N in the local shading frame). The variable + // '_channel' indicates which channel in the '_map' encodes the height offset. + // The variable '_scale' determines the relative height of the bump with respect to + // the texel size. I.e., the height of a bump is _map(u,v)*_scale. From the bump + // you need to compute the new surface normal, and from this the shading frame + // transformation. + // Modifies: nothing + // Returns: transformation3d + return transformation3d(); +} + + +void bumpMap::_print(std::ostream& s) const +{ + s << "bumpMap (" << _scale << " x " << *_map << "[" << _channel << "]) -> {" << *_shader << "}"; +} + |