-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSmoke.h
More file actions
91 lines (76 loc) · 2.37 KB
/
Copy pathSmoke.h
File metadata and controls
91 lines (76 loc) · 2.37 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
/* 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/ */
#pragma once
// 1. PROJECT
#include "Utility.h"
#include "Camera.h"
#include "Sky.h"
#include "vulkan_device.hpp"
#include "vulkan_pipeline.hpp"
#include "vulkan_ubo.hpp"
// 2. LIB
#include <vulkan/vulkan.h>
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
#include <glm/glm.hpp>
using namespace glm;
// 3. WIN
#define NOMINMAX
#include <vector>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#include <numeric>
#include <random>
using namespace std;
class Smoke
{
private:
struct ParticleGPU {
vec3 position;
float life;
vec3 velocity;
float pad;
vec4 color;
};
struct sSmokeComputePush {
float dt;
int particlesPerFrame;
int numEmitters;
int frameCount;
float shortLife;
float longLife;
};
struct sSmokeRenderPush {
mat4 view; // offset 0
mat4 projection; // offset 64
float density; // offset 128
float lifeSpan; // offset 132
float exposure; // offset 136
float padding;
};
struct sComputeUBO {
vec4 emitPositions[2];
vec4 windDirection;
};
shared_ptr<VulkanDevice> mVulkanDevice;
static constexpr uint32_t SMOKE_MAX_PARTICLES = 5000;
unique_ptr<VulkanUBO> mParticles;
vector<unique_ptr<VulkanUBO>>mComputeUBO;
uint32_t mFrameSmokeCount = 0;
VkPipeline mComputePipeline;
VkPipelineLayout mComputeLayout;
sPipeline_x mRenderPipeline;
public:
Smoke(shared_ptr<VulkanDevice>& vulkanDevice, VkRenderPass renderPassScene, VkExtent2D extent);
~Smoke();
void Update(VkCommandBuffer cmd, uint32_t frame, float dt, int nChimney, vec3 chimney1WorldPos, vec3 chimney2WorldPos, vec3 windDirection);
void Render(VkCommandBuffer cmd, uint32_t frame, Camera& camera, Sky* sky, float density);
private:
void CreatePipeline(VkRenderPass renderPassScene, VkExtent2D extent);
};