Skip to content
This repository has been archived by the owner on Jul 18, 2020. It is now read-only.

Commit

Permalink
Merge pull request #101 from DavidBluecame/experimental
Browse files Browse the repository at this point in the history
Bring all YafaRay-E fork changes to official YafaRay, experimental branch
  • Loading branch information
DavidBluecame committed Apr 6, 2016
2 parents ee254c6 + e1d10f5 commit 44d44ed
Show file tree
Hide file tree
Showing 102 changed files with 4,667 additions and 2,050 deletions.
3 changes: 3 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ Bert Buchholz (bert)
Michele Castigliego (subcomandante)
Gustavo Boiko (boiko)
Rodrigo Placencia (DarkTide)

Developers for YafaRay-E (Experimental v0.1.99 and higher)
David Bluecame
2 changes: 1 addition & 1 deletion CMakeModules/FindYafSWIG.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ IF(SWIG_EXECUTABLE)
STRING(REGEX REPLACE "[\n\r]+" ";" SWIG_swiglib_output ${SWIG_swiglib_output})
# force the path to be computed each time in case SWIG_EXECUTABLE has changed.
SET(SWIG_DIR SWIG_DIR-NOTFOUND)
FIND_PATH(SWIG_DIR swig.swg PATHS ${SWIG_swiglib_output})
FIND_PATH(SWIG_DIR swig.swg PATHS ${SWIG_swiglib_output} NO_CMAKE_FIND_ROOT_PATH)
IF(SWIG_DIR)
SET(SWIG_FOUND 1)
SET(SWIG_USE_FILE ${CMAKE_SOURCE_DIR}/CMakeModules/UseYafSWIG.cmake)
Expand Down
7 changes: 6 additions & 1 deletion include/core_api/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class YAFRAYCORE_EXPORT camera_t
public:
camera_t() { }
camera_t(const point3d_t &pos, const point3d_t &look, const point3d_t &up, int _resx, int _resy, float aspect, float const near_clip_distance, float const far_clip_distance) :
position(pos), resx(_resx), resy(_resy), aspect_ratio(aspect * (PFLOAT)resy / (PFLOAT)resx)
position(pos), resx(_resx), resy(_resy), aspect_ratio(aspect * (PFLOAT)resy / (PFLOAT)resx),camera_name(""), view_name("")
{
// Calculate and store camera axis
camY = up - position;
Expand Down Expand Up @@ -76,6 +76,9 @@ class YAFRAYCORE_EXPORT camera_t
virtual bool project(const ray_t &wo, PFLOAT lu, PFLOAT lv, PFLOAT &u, PFLOAT &v, float &pdf) const { return false; }
virtual float getNearClip() const { return nearClip; }
virtual float getFarClip() const { return farClip; }
void set_camera_name(std::string name) { camera_name = name; }
std::string get_camera_name() const { return camera_name; }
std::string get_view_name() const { return view_name; }
protected:
point3d_t position; //!< Camera position

Expand All @@ -91,6 +94,8 @@ class YAFRAYCORE_EXPORT camera_t
vector3d_t vright;

float aspect_ratio; //<! Aspect ratio of camera (not image in pixel units!)
std::string camera_name; //<! Camera name
std::string view_name; //<! View name for file saving and Blender MultiView environment

Plane near_plane, far_plane;
float nearClip, farClip;
Expand Down
65 changes: 63 additions & 2 deletions include/core_api/color.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* color.h: Color type and operators api
* This is part of the yafray package
* Copyright (C) 2002 Alejandro Conty Estévez
* Copyright (C) 2015 David Bluecame for Color Space additions
* Copyright (C) 2015 David Bluecame for Color Space modifications
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand All @@ -23,9 +23,11 @@
#ifndef Y_COLOR_H
#define Y_COLOR_H

#include<yafray_config.h>
#include <yafray_config.h>

#include <iostream>
#include <vector>
#include <string>
#include <utilities/mathOptimizations.h>

#define COLOR_SIZE 3
Expand Down Expand Up @@ -131,6 +133,8 @@ class YAFRAYCORE_EXPORT color_t
if (B<0.0) B=0.0; else if (B>1.0) B=1.0;
}

