diff --git a/projects/particle_simulation/shaders/frag.spv b/projects/particle_simulation/shaders/frag.spv index df52203662c6efe30f9b311f06075e73074edb6a..d926fa4b4ad738f5aaca2f00fbb92a91d024fd12 100644 Binary files a/projects/particle_simulation/shaders/frag.spv and b/projects/particle_simulation/shaders/frag.spv differ diff --git a/projects/particle_simulation/shaders/shader.frag b/projects/particle_simulation/shaders/shader.frag index d9fd4602b338b247d7c8d2cd5eff73acc63abce8..215fa7887491199d67ee4e25746d5a8f0559626d 100644 --- a/projects/particle_simulation/shaders/shader.frag +++ b/projects/particle_simulation/shaders/shader.frag @@ -3,9 +3,16 @@ layout(location = 0) out vec4 outColor; -layout(set=0, binding=0) uniform vec4 uColor; +layout(set=0, binding=0) uniform uColor { + vec4 color; +} Color; + +layout(set=0,binding=1) uniform uPosition{ + vec3 position; +} Position; void main() { - outColor = uColor; +// outColor = Color.color; + outColor = vec4(1.0f, 0.0f,0.f,1.f); } \ No newline at end of file diff --git a/projects/particle_simulation/shaders/shader.vert b/projects/particle_simulation/shaders/shader.vert index 3985a850cb4832973d27f61aecbdb91b8d4fa99b..6c78c446355f87d007e24daa3bc11ca6fea068fa 100644 --- a/projects/particle_simulation/shaders/shader.vert +++ b/projects/particle_simulation/shaders/shader.vert @@ -1,13 +1,17 @@ #version 450 core #extension GL_ARB_separate_shader_objects : enable -layout (location = 0) in vec3 position; - layout( push_constant ) uniform constants{ mat4 mvp; }; +vec3 positions[3] = { +vec3(-0.5, 0.5, -1), +vec3( 0.5, 0.5, -1), +vec3(0, -0.5, -1) +}; + void main() { - gl_Position = mvp * vec4(position, 1.0); + gl_Position = mvp * vec4(positions[gl_VertexIndex], 1.0); } \ No newline at end of file diff --git a/projects/particle_simulation/shaders/vert.spv b/projects/particle_simulation/shaders/vert.spv index 1d8d780bcb1a3dff229389902f9d624e83500380..9e89006811ae50bbd74619623632a0d5e4423ddb 100644 Binary files a/projects/particle_simulation/shaders/vert.spv and b/projects/particle_simulation/shaders/vert.spv differ diff --git a/projects/particle_simulation/src/main.cpp b/projects/particle_simulation/src/main.cpp index 4b798ed0402382bbc49f8b51075604c7be6822b2..c1c0b59e9368e72980884f1bcbda6527e81d5b80 100644 --- a/projects/particle_simulation/src/main.cpp +++ b/projects/particle_simulation/src/main.cpp @@ -49,9 +49,9 @@ int main(int argc, const char** argv) { testBuffer.fill(vec_data); - auto triangleIndexBuffer = core.createBuffer<uint16_t>(vkcv::BufferType::INDEX, n, vkcv::BufferMemoryType::DEVICE_LOCAL); + auto particleIndexBuffer = core.createBuffer<uint16_t>(vkcv::BufferType::INDEX, n, vkcv::BufferMemoryType::DEVICE_LOCAL); uint16_t indices[3] = { 0, 1, 2 }; - triangleIndexBuffer.fill(&indices[0], sizeof(indices)); + particleIndexBuffer.fill(&indices[0], sizeof(indices)); std::cout << "Physical device: " << physicalDevice.getProperties().deviceName << std::endl; @@ -78,6 +78,7 @@ int main(int argc, const char** argv) { particleShaderProgram.reflectShader(vkcv::ShaderStage::FRAGMENT); std::vector<vkcv::DescriptorBinding> descriptorBindings = { + vkcv::DescriptorBinding(vkcv::DescriptorType::UNIFORM_BUFFER, 1, vkcv::ShaderStage::FRAGMENT), vkcv::DescriptorBinding(vkcv::DescriptorType::UNIFORM_BUFFER, 1, vkcv::ShaderStage::FRAGMENT)}; vkcv::DescriptorSetHandle descriptorSet = core.createDescriptorSet(descriptorBindings); @@ -91,13 +92,19 @@ int main(int argc, const char** argv) { true); vkcv::PipelineHandle particlePipeline = core.createGraphicsPipeline(particlePipelineDefinition); - vkcv::Buffer<glm_vec4> color = core.createBuffer<glm_vec4>( + vkcv::Buffer<glm::vec4> color = core.createBuffer<glm::vec4>( vkcv::BufferType::UNIFORM, 1 ); + vkcv::Buffer<glm::vec4> position = core.createBuffer<glm::vec4>( + vkcv::BufferType::UNIFORM, + 1 + ); + vkcv::DescriptorWrites setWrites; - setWrites.uniformBufferWrites = {vkcv::UniformBufferDescriptorWrite(0,color.getHandle())}; + setWrites.uniformBufferWrites = {vkcv::UniformBufferDescriptorWrite(0,color.getHandle()), + vkcv::UniformBufferDescriptorWrite(1,position.getHandle())}; core.writeResourceDescription(descriptorSet,0,setWrites); if (!particlePipeline) @@ -108,8 +115,8 @@ int main(int argc, const char** argv) { const vkcv::ImageHandle swapchainInput = vkcv::ImageHandle::createSwapchainImageHandle(); - const vkcv::Mesh renderMesh({}, triangleIndexBuffer.getVulkanHandle(), 3); - vkcv::DrawcallInfo drawcalls(renderMesh, {}); + const vkcv::Mesh renderMesh({}, particleIndexBuffer.getVulkanHandle(), 3); + vkcv::DrawcallInfo drawcalls(renderMesh, {vkcv::DescriptorSetUsage(0, core.getDescriptorSet(descriptorSet).vulkanHandle)}); auto start = std::chrono::system_clock::now();