src/raytracer.h
branchpyrit
changeset 21 79b516a3803d
parent 20 f22952603f29
equal deleted inserted replaced
20:f22952603f29 21:79b516a3803d
    18 
    18 
    19 class Raytracer;
    19 class Raytracer;
    20 struct RenderrowData {
    20 struct RenderrowData {
    21 	Raytracer *rt;
    21 	Raytracer *rt;
    22 	int w;
    22 	int w;
    23 	Vector3 eye, dfix, dx;
    23 	Vector3 eye, dfix, dx, dy;
    24 #if OVERSAMPLING
       
    25 	Vector3 dy;
       
    26 #endif
       
    27 	float *iter;
    24 	float *iter;
    28 };
    25 };
    29 
    26 
    30 class Raytracer
    27 class Raytracer
    31 {
    28 {
    34 	vector<Light*> lights;
    31 	vector<Light*> lights;
    35 	Colour bg_colour;
    32 	Colour bg_colour;
    36 	int ao_samples;
    33 	int ao_samples;
    37 	float ao_distance, ao_angle;
    34 	float ao_distance, ao_angle;
    38 	int num_threads;
    35 	int num_threads;
       
    36 	int subsample;
       
    37 	int max_depth;
    39 
    38 
    40 	Vector3 SphereDistribute(int i, int n, float extent, Vector3 &normal);
    39 	Vector3 SphereDistribute(int i, int n, float extent, Vector3 &normal);
    41 public:
    40 public:
    42 	Raytracer(): top(NULL), camera(NULL), lights(), bg_colour(0.0, 0.0, 0.0),
    41 	Raytracer(): top(NULL), camera(NULL), lights(), bg_colour(0.0, 0.0, 0.0),
    43 		ao_samples(0), num_threads(4) {};
    42 		ao_samples(0), num_threads(4), subsample(8), max_depth(4) {};
    44 	void render(int w, int h, float *buffer);
    43 	void render(int w, int h, float *buffer);
    45 	Colour raytrace(Ray &ray, int depth, Shape *origin_shape);
    44 	Colour raytrace(Ray &ray, int depth, Shape *origin_shape);
    46 	void addshape(Shape *shape) { top->addShape(shape); };
    45 	void addshape(Shape *shape) { top->addShape(shape); };
    47 	void addlight(Light *light);
    46 	void addlight(Light *light);
    48 	void setCamera(Camera *cam) { camera = cam; };
    47 	void setCamera(Camera *cam) { camera = cam; };
    49 	void setTop(Container *atop) { top = atop; };
    48 	void setTop(Container *atop) { top = atop; };
    50 	Container *getTop() { return top; };
    49 	Container *getTop() { return top; };
       
    50 	int getSubsample() { return subsample; };
       
    51 	void setMaxDepth(int newdepth) { max_depth = newdepth; };
    51 
    52 
    52 	void ambientocclusion(int samples, float distance, float angle);
    53 	void ambientocclusion(int samples, float distance, float angle);
    53 	void setThreads(int num) { num_threads = num; };
    54 	void setThreads(int num) { num_threads = num; };
    54 };
    55 };
    55 
    56