void clampProportionalRGB(float maxValue);

CFLOAT linearRGB_from_sRGB(CFLOAT value_sRGB);
CFLOAT sRGB_from_linearRGB(CFLOAT value_linearRGB);

Expand Down Expand Up @@ -186,6 +190,8 @@ class YAFRAYCORE_EXPORT colorA_t : public color_t
if (A<0.0) A=0.0; else if (A>1.0) A=1.0;
}

CFLOAT colorDifference(colorA_t color2, bool useRGBcomponents = false);

// protected:
CFLOAT A;
};
Expand Down Expand Up @@ -423,6 +429,61 @@ inline void color_t::ColorSpace_from_linearRGB(colorSpaces_t colorSpace, float g
}
}

inline void color_t::clampProportionalRGB(float maxValue) //Function to clamp the current color to a maximum value, but keeping the relationship between the color components. So it will find the R,G,B component with the highest value, clamp it to the maxValue, and adjust proportionally the other two components
{
if(maxValue > 0.f) //If maxValue is 0, no clamping is done at all.
{
//If we have to clamp the result, calculate the maximum RGB component, clamp it and scale the other components acordingly to preserve color information.

float maxRGB = std::max(R, std::max(G, B));
float proportionalAdjustment = maxValue / maxRGB;

if(maxRGB > maxValue)
{
if(R >= maxRGB)
{
R = maxValue;
G *= proportionalAdjustment;
B *= proportionalAdjustment;
}

else if(G >= maxRGB)
{
G = maxValue;
R *= proportionalAdjustment;
B *= proportionalAdjustment;
}

else
{
B = maxValue;
R *= proportionalAdjustment;
G *= proportionalAdjustment;
}
}
}
}

inline CFLOAT colorA_t::colorDifference(colorA_t color2, bool useRGBcomponents)
{
float colorDifference = std::fabs(color2.col2bri() - col2bri());

if(useRGBcomponents)
{
float Rdiff = std::fabs(color2.R - R);
float Gdiff = std::fabs(color2.G - G);
float Bdiff = std::fabs(color2.B - B);
float Adiff = std::fabs(color2.A - A);

if(colorDifference < Rdiff) colorDifference = Rdiff;
if(colorDifference < Gdiff) colorDifference = Gdiff;
if(colorDifference < Bdiff) colorDifference = Bdiff;
if(colorDifference < Adiff) colorDifference = Adiff;
}

return colorDifference;
}

__END_YAFRAY

#endif // Y_COLOR_H
5 changes: 5 additions & 0 deletions include/core_api/environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "yafsystem.h"
#include <list>
#include <vector>
#include <core_api/renderpasses.h>

__BEGIN_YAFRAY
class light_t;
Expand Down Expand Up @@ -67,6 +68,9 @@ class YAFRAYCORE_EXPORT renderEnvironment_t
imageHandler_t* createImageHandler(const std::string &name, paraMap_t &params, bool addToTable = true);
void setScene(scene_t *scene) { curren_scene=scene; };
bool setupScene(scene_t &scene, const paraMap_t &params, colorOutput_t &output, progressBar_t *pb = 0);
void setupRenderPasses(const paraMap_t &params);
const renderPasses_t* getRenderPasses() const { return &renderPasses; }
const std::map<std::string,camera_t *> * getCameraTable() const { return &camera_table; }
void clearAll();

virtual void registerFactory(const std::string &name,light_factory_t *f);
Expand Down Expand Up @@ -121,6 +125,7 @@ class YAFRAYCORE_EXPORT renderEnvironment_t
std::map<std::string,std::string> imagehandler_fullnames;
std::map<std::string,std::string> imagehandler_extensions;
scene_t *curren_scene;
renderPasses_t renderPasses;
};

__END_YAFRAY
Expand Down
42 changes: 24 additions & 18 deletions include/core_api/imagefilm.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ __BEGIN_YAFRAY

/*! This class recieves all rendered image samples.
You can see it as an enhanced render buffer;
Holds RGBA, Depth and Density (for actual bidirectional pathtracing implementation) buffers.
Holds RGBA and Density (for actual bidirectional pathtracing implementation) buffers.
*/

class progressBar_t;
class renderPasses_t;
class colorPasses_t;

// Image types define
#define IF_IMAGE 1
Expand All @@ -70,20 +72,18 @@ class YAFRAYCORE_EXPORT imageFilm_t
~imageFilm_t();
/*! Initialize imageFilm for new rendering, i.e. set pixels black etc */
void init(int numPasses = 0);
/*! Allocates memory for the z-buffer rendering */
void initDepthMap();
/*! Prepare for next pass, i.e. reset area_cnt, check if pixels need resample...
\param adaptive_AA if true, flag pixels to be resampled
\param threshold color threshold for adaptive antialiasing */
int nextPass(bool adaptive_AA, std::string integratorName);
int nextPass(int numView, bool adaptive_AA, std::string integratorName);
/*! Return the next area to be rendered
CAUTION! This method MUST be threadsafe!
\return number of resampled pixels */
bool nextArea(renderArea_t &a);
\return false if no area is left to be handed out, true otherwise */
bool nextArea(int numView, renderArea_t &a);
/*! Indicate that all pixels inside the area have been sampled for this pass */
void finishArea(renderArea_t &a);
void finishArea(int numView, renderArea_t &a);
/*! Output all pixels to the color output */
void flush(int flags = IF_ALL, colorOutput_t *out = 0);
void flush(int numView, int flags = IF_ALL, colorOutput_t *out = 0);
/*! query if sample (x,y) was flagged to need more samples.
IMPORTANT! You may only call this after you have called nextPass(true, ...), otherwise
no such flags have been created !! */
Expand All @@ -92,10 +92,7 @@ class YAFRAYCORE_EXPORT imageFilm_t
IMPORTANT: when a is given, all samples within a are assumed to come from the same thread!
use a=0 for contributions outside the area associated with current thread!
*/
void addSample(const colorA_t &c, int x, int y, float dx, float dy, const renderArea_t *a = 0);
/*! Add depth (z-buffer) sample; dx and dy describe the position in the pixel (x,y)
*/
void addDepthSample(int chan, float val, int x, int y, float dx, float dy);
void addSample(colorPasses_t &colorPasses, int x, int y, float dx, float dy, const renderArea_t *a = 0, int numSample = 0, int AA_pass_number = 0, float inv_AA_max_possible_samples = 0.1f);
/*! Add light density sample; dx and dy describe the position in the pixel (x,y).
IMPORTANT: when a is given, all samples within a are assumed to come from the same thread!
use a=0 for contributions outside the area associated with current thread!
Expand All @@ -105,8 +102,6 @@ class YAFRAYCORE_EXPORT imageFilm_t
void setDensityEstimation(bool enable);
//! set number of samples for correct density estimation (if enabled)
void setNumSamples(int n){ numSamples = n; }
/*! Enables/disables color clamping */
void setClamp(bool c){ clamp = c; }
/*! (Deprecated, use setColorSpace instead) Enables/disables gamma correction of output; when gammaVal is <= 0 the current value is kept */
void setGamma(float gammaVal, bool enable);
/*! Sets the film color space and gamma correction */
Expand All @@ -115,6 +110,8 @@ class YAFRAYCORE_EXPORT imageFilm_t
void setAAThreshold(CFLOAT thresh){ AA_thesh=thresh; }
/*! Enables interactive color buffer output for preview during render */
void setInteractive(bool ia){ interactive = ia; }
/*! Enables partial image saving during render every time_interval seconds. Time=0.0 (default) disables partial saving. */
void setImageOutputPartialSaveTimeInterval(double time_interval){ imageOutputPartialSaveTimeInterval = time_interval; }
/*! Sets a custom progress bar in the image film */
void setProgressBar(progressBar_t *pb);
/*! The following methods set the strings used for the parameters badge rendering */
Expand All @@ -123,17 +120,19 @@ class YAFRAYCORE_EXPORT imageFilm_t
void setCustomString(const std::string &custom);
void setUseParamsBadge(bool on = true) { drawParams = on; }
bool getUseParamsBadge() { return drawParams; }
int getTotalPixels() const { return w*h; };
void setAANoiseParams(bool detect_color_noise, float dark_threshold_factor, int variance_edge_size, int variance_pixels, float clamp_samples);

