Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
BinaryMixedSurfaceMaterial.h
Go to the documentation of this file.
1#pragma once
2
4#include "Actor/Image/Image.h"
5#include "SDL/sdl_interface.h"
6
7#include <memory>
8
9namespace ph
10{
11
13{
14 Lerp = 0
15};
16
18{
19 SdlEnumType sdlEnum("surface-material-mix-mode");
20 sdlEnum.description("Specify how surface materials are mixed.");
21
22 sdlEnum.addEntry(EnumType::Lerp, "lerp");
23
24 return sdlEnum;
25}
26
28{
29public:
30 void genSurface(const CookingContext& ctx, SurfaceBehavior& behavior) const override;
31
33
34 void setMaterials(
35 std::shared_ptr<SurfaceMaterial> material0,
36 std::shared_ptr<SurfaceMaterial> material1);
37
38 void setFactor(real factor);
39 void setFactor(std::shared_ptr<Image> factor);
40
41private:
43 std::shared_ptr<SurfaceMaterial> m_material0;
44 std::shared_ptr<SurfaceMaterial> m_material1;
45 std::shared_ptr<Image> m_factor;
46
47public:
49 {
50 ClassType clazz("binary-mixed-surface");
51 clazz.docName("Binary Mixed Surface");
52 clazz.description("Mixing two surface materials in various ways.");
53 clazz.baseOn<SurfaceMaterial>();
54
55 TSdlEnumField<OwnerType, ESurfaceMaterialMixMode> mode("mode", &OwnerType::m_mode);
56 mode.description("Specify how two materials are mixed.");
57 mode.defaultTo(ESurfaceMaterialMixMode::Lerp);
58 mode.required();
59 clazz.addField(mode);
60
61 TSdlReference<SurfaceMaterial, OwnerType> material0("material-0", &OwnerType::m_material0);
62 material0.description("The first material that participates the mixing process.");
63 material0.required();
64 clazz.addField(material0);
65
66 TSdlReference<SurfaceMaterial, OwnerType> material1("material-1", &OwnerType::m_material1);
67 material1.description("The second material that participates the mixing process.");
68 material1.required();
69 clazz.addField(material1);
70
71 TSdlReference<Image, OwnerType> factor("factor", &OwnerType::m_factor);
72 factor.description(
73 "Factor that controls the contribution from each material. Basically, the final material "
74 "would be \"material-0 * factor + material-1 * (1 - factor)\".");
75 factor.optional();// some operation might not need a factor; check factor at cook time
76 clazz.addField(factor);
77
78 return clazz;
79 }
80};
81
82}// end namespace ph
Definition BinaryMixedSurfaceMaterial.h:28
void setMaterials(std::shared_ptr< SurfaceMaterial > material0, std::shared_ptr< SurfaceMaterial > material1)
Definition BinaryMixedSurfaceMaterial.cpp:61
void setMode(ESurfaceMaterialMixMode mode)
Definition BinaryMixedSurfaceMaterial.cpp:56
void genSurface(const CookingContext &ctx, SurfaceBehavior &behavior) const override
Definition BinaryMixedSurfaceMaterial.cpp:17
void setFactor(real factor)
Definition BinaryMixedSurfaceMaterial.cpp:69
PH_DEFINE_SDL_CLASS(TSdlOwnerClass< BinaryMixedSurfaceMaterial >)
Definition BinaryMixedSurfaceMaterial.h:48
Information about the world being cooked.
Definition CookingContext.h:24
Definition SurfaceBehavior.h:15
Definition SurfaceMaterial.h:15
Definition TSdlEnumField.h:23
SDL enum implementation with common features. Enum value and string mapping are done in a brute-force...
Definition TSdlGeneralEnum.h:26
SDL binding type for a canonical SDL resource class.
Definition TSdlOwnerClass.h:23
A value that points to a SDL resource.
Definition TSdlReference.h:21
TSdlReference & optional()
Definition TSdlReference.ipp:214
TSdlReference & required()
Definition TSdlReference.ipp:228
TSdlReference & description(std::string descriptionStr)
Definition TSdlReference.ipp:206
The root for all renderer implementations.
Definition EEngineProject.h:6
ESurfaceMaterialMixMode
Definition BinaryMixedSurfaceMaterial.h:13
#define PH_DEFINE_SDL_ENUM(...)
Define a SDL enum with function-like syntax.
Definition sdl_interface.h:142