Rise
The Vieneo Province
Loading...
Searching...
No Matches
WindshieldRain11.h
Go to the documentation of this file.
1#pragma once
2#include "Program11.h"
3#include "Math11.h"
6#include <d3d11_1.h>
7#include <filesystem>
8
9namespace Rendering
10{
12 {
13 public:
14 using Vector=DirectX::XMFLOAT3;
15 using Matrix=DirectX::XMFLOAT4X4;
16 struct Vertex {float x,y,z,nx,ny,nz,u,v;};
17 enum class DepthLayout {Unified,CockpitAndWorld};
18 static Matrix ToPhysicsTransform(const Matrix& cockpitToView);
19 static WindshieldRain::Point ProjectAcceleration(const Vector& acceleration,
20 const Matrix& inverse,const Vector& normal,const Vector& u,const Vector& v);
21 HRESULT Initialize(ID3D11Device* device,const std::filesystem::path& shaderDirectory={});
22 void Clear();
23 void SetSimulator(bool value);
24 void SetGlassCondition(int condition);
25 void ResetDevice();
26 void ReleaseTargets();
27 void AddGlass(int component,const Vertex* vertices,size_t count);
28 void AddWiper(int component,const Vertex* vertices,size_t count);
29 void FinishGeometry();
30 void Update(float elapsed,float rain,const Vector& acceleration,const Vector& relativeWind,
31 const std::vector<Matrix>& transforms,float airDensity,bool wiping,float rainAir=0);
32 HRESULT Render(ID3D11DeviceContext* context,ID3D11RenderTargetView* target,
33 ID3D11DepthStencilView* depth,const D3D11_VIEWPORT& viewport,
34 const std::vector<Matrix>& world,const Matrix& viewProjection,float opacity=1,
35 DepthLayout depthLayout=DepthLayout::Unified,float cockpitLight=0,
36 ID3D11RenderTargetView* adExclusion=nullptr);
37 size_t PaneCount() const {return panes.size();}
38 bool Wet() const;
39 float Wetness() const;
40 const std::string& Status() const {return status;}
41 private:
43 struct Image
44 {
45 Microsoft::WRL::ComPtr<ID3D11Texture2D> texture;
46 Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> srv;
47 Microsoft::WRL::ComPtr<ID3D11RenderTargetView> rtv;
48 };
49 struct Pane
50 {
52 int component=0;
54 std::vector<Vertex> vertices;
55 std::vector<Facet> facets;
57 uint64_t uploadedRevision=uint64_t(-1);
59 std::vector<WindshieldFractures::Segment> fractureNetwork;
61 Microsoft::WRL::ComPtr<ID3D11Buffer> geometry;
62 };
63 struct Wiper {int component;std::vector<Vertex> vertices;};
64 HRESULT CreateImage(Image& image,UINT width,UINT height,DXGI_FORMAT format,bool dynamic=false,DXGI_SAMPLE_DESC samples={1,0});
65 HRESULT Upload(ID3D11DeviceContext* context,Pane& pane);
66 HRESULT PrepareTargets(const D3D11_TEXTURE2D_DESC& description);
67 std::vector<Pane> panes;
68 bool simulator=false;
70 std::vector<Wiper> wipers;
71 std::vector<Matrix> previousTransforms;
72 std::vector<uint32_t> filmUpload;
73 std::vector<WindshieldRain::Surface::BeadSample> beadUpload;
74 std::vector<WindshieldRain::Surface::WakeSample> wakeUpload;
75 std::vector<float> distanceUpload;
76 Microsoft::WRL::ComPtr<ID3D11Device> device;
77 Microsoft::WRL::ComPtr<ID3DDeviceContextState> isolated;
80 std::vector<Microsoft::WRL::ComPtr<ID3D11SamplerState>> samplers;
81 Microsoft::WRL::ComPtr<ID3D11DepthStencilState> unifiedDepth,noDepth,worldDepth,cockpitDepth;
82 Microsoft::WRL::ComPtr<ID3D11BlendState> opaque,alpha,alphaWithAdMask;
84 // Test access can retain the prior mask format for exact comparisons.
86 DXGI_FORMAT visibilityFormat=DXGI_FORMAT_UNKNOWN;
87 D3D11_TEXTURE2D_DESC targetDescription{};
88 std::string status="native windshield rain not initialized";
89 };
90}
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
std::vector< Microsoft::WRL::ComPtr< ID3D11SamplerState > > samplers
Microsoft::WRL::ComPtr< ID3D11Device > device
std::vector< Wiper > wipers
const std::string & Status() const
HRESULT Initialize(ID3D11Device *device, const std::filesystem::path &shaderDirectory={})
std::vector< WindshieldRain::Surface::BeadSample > beadUpload
HRESULT CreateImage(Image &image, UINT width, UINT height, DXGI_FORMAT format, bool dynamic=false, DXGI_SAMPLE_DESC samples={1, 0})
HRESULT Render(ID3D11DeviceContext *context, ID3D11RenderTargetView *target, ID3D11DepthStencilView *depth, const D3D11_VIEWPORT &viewport, const std::vector< Matrix > &world, const Matrix &viewProjection, float opacity=1, DepthLayout depthLayout=DepthLayout::Unified, float cockpitLight=0, ID3D11RenderTargetView *adExclusion=nullptr)
void SetGlassCondition(int condition)
static Matrix ToPhysicsTransform(const Matrix &cockpitToView)
Microsoft::WRL::ComPtr< ID3DDeviceContextState > isolated
Microsoft::WRL::ComPtr< ID3D11BlendState > alphaWithAdMask
friend struct WindshieldRain11TestAccess
std::vector< float > distanceUpload
D3D11_TEXTURE2D_DESC targetDescription
std::vector< WindshieldRain::Surface::WakeSample > wakeUpload
HRESULT PrepareTargets(const D3D11_TEXTURE2D_DESC &description)
Microsoft::WRL::ComPtr< ID3D11DepthStencilState > worldDepth
void Update(float elapsed, float rain, const Vector &acceleration, const Vector &relativeWind, const std::vector< Matrix > &transforms, float airDensity, bool wiping, float rainAir=0)
static WindshieldRain::Point ProjectAcceleration(const Vector &acceleration, const Matrix &inverse, const Vector &normal, const Vector &u, const Vector &v)
Microsoft::WRL::ComPtr< ID3D11DepthStencilState > cockpitDepth
std::vector< uint32_t > filmUpload
std::vector< Matrix > previousTransforms
void AddWiper(int component, const Vertex *vertices, size_t count)
void AddGlass(int component, const Vertex *vertices, size_t count)
HRESULT Upload(ID3D11DeviceContext *context, Pane &pane)
Microsoft::WRL::ComPtr< ID3D11BlendState > alpha
Microsoft::WRL::ComPtr< ID3D11DepthStencilState > unifiedDepth
Microsoft::WRL::ComPtr< ID3D11DepthStencilState > noDepth
Microsoft::WRL::ComPtr< ID3D11BlendState > opaque
DirectX::XMFLOAT3 Vector
Definition Math11.h:7
DirectX::XMFLOAT4X4 Matrix
Definition Math11.h:9
Microsoft::WRL::ComPtr< ID3D11Texture2D > texture
Microsoft::WRL::ComPtr< ID3D11RenderTargetView > rtv
Microsoft::WRL::ComPtr< ID3D11ShaderResourceView > srv
std::vector< WindshieldFractures::Segment > fractureNetwork
Microsoft::WRL::ComPtr< ID3D11Buffer > geometry