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

Cleanup saf_r project

parent 866262dd
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@
.editorconfig
# build directories
bin/
build/
cmake-build-debug/
cmake-build-release/
......
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(location = 0) in vec3 fragColor;
layout(location = 1) in vec2 texCoord;
layout(location = 0) out vec3 outColor;
layout(set=0, binding=1) uniform sampler textureSampler;
void main() {
outColor = fragColor;
}
\ No newline at end of file
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(location = 0) out vec3 fragColor;
layout(location = 1) out vec2 texCoord;
layout( push_constant ) uniform constants{
mat4 mvp;
mat4 proj;
};
void main() {
vec3 positions[3] = {
vec3(-1, -1, -1),
vec3( 3, -1, -1),
vec3(-1, 3, -1)
};
vec3 colors[3] = {
vec3(1, 0, 0),
vec3(0, 1, 0),
vec3(0, 0, 1)
};
vec4 position = mvp * vec4(positions[gl_VertexIndex], 1.0);
gl_Position = position;
texCoord.x = ((proj * vec4(positions[gl_VertexIndex], 1.0)).x + 1.0) * 0.5;
texCoord.y = ((proj * vec4(positions[gl_VertexIndex], 1.0)).y + 1.0) * 0.5;
fragColor = colors[gl_VertexIndex];
}
\ No newline at end of file
......@@ -48,28 +48,13 @@ int main(int argc, const char** argv) {
std::string shaderPathCompute = "shaders/raytracing.comp";
//creating the shader programs
vkcv::ShaderProgram safrShaderProgram;
vkcv::shader::GLSLCompiler compiler;
vkcv::ShaderProgram computeShaderProgram{};
compiler.compile(vkcv::ShaderStage::VERTEX, std::filesystem::path("shaders/shader.vert"),
[&safrShaderProgram](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) {
safrShaderProgram.addShader(shaderStage, path);
});
compiler.compile(vkcv::ShaderStage::FRAGMENT, std::filesystem::path("shaders/shader.frag"),
[&safrShaderProgram](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) {
safrShaderProgram.addShader(shaderStage, path);
});
vkcv::ShaderProgram computeShaderProgram;
compiler.compile(vkcv::ShaderStage::COMPUTE, shaderPathCompute, [&](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) {
computeShaderProgram.addShader(shaderStage, path);
});
//create DescriptorSets (...) for every Shader
const vkcv::DescriptorBindings& descriptorBindings = safrShaderProgram.getReflectedDescriptors().at(0);
vkcv::DescriptorSetLayoutHandle descriptorSetLayout = core.createDescriptorSetLayout(descriptorBindings);
vkcv::DescriptorSetHandle descriptorSet = core.createDescriptorSet(descriptorSetLayout);
vkcv::ImageHandle swapchainInput = vkcv::ImageHandle::createSwapchainImageHandle();
const vkcv::DescriptorBindings& computeDescriptorBindings = computeShaderProgram.getReflectedDescriptors().at(0);
......@@ -103,7 +88,7 @@ int main(int argc, const char** argv) {
//spheres for the scene
std::vector<safrScene::Sphere> spheres;
spheres.push_back(safrScene::Sphere(glm::vec3(-3, 0, -16), 2, ivory));
// spheres.push_back(safrScene::Sphere(glm::vec3(-1.0, -1.5, 12), 2, mirror));
//spheres.push_back(safrScene::Sphere(glm::vec3(-1.0, -1.5, 12), 2, mirror));
spheres.push_back(safrScene::Sphere(glm::vec3(-1.0, -1.5, -12), 2, glass));
spheres.push_back(safrScene::Sphere(glm::vec3( 1.5, -0.5, -18), 3, red_rubber));
spheres.push_back(safrScene::Sphere(glm::vec3( 7, 5, -18), 4, mirror));
......@@ -158,16 +143,6 @@ int main(int argc, const char** argv) {
return EXIT_FAILURE;
}
//create the render pipeline + compute pipeline
vkcv::GraphicsPipelineHandle safrPipeline = core.createGraphicsPipeline(
vkcv::GraphicsPipelineConfig(
safrShaderProgram,
safrPass,
{},
{ descriptorSetLayout }
)
);
vkcv::ComputePipelineHandle computePipeline = core.createComputePipeline(
vkcv::ComputePipelineConfig(
computeShaderProgram,
......@@ -175,18 +150,10 @@ int main(int argc, const char** argv) {
)
);
if (!safrPipeline || !computePipeline)
{
if (!computePipeline) {
std::cout << "Error. Could not create graphics pipeline. Exiting." << std::endl;
return EXIT_FAILURE;
}
vkcv::VertexData vertexData;
vertexData.setIndexBuffer(safrIndexBuffer.getHandle());
vertexData.setCount(3);
vkcv::InstanceDrawcall drawcall (vertexData);
drawcall.useDescriptorSet(0, descriptorSet);
//create the camera
vkcv::camera::CameraManager cameraManager(window);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment