Overte C++ Documentation
RenderableProceduralParticleEffectEntityItem.h
1 //
2 // RenderableProceduralParticleEffectEntityItem.h
3 // interface/src/entities
4 //
5 // Created by HifiExperiements on 11/19/23
6 // Copyright 2023 Overte e.V.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #ifndef hifi_RenderableProceduralParticleEffectEntityItem_h
13 #define hifi_RenderableProceduralParticleEffectEntityItem_h
14 
15 #include "RenderableEntityItem.h"
16 #include <ProceduralParticleEffectEntityItem.h>
17 
18 #include <procedural/Procedural.h>
19 
20 namespace render { namespace entities {
21 
22 class ProceduralParticleEffectEntityRenderer : public TypedEntityRenderer<ProceduralParticleEffectEntityItem> {
23  using Parent = TypedEntityRenderer<ProceduralParticleEffectEntityItem>;
24  friend class EntityRenderer;
25 
26 public:
27  ProceduralParticleEffectEntityRenderer(const EntityItemPointer& entity);
28 
29  virtual void renderSimulate(RenderArgs* args) override;
30 
31  ComponentMode getFadeOutMode() const override { return ComponentMode::COMPONENT_MODE_DISABLED; }
32 
33 protected:
34  virtual void doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) override;
35  virtual void doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) override;
36 
37  bool isTransparent() const override;
38  virtual ItemKey getKey() override;
39  virtual ShapeKey getShapeKey() override;
40  virtual void doRender(RenderArgs* args) override;
41 
42 private:
43  using TexturePointer = gpu::TexturePointer;
44  using FramebufferPointer = gpu::FramebufferPointer;
45 
46  void recreateParticles();
47 
48  QString _particleUpdateData;
49  Procedural _updateProcedural;
50  QString _particleRenderData;
51  Procedural _renderProcedural { false }; // No AA on Particles
52 
53  size_t _numParticles { 0 };
54  size_t _particlePropTextureDim { 128 }; // 2^ceil(log2(sqrt(10,000)))
55  size_t _numTrianglesPerParticle { particle::DEFAULT_NUM_TRIS_PER };
56  size_t _numUpdateProps { particle::DEFAULT_NUM_UPDATE_PROPS };
57  bool _transparent { false };
58 
59  std::array<FramebufferPointer, 2> _particleBuffers;
60  bool _evenPass { true };
61 };
62 
63 } } // namespace
64 
65 #endif // hifi_RenderableProceduralParticleEffectEntityItem_h