-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Image texture mapping class is added.
- Loading branch information
Showing
4 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
set(SOURCES ${SOURCES} | ||
${CMAKE_CURRENT_LIST_DIR}/texture.cc | ||
${CMAKE_CURRENT_LIST_DIR}/constant.cc | ||
${CMAKE_CURRENT_LIST_DIR}/imagemap.cc | ||
${CMAKE_CURRENT_LIST_DIR}/uv.cc | ||
PARENT_SCOPE) | ||
|
||
set(HEADERS ${HEADERS} | ||
${CMAKE_CURRENT_LIST_DIR}/spica_texture.h | ||
${CMAKE_CURRENT_LIST_DIR}/constant.h | ||
${CMAKE_CURRENT_LIST_DIR}/imagemap.h | ||
${CMAKE_CURRENT_LIST_DIR}/texture.h | ||
${CMAKE_CURRENT_LIST_DIR}/uv.h | ||
PARENT_SCOPE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#define SPICA_API_EXPORT | ||
#include "imagemap.h" | ||
|
||
#include "../core/point2d.h" | ||
#include "../math/vector2d.h" | ||
#include "../image/mipmap.h" | ||
|
||
namespace spica { | ||
|
||
ImageTexture::ImageTexture(const Image& image, | ||
std::unique_ptr<TextureMapping2D> texmap, | ||
ImageWrap wrap) | ||
: mipmap_{ std::make_unique<MipMap>(image, wrap) } | ||
, texmap_{ std::move(texmap) } { | ||
} | ||
|
||
Spectrum ImageTexture::evaluate(const SurfaceInteraction& intr) const { | ||
Vector2d dstdx, dstdy; | ||
Point2d st = texmap_->map(intr); | ||
return mipmap_->lookup(st); | ||
} | ||
|
||
} // namespace spica |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#ifdef _MSC_VER | ||
#pragma once | ||
#endif | ||
|
||
#ifndef _SPICA_IMAGEMAP_H_ | ||
#define _SPICA_IMAGEMAP_H_ | ||
|
||
#include <string> | ||
#include <memory> | ||
|
||
#include "../core/common.h" | ||
#include "../core/forward_decl.h" | ||
#include "../core/spectrum.h" | ||
|
||
#include "texture.h" | ||
|
||
namespace spica { | ||
|
||
class ImageTexture : public Texture<Spectrum> { | ||
public: | ||
ImageTexture(const Image& image, | ||
std::unique_ptr<TextureMapping2D> texmap, | ||
ImageWrap wrap); | ||
|
||
Spectrum evaluate(const SurfaceInteraction& intr) const; | ||
|
||
private: | ||
// Private field | ||
std::unique_ptr<MipMap> mipmap_; | ||
std::unique_ptr<TextureMapping2D> texmap_; | ||
}; | ||
|
||
} // namespace spica | ||
|
||
#endif // _SPICA_IMAGEMAP_H_ |