Plasma Engine  2.0
Loading...
Searching...
No Matches
LensFlareComponent.h
1#pragma once
2
3#include <Core/ResourceManager/ResourceHandle.h>
4#include <Core/World/World.h>
5#include <Foundation/Math/Float16.h>
6#include <RendererCore/Components/RenderComponent.h>
7#include <RendererCore/Pipeline/RenderData.h>
8
9struct plMsgSetColor;
11
12class PL_RENDERERCORE_DLL plLensFlareRenderData : public plRenderData
13{
14 PL_ADD_DYNAMIC_REFLECTION(plLensFlareRenderData, plRenderData);
15
16public:
17 void FillBatchIdAndSortingKey();
18
20 plFloat16Vec4 m_Color;
21
22 float m_fSize;
23 float m_fMaxScreenSize;
24 float m_fAspectRatio;
25 float m_fShiftToCenter;
26 float m_fOcclusionSampleRadius;
27 float m_fOcclusionSampleSpread;
28 float m_fOcclusionDepthOffset;
29
30 bool m_bInverseTonemap;
31 bool m_bGreyscaleTexture;
32 bool m_bApplyFog;
33};
34
37{
39 plColor m_Color = plColor::White;
40 float m_fSize = 10000.0f;
41 float m_fMaxScreenSize = 1.0f;
42 float m_fAspectRatio = 1.0f;
43 float m_fShiftToCenter = 0.0f;
44 bool m_bGreyscaleTexture = false;
46 bool m_bInverseTonemap = false;
47
48 void SetTextureFile(const char* szFile); // [ property ]
49 const char* GetTextureFile() const; // [ property ]
50
51 plResult Serialize(plStreamWriter& inout_stream) const;
52 plResult Deserialize(plStreamReader& inout_stream);
53};
54
55PL_DECLARE_REFLECTABLE_TYPE(PL_RENDERERCORE_DLL, plLensFlareElement);
56
58
72class PL_RENDERERCORE_DLL plLensFlareComponent : public plRenderComponent
73{
75
77 // plComponent
78
79public:
80 virtual void OnActivated() override;
81 virtual void OnDeactivated() override;
82 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
83 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
84
86 // plRenderComponent
87
88public:
89 virtual plResult GetLocalBounds(plBoundingBoxSphere& ref_bounds, bool& ref_bAlwaysVisible, plMsgUpdateLocalBounds& ref_msg) override;
90
92 // plLensFlareComponent
93
94public:
97
99 float m_fIntensity = 1.0f; // [ property ]
100
109 void SetLinkToLightShape(bool bLink); // [ property ]
110 bool GetLinkToLightShape() const { return m_bLinkToLightShape; } // [ property ]
111
114 void SetOcclusionSampleRadius(float fRadius); // [ property ]
115 float GetOcclusionSampleRadius() const { return m_fOcclusionSampleRadius; } // [ property ]
116
119 float m_fOcclusionSampleSpread = 0.5f; // [ property ]
120
123 float m_fOcclusionDepthOffset = 0.0f; // [ property ]
124
125 plSmallArray<plLensFlareElement, 1> m_Elements; // [ property ]
126
127private:
128 void FindLightComponent();
129
130 void OnMsgExtractRenderData(plMsgExtractRenderData& msg) const;
131
132 float m_fOcclusionSampleRadius = 0.1f;
133 bool m_bLinkToLightShape = true;
134 bool m_bApplyFog = true;
135
136 bool m_bDirectionalLight = false;
137 plComponentHandle m_hLightComponent;
138};
plColor represents an RGBA color in linear color space. Values are stored as float,...
Definition Color.h:44
static const plColor White
#FFFFFF
Definition Color.h:194
Definition ComponentManager.h:88
A simple helper class to use half-precision floats (plFloat16) as vectors.
Definition Float16.h:79
Adds a lensflare or corona effect to a lightsource.
Definition LensFlareComponent.h:73
Definition LensFlareComponent.h:13
Base class for objects that should be rendered.
Definition RenderComponent.h:9
Base class for all render data. Render data must contain all information that is needed to render the...
Definition RenderData.h:14
Definition SmallArray.h:219
Interface for binary in (read) streams.
Definition Stream.h:22
Interface for binary out (write) streams.
Definition Stream.h:107
Reads a world description from a stream. Allows to instantiate that world multiple times in different...
Definition WorldReader.h:47
Stores an entire plWorld in a stream.
Definition WorldWriter.h:13
A handle to a component.
Definition Declarations.h:138
Represents an individual element of a lens flare.
Definition LensFlareComponent.h:37
float m_fAspectRatio
Width:height ratio, only height is adjusted while width stays fixed.
Definition LensFlareComponent.h:42
bool m_bInverseTonemap
Apply an inverse tonemapping operation on the final color. This can be useful if the lens flare is no...
Definition LensFlareComponent.h:46
float m_fMaxScreenSize
Relative screen space size in 0..1 range.
Definition LensFlareComponent.h:41
bool m_bModulateByLightColor
Modulate the element's color by the light color and intensity if the lens flare component is linked t...
Definition LensFlareComponent.h:45
bool m_bGreyscaleTexture
Whether the given texture is a greyscale or color texture.
Definition LensFlareComponent.h:44
float m_fSize
World space size.
Definition LensFlareComponent.h:40
float m_fShiftToCenter
Move the element along the lens flare origin to screen center line. 0 is at the lens flare origin,...
Definition LensFlareComponent.h:43
Definition RenderData.h:116
A message to modify the main color of some thing.
Definition SetColorMessage.h:32
Definition UpdateLocalBoundsMessage.h:9
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54