csplugincommon/rendermanager/hdrexposure.h Source File (Crystal Space 2.0 Public API Reference)

| ## Public API Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

csplugincommon/rendermanager/hdrexposure.h
Go to the documentation of this file.

    00001 /*
    00002     Copyright (C) 2008-2009 by Frank Richter
    00003
    00004     This library is free software; you can redistribute it and/or
    00005     modify it under the terms of the GNU Library General Public
    00006     License as published by the Free Software Foundation; either
    00007     version 2 of the License, or (at your option) any later version.
    00008
    00009     This library is distributed in the hope that it will be useful,
    00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00012     Library General Public License for more details.
    00013
    00014     You should have received a copy of the GNU Library General Public
    00015     License along with this library; if not, write to the Free
    00016     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    00017 */
    00018
    00019 #ifndef __CS_CSPLUGINCOMMON_RENDERMANAGER_HDREXPOSURE_H__
    00020 #define __CS_CSPLUGINCOMMON_RENDERMANAGER_HDREXPOSURE_H__
    00021
    00022 #include "csgfx/textureformatstrings.h"
    00023 #include "csplugincommon/rendermanager/hdrexposure_luminance.h"
    00024 #include "csplugincommon/rendermanager/hdrhelper.h"
    00025 #include "csplugincommon/rendermanager/posteffects.h"
    00026 #include "csutil/ref.h"
    00027
    00032 class csShaderVariable;
    00033 struct iDataBuffer;
    00034 struct iObjectRegistry;
    00035
    00036 namespace CS
    00037 {
    00038   namespace RenderManager
    00039   {
    00040     namespace HDR
    00041     {
    00042       namespace Exposure
    00043       {
    00050         class CS_CRYSTALSPACE_EXPORT Linear
    00051         {
    00052           csRef<csShaderVariable> svHDRScale;
    00053           HDRHelper* hdr;
    00054
    00055           csTicks lastTime;
    00056
    00057           float targetAvgLum;
    00058           float targetAvgLumTolerance;
    00059           float minExposure, maxExposure;
    00060           float exposureChangeRate;
    00061
    00062           Luminance::Average luminance;
    00063         public:
    00064           Linear () : hdr (0),
    00065             lastTime (0), targetAvgLum (0.8f), targetAvgLumTolerance (0.1f),
    00066             minExposure (0.1f), maxExposure (10.0f), exposureChangeRate (0.5f)
    00067           {}
    00068
    00070           void Initialize (iObjectRegistry* objReg,
    00071             HDRHelper& hdr);
    00072
    00074           void ApplyExposure (RenderTreeBase& renderTree, iView* view);
    00075
    00077           void SetTargetAverageLuminance (float f) { targetAvgLum = f; }
    00079           float GetTargetAverageLuminance () const { return targetAvgLum; }
    00080
    00082           void SetTargetAverageLuminanceTolerance (float f)
    00083           { targetAvgLumTolerance = f; }
    00085           float GetTargetAverageLuminanceTolerance () const
    00086           { return targetAvgLumTolerance; }
    00087
    00089           void SetMinMaxExposure (float min, float max)
    00090           { minExposure = min; maxExposure = max; }
    00092           void GetMinMaxExposure (float& min, float& max) const
    00093           { min = minExposure; max = maxExposure; }
    00094
    00096           void SetExposureChangeRate (float f) { exposureChangeRate = f; }
    00098           float GetExposureChangeRate () const { return exposureChangeRate; }
    00099         };
    00100
    00101         class CS_CRYSTALSPACE_EXPORT Reinhard_Simple
    00102         {
    00103           csRef<csShaderVariable> svHDRScale;
    00104           csRef<csShaderVariable> svMappingParams;
    00105           HDRHelper* hdr;
    00106
    00107           csTicks lastTime;
    00108
    00109           Luminance::LogAverage luminance;
    00110         public:
    00111           Reinhard_Simple() : lastTime (0) {}
    00112
    00114           void Initialize (iObjectRegistry* objReg,
    00115             HDRHelper& hdr);
    00116
    00118           void ApplyExposure (RenderTreeBase& renderTree, iView* view);
    00119         };
    00120
    00125         class CS_CRYSTALSPACE_EXPORT Configurable
    00126         {
    00127         protected:
    00128           struct AbstractExposure : public CS::Memory::CustomAllocated
    00129           {
    00130             virtual ~AbstractExposure() {}
    00131
    00132             virtual void Initialize (iObjectRegistry* objReg,
    00133               HDRHelper& hdr) = 0;
    00134             virtual void ApplyExposure (RenderTreeBase& renderTree, iView* view) = 0;
    00135           };
    00136
    00137           template<typename T>
    00138           struct WrapperExposure : public AbstractExposure
    00139           {
    00140             T exposure;
    00141
    00142             virtual void Initialize (iObjectRegistry* objReg,
    00143               HDRHelper& hdr)
    00144             {
    00145               exposure.Initialize (objReg, hdr);
    00146             }
    00147
    00148             virtual void ApplyExposure (RenderTreeBase& renderTree, iView* view)
    00149             {
    00150               exposure.ApplyExposure (renderTree, view);
    00151             }
    00152           };
    00153
    00154           virtual AbstractExposure* CreateExposure (const char* name);
    00155
    00156           AbstractExposure* exposure;
    00157         public:
    00158           Configurable() : exposure (0) {}
    00159           virtual ~Configurable();
    00160
    00161           void Initialize (iObjectRegistry* objReg,
    00162             HDRHelper& hdr, const HDRSettings& settings);
    00163           void ApplyExposure (RenderTreeBase& renderTree, iView* view);
    00164         };
    00165
    00166       } // namespace Exposure
    00167     } // namespace HDR
    00168   } // namespace RenderManager
    00169 } // namespace CS
    00170
    00171 #endif // __CS_CSPLUGINCOMMON_RENDERMANAGER_HDREXPOSURE_H__