00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef VRS_OPENGL_AMBIENTOCCLUSION_H
00026 #define VRS_OPENGL_AMBIENTOCCLUSION_H
00027
00028 #include <vrs/config.h>
00029 #include <vrs/bounds.h>
00030 #include <vrs/color.h>
00031 #include <vrs/callback.h>
00032 #include <vrs/uniquetexturemapping.h>
00033
00034 namespace VRS {
00035 template<typename T> class Iterator;
00036 class Image;
00037
00038 class MipmapTexture2DGL;
00039 class PolygonSet;
00040 class GLCanvas;
00041
00042 namespace GL2 {
00043 class ProgramObject;
00044 }
00045 }
00046
00047
00048 namespace VRS {
00049
00051 struct VRS_CORE_API AOLightingConfiguration {
00052
00055 AOLightingConfiguration();
00056
00061 int numSkyLightDirections;
00062 VRS::Color skyColor;
00063
00071 int numSunLightDirections;
00072 VRS::Vector primarySunDirection;
00073 double sunSize;
00074 double sunIntensityFactor;
00075 VRS::Color sunColor;
00076
00078 double brightness;
00079
00084 SO<VRS::Iterator<VRS::Vector> > lightDirections;
00085 SO<VRS::Iterator<VRS::Vector> > scaledLightColors;
00086
00088 enum Preset { PS_Dawn, PS_SunnyDay, PS_Debug };
00089 static AOLightingConfiguration create(Preset p);
00090 };
00091
00092 struct VRS_CORE_API AOCreationConfiguration {
00093 AOCreationConfiguration();
00094
00095 int tiles_x, tiles_z;
00096 };
00097
00101 class VRS_CORE_API AmbientOcclusionGL {
00102 public:
00103
00117 static UniqueTextureMapping::TexturedMeshComposite createLightingTextures(
00118 SO<VRS::Iterator<SO<VRS::PolygonSet> > > triangles,
00119 double texelPerUnit,
00120 SO<VRS::GLCanvas> canvas,
00121 const AOLightingConfiguration& config = AOLightingConfiguration(),
00122 const AOCreationConfiguration& creationConf = AOCreationConfiguration()
00123 );
00124
00127 static void createLightingTexturesCallback(
00128 SO<VRS::Iterator<SO<VRS::PolygonSet> > > triangles,
00129 double texelPerUnit,
00130 SO<VRS::GLCanvas> canvas,
00131 SO<VRS::Callback1<UniqueTextureMapping::TexturedMeshComposite&> > storageCallback,
00132 const AOLightingConfiguration& config = AOLightingConfiguration(),
00133 const AOCreationConfiguration& creationConf = AOCreationConfiguration()
00134 );
00135
00139 static UniqueTextureMapping::TexturedMeshComposite createLightingTexturesBMP(
00140 SO<VRS::Iterator<SO<VRS::PolygonSet> > > triangles,
00141 double texelPerUnit,
00142 SO<VRS::GLCanvas> canvas,
00143 const std::string &prefix,
00144 const AOLightingConfiguration& config = AOLightingConfiguration(),
00145 const AOCreationConfiguration& creationConf = AOCreationConfiguration()
00146 );
00147
00152 static SO<VRS::Image> createLightingTexture(
00153 SO<VRS::PolygonSet> targetTris,
00154 SO<VRS::PolygonSet> environmentTriangles,
00155 SO<VRS::GLCanvas> canvas,
00156 SO<VRS::Iterator<VRS::Vector> > lightDirs,
00157 const AOCreationConfiguration& creationConf = AOCreationConfiguration()
00158 );
00159
00160
00162 static SO<VRS::Iterator<VRS::Vector> > createLightDirections(int num);
00163
00165
00168 static void setIDBufferSize(int size = 1024);
00169 static int getIDBufferSize();
00170
00171
00172 static void setMaxTextureCacheSize(int size = 200*1024*1024);
00173 static int getMaxTextureCacheSize();
00174
00176 static void setMaxAtlasSize(int size = 1024);
00177 static int getMaxAtlasSize();
00178
00181 static void setFBOEnabled(bool yesNo = true);
00182 static bool getFBOEnabled();
00183
00188 static void setTextureBorderWidth(int pixels = 2);
00189 static int getTextureBorderWidth();
00190
00196 static SO<VRS::GL2::ProgramObject> getIntensityBoostProgram(bool useTexture, float minValue = 0.0f, float maxValue = 1.5f);
00197
00198 private:
00199
00200 static int s_maxAtlasSize;
00201 static int s_maxTextureCacheSize;
00202 static int s_idBufferSize;
00203 static bool s_fboEnabled;
00204 static int s_textureBorderWidth;
00205 };
00206
00208 AOLightingConfiguration defaultAOLighting();
00209
00210 }
00211
00212 #endif // LDX_UTIL_AMBIENTOCCLUSION_H