-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathClouds.h
More file actions
151 lines (121 loc) · 3.68 KB
/
Copy pathClouds.h
File metadata and controls
151 lines (121 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/* SimShip by Edouard Halbert
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License
http://creativecommons.org/licenses/by-nc-nd/4.0/ */
// Adapted from Federico Vaccaro
#pragma once
// 1. PROJECT
#include "Camera.h"
#include "Sky.h"
// 2. LIB
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <algorithm>
// 3. WIN
#include <random>
using namespace std;
using namespace glm;
class Clouds
{
public:
Clouds(shared_ptr<VulkanDevice>& vulkanDevice, VkExtent2D extent, float windSpeedKN);
~Clouds();
void InitVariables();
void SetCloudSpeed(float windSpeedKN);
void ComputeLUTs();
void ComputeNewWeatherLUT();
// Render on screen
void CreateOnScreenPipeline(VkRenderPass renderPassScene, VkExtent2D extent);
void Render(VkCommandBuffer cmd, uint32_t currentFrame, Camera& camera, Sky* sky, vec2 wind);
// Render off screen
void ComputeOffScreenImage(VkCommandBuffer cmd,uint32_t currentFrame, Camera& camera, Sky* sky, vec2 wind);
void CreatePostPipeline(VkRenderPass renderPassScene, VkExtent2D extent);
void UpdatePostDescriptors(VulkanTexture* skyTexture);
void RenderPost(VkCommandBuffer cmd, uint32_t currentFrame, Camera& camera, Sky* sky);
VkImage GetOutputImage(uint32_t currentFrame) { return mCloudsImage[currentFrame]->image; }
float Coverage = 0.0f;
float CloudSpeed = 0.0f;
float Crispiness = 0.0f;
float Curliness = 0.0f;
float Density = 0.0f;
float Illumination = 1.8f;
float Absorption = 0.0f;
float SphereInnerRadius = 0.0f;
float SphereOuterRadius = 0.0f;
float PerlinFrequency = 0.0f;
bool bPostProcess = true;
vec3 CloudColorTop = vec3(0.0f);
vec3 CloudColorBottom = vec3(0.0f);
vec3 Seed = vec3(0.0f);
bool bVisible = true;
bool PostDescriptorsInitialized = false;
private:
shared_ptr<VulkanDevice> mVulkanDevice;
uint32_t mFramesInFlight;
VkExtent2D mSwapChainExtent;
// LUTs
VulkanTexture mTexPerlin;
sPipeline_1 mPipelinePerlin;
void CreatePerlinPipeline();
void CreatePerlinDescriptors();
void UpdatePerlinDescriptors();
VulkanTexture mTexWorley;
sPipeline_1 mPipelineWorley;
void CreateWorleyPipeline();
void CreateWorleyDescriptors();
void UpdateWorleyDescriptors();
VulkanTexture mTexWeather;
sPipeline_1 mPipelineWeather;
struct sWeatherUBO
{
vec3 seed = vec3(0.0f);
float perlinAmplitude = 0.5f;
float perlinFrequency = 0.8f;
float perlinScale = 100.0f;
int perlinOctaves = 4;
float pad = 0.0f;
};
void CreateWeatherPipeline();
void CreateWeatherDescriptors();
void UpdateWeatherDescriptors();
struct sCloudsUBO {
vec2 iResolution;
float FOV;
float iTime;
mat4 inv_view;
mat4 inv_proj;
mat4 invViewProj;
vec3 cameraPosition;
float coverage_multiplier;
vec3 lightColor;
float cloudSpeed;
vec3 lightDirection;
float crispiness;
vec3 wind;
float illumination;
vec3 cloudColorTop;
float curliness;
vec3 cloudColorBottom;
float absorption;
float densityFactor;
float sphereInnerRadius;
float sphereOuterRadius;
float exposure;
};
sPipeline_x mPipelineClouds1;
void CreateOnScreenDescriptors();
void UpdateOnScreenDescriptors(uint32_t currentFrame);
sPipeline_x mPipelineClouds2;
vector<unique_ptr<VulkanTexture>>mCloudsImage;
void CreateOffScreenPipeline();
void CreateOffScreenDescriptors();
void UpdateOffScreenDescriptors();
sPipeline_x mPipelinePost;
VkSampler mSampler;
void CreatePostDescriptors();
struct sCloudsPostUBO
{
vec2 cloudsResolution;
int bShowSky;
int bShowClouds;
};
};