1 // 2 // Copyright (c) 2008-2017 the Urho3D project. 3 // 4 // Permission is hereby granted, free of charge, to any person obtaining a copy 5 // of this software and associated documentation files (the "Software"), to deal 6 // in the Software without restriction, including without limitation the rights 7 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 // copies of the Software, and to permit persons to whom the Software is 9 // furnished to do so, subject to the following conditions: 10 // 11 // The above copyright notice and this permission notice shall be included in 12 // all copies or substantial portions of the Software. 13 // 14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 // THE SOFTWARE. 21 // 22 23 #pragma once 24 25 #include "../Container/HashSet.h" 26 #include "../Core/Mutex.h" 27 #include "../Graphics/Batch.h" 28 #include "../Graphics/Drawable.h" 29 #include "../Graphics/Viewport.h" 30 #include "../Math/Color.h" 31 32 namespace Urho3D 33 { 34 35 class Geometry; 36 class Drawable; 37 class Light; 38 class Material; 39 class Pass; 40 class Technique; 41 class Octree; 42 class Graphics; 43 class RenderPath; 44 class RenderSurface; 45 class ResourceCache; 46 class Skeleton; 47 class OcclusionBuffer; 48 class Technique; 49 class Texture; 50 class Texture2D; 51 class TextureCube; 52 class View; 53 class Zone; 54 struct BatchQueue; 55 56 static const int SHADOW_MIN_PIXELS = 64; 57 static const int INSTANCING_BUFFER_DEFAULT_SIZE = 1024; 58 59 /// Light vertex shader variations. 60 enum LightVSVariation 61 { 62 LVS_DIR = 0, 63 LVS_SPOT, 64 LVS_POINT, 65 LVS_SHADOW, 66 LVS_SPOTSHADOW, 67 LVS_POINTSHADOW, 68 LVS_SHADOWNORMALOFFSET, 69 LVS_SPOTSHADOWNORMALOFFSET, 70 LVS_POINTSHADOWNORMALOFFSET, 71 MAX_LIGHT_VS_VARIATIONS 72 }; 73 74 /// Per-vertex light vertex shader variations. 75 enum VertexLightVSVariation 76 { 77 VLVS_NOLIGHTS = 0, 78 VLVS_1LIGHT, 79 VLVS_2LIGHTS, 80 VLVS_3LIGHTS, 81 VLVS_4LIGHTS, 82 MAX_VERTEXLIGHT_VS_VARIATIONS 83 }; 84 85 /// Light pixel shader variations. 86 enum LightPSVariation 87 { 88 LPS_NONE = 0, 89 LPS_SPOT, 90 LPS_POINT, 91 LPS_POINTMASK, 92 LPS_SPEC, 93 LPS_SPOTSPEC, 94 LPS_POINTSPEC, 95 LPS_POINTMASKSPEC, 96 LPS_SHADOW, 97 LPS_SPOTSHADOW, 98 LPS_POINTSHADOW, 99 LPS_POINTMASKSHADOW, 100 LPS_SHADOWSPEC, 101 LPS_SPOTSHADOWSPEC, 102 LPS_POINTSHADOWSPEC, 103 LPS_POINTMASKSHADOWSPEC, 104 MAX_LIGHT_PS_VARIATIONS 105 }; 106 107 /// Deferred light volume vertex shader variations. 108 enum DeferredLightVSVariation 109 { 110 DLVS_NONE = 0, 111 DLVS_DIR, 112 DLVS_ORTHO, 113 DLVS_ORTHODIR, 114 MAX_DEFERRED_LIGHT_VS_VARIATIONS 115 }; 116 117 /// Deferred light volume pixels shader variations. 118 enum DeferredLightPSVariation 119 { 120 DLPS_NONE = 0, 121 DLPS_SPOT, 122 DLPS_POINT, 123 DLPS_POINTMASK, 124 DLPS_SPEC, 125 DLPS_SPOTSPEC, 126 DLPS_POINTSPEC, 127 DLPS_POINTMASKSPEC, 128 DLPS_SHADOW, 129 DLPS_SPOTSHADOW, 130 DLPS_POINTSHADOW, 131 DLPS_POINTMASKSHADOW, 132 DLPS_SHADOWSPEC, 133 DLPS_SPOTSHADOWSPEC, 134 DLPS_POINTSHADOWSPEC, 135 DLPS_POINTMASKSHADOWSPEC, 136 DLPS_SHADOWNORMALOFFSET, 137 DLPS_SPOTSHADOWNORMALOFFSET, 138 DLPS_POINTSHADOWNORMALOFFSET, 139 DLPS_POINTMASKSHADOWNORMALOFFSET, 140 DLPS_SHADOWSPECNORMALOFFSET, 141 DLPS_SPOTSHADOWSPECNORMALOFFSET, 142 DLPS_POINTSHADOWSPECNORMALOFFSET, 143 DLPS_POINTMASKSHADOWSPECNORMALOFFSET, 144 DLPS_ORTHO, 145 DLPS_ORTHOSPOT, 146 DLPS_ORTHOPOINT, 147 DLPS_ORTHOPOINTMASK, 148 DLPS_ORTHOSPEC, 149 DLPS_ORTHOSPOTSPEC, 150 DLPS_ORTHOPOINTSPEC, 151 DLPS_ORTHOPOINTMASKSPEC, 152 DLPS_ORTHOSHADOW, 153 DLPS_ORTHOSPOTSHADOW, 154 DLPS_ORTHOPOINTSHADOW, 155 DLPS_ORTHOPOINTMASKSHADOW, 156 DLPS_ORTHOSHADOWSPEC, 157 DLPS_ORTHOSPOTSHADOWSPEC, 158 DLPS_ORTHOPOINTSHADOWSPEC, 159 DLPS_ORTHOPOINTMASKSHADOWSPEC, 160 DLPS_ORTHOSHADOWNORMALOFFSET, 161 DLPS_ORTHOSPOTSHADOWNORMALOFFSET, 162 DLPS_ORTHOPOINTSHADOWNORMALOFFSET, 163 DLPS_ORTHOPOINTMASKSHADOWNORMALOFFSET, 164 DLPS_ORTHOSHADOWSPECNORMALOFFSET, 165 DLPS_ORTHOSPOTSHADOWSPECNORMALOFFSET, 166 DLPS_ORTHOPOINTSHADOWSPECNORMALOFFSET, 167 DLPS_ORTHOPOINTMASKSHADOWSPECNORMALOFFSET, 168 MAX_DEFERRED_LIGHT_PS_VARIATIONS 169 }; 170 171 /// High-level rendering subsystem. Manages drawing of 3D views. 172 class URHO3D_API Renderer : public Object 173 { 174 URHO3D_OBJECT(Renderer, Object); 175 176 public: 177 typedef void(Object::*ShadowMapFilter)(View* view, Texture2D* shadowMap, float blurScale); 178 179 /// Construct. 180 Renderer(Context* context); 181 /// Destruct. 182 virtual ~Renderer(); 183 184 /// Set number of backbuffer viewports to render. 185 void SetNumViewports(unsigned num); 186 /// Set a backbuffer viewport. 187 void SetViewport(unsigned index, Viewport* viewport); 188 /// Set default renderpath. 189 void SetDefaultRenderPath(RenderPath* renderPath); 190 /// Set default renderpath from an XML file. 191 void SetDefaultRenderPath(XMLFile* file); 192 /// Set default non-textured material technique. 193 void SetDefaultTechnique(Technique* tech); 194 /// Set HDR rendering on/off. 195 void SetHDRRendering(bool enable); 196 /// Set specular lighting on/off. 197 void SetSpecularLighting(bool enable); 198 /// Set default texture max anisotropy level. 199 void SetTextureAnisotropy(int level); 200 /// Set default texture filtering. 201 void SetTextureFilterMode(TextureFilterMode mode); 202 /// Set texture quality level. See the QUALITY constants in GraphicsDefs.h. 203 void SetTextureQuality(int quality); 204 /// Set material quality level. See the QUALITY constants in GraphicsDefs.h. 205 void SetMaterialQuality(int quality); 206 /// Set shadows on/off. 207 void SetDrawShadows(bool enable); 208 /// Set shadow map resolution. 209 void SetShadowMapSize(int size); 210 /// Set shadow quality mode. See the SHADOWQUALITY enum in GraphicsDefs.h. 211 void SetShadowQuality(ShadowQuality quality); 212 /// Set shadow softness, only works when SHADOWQUALITY_BLUR_VSM is used. 213 void SetShadowSoftness(float shadowSoftness); 214 /// Set shadow parameters when VSM is used, they help to reduce light bleeding. LightBleeding must be in [0, 1[ 215 void SetVSMShadowParameters(float minVariance, float lightBleedingReduction); 216 /// Set VSM shadow map multisampling level. Default 1 (no multisampling.) 217 void SetVSMMultiSample(int multiSample); 218 /// Set post processing filter to the shadow map 219 void SetShadowMapFilter(Object* instance, ShadowMapFilter functionPtr); 220 /// Set reuse of shadow maps. Default is true. If disabled, also transparent geometry can be shadowed. 221 void SetReuseShadowMaps(bool enable); 222 /// Set maximum number of shadow maps created for one resolution. Only has effect if reuse of shadow maps is disabled. 223 void SetMaxShadowMaps(int shadowMaps); 224 /// Set dynamic instancing on/off. When on (default), drawables using the same static-type geometry and material will be automatically combined to an instanced draw call. 225 void SetDynamicInstancing(bool enable); 226 /// Set number of extra instancing buffer elements. Default is 0. Extra 4-vectors are available through TEXCOORD7 and further. 227 void SetNumExtraInstancingBufferElements(int elements); 228 /// Set minimum number of instances required in a batch group to render as instanced. 229 void SetMinInstances(int instances); 230 /// Set maximum number of sorted instances per batch group. If exceeded, instances are rendered unsorted. 231 void SetMaxSortedInstances(int instances); 232 /// Set maximum number of occluder triangles. 233 void SetMaxOccluderTriangles(int triangles); 234 /// Set occluder buffer width. 235 void SetOcclusionBufferSize(int size); 236 /// Set required screen size (1.0 = full screen) for occluders. 237 void SetOccluderSizeThreshold(float screenSize); 238 /// Set whether to thread occluder rendering. Default false. 239 void SetThreadedOcclusion(bool enable); 240 /// Set shadow depth bias multiplier for mobile platforms to counteract possible worse shadow map precision. Default 1.0 (no effect.) 241 void SetMobileShadowBiasMul(float mul); 242 /// Set shadow depth bias addition for mobile platforms to counteract possible worse shadow map precision. Default 0.0 (no effect.) 243 void SetMobileShadowBiasAdd(float add); 244 /// Set shadow normal offset multiplier for mobile platforms to counteract possible worse shadow map precision. Default 1.0 (no effect.) 245 void SetMobileNormalOffsetMul(float mul); 246 /// Force reload of shaders. 247 void ReloadShaders(); 248 249 /// Apply post processing filter to the shadow map. Called by View. 250 void ApplyShadowMapFilter(View* view, Texture2D* shadowMap, float blurScale); 251 252 /// Return number of backbuffer viewports. GetNumViewports()253 unsigned GetNumViewports() const { return viewports_.Size(); } 254 255 /// Return backbuffer viewport by index. 256 Viewport* GetViewport(unsigned index) const; 257 /// Return default renderpath. 258 RenderPath* GetDefaultRenderPath() const; 259 /// Return default non-textured material technique. 260 Technique* GetDefaultTechnique() const; 261 262 /// Return whether HDR rendering is enabled. GetHDRRendering()263 bool GetHDRRendering() const { return hdrRendering_; } 264 265 /// Return whether specular lighting is enabled. GetSpecularLighting()266 bool GetSpecularLighting() const { return specularLighting_; } 267 268 /// Return whether drawing shadows is enabled. GetDrawShadows()269 bool GetDrawShadows() const { return drawShadows_; } 270 271 /// Return default texture max. anisotropy level. GetTextureAnisotropy()272 int GetTextureAnisotropy() const { return textureAnisotropy_; } 273 274 /// Return default texture filtering mode. GetTextureFilterMode()275 TextureFilterMode GetTextureFilterMode() const { return textureFilterMode_; } 276 277 /// Return texture quality level. GetTextureQuality()278 int GetTextureQuality() const { return textureQuality_; } 279 280 /// Return material quality level. GetMaterialQuality()281 int GetMaterialQuality() const { return materialQuality_; } 282 283 /// Return shadow map resolution. GetShadowMapSize()284 int GetShadowMapSize() const { return shadowMapSize_; } 285 286 /// Return shadow quality. GetShadowQuality()287 ShadowQuality GetShadowQuality() const { return shadowQuality_; } 288 289 /// Return shadow softness. GetShadowSoftness()290 float GetShadowSoftness() const { return shadowSoftness_; } 291 292 /// Return VSM shadow parameters. GetVSMShadowParameters()293 Vector2 GetVSMShadowParameters() const { return vsmShadowParams_; }; 294 295 /// Return VSM shadow multisample level. GetVSMMultiSample()296 int GetVSMMultiSample() const { return vsmMultiSample_; } 297 298 /// Return whether shadow maps are reused. GetReuseShadowMaps()299 bool GetReuseShadowMaps() const { return reuseShadowMaps_; } 300 301 /// Return maximum number of shadow maps per resolution. GetMaxShadowMaps()302 int GetMaxShadowMaps() const { return maxShadowMaps_; } 303 304 /// Return whether dynamic instancing is in use. GetDynamicInstancing()305 bool GetDynamicInstancing() const { return dynamicInstancing_; } 306 307 /// Return number of extra instancing buffer elements. GetNumExtraInstancingBufferElements()308 int GetNumExtraInstancingBufferElements() const { return numExtraInstancingBufferElements_; }; 309 310 /// Return minimum number of instances required in a batch group to render as instanced. GetMinInstances()311 int GetMinInstances() const { return minInstances_; } 312 313 /// Return maximum number of sorted instances per batch group. GetMaxSortedInstances()314 int GetMaxSortedInstances() const { return maxSortedInstances_; } 315 316 /// Return maximum number of occluder triangles. GetMaxOccluderTriangles()317 int GetMaxOccluderTriangles() const { return maxOccluderTriangles_; } 318 319 /// Return occlusion buffer width. GetOcclusionBufferSize()320 int GetOcclusionBufferSize() const { return occlusionBufferSize_; } 321 322 /// Return occluder screen size threshold. GetOccluderSizeThreshold()323 float GetOccluderSizeThreshold() const { return occluderSizeThreshold_; } 324 325 /// Return whether occlusion rendering is threaded. GetThreadedOcclusion()326 bool GetThreadedOcclusion() const { return threadedOcclusion_; } 327 328 /// Return shadow depth bias multiplier for mobile platforms. GetMobileShadowBiasMul()329 float GetMobileShadowBiasMul() const { return mobileShadowBiasMul_; } 330 331 /// Return shadow depth bias addition for mobile platforms. GetMobileShadowBiasAdd()332 float GetMobileShadowBiasAdd() const { return mobileShadowBiasAdd_; } 333 334 /// Return shadow normal offset multiplier for mobile platforms. GetMobileNormalOffsetMul()335 float GetMobileNormalOffsetMul() const { return mobileNormalOffsetMul_; } 336 337 /// Return number of views rendered. GetNumViews()338 unsigned GetNumViews() const { return views_.Size(); } 339 340 /// Return number of primitives rendered. GetNumPrimitives()341 unsigned GetNumPrimitives() const { return numPrimitives_; } 342 343 /// Return number of batches rendered. GetNumBatches()344 unsigned GetNumBatches() const { return numBatches_; } 345 346 /// Return number of geometries rendered. 347 unsigned GetNumGeometries(bool allViews = false) const; 348 /// Return number of lights rendered. 349 unsigned GetNumLights(bool allViews = false) const; 350 /// Return number of shadow maps rendered. 351 unsigned GetNumShadowMaps(bool allViews = false) const; 352 /// Return number of occluders rendered. 353 unsigned GetNumOccluders(bool allViews = false) const; 354 355 /// Return the default zone. GetDefaultZone()356 Zone* GetDefaultZone() const { return defaultZone_; } 357 358 /// Return the default material. GetDefaultMaterial()359 Material* GetDefaultMaterial() const { return defaultMaterial_; } 360 361 /// Return the default range attenuation texture. GetDefaultLightRamp()362 Texture2D* GetDefaultLightRamp() const { return defaultLightRamp_; } 363 364 /// Return the default spotlight attenuation texture. GetDefaultLightSpot()365 Texture2D* GetDefaultLightSpot() const { return defaultLightSpot_; } 366 367 /// Return the shadowed pointlight face selection cube map. GetFaceSelectCubeMap()368 TextureCube* GetFaceSelectCubeMap() const { return faceSelectCubeMap_; } 369 370 /// Return the shadowed pointlight indirection cube map. GetIndirectionCubeMap()371 TextureCube* GetIndirectionCubeMap() const { return indirectionCubeMap_; } 372 373 /// Return the instancing vertex buffer GetInstancingBuffer()374 VertexBuffer* GetInstancingBuffer() const { return dynamicInstancing_ ? instancingBuffer_ : (VertexBuffer*)0; } 375 376 /// Return the frame update parameters. GetFrameInfo()377 const FrameInfo& GetFrameInfo() const { return frame_; } 378 379 /// Update for rendering. Called by HandleRenderUpdate(). 380 void Update(float timeStep); 381 /// Render. Called by Engine. 382 void Render(); 383 /// Add debug geometry to the debug renderer. 384 void DrawDebugGeometry(bool depthTest); 385 /// Queue a render surface's viewports for rendering. Called by the surface, or by View. 386 void QueueRenderSurface(RenderSurface* renderTarget); 387 /// Queue a viewport for rendering. Null surface means backbuffer. 388 void QueueViewport(RenderSurface* renderTarget, Viewport* viewport); 389 390 /// Return volume geometry for a light. 391 Geometry* GetLightGeometry(Light* light); 392 /// Return quad geometry used in postprocessing. 393 Geometry* GetQuadGeometry(); 394 /// Allocate a shadow map. If shadow map reuse is disabled, a different map is returned each time. 395 Texture2D* GetShadowMap(Light* light, Camera* camera, unsigned viewWidth, unsigned viewHeight); 396 /// Allocate a rendertarget or depth-stencil texture for deferred rendering or postprocessing. Should only be called during actual rendering, not before. 397 Texture* GetScreenBuffer 398 (int width, int height, unsigned format, int multiSample, bool autoResolve, bool cubemap, bool filtered, bool srgb, unsigned persistentKey = 0); 399 /// Allocate a depth-stencil surface that does not need to be readable. Should only be called during actual rendering, not before. 400 RenderSurface* GetDepthStencil(int width, int height, int multiSample, bool autoResolve); 401 /// Allocate an occlusion buffer. 402 OcclusionBuffer* GetOcclusionBuffer(Camera* camera); 403 /// Allocate a temporary shadow camera and a scene node for it. Is thread-safe. 404 Camera* GetShadowCamera(); 405 /// Mark a view as prepared by the specified culling camera. 406 void StorePreparedView(View* view, Camera* cullCamera); 407 /// Return a prepared view if exists for the specified camera. Used to avoid duplicate view preparation CPU work. 408 View* GetPreparedView(Camera* cullCamera); 409 /// Choose shaders for a forward rendering batch. The related batch queue is provided in case it has extra shader compilation defines. 410 void SetBatchShaders(Batch& batch, Technique* tech, bool allowShadows, const BatchQueue& queue); 411 /// Choose shaders for a deferred light volume batch. 412 void SetLightVolumeBatchShaders 413 (Batch& batch, Camera* camera, const String& vsName, const String& psName, const String& vsDefines, const String& psDefines); 414 /// Set cull mode while taking possible projection flipping into account. 415 void SetCullMode(CullMode mode, Camera* camera); 416 /// Ensure sufficient size of the instancing vertex buffer. Return true if successful. 417 bool ResizeInstancingBuffer(unsigned numInstances); 418 /// Save the screen buffer allocation status. Called by View. 419 void SaveScreenBufferAllocations(); 420 /// Restore the screen buffer allocation status. Called by View. 421 void RestoreScreenBufferAllocations(); 422 /// Optimize a light by scissor rectangle. 423 void OptimizeLightByScissor(Light* light, Camera* camera); 424 /// Optimize a light by marking it to the stencil buffer and setting a stencil test. 425 void OptimizeLightByStencil(Light* light, Camera* camera); 426 /// Return a scissor rectangle for a light. 427 const Rect& GetLightScissor(Light* light, Camera* camera); 428 429 /// Return a view or its source view if it uses one. Used internally for render statistics. 430 static View* GetActualView(View* view); 431 432 private: 433 /// Initialize when screen mode initially set. 434 void Initialize(); 435 /// Reload shaders. 436 void LoadShaders(); 437 /// Reload shaders for a material pass. The related batch queue is provided in case it has extra shader compilation defines. 438 void LoadPassShaders(Pass* pass, Vector<SharedPtr<ShaderVariation> >& vertexShaders, Vector<SharedPtr<ShaderVariation> >& pixelShaders, const BatchQueue& queue); 439 /// Release shaders used in materials. 440 void ReleaseMaterialShaders(); 441 /// Reload textures. 442 void ReloadTextures(); 443 /// Create light volume geometries. 444 void CreateGeometries(); 445 /// Create instancing vertex buffer. 446 void CreateInstancingBuffer(); 447 /// Create point light shadow indirection texture data. 448 void SetIndirectionTextureData(); 449 /// Update a queued viewport for rendering. 450 void UpdateQueuedViewport(unsigned index); 451 /// Prepare for rendering of a new view. 452 void PrepareViewRender(); 453 /// Remove unused occlusion and screen buffers. 454 void RemoveUnusedBuffers(); 455 /// Reset shadow map allocation counts. 456 void ResetShadowMapAllocations(); 457 /// Reset screem buffer allocation counts. 458 void ResetScreenBufferAllocations(); 459 /// Remove all shadow maps. Called when global shadow map resolution or format is changed. 460 void ResetShadowMaps(); 461 /// Remove all occlusion and screen buffers. 462 void ResetBuffers(); 463 /// Find variations for shadow shaders 464 String GetShadowVariations() const; 465 /// Handle screen mode event. 466 void HandleScreenMode(StringHash eventType, VariantMap& eventData); 467 /// Handle render update event. 468 void HandleRenderUpdate(StringHash eventType, VariantMap& eventData); 469 /// Blur the shadow map. 470 void BlurShadowMap(View* view, Texture2D* shadowMap, float blurScale); 471 472 /// Graphics subsystem. 473 WeakPtr<Graphics> graphics_; 474 /// Default renderpath. 475 SharedPtr<RenderPath> defaultRenderPath_; 476 /// Default non-textured material technique. 477 SharedPtr<Technique> defaultTechnique_; 478 /// Default zone. 479 SharedPtr<Zone> defaultZone_; 480 /// Directional light quad geometry. 481 SharedPtr<Geometry> dirLightGeometry_; 482 /// Spot light volume geometry. 483 SharedPtr<Geometry> spotLightGeometry_; 484 /// Point light volume geometry. 485 SharedPtr<Geometry> pointLightGeometry_; 486 /// Instance stream vertex buffer. 487 SharedPtr<VertexBuffer> instancingBuffer_; 488 /// Default material. 489 SharedPtr<Material> defaultMaterial_; 490 /// Default range attenuation texture. 491 SharedPtr<Texture2D> defaultLightRamp_; 492 /// Default spotlight attenuation texture. 493 SharedPtr<Texture2D> defaultLightSpot_; 494 /// Face selection cube map for shadowed pointlights. 495 SharedPtr<TextureCube> faceSelectCubeMap_; 496 /// Indirection cube map for shadowed pointlights. 497 SharedPtr<TextureCube> indirectionCubeMap_; 498 /// Reusable scene nodes with shadow camera components. 499 Vector<SharedPtr<Node> > shadowCameraNodes_; 500 /// Reusable occlusion buffers. 501 Vector<SharedPtr<OcclusionBuffer> > occlusionBuffers_; 502 /// Shadow maps by resolution. 503 HashMap<int, Vector<SharedPtr<Texture2D> > > shadowMaps_; 504 /// Shadow map dummy color buffers by resolution. 505 HashMap<int, SharedPtr<Texture2D> > colorShadowMaps_; 506 /// Shadow map allocations by resolution. 507 HashMap<int, PODVector<Light*> > shadowMapAllocations_; 508 /// Instance of shadow map filter 509 Object* shadowMapFilterInstance_; 510 /// Function pointer of shadow map filter 511 ShadowMapFilter shadowMapFilter_; 512 /// Screen buffers by resolution and format. 513 HashMap<long long, Vector<SharedPtr<Texture> > > screenBuffers_; 514 /// Current screen buffer allocations by resolution and format. 515 HashMap<long long, unsigned> screenBufferAllocations_; 516 /// Saved status of screen buffer allocations for restoring. 517 HashMap<long long, unsigned> savedScreenBufferAllocations_; 518 /// Cache for light scissor queries. 519 HashMap<Pair<Light*, Camera*>, Rect> lightScissorCache_; 520 /// Backbuffer viewports. 521 Vector<SharedPtr<Viewport> > viewports_; 522 /// Render surface viewports queued for update. 523 Vector<Pair<WeakPtr<RenderSurface>, WeakPtr<Viewport> > > queuedViewports_; 524 /// Views that have been processed this frame. 525 Vector<WeakPtr<View> > views_; 526 /// Prepared views by culling camera. 527 HashMap<Camera*, WeakPtr<View> > preparedViews_; 528 /// Octrees that have been updated during the frame. 529 HashSet<Octree*> updatedOctrees_; 530 /// Techniques for which missing shader error has been displayed. 531 HashSet<Technique*> shaderErrorDisplayed_; 532 /// Mutex for shadow camera allocation. 533 Mutex rendererMutex_; 534 /// Current variation names for deferred light volume shaders. 535 Vector<String> deferredLightPSVariations_; 536 /// Frame info for rendering. 537 FrameInfo frame_; 538 /// Texture anisotropy level. 539 int textureAnisotropy_; 540 /// Texture filtering mode. 541 TextureFilterMode textureFilterMode_; 542 /// Texture quality level. 543 int textureQuality_; 544 /// Material quality level. 545 int materialQuality_; 546 /// Shadow map resolution. 547 int shadowMapSize_; 548 /// Shadow quality. 549 ShadowQuality shadowQuality_; 550 /// Shadow softness, only works when SHADOWQUALITY_BLUR_VSM is used. 551 float shadowSoftness_; 552 /// Shadow parameters when VSM is used, they help to reduce light bleeding. 553 Vector2 vsmShadowParams_; 554 /// Multisample level for VSM shadows. 555 int vsmMultiSample_; 556 /// Maximum number of shadow maps per resolution. 557 int maxShadowMaps_; 558 /// Minimum number of instances required in a batch group to render as instanced. 559 int minInstances_; 560 /// Maximum sorted instances per batch group. 561 int maxSortedInstances_; 562 /// Maximum occluder triangles. 563 int maxOccluderTriangles_; 564 /// Occlusion buffer width. 565 int occlusionBufferSize_; 566 /// Occluder screen size threshold. 567 float occluderSizeThreshold_; 568 /// Mobile platform shadow depth bias multiplier. 569 float mobileShadowBiasMul_; 570 /// Mobile platform shadow depth bias addition. 571 float mobileShadowBiasAdd_; 572 /// Mobile platform shadow normal offset multiplier. 573 float mobileNormalOffsetMul_; 574 /// Number of occlusion buffers in use. 575 unsigned numOcclusionBuffers_; 576 /// Number of temporary shadow cameras in use. 577 unsigned numShadowCameras_; 578 /// Number of primitives (3D geometry only.) 579 unsigned numPrimitives_; 580 /// Number of batches (3D geometry only.) 581 unsigned numBatches_; 582 /// Frame number on which shaders last changed. 583 unsigned shadersChangedFrameNumber_; 584 /// Current stencil value for light optimization. 585 unsigned char lightStencilValue_; 586 /// HDR rendering flag. 587 bool hdrRendering_; 588 /// Specular lighting flag. 589 bool specularLighting_; 590 /// Draw shadows flag. 591 bool drawShadows_; 592 /// Shadow map reuse flag. 593 bool reuseShadowMaps_; 594 /// Dynamic instancing flag. 595 bool dynamicInstancing_; 596 /// Number of extra instancing data elements. 597 int numExtraInstancingBufferElements_; 598 /// Threaded occlusion rendering flag. 599 bool threadedOcclusion_; 600 /// Shaders need reloading flag. 601 bool shadersDirty_; 602 /// Initialized flag. 603 bool initialized_; 604 /// Flag for views needing reset. 605 bool resetViews_; 606 }; 607 608 } 609