Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
CheckerboardImage.h
Go to the documentation of this file.
1#pragma once
2
3#include "Actor/Image/Image.h"
4#include "SDL/sdl_interface.h"
5
6#include <Common/primitive_type.h>
7
8#include <memory>
9#include <functional>
10#include <utility>
11
12namespace ph
13{
14
16{
17public:
18 std::shared_ptr<TTexture<Image::ArrayType>> genNumericTexture(
19 const CookingContext& ctx) override;
20
21 std::shared_ptr<TTexture<math::Spectrum>> genColorTexture(
22 const CookingContext& ctx) override;
23
24 void setNumTiles(real numTilesU, real numTilesV);
25 void setOddImage(std::shared_ptr<Image> oddImage);
26 void setEvenImage(std::shared_ptr<Image> evenImage);
27
28private:
29 auto getOddAndEvenImages() const -> std::pair<std::shared_ptr<Image>, std::shared_ptr<Image>>;
30
31 std::shared_ptr<Image> m_oddImage;
32 std::shared_ptr<Image> m_evenImage;
33 real m_numTilesU;
34 real m_numTilesV;
35
36public:
38 {
39 ClassType clazz("checkerboard");
40 clazz.docName("Checkerboard Image");
41 clazz.description(
42 "A procedural image that divides its parametric domain into rectangular tiles. Each tile "
43 "can be categorized into even and odd, where all neighboring tiles of an even tile is odd "
44 "and all neighboring tiles of an odd tile is even.");
45 clazz.baseOn<Image>();
46
47 TSdlReference<Image, OwnerType> oddImage("odd", &OwnerType::m_oddImage);
48 oddImage.description(
49 "The image to use in the odd tile.");
50 oddImage.required();
51 clazz.addField(oddImage);
52
53 TSdlReference<Image, OwnerType> evenImage("even", &OwnerType::m_evenImage);
54 evenImage.description(
55 "The image to use in the even tile.");
56 evenImage.required();
57 clazz.addField(evenImage);
58
59 TSdlReal<OwnerType> uTiles("u-tiles", &OwnerType::m_numTilesU);
60 uTiles.description(
61 "Number of tiles in the U axis of the parametric coordinates.");
62 uTiles.defaultTo(2.0_r);
63 uTiles.optional();
64 clazz.addField(uTiles);
65
66 TSdlReal<OwnerType> vTiles("v-tiles", &OwnerType::m_numTilesV);
67 vTiles.description(
68 "Number of tiles in the V axis of the parametric coordinates.");
69 vTiles.defaultTo(2.0_r);
70 vTiles.optional();
71 clazz.addField(vTiles);
72
73 return clazz;
74 }
75};
76
77}// end namespace ph
Definition CheckerboardImage.h:16
PH_DEFINE_SDL_CLASS(TSdlOwnerClass< CheckerboardImage >)
Definition CheckerboardImage.h:37
std::shared_ptr< TTexture< Image::ArrayType > > genNumericTexture(const CookingContext &ctx) override
Definition CheckerboardImage.cpp:14
void setOddImage(std::shared_ptr< Image > oddImage)
Definition CheckerboardImage.cpp:56
std::shared_ptr< TTexture< math::Spectrum > > genColorTexture(const CookingContext &ctx) override
Definition CheckerboardImage.cpp:26
void setNumTiles(real numTilesU, real numTilesV)
Definition CheckerboardImage.cpp:38
void setEvenImage(std::shared_ptr< Image > evenImage)
Definition CheckerboardImage.cpp:61
Information about the world being cooked.
Definition CookingContext.h:24
Definition Image.h:21
SDL binding type for a canonical SDL resource class.
Definition TSdlOwnerClass.h:23
A field class that binds a floating point member variable.
Definition TSdlReal.h:21
A value that points to a SDL resource.
Definition TSdlReference.h:21
TSdlReference & required()
Definition TSdlReference.ipp:228
TSdlReference & description(std::string descriptionStr)
Definition TSdlReference.ipp:206
TSdlValue & description(std::string descriptionStr)
Definition TSdlValue.ipp:95
TSdlValue & optional()
Definition TSdlValue.ipp:103
TSdlValue & defaultTo(T defaultValue)
Definition TSdlValue.ipp:71
The root for all renderer implementations.
Definition EEngineProject.h:6