tinypbrt 1.1.1
pbrt-v4 scene file parser for C11 with a header-only C++20 wrapper
Loading...
Searching...
No Matches
texture.hpp
Go to the documentation of this file.
1#pragma once
2#ifndef _TINYPBRT_TEXTURE_HPP_
3#define _TINYPBRT_TEXTURE_HPP_
4
6
8
12
13namespace tpbrt {
31
38 [[nodiscard]] constexpr std::string_view to_string(const texture_handle_value_type type) noexcept {
40 switch (type) {
41 case TEXTURE_IDX: return "textureidx";
42 case SPECTRUM: return "spectrum";
43 case MAX_NUM: return "maxnum";
44 default: return "UNKNOWN";
45 }
46 }
47
52 struct texture_handle : detail::wrapper<texture_handle, tpbrt_texture_handle_t>,
53 detail::with_variant<texture_handle, texture_idx_t, spectrum> {
55 using wrapper::wrapper;
56
58 [[nodiscard]] constexpr texture_handle_value_type value_type() const noexcept {
59 return static_cast<texture_handle_value_type>(_native->value_type);
60 }
61
63 [[nodiscard]] constexpr bool_t is_texture_idx() const noexcept {
65 }
66
68 [[nodiscard]] constexpr bool_t is_spectrum() const noexcept {
70 }
71
73 [[nodiscard]] constexpr std::optional<texture_idx_t> as_texture_idx() const noexcept {
74 if (!is_texture_idx()) { return std::nullopt; }
75 return _native->as.texture_idx;
76 }
77
79 [[nodiscard]] constexpr std::optional<spectrum> as_spectrum() const noexcept {
80 if (!is_spectrum()) { return std::nullopt; }
81 return _native->as.spectrum;
82 }
83
85 [[nodiscard]] constexpr variant_type to_variant() const noexcept {
87 switch (value_type()) {
88 case TEXTURE_IDX: return _native->as.texture_idx;
89 case SPECTRUM: return _native->as.spectrum;
90 case MAX_NUM: [[fallthrough]];
91 default: break;
92 }
93 return std::nullopt;
94 }
95
97 [[nodiscard]] constexpr auto reflect() const noexcept { return std::make_tuple(to_variant(), value_type()); }
98 };
99
112
119 [[nodiscard]] constexpr std::string_view to_string(const texture_type type) noexcept {
120 using enum texture_type;
121 switch (type) {
122 case FLOAT: return "float";
123 case SPECTRUM: return "spectrum";
124 case MAX_NUM: return "maxnum";
125 default: return "UNKNOWN";
126 }
127 }
128
163
170 [[nodiscard]] constexpr std::string_view to_string(const texture_class class_val) noexcept {
171 using enum texture_class;
172 switch (class_val) {
173 case BILERP: return "bilerp";
174 case CHECKER_BOARD: return "checkerboard";
175 case CONSTANT: return "constant";
176 case DIRECTION_MIX: return "directionmix";
177 case DOTS: return "dots";
178 case FBM: return "fbm";
179 case IMAGE_MAP: return "imagemap";
180 case MARBLE: return "marble";
181 case MIX: return "mix";
182 case PTEX: return "ptex";
183 case SCALE: return "scale";
184 case WINDY: return "windy";
185 case WRINKLED: return "wrinkled";
186 case MAX_NUM: return "maxnum";
187 default: return "UNKNOWN";
188 }
189 }
190
195 struct texture_bilerp_params : detail::wrapper<texture_bilerp_params, tpbrt_texture_bilerp_params_t> {
197 using wrapper::wrapper;
198
200 [[nodiscard]] constexpr texture_handle v00() const noexcept { return _native->v00; }
201
203 [[nodiscard]] constexpr texture_handle v01() const noexcept { return _native->v01; }
204
206 [[nodiscard]] constexpr texture_handle v10() const noexcept { return _native->v10; }
207
209 [[nodiscard]] constexpr texture_handle v11() const noexcept { return _native->v11; }
210
212 [[nodiscard]] constexpr auto reflect() const noexcept { return std::make_tuple(v00(), v01(), v10(), v11()); }
213 };
214
219 struct texture_checkerboard_params : detail::wrapper<texture_checkerboard_params, tpbrt_texture_checkerboard_params_t> {
221 using wrapper::wrapper;
222
224 [[nodiscard]] constexpr texture_handle tex1() const noexcept { return _native->tex1; }
225
227 [[nodiscard]] constexpr texture_handle tex2() const noexcept { return _native->tex2; }
228
230 [[nodiscard]] constexpr uint_t dimension() const noexcept { return _native->dimension; }
231
233 [[nodiscard]] constexpr auto reflect() const noexcept { return std::make_tuple(tex1(), tex2(), dimension()); }
234 };
235
240 struct texture_constant_params : detail::wrapper<texture_constant_params, tpbrt_texture_constant_params_t> {
242 using wrapper::wrapper;
243
245 [[nodiscard]] constexpr texture_handle value() const noexcept { return _native->value; }
246
248 [[nodiscard]] constexpr auto reflect() const noexcept { return std::make_tuple(value()); }
249 };
250
255 struct texture_direction_mix_params : detail::wrapper<texture_direction_mix_params, tpbrt_texture_direction_mix_params_t> {
257 using wrapper::wrapper;
258
260 [[nodiscard]] constexpr texture_handle tex1() const noexcept { return _native->tex1; }
261
263 [[nodiscard]] constexpr texture_handle tex2() const noexcept { return _native->tex2; }
264
266 [[nodiscard]] constexpr vec dir() const noexcept { return _native->dir; }
267
269 [[nodiscard]] constexpr auto reflect() const noexcept { return std::make_tuple(tex1(), tex2(), dir()); }
270 };
271
276 struct texture_dots_params : detail::wrapper<texture_dots_params, tpbrt_texture_dots_params_t> {
278 using wrapper::wrapper;
279
281 [[nodiscard]] constexpr texture_handle inside() const noexcept { return _native->inside; }
282
284 [[nodiscard]] constexpr texture_handle outside() const noexcept { return _native->outside; }
285
287 [[nodiscard]] constexpr auto reflect() const noexcept { return std::make_tuple(inside(), outside()); }
288 };
289
297 template<texture_class Class>
298 struct texture_noise_params : detail::wrapper<texture_noise_params<Class>, tpbrt_texture_fbm_params_t> {
300 static constexpr texture_class TextureClass = Class;
301
303 using detail::wrapper<texture_noise_params, tpbrt_texture_fbm_params_t>::wrapper;
304
306 [[nodiscard]] constexpr uint_t octaves() const noexcept { return this->_native->octaves; }
307
309 [[nodiscard]] constexpr float_t roughness() const noexcept { return this->_native->roughness; }
310
312 [[nodiscard]] constexpr transform_handle transform() const noexcept { return this->_native->transform; }
313
315 [[nodiscard]] constexpr auto reflect() const noexcept { return std::make_tuple(octaves(), roughness(), transform()); }
316 };
317
323
329
335
350
357 [[nodiscard]] constexpr std::string_view to_string(const texture_wrap wrap) noexcept {
358 using enum texture_wrap;
359 switch (wrap) {
360 case REPEAT: return "repeat";
361 case BLACK: return "black";
362 case CLAMP: return "clamp";
363 case MAX_NUM: return "maxnum";
364 default: return "UNKNOWN";
365 }
366 }
367
384
391 [[nodiscard]] constexpr std::string_view to_string(const texture_filter filter) noexcept {
392 using enum texture_filter;
393 switch (filter) {
394 case BILINEAR: return "bilinear";
395 case EWA: return "ewa";
396 case TRILINEAR: return "trilinear";
397 case POINT: return "point";
398 case MAX_NUM: return "maxnum";
399 default: return "UNKNOWN";
400 }
401 }
402
417
424 [[nodiscard]] constexpr std::string_view to_string(const texture_encoding encoding) noexcept {
425 using enum texture_encoding;
426 switch (encoding) {
427 case SRGB: return "sRGB";
428 case LINEAR: return "linear";
429 case GAMMA: return "gamma";
430 case MAX_NUM: return "maxnum";
431 default: return "UNKNOWN";
432 }
433 }
434
439 struct texture_image_map_params : detail::wrapper<texture_image_map_params, tpbrt_texture_image_map_params_t> {
441 using wrapper::wrapper;
442
444 [[nodiscard]] constexpr string file_name() const noexcept { return _native->file_name; }
445
447 [[nodiscard]] constexpr float_t max_anisotropy() const noexcept { return _native->max_anisotropy; }
448
450 [[nodiscard]] constexpr float_t scale() const noexcept { return _native->scale; }
451
453 [[nodiscard]] constexpr opt_float gamma() const noexcept { return _native->gamma; }
454
456 [[nodiscard]] constexpr texture_wrap wrap() const noexcept { return static_cast<texture_wrap>(_native->wrap); }
457
459 [[nodiscard]] constexpr texture_filter filter() const noexcept { return static_cast<texture_filter>(_native->filter); }
460
462 [[nodiscard]] constexpr texture_encoding encoding() const noexcept {
463 return static_cast<texture_encoding>(_native->encoding);
464 }
465
467 [[nodiscard]] constexpr bool_t invert() const noexcept { return _native->invert; }
468
470 [[nodiscard]] constexpr auto reflect() const noexcept {
471 return std::make_tuple(file_name(), max_anisotropy(), scale(), gamma(), wrap(), filter(), encoding(), invert());
472 }
473 };
474
479 struct texture_marble_params : detail::wrapper<texture_marble_params, tpbrt_texture_marble_params_t> {
481 using wrapper::wrapper;
482
484 [[nodiscard]] constexpr uint_t octaves() const noexcept { return _native->octaves; }
485
487 [[nodiscard]] constexpr float_t roughness() const noexcept { return _native->roughness; }
488
490 [[nodiscard]] constexpr float_t scale() const noexcept { return _native->scale; }
491
493 [[nodiscard]] constexpr float_t variation() const noexcept { return _native->variation; }
494
496 [[nodiscard]] constexpr auto reflect() const noexcept {
497 return std::make_tuple(octaves(), roughness(), scale(), variation());
498 }
499 };
500
505 struct texture_mix_params : detail::wrapper<texture_mix_params, tpbrt_texture_mix_params_t> {
507 using wrapper::wrapper;
508
510 [[nodiscard]] constexpr texture_handle tex1() const noexcept { return _native->tex1; }
511
513 [[nodiscard]] constexpr texture_handle tex2() const noexcept { return _native->tex2; }
514
516 [[nodiscard]] constexpr texture_handle amount() const noexcept { return _native->amount; }
517
519 [[nodiscard]] constexpr auto reflect() const noexcept { return std::make_tuple(tex1(), tex2(), amount()); }
520 };
521
526 struct texture_ptex_params : detail::wrapper<texture_ptex_params, tpbrt_texture_ptex_params_t> {
528 using wrapper::wrapper;
529
531 [[nodiscard]] constexpr opt_float gamma() const noexcept { return _native->gamma; }
532
534 [[nodiscard]] constexpr string file_name() const noexcept { return _native->file_name; }
535
537 [[nodiscard]] constexpr float_t scale() const noexcept { return _native->scale; }
538
540 [[nodiscard]] constexpr texture_encoding encoding() const noexcept {
541 return static_cast<texture_encoding>(_native->encoding);
542 }
543
545 [[nodiscard]] constexpr auto reflect() const noexcept {
546 return std::make_tuple(gamma(), file_name(), scale(), encoding());
547 }
548 };
549
554 struct texture_scale_params : detail::wrapper<texture_scale_params, tpbrt_texture_scale_params_t> {
556 using wrapper::wrapper;
557
559 [[nodiscard]] constexpr texture_handle tex() const noexcept { return _native->tex; }
560
562 [[nodiscard]] constexpr texture_handle scale() const noexcept { return _native->scale; }
563
565 [[nodiscard]] constexpr auto reflect() const noexcept { return std::make_tuple(tex(), scale()); }
566 };
567
584
591 [[nodiscard]] constexpr std::string_view to_string(const texture_mapping mapping) noexcept {
592 using enum texture_mapping;
593 switch (mapping) {
594 case UV: return "uv";
595 case SPHERICAL: return "spherical";
596 case CYLINDRICAL: return "cylindrical";
597 case PLANAR: return "planar";
598 case MAX_NUM: return "maxnum";
599 default: return "UNKNOWN";
600 }
601 }
602
607 struct texture_mapping_uv_params : detail::wrapper<texture_mapping_uv_params, tpbrt_texture_mapping_uv_params_t> {
609 using wrapper::wrapper;
610
612 [[nodiscard]] constexpr float_t u_scale() const noexcept { return _native->u_scale; }
613
615 [[nodiscard]] constexpr float_t v_scale() const noexcept { return _native->v_scale; }
616
618 [[nodiscard]] constexpr float_t u_delta() const noexcept { return _native->u_delta; }
619
621 [[nodiscard]] constexpr float_t v_delta() const noexcept { return _native->v_delta; }
622
624 [[nodiscard]] constexpr auto reflect() const noexcept {
625 return std::make_tuple(u_scale(), v_scale(), u_delta(), v_delta());
626 }
627 };
628
635 template<texture_mapping Mapping>
637 : detail::wrapper<texture_mapping_transform_params<Mapping>, tpbrt_texture_mapping_spherical_params_t> {
639 static constexpr texture_mapping TextureMapping = Mapping;
640
643
645 [[nodiscard]] constexpr transform_handle transform() const noexcept { return this->_native->transform; }
646
648 [[nodiscard]] constexpr auto reflect() const noexcept { return std::make_tuple(transform()); }
649 };
650
656
662
668 struct texture_mapping_planar_params : detail::wrapper<texture_mapping_planar_params, tpbrt_texture_mapping_planar_params_t> {
670 using wrapper::wrapper;
671
673 [[nodiscard]] constexpr float_t u_delta() const noexcept { return _native->u_delta; }
674
676 [[nodiscard]] constexpr float_t v_delta() const noexcept { return _native->v_delta; }
677
679 [[nodiscard]] constexpr vec v1() const noexcept { return _native->v1; }
680
682 [[nodiscard]] constexpr vec v2() const noexcept { return _native->v2; }
683
685 [[nodiscard]] constexpr auto reflect() const noexcept { return std::make_tuple(u_delta(), v_delta(), v1(), v2()); }
686 };
687
692 struct texture
693 : detail::wrapper<texture, tpbrt_texture_t>,
694 detail::with_variant<texture, texture_bilerp_params, texture_checkerboard_params, texture_constant_params,
695 texture_direction_mix_params, texture_dots_params, texture_fbm_params, texture_wrinkled_params, texture_windy_params,
696 texture_image_map_params, texture_marble_params, texture_mix_params, texture_ptex_params, texture_scale_params> {
700
702 using wrapper::wrapper;
703
705 [[nodiscard]] constexpr texture_idx_t idx() const noexcept { return _native->idx; }
706
708 [[nodiscard]] constexpr string name() const noexcept { return _native->name; }
709
711 [[nodiscard]] constexpr texture_type type() const noexcept { return static_cast<texture_type>(_native->type); }
712
714 [[nodiscard]] constexpr texture_class tex_class() const noexcept {
715 return static_cast<texture_class>(_native->tex_class);
716 }
717
719 [[nodiscard]] constexpr bool_t is_bilerp() const noexcept { return tex_class() == texture_class::BILERP; }
720
722 [[nodiscard]] constexpr bool_t is_checkerboard() const noexcept { return tex_class() == texture_class::CHECKER_BOARD; }
723
725 [[nodiscard]] constexpr bool_t is_constant() const noexcept { return tex_class() == texture_class::CONSTANT; }
726
728 [[nodiscard]] constexpr bool_t is_direction_mix() const noexcept { return tex_class() == texture_class::DIRECTION_MIX; }
729
731 [[nodiscard]] constexpr bool_t is_dots() const noexcept { return tex_class() == texture_class::DOTS; }
732
734 [[nodiscard]] constexpr bool_t is_fbm() const noexcept { return tex_class() == texture_class::FBM; }
735
737 [[nodiscard]] constexpr bool_t is_wrinkled() const noexcept { return tex_class() == texture_class::WRINKLED; }
738
740 [[nodiscard]] constexpr bool_t is_windy() const noexcept { return tex_class() == texture_class::WINDY; }
741
743 [[nodiscard]] constexpr bool_t is_image_map() const noexcept { return tex_class() == texture_class::IMAGE_MAP; }
744
746 [[nodiscard]] constexpr bool_t is_marble() const noexcept { return tex_class() == texture_class::MARBLE; }
747
749 [[nodiscard]] constexpr bool_t is_mix() const noexcept { return tex_class() == texture_class::MIX; }
750
752 [[nodiscard]] constexpr bool_t is_ptex() const noexcept { return tex_class() == texture_class::PTEX; }
753
755 [[nodiscard]] constexpr bool_t is_scale() const noexcept { return tex_class() == texture_class::SCALE; }
756
758 [[nodiscard]] constexpr std::optional<texture_bilerp_params> as_bilerp() const noexcept {
759 if (!is_bilerp()) { return std::nullopt; }
760 return _native->as.bilerp;
761 }
762
764 [[nodiscard]] constexpr std::optional<texture_checkerboard_params> as_checkerboard() const noexcept {
765 if (!is_checkerboard()) { return std::nullopt; }
766 return _native->as.checkerboard;
767 }
768
770 [[nodiscard]] constexpr std::optional<texture_constant_params> as_constant() const noexcept {
771 if (!is_constant()) { return std::nullopt; }
772 return _native->as.constant;
773 }
774
776 [[nodiscard]] constexpr std::optional<texture_direction_mix_params> as_direction_mix() const noexcept {
777 if (!is_direction_mix()) { return std::nullopt; }
778 return _native->as.direction_mix;
779 }
780
782 [[nodiscard]] constexpr std::optional<texture_dots_params> as_dots() const noexcept {
783 if (!is_dots()) { return std::nullopt; }
784 return _native->as.dots;
785 }
786
788 [[nodiscard]] constexpr std::optional<texture_fbm_params> as_fbm() const noexcept {
789 if (!is_fbm()) { return std::nullopt; }
790 return _native->as.fbm;
791 }
792
794 [[nodiscard]] constexpr std::optional<texture_wrinkled_params> as_wrinkled() const noexcept {
795 if (!is_wrinkled()) { return std::nullopt; }
796 return _native->as.wrinkled;
797 }
798
800 [[nodiscard]] constexpr std::optional<texture_windy_params> as_windy() const noexcept {
801 if (!is_windy()) { return std::nullopt; }
802 return _native->as.windy;
803 }
804
806 [[nodiscard]] constexpr std::optional<texture_image_map_params> as_image_map() const noexcept {
807 if (!is_image_map()) { return std::nullopt; }
808 return _native->as.image_map;
809 }
810
812 [[nodiscard]] constexpr std::optional<texture_marble_params> as_marble() const noexcept {
813 if (!is_marble()) { return std::nullopt; }
814 return _native->as.marble;
815 }
816
818 [[nodiscard]] constexpr std::optional<texture_mix_params> as_mix() const noexcept {
819 if (!is_mix()) { return std::nullopt; }
820 return _native->as.mix;
821 }
822
824 [[nodiscard]] constexpr std::optional<texture_ptex_params> as_ptex() const noexcept {
825 if (!is_ptex()) { return std::nullopt; }
826 return _native->as.ptex;
827 }
828
830 [[nodiscard]] constexpr std::optional<texture_scale_params> as_scale() const noexcept {
831 if (!is_scale()) { return std::nullopt; }
832 return _native->as.scale;
833 }
834
836 [[nodiscard]] constexpr variant_type to_variant() const noexcept {
837 using enum texture_class;
838 switch (tex_class()) {
839 case BILERP: return _native->as.bilerp;
840 case CHECKER_BOARD: return _native->as.checkerboard;
841 case CONSTANT: return _native->as.constant;
842 case DIRECTION_MIX: return _native->as.direction_mix;
843 case DOTS: return _native->as.dots;
844 case FBM: return texture_fbm_params(_native->as.fbm);
845 case WRINKLED: return texture_wrinkled_params(_native->as.wrinkled);
846 case WINDY: return texture_windy_params(_native->as.windy);
847 case IMAGE_MAP: return _native->as.image_map;
848 case MARBLE: return _native->as.marble;
849 case MIX: return _native->as.mix;
850 case PTEX: return _native->as.ptex;
851 case SCALE: return _native->as.scale;
852 case MAX_NUM: [[fallthrough]];
853 default: break;
854 }
855 return std::nullopt;
856 }
857
859 [[nodiscard]] constexpr texture_mapping mapping() const noexcept {
860 return static_cast<texture_mapping>(_native->mapping);
861 }
862
864 [[nodiscard]] constexpr bool_t is_mapping_uv() const noexcept { return mapping() == texture_mapping::UV; }
865
867 [[nodiscard]] constexpr bool_t is_mapping_spherical() const noexcept { return mapping() == texture_mapping::SPHERICAL; }
868
870 [[nodiscard]] constexpr bool_t is_mapping_cylindrical() const noexcept {
872 }
873
875 [[nodiscard]] constexpr bool_t is_mapping_planar() const noexcept { return mapping() == texture_mapping::PLANAR; }
876
878 [[nodiscard]] constexpr std::optional<texture_mapping_uv_params> mapping_as_uv() const noexcept {
879 if (!is_mapping_uv()) { return std::nullopt; }
880 return _native->mapping_as.uv;
881 }
882
884 [[nodiscard]] constexpr std::optional<texture_mapping_spherical_params> mapping_as_spherical() const noexcept {
885 if (!is_mapping_spherical()) { return std::nullopt; }
886 return _native->mapping_as.spherical;
887 }
888
890 [[nodiscard]] constexpr std::optional<texture_mapping_cylindrical_params> mapping_as_cylindrical() const noexcept {
891 if (!is_mapping_cylindrical()) { return std::nullopt; }
892 return _native->mapping_as.cylindrical;
893 }
894
896 [[nodiscard]] constexpr std::optional<texture_mapping_planar_params> mapping_as_planar() const noexcept {
897 if (!is_mapping_planar()) { return std::nullopt; }
898 return _native->mapping_as.planar;
899 }
900
902 [[nodiscard]] constexpr mapping_variant_type mapping_to_variant() const noexcept {
903 using enum texture_mapping;
904 switch (mapping()) {
905 case UV: return _native->mapping_as.uv;
906 case SPHERICAL: return texture_mapping_spherical_params(_native->mapping_as.spherical);
907 case CYLINDRICAL: return texture_mapping_cylindrical_params(_native->mapping_as.cylindrical);
908 case PLANAR: return _native->mapping_as.planar;
909 case MAX_NUM: [[fallthrough]];
910 default: break;
911 }
912 return std::nullopt;
913 }
914
916 template<class Visitor>
917 constexpr auto visit_mapping(Visitor&& visitor) const {
918 return detail::visit_optional(std::forward<Visitor>(visitor), mapping_to_variant());
919 }
920
922 [[nodiscard]] constexpr auto reflect() const noexcept {
923 return std::make_tuple(idx(), type(), tex_class(), mapping(), name(), mapping_to_variant(), to_variant());
924 }
925 };
926
933 struct textures_list : array<tpbrt_textures_list_t, texture, &tpbrt_textures_list_t::textures> {
935 using array::array;
936
938 using array::at;
939
941 using array::operator[];
942
944 [[nodiscard]] result<element_type> at(const texture_handle handle) const noexcept {
945 return detail::find_in<element_type, tpbrt_texture_t>(tpbrt_get_texture_by_handle, _native, &handle.native());
946 }
947
949 [[nodiscard]] result<element_type> at(const std::string_view name) const noexcept {
950 return detail::find_in<element_type, tpbrt_texture_t>(tpbrt_get_texture_by_name, _native,
951 detail::to_native_string(name));
952 }
953
955 [[nodiscard]] result<element_type> operator[](const texture_handle handle) const noexcept { return at(handle); }
956
958 [[nodiscard]] result<element_type> operator[](const std::string_view name) const noexcept { return at(name); }
959 };
960
968 [[nodiscard]] inline result<texture> get_texture(const textures_list list, const texture_handle handle) noexcept {
969 return list.at(handle);
970 }
971
979 [[nodiscard]] inline result<texture> get_texture(const textures_list list, const std::string_view name) noexcept {
980 return list.at(name);
981 }
982} // namespace tpbrt
983#endif // _TINYPBRT_TEXTURE_HPP_
constexpr std::string_view to_string(const accelerator_type type) noexcept
Converts accelerator_type enum value to string.
Definition accelerator.hpp:39
@ MAX_NUM
Count of available accelerator types.
@ SPHERICAL
Spherical camera.
@ CONSTANT
Spectrum defined as single constant float value.
@ SRGB
The venerable sRGB color space; it has the smallest gamut of pbrt-v4's color spaces,...
tpbrt_uchar_t uchar_t
Unsigned char type.
Definition fwd.hpp:34
@ POINT
Point light source.
tpbrt_uint_t uint_t
Unsigned int type.
Definition fwd.hpp:92
bool bool_t
Bool type.
Definition fwd.hpp:82
tpbrt_float_t float_t
Float type.
Definition fwd.hpp:97
tpbrt_texture_idx_t texture_idx_t
Texture index type.
Definition fwd.hpp:254
texture_encoding
Texture encoding types.
Definition texture.hpp:407
texture_noise_params< texture_class::FBM > texture_fbm_params
C++ wrapper for tpbrt_texture_fbm_params_t.
Definition texture.hpp:322
texture_noise_params< texture_class::WRINKLED > texture_wrinkled_params
C++ wrapper for tpbrt_texture_wrinkled_params_t.
Definition texture.hpp:328
result< texture > get_texture(const textures_list list, const texture_handle handle) noexcept
Returns texture to which handle is provided.
Definition texture.hpp:968
texture_class
Texture classes.
Definition texture.hpp:133
texture_handle_value_type
Texture handle value types.
Definition texture.hpp:23
texture_mapping
Texture mapping types.
Definition texture.hpp:572
texture_type
Textures types.
Definition texture.hpp:104
texture_wrap
Texture wrap types.
Definition texture.hpp:340
texture_filter
Texture filter types.
Definition texture.hpp:372
texture_mapping_transform_params< texture_mapping::CYLINDRICAL > texture_mapping_cylindrical_params
C++ wrapper for tpbrt_texture_mapping_cylindrical_params_t.
Definition texture.hpp:661
texture_noise_params< texture_class::WINDY > texture_windy_params
C++ wrapper for tpbrt_texture_windy_params_t.
Definition texture.hpp:334
texture_mapping_transform_params< texture_mapping::SPHERICAL > texture_mapping_spherical_params
C++ wrapper for tpbrt_texture_mapping_spherical_params_t.
Definition texture.hpp:655
@ GAMMA
Applies a gamma correction curve with the specified exponent.
@ LINEAR
Directly maps them, dividing their values by 255.
@ MARBLE
Marble texture.
@ SCALE
Scale texture.
@ IMAGE_MAP
Image map texture.
@ WRINKLED
Wrinkled texture.
@ DIRECTION_MIX
Direction mix texture.
@ CHECKER_BOARD
Checker board texture.
@ CONSTANT
Constant texture.
@ PTEX
PTEX texture.
@ BILERP
Bilerp texture.
@ DOTS
Dots texture.
@ MIX
Mix texture.
@ FBM
FBM texture.
@ WINDY
Windy texture.
@ PLANAR
Planar mapping.
@ SPHERICAL
Spherical mapping.
@ UV
Based on the surface's (u,v) parameterization.
@ CYLINDRICAL
Cylindrical mapping.
@ FLOAT
Float texture.
@ BLACK
Returns black when outside the legal range.
@ REPEAT
Simply tiles the texture.
@ CLAMP
Always returns the nearest border texel.
@ TRILINEAR
Does trilinear interpolation between two MIP levels.
@ BILINEAR
Does bilinear sampling of a single MIP level.
@ EWA
Uses the high quality but much slower elliptically weighted average algorithm.
tpbrt_error_t tpbrt_get_texture_by_name(const tpbrt_textures_list_t *textures, tpbrt_string_t name, const tpbrt_texture_t **texture)
Returns pointer to texture with given name.
tpbrt_error_t tpbrt_get_texture_by_handle(const tpbrt_textures_list_t *textures, const tpbrt_texture_handle_t *handle, const tpbrt_texture_t **texture)
Returns pointer to texture to which handle is provided.
@ TPBRT_TEXTURE_WRAP_MAX_NUM
Count of available texture wrap types.
Definition texture.h:197
@ TPBRT_TEXTURE_WRAP_REPEAT
Simply tiles the texture.
Definition texture.h:191
@ TPBRT_TEXTURE_WRAP_BLACK
Returns black when outside the legal range.
Definition texture.h:193
@ TPBRT_TEXTURE_WRAP_CLAMP
Always returns the nearest border texel.
Definition texture.h:195
@ TPBRT_TEXTURE_TYPE_FLOAT
Float texture.
Definition texture.h:58
@ TPBRT_TEXTURE_TYPE_MAX_NUM
Count of available texture types.
Definition texture.h:62
@ TPBRT_TEXTURE_TYPE_SPECTRUM
Spectrum texture.
Definition texture.h:60
@ TPBRT_TEXTURE_FILTER_BILINEAR
Does bilinear sampling of a single MIP level.
Definition texture.h:206
@ TPBRT_TEXTURE_FILTER_TRILINEAR
Does trilinear interpolation between two MIP levels.
Definition texture.h:210
@ TPBRT_TEXTURE_FILTER_EWA
Uses the high quality but much slower elliptically weighted average algorithm.
Definition texture.h:208
@ TPBRT_TEXTURE_FILTER_POINT
Point sampling.
Definition texture.h:212
@ TPBRT_TEXTURE_FILTER_MAX_NUM
Count of available texture filter types.
Definition texture.h:214
@ TPBRT_TEXTURE_ENCODING_MAX_NUM
Count of available texture encoding types.
Definition texture.h:229
@ TPBRT_TEXTURE_ENCODING_SRGB
Applies the sRGB nonlinear mapping.
Definition texture.h:223
@ TPBRT_TEXTURE_ENCODING_GAMMA
Applies a gamma correction curve with the specified exponent.
Definition texture.h:227
@ TPBRT_TEXTURE_ENCODING_LINEAR
Directly maps them, dividing their values by 255.
Definition texture.h:225
@ TPBRT_TEXTURE_CLASS_WRINKLED
Wrinkled texture.
Definition texture.h:95
@ TPBRT_TEXTURE_CLASS_CONSTANT
Constant texture.
Definition texture.h:75
@ TPBRT_TEXTURE_CLASS_MIX
Mix texture.
Definition texture.h:87
@ TPBRT_TEXTURE_CLASS_BILERP
Bilerp texture.
Definition texture.h:71
@ TPBRT_TEXTURE_CLASS_PTEX
PTEX texture.
Definition texture.h:89
@ TPBRT_TEXTURE_CLASS_MAX_NUM
Count of available texture classes.
Definition texture.h:97
@ TPBRT_TEXTURE_CLASS_DOTS
Dots texture.
Definition texture.h:79
@ TPBRT_TEXTURE_CLASS_SCALE
Scale texture.
Definition texture.h:91
@ TPBRT_TEXTURE_CLASS_FBM
FBM texture.
Definition texture.h:81
@ TPBRT_TEXTURE_CLASS_WINDY
Windy texture.
Definition texture.h:93
@ TPBRT_TEXTURE_CLASS_MARBLE
Marble texture.
Definition texture.h:85
@ TPBRT_TEXTURE_CLASS_DIRECTION_MIX
Direction mix texture.
Definition texture.h:77
@ TPBRT_TEXTURE_CLASS_IMAGE_MAP
Image map texture.
Definition texture.h:83
@ TPBRT_TEXTURE_CLASS_CHECKER_BOARD
Checker board texture.
Definition texture.h:73
@ TPBRT_TEXTURE_MAPPING_UV
Based on the surface's (u,v) parameterization.
Definition texture.h:315
@ TPBRT_TEXTURE_MAPPING_SPHERICAL
Spherical mapping.
Definition texture.h:317
@ TPBRT_TEXTURE_MAPPING_PLANAR
Planar mapping.
Definition texture.h:321
@ TPBRT_TEXTURE_MAPPING_CYLINDRICAL
Cylindrical mapping.
Definition texture.h:319
@ TPBRT_TEXTURE_MAPPING_MAX_NUM
Count of available texture mapping types.
Definition texture.h:323
@ TPBRT_TEXTURE_HANDLE_VALUE_TYPE_SPECTRUM
Spectrum.
Definition texture.h:30
@ TPBRT_TEXTURE_HANDLE_VALUE_TYPE_MAX_NUM
Count of available texture handle value types.
Definition texture.h:32
@ TPBRT_TEXTURE_HANDLE_VALUE_TYPE_TEXTURE_IDX
Texture index.
Definition texture.h:28
Definition accelerator.hpp:14
Generic C++ array view with type conversion (a non owning view on memory owned by the C library).
Definition common.hpp:448
constexpr result< element_type > at(const size_t index) const noexcept
Returns element on given index or error::INDEX_OUT_OF_RANGE.
Definition common.hpp:519
C++ wrapper for tpbrt_filter_t.
Definition filter.hpp:108
C++ wrapper for tpbrt_opt_float_t.
Definition math.hpp:24
Result of an operation: either a value or an error code (similar to C++23 std::expected).
Definition error.hpp:165
C++ wrapper for tpbrt_texture_bilerp_params_t.
Definition texture.hpp:195
constexpr texture_handle v00() const noexcept
Returns v00 value.
Definition texture.hpp:200
constexpr texture_handle v11() const noexcept
Returns v11 value.
Definition texture.hpp:209
constexpr texture_handle v10() const noexcept
Returns v10 value.
Definition texture.hpp:206
constexpr texture_handle v01() const noexcept
Returns v01 value.
Definition texture.hpp:203
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition texture.hpp:212
C++ wrapper for tpbrt_texture_checkerboard_params_t.
Definition texture.hpp:219
constexpr uint_t dimension() const noexcept
Returns dimension value.
Definition texture.hpp:230
constexpr texture_handle tex2() const noexcept
Returns tex2 value.
Definition texture.hpp:227
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition texture.hpp:233
constexpr texture_handle tex1() const noexcept
Returns tex1 value.
Definition texture.hpp:224
C++ wrapper for tpbrt_texture_constant_params_t.
Definition texture.hpp:240
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition texture.hpp:248
constexpr texture_handle value() const noexcept
Returns value value.
Definition texture.hpp:245
C++ wrapper for tpbrt_texture_direction_mix_params_t.
Definition texture.hpp:255
constexpr texture_handle tex1() const noexcept
Returns tex1 value.
Definition texture.hpp:260
constexpr texture_handle tex2() const noexcept
Returns tex2 value.
Definition texture.hpp:263
constexpr vec dir() const noexcept
Returns dir value.
Definition texture.hpp:266
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition texture.hpp:269
C++ wrapper for tpbrt_texture_dots_params_t.
Definition texture.hpp:276
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition texture.hpp:287
constexpr texture_handle outside() const noexcept
Returns outside value.
Definition texture.hpp:284
constexpr texture_handle inside() const noexcept
Returns inside value.
Definition texture.hpp:281
C++ wrapper for tpbrt_texture_handle_t.
Definition texture.hpp:53
constexpr variant_type to_variant() const noexcept
Conversion to variant.
Definition texture.hpp:85
constexpr bool_t is_texture_idx() const noexcept
Returns true if type is texture_idx.
Definition texture.hpp:63
constexpr bool_t is_spectrum() const noexcept
Returns true if type is spectrum.
Definition texture.hpp:68
constexpr std::optional< spectrum > as_spectrum() const noexcept
Returns texture handle value as spectrum.
Definition texture.hpp:79
constexpr std::optional< texture_idx_t > as_texture_idx() const noexcept
Returns texture handle value as texture_idx.
Definition texture.hpp:73
constexpr texture_handle_value_type value_type() const noexcept
Returns value_type value.
Definition texture.hpp:58
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition texture.hpp:97
C++ wrapper for tpbrt_texture_image_map_params_t.
Definition texture.hpp:439
constexpr opt_float gamma() const noexcept
Returns gamma value.
Definition texture.hpp:453
constexpr float_t max_anisotropy() const noexcept
Returns max_anisotropy value.
Definition texture.hpp:447
constexpr texture_wrap wrap() const noexcept
Returns wrap value.
Definition texture.hpp:456
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition texture.hpp:470
constexpr texture_filter filter() const noexcept
Returns filter value.
Definition texture.hpp:459
constexpr float_t scale() const noexcept
Returns scale value.
Definition texture.hpp:450
constexpr texture_encoding encoding() const noexcept
Returns encoding value.
Definition texture.hpp:462
constexpr bool_t invert() const noexcept
Returns invert value.
Definition texture.hpp:467
constexpr string file_name() const noexcept
Returns file_name value.
Definition texture.hpp:444
C++ wrapper for tpbrt_texture_mapping_planar_params_t.
Definition texture.hpp:668
constexpr vec v1() const noexcept
Returns v1 value.
Definition texture.hpp:679
constexpr float_t u_delta() const noexcept
Returns u_delta value.
Definition texture.hpp:673
constexpr float_t v_delta() const noexcept
Returns v_delta value.
Definition texture.hpp:676
constexpr vec v2() const noexcept
Returns v2 value.
Definition texture.hpp:682
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition texture.hpp:685
C++ wrapper for tpbrt_texture_mapping_spherical_params_t, shared by the spherical and cylindrical map...
Definition texture.hpp:637
static constexpr texture_mapping TextureMapping
Mapping described by these parameters.
Definition texture.hpp:639
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition texture.hpp:648
constexpr transform_handle transform() const noexcept
Returns transform value.
Definition texture.hpp:645
C++ wrapper for tpbrt_texture_mapping_uv_params_t.
Definition texture.hpp:607
constexpr float_t v_delta() const noexcept
Returns v_delta value.
Definition texture.hpp:621
constexpr float_t u_scale() const noexcept
Returns u_scale value.
Definition texture.hpp:612
constexpr float_t v_scale() const noexcept
Returns v_scale value.
Definition texture.hpp:615
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition texture.hpp:624
constexpr float_t u_delta() const noexcept
Returns u_delta value.
Definition texture.hpp:618
C++ wrapper for tpbrt_texture_marble_params_t.
Definition texture.hpp:479
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition texture.hpp:496
constexpr float_t roughness() const noexcept
Returns roughness value.
Definition texture.hpp:487
constexpr float_t scale() const noexcept
Returns scale value.
Definition texture.hpp:490
constexpr uint_t octaves() const noexcept
Returns octaves value.
Definition texture.hpp:484
constexpr float_t variation() const noexcept
Returns variation value.
Definition texture.hpp:493
C++ wrapper for tpbrt_texture_mix_params_t.
Definition texture.hpp:505
constexpr texture_handle tex1() const noexcept
Returns tex1 value.
Definition texture.hpp:510
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition texture.hpp:519
constexpr texture_handle amount() const noexcept
Returns amount value.
Definition texture.hpp:516
constexpr texture_handle tex2() const noexcept
Returns tex2 value.
Definition texture.hpp:513
C++ wrapper for tpbrt_texture_fbm_params_t, shared by the fbm, wrinkled and windy textures.
Definition texture.hpp:298
constexpr transform_handle transform() const noexcept
Returns transform value.
Definition texture.hpp:312
static constexpr texture_class TextureClass
Texture class described by these parameters.
Definition texture.hpp:300
constexpr float_t roughness() const noexcept
Returns roughness value.
Definition texture.hpp:309
constexpr uint_t octaves() const noexcept
Returns octaves value.
Definition texture.hpp:306
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition texture.hpp:315
C++ wrapper for tpbrt_texture_ptex_params_t.
Definition texture.hpp:526
constexpr opt_float gamma() const noexcept
Returns gamma value.
Definition texture.hpp:531
constexpr float_t scale() const noexcept
Returns scale value.
Definition texture.hpp:537
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition texture.hpp:545
constexpr string file_name() const noexcept
Returns file_name value.
Definition texture.hpp:534
constexpr texture_encoding encoding() const noexcept
Returns encoding value.
Definition texture.hpp:540
C++ wrapper for tpbrt_texture_scale_params_t.
Definition texture.hpp:554
constexpr texture_handle scale() const noexcept
Returns scale value.
Definition texture.hpp:562
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition texture.hpp:565
constexpr texture_handle tex() const noexcept
Returns tex value.
Definition texture.hpp:559
C++ wrapper for tpbrt_texture_t.
Definition texture.hpp:696
constexpr std::optional< texture_windy_params > as_windy() const noexcept
Returns texture parameters as windy.
Definition texture.hpp:800
constexpr std::optional< texture_mapping_spherical_params > mapping_as_spherical() const noexcept
Returns texture mapping parameters as spherical.
Definition texture.hpp:884
constexpr std::optional< texture_bilerp_params > as_bilerp() const noexcept
Returns texture parameters as bilerp.
Definition texture.hpp:758
constexpr std::optional< texture_ptex_params > as_ptex() const noexcept
Returns texture parameters as ptex.
Definition texture.hpp:824
constexpr bool_t is_checkerboard() const noexcept
Returns true if type is checkerboard.
Definition texture.hpp:722
constexpr bool_t is_mix() const noexcept
Returns true if type is mix.
Definition texture.hpp:749
constexpr bool_t is_marble() const noexcept
Returns true if type is marble.
Definition texture.hpp:746
constexpr bool_t is_wrinkled() const noexcept
Returns true if type is wrinkled.
Definition texture.hpp:737
constexpr bool_t is_scale() const noexcept
Returns true if type is scale.
Definition texture.hpp:755
constexpr std::optional< texture_mapping_uv_params > mapping_as_uv() const noexcept
Returns texture mapping parameters as uv.
Definition texture.hpp:878
constexpr bool_t is_mapping_cylindrical() const noexcept
Returns true if type is cylindrical.
Definition texture.hpp:870
constexpr bool_t is_dots() const noexcept
Returns true if type is dots.
Definition texture.hpp:731
constexpr std::optional< texture_constant_params > as_constant() const noexcept
Returns texture parameters as constant.
Definition texture.hpp:770
constexpr string name() const noexcept
Returns name value.
Definition texture.hpp:708
constexpr bool_t is_windy() const noexcept
Returns true if type is windy.
Definition texture.hpp:740
constexpr bool_t is_image_map() const noexcept
Returns true if type is image_map.
Definition texture.hpp:743
constexpr std::optional< texture_mapping_planar_params > mapping_as_planar() const noexcept
Returns texture mapping parameters as planar.
Definition texture.hpp:896
constexpr bool_t is_mapping_planar() const noexcept
Returns true if type is planar.
Definition texture.hpp:875
constexpr variant_type to_variant() const noexcept
Conversion to variant.
Definition texture.hpp:836
constexpr bool_t is_bilerp() const noexcept
Returns true if type is bilerp.
Definition texture.hpp:719
constexpr bool_t is_direction_mix() const noexcept
Returns true if type is direction_mix.
Definition texture.hpp:728
constexpr bool_t is_mapping_uv() const noexcept
Returns true if type is uv.
Definition texture.hpp:864
constexpr std::optional< texture_fbm_params > as_fbm() const noexcept
Returns texture parameters as fbm.
Definition texture.hpp:788
constexpr std::optional< texture_mix_params > as_mix() const noexcept
Returns texture parameters as mix.
Definition texture.hpp:818
constexpr bool_t is_mapping_spherical() const noexcept
Returns true if type is spherical.
Definition texture.hpp:867
constexpr texture_mapping mapping() const noexcept
Returns mapping value.
Definition texture.hpp:859
constexpr texture_type type() const noexcept
Returns type value.
Definition texture.hpp:711
constexpr std::optional< texture_wrinkled_params > as_wrinkled() const noexcept
Returns texture parameters as wrinkled.
Definition texture.hpp:794
constexpr bool_t is_constant() const noexcept
Returns true if type is constant.
Definition texture.hpp:725
detail::optional_variant< texture_mapping_uv_params, texture_mapping_spherical_params, texture_mapping_cylindrical_params, texture_mapping_planar_params > mapping_variant_type
Type used for better reading mapping tagged union of parameters.
Definition texture.hpp:699
constexpr std::optional< texture_checkerboard_params > as_checkerboard() const noexcept
Returns texture parameters as checkerboard.
Definition texture.hpp:764
constexpr bool_t is_ptex() const noexcept
Returns true if type is ptex.
Definition texture.hpp:752
constexpr std::optional< texture_mapping_cylindrical_params > mapping_as_cylindrical() const noexcept
Returns texture mapping parameters as cylindrical.
Definition texture.hpp:890
constexpr texture_idx_t idx() const noexcept
Returns idx value.
Definition texture.hpp:705
constexpr std::optional< texture_marble_params > as_marble() const noexcept
Returns texture parameters as marble.
Definition texture.hpp:812
constexpr std::optional< texture_scale_params > as_scale() const noexcept
Returns texture parameters as scale.
Definition texture.hpp:830
constexpr std::optional< texture_direction_mix_params > as_direction_mix() const noexcept
Returns texture parameters as direction_mix.
Definition texture.hpp:776
constexpr texture_class tex_class() const noexcept
Returns tex_class value.
Definition texture.hpp:714
constexpr auto visit_mapping(Visitor &&visitor) const
Visits mapping parameters.
Definition texture.hpp:917
constexpr bool_t is_fbm() const noexcept
Returns true if type is fbm.
Definition texture.hpp:734
constexpr mapping_variant_type mapping_to_variant() const noexcept
Conversion to variant.
Definition texture.hpp:902
constexpr std::optional< texture_image_map_params > as_image_map() const noexcept
Returns texture parameters as image_map.
Definition texture.hpp:806
constexpr std::optional< texture_dots_params > as_dots() const noexcept
Returns texture parameters as dots.
Definition texture.hpp:782
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition texture.hpp:922
C++ wrapper for tpbrt_textures_list_t.
Definition texture.hpp:933
result< element_type > operator[](const std::string_view name) const noexcept
Returns texture with given name.
Definition texture.hpp:958
result< element_type > at(const texture_handle handle) const noexcept
Returns texture pointed by given handle.
Definition texture.hpp:944
result< element_type > operator[](const texture_handle handle) const noexcept
Returns texture pointed by given handle.
Definition texture.hpp:955
result< element_type > at(const std::string_view name) const noexcept
Returns texture with given name.
Definition texture.hpp:949
C++ wrapper for tpbrt_transform_handle_t.
Definition transform.hpp:24
C++ wrapper for tpbrt_vec3_t.
Definition math.hpp:132
FBM texture parameters.
Definition texture.h:165
Spherical texture mapping parameters.
Definition texture.h:345