Skip to content
Snippets Groups Projects
Verified Commit 95d4cca0 authored by Tobias Frisch's avatar Tobias Frisch
Browse files

Added first rendering of particles as red blobs

parent 62298d4b
No related branches found
No related tags found
1 merge request!103Added project wobble_bobble and refactored some parts of the framework
#version 450
layout(location = 0) in vec2 passPos;
layout(location = 0) out vec4 outColor;
void main() {
const float value = length(passPos);
if (value < 0.5f) {
outColor = vec4(1.0f - value, 0.0f, 0.0f, 1.0f);
} else {
discard;
}
}
\ No newline at end of file
#version 450
layout(triangles) in;
layout (triangle_strip, max_vertices = 3) out;
void main() {
}
\ No newline at end of file
#version 450
#extension GL_GOOGLE_include_directive : enable
#include "particle.inc"
layout(set=0, binding=0, std430) buffer particleBuffer {
Particle particles [];
};
layout(location = 0) in vec2 vertexPos;
layout(location = 0) out vec2 passPos;
void main() {
vec3 position = particles[gl_InstanceIndex].minimal.position;
float size = particles[gl_InstanceIndex].minimal.size;
passPos = vertexPos;
gl_Position = vec4(position + vec3(vertexPos * size, 0), 1);
}
\ No newline at end of file
......@@ -226,14 +226,6 @@ int main(int argc, const char **argv) {
}
);
compiler.compile(
vkcv::ShaderStage::GEOMETRY,
"shaders/particle.geom",
[&gfxProgram](vkcv::ShaderStage stage, const std::filesystem::path& path) {
gfxProgram.addShader(stage, path);
}
);
compiler.compile(
vkcv::ShaderStage::FRAGMENT,
"shaders/particle.frag",
......@@ -257,8 +249,9 @@ int main(int argc, const char **argv) {
vkcv::PassHandle gfxPass = core.createPass(passConfig);
std::vector<vkcv::VertexBinding> vertexBindings;
vkcv::VertexLayout vertexLayout (vertexBindings);
vkcv::VertexLayout vertexLayout ({
vkcv::VertexBinding(0, gfxProgram.getVertexAttachments())
});
vkcv::GraphicsPipelineConfig gfxPipelineConfig;
gfxPipelineConfig.m_ShaderProgram = gfxProgram;
......@@ -266,14 +259,39 @@ int main(int argc, const char **argv) {
gfxPipelineConfig.m_Height = windowHeight;
gfxPipelineConfig.m_PassHandle = gfxPass;
gfxPipelineConfig.m_VertexLayout = vertexLayout;
gfxPipelineConfig.m_DescriptorLayouts = {};
gfxPipelineConfig.m_DescriptorLayouts = { core.getDescriptorSetLayout(transformParticlesToGridLayouts[0]).vulkanHandle };
gfxPipelineConfig.m_UseDynamicViewport = true;
gfxPipelineConfig.m_blendMode = vkcv::BlendMode::Additive;
vkcv::GraphicsPipelineHandle gfxPipeline = core.createGraphicsPipeline(gfxPipelineConfig);
vkcv::Buffer<glm::vec2> trianglePositions = core.createBuffer<glm::vec2>(vkcv::BufferType::VERTEX, 3);
trianglePositions.fill({
glm::vec2(-1.0f, -1.0f),
glm::vec2(+0.0f, +1.0f),
glm::vec2(+1.0f, -1.0f),
});
vkcv::Buffer<uint16_t> triangleIndices = core.createBuffer<uint16_t>(vkcv::BufferType::INDEX, 3);
triangleIndices.fill({
0, 1, 2
});
vkcv::Mesh triangleMesh (
{ vkcv::VertexBufferBinding(0, trianglePositions.getVulkanHandle()) },
triangleIndices.getVulkanHandle(),
triangleIndices.getCount()
);
vkcv::PushConstants pushConstants (0);
std::vector<vkcv::DrawcallInfo> drawcalls;
drawcalls.push_back(vkcv::DrawcallInfo(
triangleMesh,
{ vkcv::DescriptorSetUsage(0, core.getDescriptorSet(transformParticlesToGridSets[0]).vulkanHandle) },
particles.getCount()
));
bool initializedParticleVolumes = false;
auto start = std::chrono::system_clock::now();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment