Changeset 4a9416a in opengl-game for vulkan-game.hpp


Ignore:
Timestamp:
Apr 26, 2020, 9:50:00 PM (4 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master
Children:
b8d4456
Parents:
52a02e6
git-author:
Dmitry Portnoy <dmitry.portnoy@…> (04/26/20 19:00:18)
git-committer:
Dmitry Portnoy <dmitry.portnoy@…> (04/26/20 21:50:00)
Message:

Create a pipeline and shaders to render explosions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vulkan-game.hpp

    r52a02e6 r4a9416a  
    5757};
    5858
     59struct ExplosionVertex {
     60   vec3 particleStartVelocity;
     61   float particleStartTime;
     62   unsigned int objIndex;
     63};
     64
    5965struct SSBO_ModelObject {
    6066   alignas(16) mat4 model;
     
    7379};
    7480
     81struct SSBO_Explosion {
     82   alignas(16) mat4 model;
     83   alignas(4) float explosionStartTime;
     84   alignas(4) float explosionDuration;
     85   alignas(4) unsigned int deleted;
     86};
     87
    7588struct UBO_VP_mats {
    7689   alignas(16) mat4 view;
    7790   alignas(16) mat4 proj;
     91};
     92
     93struct UBO_Explosion {
     94   alignas(16) mat4 view;
     95   alignas(16) mat4 proj;
     96   alignas(4) float cur_time;
    7897};
    7998
     
    183202      const float FOV_ANGLE = 67.0f; // means the camera lens goes from -33 deg to 33 def
    184203
     204      const int EXPLOSION_PARTICLE_COUNT = 300;
     205      const vec3 LASER_COLOR = vec3(0.2f, 1.0f, 0.2f);
     206
    185207      vec3 cam_pos;
    186208
     
    287309
    288310      UBO_VP_mats laser_VP_mats;
     311
     312      GraphicsPipeline_Vulkan<ExplosionVertex, SSBO_Explosion> explosionPipeline;
     313      vector<SceneObject<ExplosionVertex, SSBO_Explosion>> explosionObjects;
     314
     315      vector<VkBuffer> uniformBuffers_explosionPipeline;
     316      vector<VkDeviceMemory> uniformBuffersMemory_explosionPipeline;
     317      vector<VkDescriptorBufferInfo> uniformBufferInfoList_explosionPipeline;
     318
     319      UBO_Explosion explosion_UBO;
    289320
    290321      vector<BaseEffectOverTime*> effects;
     
    368399            vec3& start, vec3& end, vec3& intersection);
    369400
     401      void addExplosion(mat4 model_mat, float duration, float cur_time);
     402
    370403      void createBufferSet(VkDeviceSize bufferSize, VkBufferUsageFlags flags,
    371404            vector<VkBuffer>& buffers, vector<VkDeviceMemory>& buffersMemory,
     
    382415            void* pUserData);
    383416};
     417
     418// Start of specialized no-op functions
     419
     420template<>
     421inline void VulkanGame::centerObject(SceneObject<ExplosionVertex, SSBO_Explosion>& object) {
     422}
     423
     424// End of specialized no-op functions
    384425
    385426// TODO: Right now, it's basically necessary to pass the identity matrix in for ssbo.model
     
    409450   SceneObject<VertexType, SSBOType>& obj = objects.back();
    410451
    411    if (!is_same_v<VertexType, LaserVertex>) {
     452   if (!is_same_v<VertexType, LaserVertex> && !is_same_v<VertexType, ExplosionVertex>) {
    412453      centerObject(obj);
    413454   }
Note: See TracChangeset for help on using the changeset viewer.