Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
RasterFileImage.h
Go to the documentation of this file.
1#pragma once
2
5#include "SDL/sdl_interface.h"
9
10#include <memory>
11
12namespace ph
13{
14
15class RegularPicture;
16
18{
19public:
20 std::shared_ptr<TTexture<Image::ArrayType>> genNumericTexture(
21 const CookingContext& ctx) override;
22
23 std::shared_ptr<TTexture<math::Spectrum>> genColorTexture(
24 const CookingContext& ctx) override;
25
27 void setFilePath(Path filePath);
28
29protected:
30 std::shared_ptr<PixelBuffer2D> loadPixelBuffer(
31 const CookingContext& ctx,
32 math::EColorSpace* out_colorSpace = nullptr,
33 pixel_texture::EPixelLayout* out_pixelLayout = nullptr) const;
34
38
39private:
40 ResourceIdentifier m_imageFile;
41 math::EColorSpace m_colorSpace;
42 bool m_isColor;
43
44public:
46 {
47 ClassType clazz("raster-file");
48 clazz.docName("Raster File Image");
49 clazz.description(
50 "Raster-based image file (most common image file formats belongs to this category).");
51 clazz.baseOn<RasterImageBase>();
52
53 TSdlResourceIdentifier<OwnerType> imageFile("image-file", &OwnerType::m_imageFile);
54 imageFile.description("The image file.");
55 imageFile.required();
56 clazz.addField(imageFile);
57
58 TSdlEnumField<OwnerType, math::EColorSpace> colorSpace(&OwnerType::m_colorSpace);
59 colorSpace.description(
60 "Color space of the raster image. By default, color space is retrieved from the file, "
61 "and if such information is not available, the engine will make an educated guess. "
62 "If user has specified a non-default color space, then the engine will use it instead "
63 "(even if the file said otherwise). Note that when the image is used in numeric mode, "
64 "the engine still follow the same convention--color space is dropped and raw values "
65 "are used.");
67 colorSpace.optional();
68 clazz.addField(colorSpace);
69
70 TSdlBool<OwnerType> isColor("is-color", &OwnerType::m_isColor);
71 isColor.description(
72 "If this flag is set to false, then the raster image will be treated as raw data even "
73 "if the image is used in color mode. This is useful for situations where color-related "
74 "numeric values are used (e.g., math operations involving other color data). When the "
75 "engine is in spectral mode, raw data may be treated as linear sRGB if a direct "
76 "conversion is impossible.");
77 isColor.defaultTo(true);
78 isColor.optional();
79 clazz.addField(isColor);
80
81 return clazz;
82 }
83};
84
85}// end namespace ph
Information about the world being cooked.
Definition CookingContext.h:24
General path representation. Does not check whether the target actually exists (e....
Definition Path.h:21
Definition RasterFileImage.h:18
void setFilePath(Path filePath)
Definition RasterFileImage.cpp:180
pixel_texture::EWrapMode getTextureWrapModeT() const
Definition RasterFileImage.cpp:289
std::shared_ptr< PixelBuffer2D > loadPixelBuffer(const CookingContext &ctx, math::EColorSpace *out_colorSpace=nullptr, pixel_texture::EPixelLayout *out_pixelLayout=nullptr) const
Definition RasterFileImage.cpp:185
pixel_texture::EWrapMode getTextureWrapModeS() const
Definition RasterFileImage.cpp:284
PH_DEFINE_SDL_CLASS(TSdlOwnerClass< RasterFileImage >)
Definition RasterFileImage.h:45
pixel_texture::ESampleMode getTextureSampleMode() const
Definition RasterFileImage.cpp:265
RegularPicture loadRegularPicture() const
Definition RasterFileImage.cpp:166
std::shared_ptr< TTexture< math::Spectrum > > genColorTexture(const CookingContext &ctx) override
Definition RasterFileImage.cpp:101
std::shared_ptr< TTexture< Image::ArrayType > > genNumericTexture(const CookingContext &ctx) override
Definition RasterFileImage.cpp:86
Definition RasterImageBase.h:14
Raw representation of common picture types.
Definition RegularPicture.h:50
An general identifier that points to some resource. This is the most general form of a resource ident...
Definition ResourceIdentifier.h:20
A field class that binds a bool member variable.
Definition TSdlBool.h:21
Definition TSdlEnumField.h:23
SDL binding type for a canonical SDL resource class.
Definition TSdlOwnerClass.h:23
A field class that binds a resource identifier member. Though the member type that is binded by defau...
Definition TSdlResourceIdentifier.h:28
TSdlValue & description(std::string descriptionStr)
Definition TSdlValue.ipp:95
TSdlValue & optional()
Definition TSdlValue.ipp:103
TSdlValue & defaultTo(T defaultValue)
Definition TSdlValue.ipp:71
EColorSpace
Definition color_enums.h:7
EPixelLayout
Pixel layout of pixel texture. Represent the ordering of pixel components with respect to a color spa...
Definition pixel_texture_basics.h:40
EWrapMode
Definition pixel_texture_basics.h:21
ESampleMode
Definition pixel_texture_basics.h:28
The root for all renderer implementations.
Definition EEngineProject.h:6