/*! Methods for rendering the parameters badge; Note that FreeType lib is needed to render text */
void drawRenderSettings();
void reset_accumulated_image_area_flush_time() { accumulated_image_area_flush_time = 0.0; }

#if HAVE_FREETYPE
void drawFontBitmap( FT_Bitmap_* bitmap, int x, int y);
#endif

protected:
rgba2DImage_t *image; //!< rgba color buffer
gray2DImage_t *depthMap; //!< storage for z-buffer channel
std::vector<rgba2DImage_t*> imagePasses; //!< rgba color buffers for the render passes
rgb2DImage_nw_t *densityImage; //!< storage for z-buffer channel
rgba2DImage_nw_t *dpimage; //!< render parameters badge image
tiledBitArray2D_t<3> *flags; //!< flags for adaptive AA sampling;
Expand All @@ -144,12 +143,18 @@ class YAFRAYCORE_EXPORT imageFilm_t
colorSpaces_t colorSpace;
float gamma;
CFLOAT AA_thesh;
bool AA_detect_color_noise;
float AA_dark_threshold_factor;
int AA_variance_edge_size;
int AA_variance_pixels;
float AA_clamp_samples;
float filterw, tableScale;
float *filterTable;
colorOutput_t *output;
// Thread mutes for shared access
yafthreads::mutex_t imageMutex, splitterMutex, outMutex, depthMapMutex, densityImageMutex;
bool clamp, split, interactive, abort;
yafthreads::mutex_t imageMutex, splitterMutex, outMutex, densityImageMutex;
bool split, interactive, abort;
double imageOutputPartialSaveTimeInterval;
bool estimateDensity;
int numSamples;
imageSpliter_t *splitter;
Expand All @@ -165,6 +170,7 @@ class YAFRAYCORE_EXPORT imageFilm_t
std::string aaSettings;
std::string integratorSettings;
std::string customString;
double accumulated_image_area_flush_time;
};

__END_YAFRAY
Expand Down
31 changes: 24 additions & 7 deletions include/core_api/imagehandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,53 @@
#include "yafray_constants.h"
#include <utilities/image_buffers.h>
#include <string>
#include <core_api/renderpasses.h>

__BEGIN_YAFRAY

typedef unsigned char yByte;
typedef unsigned short yWord;

enum textureOptimization_t
{
TEX_OPTIMIZATION_NONE = 1,
TEX_OPTIMIZATION_OPTIMIZED = 2,
TEX_OPTIMIZATION_COMPRESSED = 3
};

