Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
IdealSubstance.h
Go to the documentation of this file.
1#pragma once
2
5#include "Math/TVector3.h"
6#include "SDL/sdl_interface.h"
9
10#include <Common/primitive_type.h>
11
12#include <optional>
13
14namespace ph
15{
16
25
27{
28 SdlEnumType sdlEnum("ideal-substance");
29 sdlEnum.description("Type of the physical behavior of a perfectly smooth surface.");
30
31 sdlEnum.addEntry(EnumType::Absorber, "absorber");
32 sdlEnum.addEntry(EnumType::DielectricReflector, "dielectric-reflector");
33 sdlEnum.addEntry(EnumType::DielectricTransmitter,"dielectric-transmitter");
34 sdlEnum.addEntry(EnumType::MetallicReflector, "metallic-reflector");
35 sdlEnum.addEntry(EnumType::Dielectric, "dielectric");
36
37 return sdlEnum;
38}
39
41{
42public:
44
45 void genSurface(const CookingContext& ctx, SurfaceBehavior& behavior) const override;
46
47 void setSubstance(EIdealSubstance substance);
48
49private:
50 EIdealSubstance m_substance;
51 EInterfaceFresnel m_fresnel;
52 real m_iorOuter;
53 real m_iorInner;
54 math::Spectrum m_f0;
55 math::Spectrum m_reflectionScale;
56 math::Spectrum m_transmissionScale;
57 std::optional<math::Spectrum> m_iorInnerN;
58 std::optional<math::Spectrum> m_iorInnerK;
59
60public:
62 {
63 ClassType clazz("ideal-substance");
64 clazz.description("Models a perfectly smooth surface with various physical properties.");
65 clazz.docName("Ideal Substance Material");
66 clazz.baseOn<SurfaceMaterial>();
67
68 TSdlEnumField<OwnerType, EIdealSubstance> substance("substance", &OwnerType::m_substance);
69 substance.description("Specifying the physical property/behavior of the surface.");
70 substance.required();
71 substance.defaultTo(EIdealSubstance::Absorber);
72 clazz.addField(substance);
73
74 TSdlEnumField<OwnerType, EInterfaceFresnel> fresnel("fresnel", &OwnerType::m_fresnel);
75 fresnel.description("Type of the Fresnel for the interface.");
77 fresnel.optional();
78 clazz.addField(fresnel);
79
80 TSdlReal<OwnerType> iorOuter("ior-outer", &OwnerType::m_iorOuter);
81 iorOuter.description("The index of refraction outside the surface.");
82 iorOuter.defaultTo(1);
83 iorOuter.optional();
84 clazz.addField(iorOuter);
85
86 TSdlReal<OwnerType> iorInner("ior-inner", &OwnerType::m_iorInner);
87 iorInner.description("The index of refraction inside the surface.");
88 iorInner.defaultTo(1.5_r);
89 iorInner.optional();
90 clazz.addField(iorInner);
91
92 TSdlSpectrum<OwnerType> f0("f0", math::EColorUsage::Raw, &OwnerType::m_f0);
93 f0.description(
94 "Surface reflectance on normal incidence. This value is expected "
95 "to be given in linear-sRGB space. When this parameter is used, "
96 "the underlying Fresnel model will be an approximated one (schlick) "
97 "which is pretty popular in real-time graphics.");
98 f0.optional();
100 clazz.addField(f0);
101
102 TSdlSpectrum<OwnerType> reflectionScale("reflection-scale", math::EColorUsage::Raw, &OwnerType::m_reflectionScale);
103 reflectionScale.description(
104 "A scaling factor for reflected energy. Note that this property is only for "
105 "artistic control and is not physically correct.");
106 reflectionScale.defaultTo(math::Spectrum(1));
107 reflectionScale.optional();
108 clazz.addField(reflectionScale);
109
110 TSdlSpectrum<OwnerType> transmissionScale("transmission-scale", math::EColorUsage::Raw, &OwnerType::m_transmissionScale);
111 transmissionScale.description(
112 "A scaling factor for transmitted energy. Note that this property is only for "
113 "artistic control and is not physically correct.");
114 transmissionScale.defaultTo(math::Spectrum(1));
115 transmissionScale.optional();
116 clazz.addField(transmissionScale);
117
118 TSdlOptionalSpectrum<OwnerType> iorInnerN("ior-inner-n", math::EColorUsage::Raw, &OwnerType::m_iorInnerN);
119 iorInnerN.description("The complex index of refraction (real part) inside the metallic interface.");
120 clazz.addField(iorInnerN);
121
122 TSdlOptionalSpectrum<OwnerType> iorInnerK("ior-inner-k", math::EColorUsage::Raw, &OwnerType::m_iorInnerK);
123 iorInnerK.description("The complex index of refraction (imaginary part) inside the metallic interface.");
124 clazz.addField(iorInnerK);
125
126 return clazz;
127 }
128};
129
130}// end namespace ph
Information about the world being cooked.
Definition CookingContext.h:24
Definition IdealSubstance.h:41
PH_DEFINE_SDL_CLASS(TSdlOwnerClass< IdealSubstance >)
Definition IdealSubstance.h:61
IdealSubstance()
Definition IdealSubstance.cpp:26
void genSurface(const CookingContext &ctx, SurfaceBehavior &behavior) const override
Definition IdealSubstance.cpp:41
void setSubstance(EIdealSubstance substance)
Definition IdealSubstance.cpp:138
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 field class that binds a floating point member variable.
Definition TSdlReal.h:21
Definition TSdlSpectrum.h:27
TSdlValue & description(std::string descriptionStr)
Definition TSdlValue.ipp:95
TSdlValue & optional()
Definition TSdlValue.ipp:103
TSdlValue & defaultTo(T defaultValue)
Definition TSdlValue.ipp:71
Definition TTristimulusSpectrum.h:11
The root for all renderer implementations.
Definition EEngineProject.h:6
EInterfaceFresnel
Definition sdl_component_enums.h:10
EIdealSubstance
Definition IdealSubstance.h:18
#define PH_DEFINE_SDL_ENUM(...)
Define a SDL enum with function-like syntax.
Definition sdl_interface.h:142