00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef LUX_FILM_H
00024 #define LUX_FILM_H
00025
00026 #include "lux.h"
00027 #include "color.h"
00028 #include "error.h"
00029
00030 #include <boost/serialization/split_member.hpp>
00031
00032 namespace lux {
00033
00034 enum ImageType {
00035 IMAGE_NONE = 0,
00036 IMAGE_FILEOUTPUT = 1 << 1,
00037 IMAGE_FRAMEBUFFER = 1 << 2,
00038 IMAGE_ALL = IMAGE_FILEOUTPUT | IMAGE_FRAMEBUFFER
00039 };
00040
00041
00042
00043 enum BufferType {
00044 BUF_TYPE_PER_PIXEL = 0,
00045 BUF_TYPE_PER_SCREEN,
00046 BUF_TYPE_RAW,
00047 NUM_OF_BUFFER_TYPES
00048 };
00049
00050 enum BufferOutputConfig {
00051 BUF_FRAMEBUFFER = 1 << 0,
00052 BUF_STANDALONE = 1 << 1,
00053 BUF_RAWDATA = 1 << 2
00054 };
00055
00056 class FlexImageFilm;
00057
00058 class ArrSample {
00059 friend class boost::serialization::access;
00060
00061 template<class Archive>
00062 void serialize(Archive & ar, const unsigned int version) {
00063 ar & sX;
00064 ar & sY;
00065 ar & xyz;
00066 ar & alpha;
00067 ar & buf_id;
00068 ar & bufferGroup;
00069 }
00070
00071 public:
00072 void Sample() {
00073 sX = 0;
00074 sY = 0;
00075 xyz = XYZColor(0.);
00076 alpha = 0;
00077 buf_id = 0;
00078 bufferGroup = 0;
00079 }
00080
00081 float sX;
00082 float sY;
00083 XYZColor xyz;
00084 float alpha;
00085 int buf_id;
00086 int bufferGroup;
00087 };
00088
00089
00090
00091 class Film {
00092 public:
00093
00094
00095 Film(int xres, int yres, int haltspp) :
00096 xResolution(xres), yResolution(yres), haltSamplePerPixel(haltspp),
00097 enoughSamplePerPixel(false) {
00098 invSamplePerPass = 1.0 / (xResolution * yResolution);
00099 }
00100 virtual ~Film() { }
00101
00102 virtual void AddSample(float sX, float sY, const XYZColor &L, float alpha, int buffer = 0, int bufferGroup = 0) = 0;
00103
00104 virtual void AddSampleCount(float count, int bufferGroup = 0) { }
00105 virtual void WriteImage(ImageType type) = 0;
00106 virtual void GetSampleExtent(int *xstart, int *xend, int *ystart, int *yend) const = 0;
00107
00108 virtual int RequestBuffer(BufferType type, BufferOutputConfig output, const string& filePostfix) {
00109 return 0;
00110 }
00111
00112 virtual void CreateBuffers() {
00113 }
00114 virtual unsigned char* getFrameBuffer() = 0;
00115 virtual void updateFrameBuffer() = 0;
00116 virtual float getldrDisplayInterval() = 0;
00117
00118 void SetScene(Scene *scene1) {
00119 scene = scene1;
00120 }
00121
00122
00123 int xResolution, yResolution;
00124 float* flux2radiance;
00125
00126
00127
00128 int haltSamplePerPixel;
00129 bool enoughSamplePerPixel;
00130
00131 protected:
00132 Scene *scene;
00133
00134
00135 float invSamplePerPass;
00136 };
00137
00138
00139 extern void ApplyImagingPipeline(float *rgb, int xResolution, int yResolution,
00140 float *yWeight = NULL, float bloomRadius = .2f,
00141 float bloomWeight = 0.f, const char *tonemap = NULL,
00142 const ParamSet *toneMapParams = NULL, float gamma = 2.2,
00143 float dither = 0.5f, int maxDisplayValue = 255);
00144
00145 }
00146
00147 #endif // LUX_FILM_H