Rise
The Vieneo Province
Loading...
Searching...
No Matches
ProceduralLightning11.h
Go to the documentation of this file.
1#pragma once
2#include "CloudRenderer11.h"
6#include <array>
7namespace Rendering
8{
10 {
11 public:
12 using Matrix=DirectX::XMFLOAT4X4;
14 HRESULT Initialize(ID3D11Device* device,const std::filesystem::path& directory={});
15 void Reset();
16 HRESULT Render(ID3D11DeviceContext* context,ID3D11RenderTargetView* scene,const SceneDepth11& depth,
17 const D3D11_VIEWPORT& viewport,const Matrix& view,const Matrix& projection,
18 Vector observerOrigin,Vector ground,Vector cloud,uint32_t seed,
19 const RiseMath::Color& color,float pulse,float visibilityKm,CloudRenderer11* atmosphere=nullptr,float growth=1.f);
20 unsigned GeometryBuilds() const {return builds;}
21 unsigned IndexCount() const {return indexCount;}
22 void BeginAfterimage(double now,bool enabled,float ambient,uint64_t viewer);
24 bool AfterimageActive() const {return afterimage.active;}
25 HRESULT CompositeAfterimage(ID3D11DeviceContext* context,ID3D11RenderTargetView* scene,
26 const SceneDepth11& depth,const D3D11_VIEWPORT& viewport);
27 private:
28 HRESULT Geometry(Vector offset,uint32_t seed);
29 struct Target
30 {
31 Microsoft::WRL::ComPtr<ID3D11Texture2D> texture;
32 Microsoft::WRL::ComPtr<ID3D11RenderTargetView> rtv;
33 Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> srv;
34 };
35 HRESULT AfterimageTargets(const SceneDepth11& depth,const D3D11_VIEWPORT& viewport);
36 bool AfterimageSizeMatches(const SceneDepth11& depth,const D3D11_VIEWPORT& viewport) const;
39 D3D11_TEXTURE2D_DESC captureDescription{};
40 D3D11_VIEWPORT captureViewport{};
41 unsigned historyIndex=0;
42 bool historyClear=true,captured=false;
44 Microsoft::WRL::ComPtr<ID3D11DepthStencilState> noDepth;
45 Microsoft::WRL::ComPtr<ID3D11BlendState> captureBlend,ghostBlend;
46 Microsoft::WRL::ComPtr<ID3D11Device> device;
47 Microsoft::WRL::ComPtr<ID3DDeviceContextState> state;
48 Microsoft::WRL::ComPtr<ID3D11RasterizerState> raster;
49 Microsoft::WRL::ComPtr<ID3D11DepthStencilState> depthState;
50 Microsoft::WRL::ComPtr<ID3D11BlendState> blend;
51 Microsoft::WRL::ComPtr<ID3D11SamplerState> sampler;
52 Microsoft::WRL::ComPtr<ID3D11Buffer> vertices,indices;
55 {
57 uint32_t seed=0;
58 unsigned indexCount=0;
59 Microsoft::WRL::ComPtr<ID3D11Buffer> vertices,indices;
60 };
61 // One immutable mesh per visible channel, retained across return strokes.
62 std::array<GeometryEntry,LightningTiming::MaxChainedBolts+1> geometryCache{};
63 unsigned nextGeometry=0;
64 unsigned indexCount=0,builds=0;
65 };
66}
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
Microsoft::WRL::ComPtr< ID3DDeviceContextState > state
HRESULT CompositeAfterimage(ID3D11DeviceContext *context, ID3D11RenderTargetView *scene, const SceneDepth11 &depth, const D3D11_VIEWPORT &viewport)
void BeginAfterimage(double now, bool enabled, float ambient, uint64_t viewer)
Microsoft::WRL::ComPtr< ID3D11SamplerState > sampler
Microsoft::WRL::ComPtr< ID3D11BlendState > ghostBlend
Microsoft::WRL::ComPtr< ID3D11Buffer > vertices
std::array< GeometryEntry, LightningTiming::MaxChainedBolts+1 > geometryCache
HRESULT Initialize(ID3D11Device *device, const std::filesystem::path &directory={})
HRESULT Render(ID3D11DeviceContext *context, ID3D11RenderTargetView *scene, const SceneDepth11 &depth, const D3D11_VIEWPORT &viewport, const Matrix &view, const Matrix &projection, Vector observerOrigin, Vector ground, Vector cloud, uint32_t seed, const RiseMath::Color &color, float pulse, float visibilityKm, CloudRenderer11 *atmosphere=nullptr, float growth=1.f)
Microsoft::WRL::ComPtr< ID3D11BlendState > blend
LightningAfterimage::State afterimage
Microsoft::WRL::ComPtr< ID3D11DepthStencilState > noDepth
Microsoft::WRL::ComPtr< ID3D11Buffer > indices
Microsoft::WRL::ComPtr< ID3D11DepthStencilState > depthState
Microsoft::WRL::ComPtr< ID3D11Device > device
bool AfterimageSizeMatches(const SceneDepth11 &depth, const D3D11_VIEWPORT &viewport) const
Microsoft::WRL::ComPtr< ID3D11RasterizerState > raster
HRESULT AfterimageTargets(const SceneDepth11 &depth, const D3D11_VIEWPORT &viewport)
HRESULT Geometry(Vector offset, uint32_t seed)
Microsoft::WRL::ComPtr< ID3D11BlendState > captureBlend
DirectX::XMFLOAT3 Vector
Definition Math11.h:7
DirectX::XMFLOAT4X4 Matrix
Definition Math11.h:9
Vector offset
uint32_t seed
Microsoft::WRL::ComPtr< ID3D11Buffer > indices
Microsoft::WRL::ComPtr< ID3D11Buffer > vertices
unsigned indexCount
Microsoft::WRL::ComPtr< ID3D11RenderTargetView > rtv
Microsoft::WRL::ComPtr< ID3D11Texture2D > texture
Microsoft::WRL::ComPtr< ID3D11ShaderResourceView > srv