Rise
The Vieneo Province
Loading...
Searching...
No Matches
FogBeams11.h
Go to the documentation of this file.
1#pragma once
2#include "Device11.h"
3#include "Program11.h"
5#include <d3d11_1.h>
6#include <DirectXMath.h>
7#include <array>
8#include <filesystem>
9
10namespace Rendering
11{
12 // Bounded single scattering in homogeneous weather fog. Cloud lighting is
13 // still owned by CloudPass11; its density/optical-depth map only attenuate us.
15 {
16 public:
17 static constexpr unsigned MaxLights=8;
18 using Vector=DirectX::XMFLOAT3;
19 using Matrix=DirectX::XMFLOAT4X4;
20 struct Light
21 {
22 Vector position{},direction{0,0,-1},up{0,1,0}; // camera-relative km
23 DirectX::XMFLOAT4 color{1,1,1,1};
26 int cloudIndex=-1;
27 };
28 HRESULT Initialize(ID3D11Device* device,const std::filesystem::path& directory={});
29 void Reset();
31 {
32 if(enabled && !organicReady)return E_NOTIMPL;
33 organic=enabled;return S_OK;
34 }
35 bool Ready() const {return state!=nullptr;}
36 bool OrganicAvailable() const {return organicReady;}
37 HRESULT Render(ID3D11DeviceContext* context,ID3D11RenderTargetView* scene,const SceneDepth11& depth,
38 const D3D11_VIEWPORT& viewport,const Matrix& view,const Matrix& projection,
39 const std::vector<Light>& lights,const Parameters11* clouds=nullptr);
40 unsigned LastDraws() const {return lastDraws;}
41 // Zero selects the bounded default buffer (at least 4:1 reduction).
42 // One retains the reference integrator; eight uses 1/64 as many rays.
43 void SetResolutionDivisor(unsigned value) {resolutionDivisor=value==0 || value==1 || value==2 || value==4 ? value : 8;}
44 void ReleaseTargets();
45 private:
46 HRESULT PreparePrograms(unsigned variant);
47 HRESULT PrepareTargets(unsigned width,unsigned height);
48 std::filesystem::path shaderDirectory;
49 Microsoft::WRL::ComPtr<ID3D11Device> device;
50 Microsoft::WRL::ComPtr<ID3DDeviceContextState> state;
51 Microsoft::WRL::ComPtr<ID3D11RasterizerState> raster;
52 Microsoft::WRL::ComPtr<ID3D11DepthStencilState> stencil;
53 Microsoft::WRL::ComPtr<ID3D11BlendState> blend,lowBlend;
54 Microsoft::WRL::ComPtr<ID3D11SamplerState> fallbackSampler;
55 std::array<Program11,4> pixel,edge;
56 std::array<Program11,4> organicPixel,organicEdge;
58 Microsoft::WRL::ComPtr<ID3D11Texture2D> scattering;
59 Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> scatteringView;
60 Microsoft::WRL::ComPtr<ID3D11RenderTargetView> scatteringAll;
62 bool organicReady=false,organic=false;
63 unsigned lastDraws=0;
64 };
65}
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
Microsoft::WRL::ComPtr< ID3D11Device > device
Definition FogBeams11.h:49
Microsoft::WRL::ComPtr< ID3D11DepthStencilState > stencil
Definition FogBeams11.h:52
unsigned resolutionDivisor
Definition FogBeams11.h:61
HRESULT PrepareTargets(unsigned width, unsigned height)
Microsoft::WRL::ComPtr< ID3D11Texture2D > scattering
Definition FogBeams11.h:58
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, const std::vector< Light > &lights, const Parameters11 *clouds=nullptr)
std::array< Program11, 4 > pixel
Definition FogBeams11.h:55
std::array< Program11, 4 > edge
Definition FogBeams11.h:55
bool OrganicAvailable() const
Definition FogBeams11.h:36
Microsoft::WRL::ComPtr< ID3D11BlendState > lowBlend
Definition FogBeams11.h:53
static constexpr unsigned MaxLights
Definition FogBeams11.h:17
unsigned LastDraws() const
Definition FogBeams11.h:40
std::array< Program11, 4 > organicEdge
Definition FogBeams11.h:56
std::array< Program11, 4 > resolveEdge
Definition FogBeams11.h:57
std::filesystem::path shaderDirectory
Definition FogBeams11.h:48
std::array< Program11, 4 > organicLowPixel
Definition FogBeams11.h:57
Microsoft::WRL::ComPtr< ID3D11ShaderResourceView > scatteringView
Definition FogBeams11.h:59
std::array< Program11, 4 > lowPixel
Definition FogBeams11.h:57
Microsoft::WRL::ComPtr< ID3D11RenderTargetView > scatteringAll
Definition FogBeams11.h:60
void SetResolutionDivisor(unsigned value)
Definition FogBeams11.h:43
Microsoft::WRL::ComPtr< ID3D11RasterizerState > raster
Definition FogBeams11.h:51
HRESULT PreparePrograms(unsigned variant)
Microsoft::WRL::ComPtr< ID3D11SamplerState > fallbackSampler
Definition FogBeams11.h:54
bool Ready() const
Definition FogBeams11.h:35
DirectX::XMFLOAT4X4 Matrix
Definition FogBeams11.h:19
Microsoft::WRL::ComPtr< ID3DDeviceContextState > state
Definition FogBeams11.h:50
std::array< Program11, 4 > organicPixel
Definition FogBeams11.h:56
std::array< Program11, 4 > resolvePixel
Definition FogBeams11.h:57
Microsoft::WRL::ComPtr< ID3D11BlendState > blend
Definition FogBeams11.h:53
HRESULT ConfigureOrganic(bool enabled)
Definition FogBeams11.h:30
DirectX::XMFLOAT3 Vector
Definition FogBeams11.h:18
DirectX::XMFLOAT4X4 Matrix
Definition Math11.h:9
LandingLights::Profile profile
Definition FogBeams11.h:24
DirectX::XMFLOAT4 color
Definition FogBeams11.h:23