From db072ad4dc181eca5a1458656b130beb43f475bf Mon Sep 17 00:00:00 2001 From: 53hornet <53hornet@gmail.com> Date: Sat, 2 Feb 2019 23:33:15 -0500 Subject: Init. --- hw5/src/bumpMap.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 hw5/src/bumpMap.cpp (limited to 'hw5/src/bumpMap.cpp') 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 +#include +#include "bumpMap.h" +#include "coordinateTransform.h" + +////////////////// +// Constructors // +////////////////// +bumpMap::bumpMap(const std::shared_ptr& map, float scale, unsigned int channel, const std::shared_ptr& 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 << "}"; +} + -- cgit v1.2.3