Loading...
Searching...
No Matches
bsdf_attribute.h
Go to the documentation of this file.
1#ifndef _BBM_BSDF_ATTRIBUTE_H_
2#define _BBM_BSDF_ATTRIBUTE_H_
3
4#include <limits>
5
7
9#include "util/make_from.h"
10#include "core/attribute.h"
11#include "core/ior.h"
12
13/***********************************************************************/
14/*! \file bsdf_attribute.h
15 \brief Default bsdf attribute types
16
17 List of types:
18 + bsdf_attribute<type, Flag, Default=1.0, Upperbound=max, Lowerbound=0.0>
19 + bsdf_scale<type, Flag>
20 + diffuse_scale<type>
21 + specular_scale<type>
22 + bsdf_roughness<type, Flag>
23 + diffuse_roughness<type>
24 + specular_roughness<type>
25 + bsdf_sharpness<type, Flag>
26 + diffuse_sharpness<type>
27 + specular_sharpness<type>
28 + fresnel_parameter<type, Flag==bsdf_attr::SpecularParameter>
29************************************************************************/
30
31namespace bbm {
32
33 /*********************************************************************/
34 /*! @{ \name Helper Methods for extracting default value / bounds
35 *********************************************************************/
36 template<typename T> requires concepts::bsdf_attribute<T>
37 inline constexpr auto default_value(T) { return std::decay_t<T>::prop::default_value(); }
38
39 template<typename T> requires concepts::bsdf_attribute<T>
40 inline constexpr auto lower_bound(T) { return std::decay_t<T>::prop::lower_bound(); }
41
42 template<typename T> requires concepts::bsdf_attribute<T>
43 inline constexpr auto upper_bound(T) { return std::decay_t<T>::prop::upper_bound(); }
44
45 template<typename T> requires concepts::bsdf_attribute<T>
46 inline constexpr auto bsdf_attr_flag(T) { return std::decay_t<T>::prop::flag; }
47
48 /*********************************************************************/
49 /*! \brief bsdf_parameter property
50
51 \tparam T = type of the value
52 \tparam Flag = bsdf_attr flag
53 \tparam Default = default value (default = 1)
54 \tparam UpperBound = upper bound value (default = std::numeric_limits<scalar_t<type>>::max())
55 \tparam LowerBound = lower bound (default = 0)
56 *********************************************************************/
57 template<typename T, bsdf_attr Flag, literal Default=1.0, literal UpperBound = std::numeric_limits<scalar_t<T>>::max(), literal LowerBound=0.0>
59 {
60 using type = T;
61 static constexpr bsdf_attr flag = Flag;
62 inline static type default_value(void) { return make_from<T,Default>(); }
63 inline static type lower_bound(void) { return make_from<T,LowerBound>(); }
64 inline static type upper_bound(void) { return make_from<T,UpperBound>(); }
65 };
66
67 ////////////////////////////////////
68 //! @{ \name Predefined Default BSDF attributes
69 ////////////////////////////////////
70 template<typename T, bsdf_attr Flag, literal Default=1.0, literal UpperBound = std::numeric_limits<scalar_t<T>>::max(), literal LowerBound=0.0>
72
73 template<typename T, bsdf_attr Flag> using bsdf_scale = attribute<bsdf_properties<T, Flag, 0.5, 1.0>>;
76
77 // roughness
78 template<typename T, bsdf_attr Flag> using bsdf_roughness = attribute<bsdf_properties<T, Flag, 0.1, 1.0, constants<scalar_t<T>>::Epsilon()>>;
81
82 // sharpness = ~1/roughness
83 template<typename T, bsdf_attr Flag> using bsdf_sharpness = attribute<bsdf_properties<T, Flag, 32.0>>;
86
87 // ior and reflectance (R0)
88 template<typename T, bsdf_attr Flag = bsdf_attr::SpecularParameter> struct bsdf_fresnel_properties;
89 template<typename T, bsdf_attr Flag> struct bsdf_fresnel_properties<ior::ior<T>, Flag> : bsdf_properties<ior::ior<T>, Flag, 1.3, 5.0, 1.0> {};
90 template<typename T, bsdf_attr Flag> struct bsdf_fresnel_properties<ior::reflectance<T>, Flag> : bsdf_properties<ior::reflectance<T>, Flag, 0.1, 1.0> {};
91 template<typename T, bsdf_attr Flag> struct bsdf_fresnel_properties<ior::complex_ior<T>, Flag> : bsdf_properties<ior::complex_ior<T>, Flag, std::array{1.3, 0.0}, std::array{5.0, 10.0}, std::array{0.1, 0.0}> {};
92
93 template<typename T, bsdf_attr Flag = bsdf_attr::SpecularParameter>
95 //! @}
96
97}
98
99#endif /* _BBM_BSDF_ATTRIBUTE_H_ */
Flags to mark properties of a bsdf's attribute.
bsdf attribute contract
A warpper class to attach a properties to a class via a property struct. The propert expects by defau...
Defines 'ior' and 'reflectance' types.
Tools for making an object:
Definition: aggregatebsdf.h:29
constexpr auto default_value(T)
Definition: bsdf_attribute.h:37
constexpr auto bsdf_attr_flag(T)
Definition: bsdf_attribute.h:46
constexpr auto lower_bound(T)
Definition: bsdf_attribute.h:40
constexpr auto upper_bound(T)
Definition: bsdf_attribute.h:43
bsdf_attr
Attribute Property Flags.
Definition: bsdf_attr_flag.h:17
Base declaration of attribute; further specialized below.
Definition: attribute.h:26
Definition: bsdf_attribute.h:88
bsdf_parameter property
Definition: bsdf_attribute.h:59
static type default_value(void)
Definition: bsdf_attribute.h:62
static type lower_bound(void)
Definition: bsdf_attribute.h:63
static type upper_bound(void)
Definition: bsdf_attribute.h:64
static constexpr bsdf_attr flag
Definition: bsdf_attribute.h:61
T type
Definition: bsdf_attribute.h:60
Definition: constants.h:17