Renderer.h 25 KB

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