/******************************************************************/ /* 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 << "}"; }