Skip to content

Commit

Permalink
#5 31.4 Basic Noise Textures
Browse files Browse the repository at this point in the history
Add FBmTexture.
  • Loading branch information
mandyedi committed Dec 1, 2024
1 parent 66da139 commit b7a1dad
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ set (SOURCE_TEXTURES
src/Textures/CylinderChecker.h
src/Textures/DiskChecker.h
src/Textures/DiskChecker.cpp
src/Textures/FBmTexture.cpp
src/Textures/FBmTexture.h
src/Textures/ImageTexture.cpp
src/Textures/ImageTexture.h
src/Textures/PlaneChecker.cpp
Expand Down
1 change: 1 addition & 0 deletions src/Textures/FBmTexture.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Copyright (C) Kevin Suffern 2000-2007.// This C++ code is for non-commercial purposes only.// This C++ code is licensed under the GNU General Public License Version 2.// See the file COPYING.txt for the full license.// Copyright notice for changes since the originally published version:// Copyright (C) Eduárd Mándy 2019-2021// Though this C++ code was change in a large measure it still has the original copyright notice.// This C++ code is for non-commercial purposes only.// This C++ code is licensed under the GNU General Public License Version 2.// See the file COPYING.txt for the full license.#include "FBmTexture.h"#include "../Noises/LatticeNoise.h"FBmTexture::FBmTexture(LatticeNoise *ln_ptr) { noise_ptr = ln_ptr;}RGBColor FBmTexture::get_color(const ShadeRec& sr) const { float value = noise_ptr->value_fbm(sr.local_hit_point); // in the range (0, 1) value = min_value + (max_value - min_value) * value; // in the range (min_value, max_value) if (value < 0.0 || value > 1.0) { return RGBColor(1, 0, 0); } else { return (value * color); }}
Expand Down
1 change: 1 addition & 0 deletions src/Textures/FBmTexture.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Copyright (C) Kevin Suffern 2000-2007.// This C++ code is for non-commercial purposes only.// This C++ code is licensed under the GNU General Public License Version 2.// See the file COPYING.txt for the full license.// Copyright notice for changes since the originally published version:// Copyright (C) Eduárd Mándy 2019-2021// Though this C++ code was change in a large measure it still has the original copyright notice.// This C++ code is for non-commercial purposes only.// This C++ code is licensed under the GNU General Public License Version 2.// See the file COPYING.txt for the full license.#include "Texture.h"#include "../Utilities/RGBColor.h"class ShadeRec;class LatticeNoise;class FBmTexture: public Texture {public: FBmTexture() = default; FBmTexture(LatticeNoise *ln_ptr); void set_color(const float r, const float g, const float b); void set_min_value(const float min); void set_max_value(const float max); virtual RGBColor get_color(const ShadeRec& sr) const;private: LatticeNoise* noise_ptr = nullptr; RGBColor color = RGBColor::black; float min_value = 0.0f; float max_value = 1.0f;};inline void FBmTexture::set_color(const float r, const float g, const float b) { color.r = r; color.g = g; color.b = b;}inline void FBmTexture::set_min_value(const float min) { min_value = min;}inline void FBmTexture::set_max_value(const float max) { max_value = max;}
Expand Down

0 comments on commit b7a1dad

Please sign in to comment.