class YAFRAYCORE_EXPORT imageHandler_t
{
public:
virtual void initForOutput(int width, int height, bool withAlpha = false, bool withDepth = false) = 0;
virtual void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool withAlpha = false, bool multi_layer = false) = 0;
virtual ~imageHandler_t() {};
virtual bool loadFromFile(const std::string &name) = 0;
virtual bool loadFromMemory(const yByte *data, size_t size) {return false; }
virtual bool saveToFile(const std::string &name) = 0;
virtual void putPixel(int x, int y, const colorA_t &rgba, float depth = 0.f) = 0;
virtual colorA_t getPixel(int x, int y) = 0;
virtual bool saveToFile(const std::string &name, int imagePassNumber = 0) = 0;
virtual bool saveToFileMultiChannel(const std::string &name, const renderPasses_t *renderPasses) { return false; };
virtual void putPixel(int x, int y, const colorA_t &rgba, int imagePassNumber = 0) = 0;
virtual colorA_t getPixel(int x, int y, int imagePassNumber = 0) = 0;
virtual int getWidth() { return m_width; }
virtual int getHeight() { return m_height; }
virtual bool isHDR() { return false; }
virtual bool isMultiLayer() { return m_MultiLayer; }
int getTextureOptimization() { return m_textureOptimization; }
void setTextureOptimization(int texture_optimization) { m_textureOptimization = texture_optimization; }

protected:
std::string handlerName;
int m_width;
int m_height;
bool m_hasAlpha;
bool m_hasDepth;
rgba2DImage_nw_t *m_rgba;
gray2DImage_nw_t *m_depth;
int m_textureOptimization;
std::vector<rgba2DImage_nw_t*> imagePasses; //!< rgba color buffers for the additional render passes
rgbaOptimizedImage_nw_t *rgbaOptimizedBuffer; //!< optimized RGBA (32bit/pixel) with alpha buffer
rgbaCompressedImage_nw_t *rgbaCompressedBuffer; //!< compressed RGBA (24bit/pixel) LOSSY! with alpha buffer
rgbOptimizedImage_nw_t *rgbOptimizedBuffer; //!< optimized RGB (24bit/pixel) without alpha buffer
rgbCompressedImage_nw_t *rgbCompressedBuffer; //!< compressed RGB (16bit/pixel) LOSSY! without alpha buffer
bool m_MultiLayer;
};


__END_YAFRAY

#endif
7 changes: 4 additions & 3 deletions include/core_api/integrator.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "scene.h"
#include <yafraycore/monitor.h>
#include <string>
#include <core_api/renderpasses.h>

__BEGIN_YAFRAY

Expand All @@ -44,7 +45,7 @@ class YAFRAYCORE_EXPORT integrator_t
//! this MUST be called before any other member function!
void setScene(scene_t *s) { scene=s; }
/*! do whatever is required to render the image, if suitable for integrating whole image */
virtual bool render(imageFilm_t *imageFilm) { return false; }
virtual bool render(int numView, imageFilm_t *imageFilm) { return false; }
virtual void setProgressBar(progressBar_t *pb) { intpb = pb; }
virtual std::string getSettings() const { return settings; }
virtual std::string getShortName() const { return integratorShortName; }
Expand All @@ -71,7 +72,7 @@ class YAFRAYCORE_EXPORT surfaceIntegrator_t: public integrator_t
(possibly also important for multiframe rendering in the future) */
virtual void cleanup() {}
// virtual bool setupSampler(sampler_t &sam);
virtual colorA_t integrate(renderState_t &state, diffRay_t &ray/*, sampler_t &sam*/) const = 0;
virtual colorA_t integrate(renderState_t &state, diffRay_t &ray, colorPasses_t &colPasses /*, sampler_t &sam*/) const = 0;
protected:
surfaceIntegrator_t() {} //don't use...
};
Expand All @@ -81,7 +82,7 @@ class YAFRAYCORE_EXPORT volumeIntegrator_t: public integrator_t
public:
volumeIntegrator_t() {}
virtual colorA_t transmittance(renderState_t &state, ray_t &ray) const = 0;
virtual colorA_t integrate(renderState_t &state, ray_t &ray) const = 0;
virtual colorA_t integrate(renderState_t &state, ray_t &ray, colorPasses_t &colPasses) const = 0;
virtual bool preprocess() { return true; }

protected:
Expand Down
Loading

0 comments on commit 44d44ed

Please sign in to comment.