LightsprintSDK 2021.08.08
|
#include <RRSolverGL.h>
Public Types | |
enum | DDIQuality { DDI_AUTO , DDI_4X4 , DDI_8X8 } |
Public Types inherited from rr::RRSolver | |
enum | InternalSolverType { NONE , ARCHITECT , FIREBALL , BOTH } |
Public Member Functions | |
RRSolverGL (const rr::RRString &pathToShaders, const rr::RRString &pathToMaps, DDIQuality detectionQuality=DDI_AUTO) | |
virtual | ~RRSolverGL () |
virtual void | setLights (const rr::RRLights &lights) override |
virtual void | renderLights (const rr::RRCamera &_camera) |
virtual void | reportDirectIlluminationChange (int lightIndex, bool dirtyShadowmap, bool dirtyGI, bool dirtyRange) override |
virtual void | calculate (const CalculateParameters *params=nullptr) override |
virtual unsigned | updateEnvironmentMap (rr::RRObjectIllumination *illumination, unsigned layerEnvironment, unsigned layerLightmap, unsigned layerAmbientMap) override |
UberProgram * | getUberProgram () |
Renderer * | getRenderer () |
Public Member Functions inherited from rr::RRSolver | |
RRSolver () | |
virtual | ~RRSolver () |
virtual void | setColorSpace (const RRColorSpace *colorSpace) |
const RRColorSpace * | getColorSpace () const |
void | setEnvironment (RRBuffer *environment0, RRBuffer *environment1=nullptr, RRReal angleRad0=0, RRReal angleRad1=0) |
RRBuffer * | getEnvironment (unsigned environmentIndex=0, RRReal *angleRad=nullptr) const |
void | setEnvironmentBlendFactor (float blendFactor) |
float | getEnvironmentBlendFactor () const |
virtual void | setLights (const RRLights &lights) |
const RRLights & | getLights () const |
void | setDirectIllumination (const unsigned *perTriangleIrradianceRGBA) |
const unsigned * | getDirectIllumination () |
virtual void | setStaticObjects (const RRObjects &objects, const SmoothingParameters *smoothing, const char *cacheLocation=nullptr, RRCollider::IntersectTechnique intersectTechnique=RRCollider::IT_BVH_FAST, RRSolver *copyFrom=nullptr) |
const RRObjects & | getStaticObjects () const |
void | setDynamicObjects (const RRObjects &objects) |
const RRObjects & | getDynamicObjects () const |
RRObjects | getObjects () const |
RRObject * | getObject (unsigned index) const |
RRCollider * | getCollider () const |
const RRObject * | getAABB (RRVec3 *_mini, RRVec3 *_maxi, RRVec3 *_center) const |
void | processBuffers (const RRVector< unsigned > *layers, std::function< void(RRBuffer *)> func) const |
virtual void | calculate (const CalculateParameters *params=nullptr) |
unsigned | getSolutionVersion () const |
virtual unsigned | updateLightmap (int objectNumber, RRBuffer *lightmap, RRBuffer *directionalLightmap[3], RRBuffer *bentNormals, const UpdateParameters *params, const FilteringParameters *filtering=nullptr) |
virtual unsigned | updateLightmaps (int layerLightmap, int layerDirectionalLightmap, int layerBentNormals, const UpdateParameters *params, const FilteringParameters *filtering) |
virtual unsigned | updateEnvironmentMap (RRObjectIllumination *illumination, unsigned layerEnvironment, unsigned layerLightmap, unsigned layerAmbientMap) |
bool | getTriangleMeasure (unsigned triangle, unsigned vertex, RRRadiometricMeasure measure, RRVec3 &out) const |
virtual void | reportMaterialChange (bool dirtyShadows, bool dirtyGI) |
virtual void | reportDirectIlluminationChange (int lightIndex, bool dirtyShadows, bool dirtyGI, bool dirtyRange) |
virtual void | reportInteraction () |
bool | buildFireball (unsigned avgRaysPerTriangle, const RRString &filename) |
bool | loadFireball (const RRString &filename, bool onlyPerfectMatch) |
void | leaveFireball () |
InternalSolverType | getInternalSolverType () const |
void | checkConsistency () |
virtual bool | containsLightSource () const |
virtual bool | containsRealtimeGILightSource () const |
virtual void | allocateBuffersForRealtimeGI (int layerLightmap, int layerEnvironment, unsigned diffuseEnvMapSize=4, unsigned specularEnvMapSize=16, unsigned refractEnvMapSize=16, bool allocateNewBuffers=true, bool changeExistingBuffers=true, float specularThreshold=0.2f, float depthThreshold=0.1f) const |
RRObject * | getMultiObject () const |
void | pathTraceFrame (const RRCamera &camera, RRBuffer *frame, unsigned accumulate, const PathTracingParameters ¶meters) |
Public Member Functions inherited from rr::RRUniformlyAllocated | |
void * | operator new (std::size_t n) |
void * | operator new[] (std::size_t n) |
void | operator delete (void *p, std::size_t n) |
void | operator delete[] (void *p, std::size_t n) |
Public Attributes | |
rr::RRVector< RealtimeLight * > | realtimeLights |
rr::RRCamera * | observer |
Public Attributes inherited from rr::RRSolver | |
bool | aborting |
Protected Member Functions | |
virtual const unsigned * | detectDirectIllumination (unsigned delayDDI) |
Protected Member Functions inherited from rr::RRSolver | |
void | calculateDirtyLights (const CalculateParameters *params=nullptr) |
Protected Member Functions inherited from rr::RRUniformlyAllocatedNonCopyable | |
RRUniformlyAllocatedNonCopyable () | |
~RRUniformlyAllocatedNonCopyable () | |
Implementation of rr::RRSolver generic GPU operations using OpenGL 2.0.
Before creating solver, make sure OpenGL context already exists, and OpenGL version is at least 2.0.
rr_gl::RRSolverGL::RRSolverGL | ( | const rr::RRString & | pathToShaders, |
const rr::RRString & | pathToMaps, | ||
DDIQuality | detectionQuality = DDI_AUTO |
||
) |
Initializes generic GPU access implemented in RRSolverGL.
pathToShaders | Path to directory with shaders. Must be terminated with slash (or be empty for current dir). It is also passed to renderer and its plugins. |
pathToMaps | Path to directory with maps. Must be terminated with slash (or be empty for current dir). It is passed to renderer and its plugins, solver itself doesn't use any maps. |
detectionQuality | Sets quality of our detectDirectIllumination() routine. |
|
virtual |
|
overridevirtual |
Sets lights used by both realtime and offline renderer.
For realtime rendering, realtimeLights are created based on lights given here.
It is legal to modify light properties after set, but not number of lights. Changes are processed when RealtimeLight::dirtyXxx flag is set. While renderer reads most of light properties from original lights, 'camera' properties like position, direction, fov are taken from realtimeLights.
By default, light's near/far range is autodetected from distance to static objects in solver (to avoid clipping), but if you wish to set range manually, clear RealtimeLight::dirtyRange after setLights() to prevent autodetection and set your own range.
Reimplemented from rr::RRSolver.
|
virtual |
Renders scene in solver, with all static and dynamic objects, lights, environment.
Renders wireframe frustums or boxes of lights.
|
overridevirtual |
Sets dirty flags in given light, or in all lights if lightIndex is -1.
Reimplemented from rr::RRSolver.
|
overridevirtual |
Updates shadowmaps, detects direct illumination, calculates GI.
Call this function once per frame while rendering realtime shadows or realtime GI. You can call it even when not rendering, to improve GI solution inside solver (so that you have it ready when you render scene later). On the other hand, don't call it when you don't need realtime shadows and realtime GI, for example when rendering offline baked lightmaps, it would still spend time calculating realtime GI even if you don't need it.
It updates illumination from dirty lights only, call reportDirectIlluminationChange() to mark light dirty.
You can update only shadowmaps by setting params->qualityIndirectDynamic=0.
Note that RRSolverGL::calculate() calls setDirectIllumination() automatically. If you want to provide your own direct illumination data, switch from RRSolverGL to rr::RRSolver and call setDirectIllumination() manually before calculate().
Reimplemented from rr::RRSolver.
|
overridevirtual |
Calculates and updates object's environment map, stored in given layer of given illumination.
Function renders map with LightsprintGL's renderer, honouring all light and material properties, with indirect illumination taken from buffers in layerXxx. If your envmap has low resolution (less than approximately 32x32x6), consider calling RRSolver::updateEnvironmentMap() instead, which is faster.
Reimplemented from rr::RRSolver.
|
inline |
Users can reuse our uberprogram for their own rendering.
|
inline |
Users can reuse our renderer for their own rendering.
|
protectedvirtual |
Detects direct illumination from lights (see setLights()) on all faces in scene and returns it in array of RGBA values. Result may be immediately passed to setDirectIllumination().
rr::RRVector<RealtimeLight*> rr_gl::RRSolverGL::realtimeLights |
Realtime lights, set by setLights(). You may modify them freely.
rr::RRCamera* rr_gl::RRSolverGL::observer |
Scene observer, inited to nullptr. You may modify it freely. Shadow quality is optimized for observer.