mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-01-22 05:30:06 -05:00
330074cfb2
-Add new variations: bubbleT3D, crob, hexaplay3D, hexcrop, hexes, hexnix3D, loonie2, loonie3, nBlur, octapol and synth. -Allow for pre/post versions of dc_bubble, dc_cylinder and dc_linear whereas before they were omitted. -When saving a file with multiple embers in it, detect if time values are all the same and if so, start them at zero and increment by 1 for each ember. -Allow for numerous quality increases to be coalesced into one. It will pick up at the end of the current render. -Show selection highlight on variations tree in response to mouse hover. This makes it easier to see for which variation or param the current mouse wheel action will apply. -Make default temporal samples be 100, whereas before it was 1000 which was overkill. -Require the shift key to be held with delete for deleting an ember to prevent it from triggering when the user enters delete in the edit box. -This wasn't otherwise fixable without writing a lot more code. --Bug fixes -EmberGenome was crashing when generating a sequence from a source file with more than 2 embers in it. -EmberGenome was improperly handling the first frame of a merge after the last frame of the loop. -These bugs were due to a previous commit. Revert parts of that commit. -Prevent a zoom value of less than 0 when reading from xml. -Slight optimization of the crescents, and mask variations, if the compiler wasn't doing it already. -Unique file naming was broken because it was looking for _# and the default names ended with -#. -Disallow renaming of an ember in the library tree to an empty string. -Severe bug that prevented some variations from being read correctly from params generated outside this program. -Severe OpenCL randomization bug. The first x coordinates of the first points in the first kernel call of the first ember of a render since the OpenCL renderer object was created were not random and were mostly -1. -Severe bug when populating xform selection distributions that could sometimes cause a crash due to roundoff error. Fix by using double. -Limit the max number of variations in a random ember to MAX_CL_VARS, which is 8. This ensures they'll look the same on CPU and GPU. -Prevent user from saving stylesheet to default.qss, it's a special reserved filename. --Code changes -Generalize using the running sum output point inside of a variation for all cases: pre, reg and post. -Allow for array variables in variations where the address of each element is stored in m_Params. -Qualify all math functions with std:: -No longer use our own Clamp() in OpenCL, instead use the standard clamp(). -Redesign how functions are used in the variations OpenCL code. -Add tests to EmberTester to verify some of the new functionality. -Place more const and override qualifiers on functions where appropriate. -Add a global rand with a lock to be used very sparingly. -Use a map instead of a vector for bad param names in Xml parsing. -Prefix affine interpolation mode defines with "AFFINE_" to make their purpose more clear. -Allow for variations that change state during iteration by sending a separate copy of the ember to each rendering thread. -Implement this same functionality with a local struct in OpenCL. It's members are the total of all variables that need to change state within an ember. -Add Contains() function to Utils.h. -EmberRender: print names of kernels being printed with --dump_kernel option. -Clean up EmberTester to handle some of the recent changes. -Fix various casts. -Replace % 2 with & 1, even though the compiler was likely doing this already. -Add new file Variations06.h to accommodate new variations. -General cleanup.
196 lines
9.1 KiB
C++
196 lines
9.1 KiB
C++
#pragma once
|
|
|
|
#include "RendererBase.h"
|
|
#include "Iterator.h"
|
|
#include "SpatialFilter.h"
|
|
#include "TemporalFilter.h"
|
|
#include "Interpolate.h"
|
|
#include "CarToRas.h"
|
|
#include "EmberToXml.h"
|
|
|
|
/// <summary>
|
|
/// Renderer.
|
|
/// </summary>
|
|
|
|
namespace EmberNs
|
|
{
|
|
/// <summary>
|
|
/// Renderer is the main class where all of the execution takes place.
|
|
/// It is intended that the program have one instance of it that it
|
|
/// keeps around for its duration. After a user sets up an ember, it's passed
|
|
/// in to be rendered.
|
|
/// This class derives from EmberReport, so the caller is able
|
|
/// to retrieve a text dump of error information if any errors occur.
|
|
/// The final image output vector is also passed in because the calling code has more
|
|
/// use for it than this class does.
|
|
/// Several functions are made virtual and have a default CPU-based implementation
|
|
/// that roughly matches what flam3 did. However they can be overridden in derived classes
|
|
/// to provide alternative rendering implementations, such as using the GPU.
|
|
/// Since this is a templated class, it's supposed to be entirely implemented in this .h file.
|
|
/// However, VC++ 2010 has very crippled support for lambdas, which Renderer makes use of.
|
|
/// If too many lambdas are used in a .h file, it will crash the compiler when another library
|
|
/// tries to link to it. To work around the bug, only declarations are here and all implementations
|
|
/// are in the .cpp file. It's unclear at what point it starts/stops working. But it seems that once
|
|
/// enough code is placed in the .h file, the compiler crashes. So for the sake of consistency, everything
|
|
/// is moved to the .cpp, even simple getters. One drawback however, is that the class must be
|
|
/// explicitly exported at the bottom of the file.
|
|
/// Also, despite explicitly doing this, the compiler throws a C4661 warning
|
|
/// for every single function in this class, saying it can't find the implementation. This warning
|
|
/// can be safely ignored.
|
|
/// Template argument T expected to be float or double.
|
|
/// Template argument bucketT must always be float.
|
|
/// </summary>
|
|
template <typename T, typename bucketT>
|
|
class EMBER_API Renderer : public RendererBase
|
|
{
|
|
//using EmberReport::m_ErrorReport;
|
|
public:
|
|
Renderer();
|
|
virtual ~Renderer();
|
|
|
|
//Non-virtual processing functions.
|
|
void AddEmber(Ember<T>& ember);
|
|
bool AssignIterator();
|
|
|
|
//Virtual processing functions overriden from RendererBase.
|
|
virtual void ComputeBounds() override;
|
|
virtual void ComputeQuality() override;
|
|
virtual void ComputeCamera() override;
|
|
virtual void SetEmber(Ember<T>& ember, eProcessAction action = FULL_RENDER) override;
|
|
virtual void SetEmber(vector<Ember<T>>& embers) override;
|
|
virtual bool CreateDEFilter(bool& newAlloc) override;
|
|
virtual bool CreateSpatialFilter(bool& newAlloc) override;
|
|
virtual bool CreateTemporalFilter(bool& newAlloc) override;
|
|
virtual size_t HistBucketSize() const override { return sizeof(tvec4<bucketT, glm::defaultp>); }
|
|
virtual eRenderStatus Run(vector<byte>& finalImage, double time = 0, size_t subBatchCountOverride = 0, bool forceOutput = false, size_t finalOffset = 0) override;
|
|
virtual EmberImageComments ImageComments(const EmberStats& stats, size_t printEditDepth = 0, bool intPalette = false, bool hexPalette = true) override;
|
|
|
|
protected:
|
|
//New virtual functions to be overridden in derived renderers that use the GPU, but not accessed outside.
|
|
virtual void MakeDmap(T colorScalar);
|
|
virtual bool Alloc(bool histOnly = false);
|
|
virtual bool ResetBuckets(bool resetHist = true, bool resetAccum = true);
|
|
virtual eRenderStatus LogScaleDensityFilter(bool forceOutput = false);
|
|
virtual eRenderStatus GaussianDensityFilter();
|
|
virtual eRenderStatus AccumulatorToFinalImage(vector<byte>& pixels, size_t finalOffset);
|
|
virtual eRenderStatus AccumulatorToFinalImage(byte* pixels, size_t finalOffset);
|
|
virtual EmberStats Iterate(size_t iterCount, size_t temporalSample);
|
|
|
|
public:
|
|
//Non-virtual render properties, getters and setters.
|
|
inline T PixelAspectRatio() const;
|
|
void PixelAspectRatio(T pixelAspectRatio);
|
|
|
|
//Non-virtual renderer properties, getters only.
|
|
inline T Scale() const;
|
|
inline T PixelsPerUnitX() const;
|
|
inline T PixelsPerUnitY() const;
|
|
inline bucketT K1() const;
|
|
inline bucketT K2() const;
|
|
inline const CarToRas<T>& CoordMap() const;
|
|
inline tvec4<bucketT, glm::defaultp>* HistBuckets();
|
|
inline tvec4<bucketT, glm::defaultp>* AccumulatorBuckets();
|
|
inline SpatialFilter<bucketT>* GetSpatialFilter();
|
|
inline TemporalFilter<T>* GetTemporalFilter();
|
|
|
|
//Virtual renderer properties overridden from RendererBase, getters only.
|
|
virtual double ScaledQuality() const override;
|
|
virtual double LowerLeftX(bool gutter = true) const override;
|
|
virtual double LowerLeftY(bool gutter = true) const override;
|
|
virtual double UpperRightX(bool gutter = true) const override;
|
|
virtual double UpperRightY(bool gutter = true) const override;
|
|
virtual DensityFilterBase* GetDensityFilter() override;
|
|
|
|
//Non-virtual ember wrappers, getters only.
|
|
inline bool XaosPresent() const;
|
|
inline size_t Supersample() const;
|
|
inline size_t PaletteIndex() const;
|
|
inline T Time() const;
|
|
inline T Quality() const;
|
|
inline T SpatialFilterRadius() const;
|
|
inline T PixelsPerUnit() const;
|
|
inline T Zoom() const;
|
|
inline T CenterX() const;
|
|
inline T CenterY() const;
|
|
inline T Rotate() const;
|
|
inline T Hue() const;
|
|
inline bucketT Brightness() const;
|
|
inline bucketT Contrast() const;
|
|
inline bucketT Gamma() const;
|
|
inline bucketT Vibrancy() const;
|
|
inline bucketT GammaThresh() const;
|
|
inline bucketT HighlightPower() const;
|
|
inline Color<T> Background() const;
|
|
inline const Xform<T>* Xforms() const;
|
|
inline Xform<T>* NonConstXforms();
|
|
inline size_t XformCount() const;
|
|
inline const Xform<T>* FinalXform() const;
|
|
inline Xform<T>* NonConstFinalXform();
|
|
inline bool UseFinalXform() const;
|
|
inline const Palette<T>* GetPalette() const;
|
|
inline ePaletteMode PaletteMode() const;
|
|
|
|
//Virtual ember wrappers overridden from RendererBase, getters only.
|
|
virtual size_t TemporalSamples() const override;
|
|
virtual size_t FinalRasW() const override;
|
|
virtual size_t FinalRasH() const override;
|
|
virtual size_t SubBatchSize() const override;
|
|
virtual size_t FuseCount() const override;
|
|
|
|
//Non-virtual iterator wrappers.
|
|
const byte* XformDistributions() const;
|
|
size_t XformDistributionsSize() const;
|
|
Point<T>* Samples(size_t threadIndex) const;
|
|
|
|
protected:
|
|
//Non-virtual functions that might be needed by a derived class.
|
|
void PrepFinalAccumVals(Color<bucketT>& background, bucketT& g, bucketT& linRange, bucketT& vibrancy);
|
|
|
|
private:
|
|
//Miscellaneous non-virtual functions used only in this class.
|
|
void Accumulate(QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand, Point<T>* samples, size_t sampleCount, const Palette<bucketT>* palette);
|
|
/*inline*/ void AddToAccum(const tvec4<bucketT, glm::defaultp>& bucket, intmax_t i, intmax_t ii, intmax_t j, intmax_t jj);
|
|
template <typename accumT> void GammaCorrection(tvec4<bucketT, glm::defaultp>& bucket, Color<bucketT>& background, bucketT g, bucketT linRange, bucketT vibrancy, bool doAlpha, bool scale, accumT* correctedChannels);
|
|
void CurveAdjust(bucketT& a, const glm::length_t& index);
|
|
void VectorizedLogScale(size_t row, size_t rowEnd);
|
|
|
|
protected:
|
|
T m_Scale;
|
|
T m_PixelsPerUnitX;
|
|
T m_PixelsPerUnitY;
|
|
T m_PixelAspectRatio;
|
|
T m_LowerLeftX;
|
|
T m_LowerLeftY;
|
|
T m_UpperRightX;
|
|
T m_UpperRightY;
|
|
bucketT m_K1;
|
|
bucketT m_K2;
|
|
bucketT m_Vibrancy;//Accumulate these after each temporal sample.
|
|
bucketT m_Gamma;
|
|
T m_ScaledQuality;
|
|
Color<bucketT> m_Background;//This is a scaled copy of the m_Background member of m_Ember, but with a type of bucketT.
|
|
Affine2D<T> m_RotMat;
|
|
Ember<T> m_Ember;
|
|
Ember<T> m_TempEmber;
|
|
Ember<T> m_LastEmber;
|
|
vector<Ember<T>> m_Embers;
|
|
vector<Ember<T>> m_ThreadEmbers;
|
|
CarToRas<T> m_CarToRas;
|
|
Iterator<T>* m_Iterator;
|
|
unique_ptr<StandardIterator<T>> m_StandardIterator;
|
|
unique_ptr<XaosIterator<T>> m_XaosIterator;
|
|
Palette<bucketT> m_Dmap, m_Csa;
|
|
vector<tvec4<bucketT, glm::defaultp>> m_HistBuckets;
|
|
vector<tvec4<bucketT, glm::defaultp>> m_AccumulatorBuckets;
|
|
unique_ptr<SpatialFilter<bucketT>> m_SpatialFilter;
|
|
unique_ptr<TemporalFilter<T>> m_TemporalFilter;
|
|
unique_ptr<DensityFilter<bucketT>> m_DensityFilter;
|
|
vector<vector<Point<T>>> m_Samples;
|
|
EmberToXml<T> m_EmberToXml;
|
|
};
|
|
|
|
//This class had to be implemented in a cpp file because the compiler was breaking.
|
|
//So the explicit instantiation must be declared here rather than in Ember.cpp where
|
|
//all of the other classes are done.
|
|
}
|