Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
VkCV Framework
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vulkan2021
VkCV Framework
Commits
619099e9
Commit
619099e9
authored
3 years ago
by
Susanne Dötsch
Browse files
Options
Downloads
Patches
Plain Diff
[
#94
] Added Materials, Spheres and Lights to copmute Shader
parent
0d1c880f
No related branches found
No related tags found
1 merge request
!77
Resolve "SAF-R Module"
Pipeline
#26835
passed
3 years ago
Stage: build
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
projects/saf_r/shaders/raytracing.comp
+21
-2
21 additions, 2 deletions
projects/saf_r/shaders/raytracing.comp
projects/saf_r/src/main.cpp
+24
-10
24 additions, 10 deletions
projects/saf_r/src/main.cpp
with
45 additions
and
12 deletions
projects/saf_r/shaders/raytracing.comp
+
21
−
2
View file @
619099e9
#version 450 core
#extension GL_ARB_separate_shader_objects : enable
layout(std430, binding = 0) coherent buffer safrBuffers{
int inumbers[];
struct Material {
vec3 diffuse_color;
vec3 albedo;
float specular_exponent;
};
layout(std430, binding = 0) coherent buffer Lights{
vec3 position [];
float intensity [];
};
layout(std430, binding = 1) coherent buffer Materials{
vec3 diffuse_color;
vec3 albedo;
float specular_exponent;
};
layout(std430, binding = 2) coherent buffer Spheres{
vec3 center;
float radius;
Material material;
};
void main(){
...
...
This diff is collapsed.
Click to expand it.
projects/saf_r/src/main.cpp
+
24
−
10
View file @
619099e9
...
...
@@ -12,8 +12,6 @@
#include
"safrScene.hpp"
int
main
(
int
argc
,
const
char
**
argv
)
{
const
char
*
applicationName
=
"SAF_R"
;
...
...
@@ -55,7 +53,6 @@ int main(int argc, const char** argv) {
computeShaderProgram
.
addShader
(
shaderStage
,
path
);
});
//Out of range Problem
vkcv
::
DescriptorSetHandle
computeDescriptorSet
=
core
.
createDescriptorSet
(
computeShaderProgram
.
getReflectedDescriptors
()[
0
]);
const
std
::
vector
<
vkcv
::
VertexAttachment
>
computeVertexAttachments
=
computeShaderProgram
.
getVertexAttachments
();
...
...
@@ -82,9 +79,13 @@ int main(int argc, const char** argv) {
vkcv
::
DescriptorSetHandle
descriptorSet
=
core
.
createDescriptorSet
(
descriptorBindings
);
//materials for the spheres
std
::
vector
<
safrScene
::
Material
>
materials
;
safrScene
::
Material
ivory
(
glm
::
vec3
(
0.6
,
0.3
,
0.1
),
glm
::
vec3
(
0.4
,
0.4
,
0.3
),
50.
);
safrScene
::
Material
red_rubber
(
glm
::
vec3
(
0.9
,
0.1
,
0.0
),
glm
::
vec3
(
0.3
,
0.1
,
0.1
),
10.
);
safrScene
::
Material
mirror
(
glm
::
vec3
(
0.0
,
10.0
,
0.8
),
glm
::
vec3
(
1.0
,
1.0
,
1.0
),
1425.
);
materials
.
push_back
(
ivory
);
materials
.
push_back
(
red_rubber
);
materials
.
push_back
(
mirror
);
//spheres for the scene
std
::
vector
<
safrScene
::
Sphere
>
spheres
;
...
...
@@ -114,14 +115,25 @@ int main(int argc, const char** argv) {
vkcv
::
SamplerAddressMode
::
REPEAT
);
vkcv
::
Buffer
<
int
>
safrBuffer
=
core
.
createBuffer
<
int
>
(
//create Buffer for compute shader
vkcv
::
Buffer
<
safrScene
::
Light
>
lightsBuffer
=
core
.
createBuffer
<
safrScene
::
Light
>
(
vkcv
::
BufferType
::
STORAGE
,
lights
.
size
()
);
lightsBuffer
.
fill
(
lights
);
vkcv
::
Buffer
<
safrScene
::
Sphere
>
sphereBuffer
=
core
.
createBuffer
<
safrScene
::
Sphere
>
(
vkcv
::
BufferType
::
STORAGE
,
spheres
.
size
()
);
sphereBuffer
.
fill
(
spheres
);
vkcv
::
Buffer
<
safrScene
::
Material
>
materialBuffer
=
core
.
createBuffer
<
safrScene
::
Material
>
(
vkcv
::
BufferType
::
STORAGE
,
2
materials
.
size
()
);
materialBuffer
.
fill
(
materials
);
std
::
vector
<
int
>
vec
=
{
42
,
1337
};
safrBuffer
.
fill
(
vec
);
//particleBuffer.fill(particleSystem.getParticles());
vkcv
::
DescriptorWrites
setWrites
;
setWrites
.
sampledImageWrites
=
{
vkcv
::
SampledImageDescriptorWrite
(
0
,
texture
.
getHandle
())
};
...
...
@@ -129,7 +141,9 @@ int main(int argc, const char** argv) {
core
.
writeDescriptorSet
(
descriptorSet
,
setWrites
);
vkcv
::
DescriptorWrites
computeWrites
;
computeWrites
.
storageBufferWrites
=
{
vkcv
::
BufferDescriptorWrite
(
0
,
safrBuffer
.
getHandle
())
};
computeWrites
.
storageBufferWrites
=
{
vkcv
::
BufferDescriptorWrite
(
0
,
lightsBuffer
.
getHandle
())
};
computeWrites
.
storageBufferWrites
=
{
vkcv
::
BufferDescriptorWrite
(
1
,
materialBuffer
.
getHandle
())
};
computeWrites
.
storageBufferWrites
=
{
vkcv
::
BufferDescriptorWrite
(
2
,
sphereBuffer
.
getHandle
())
};
core
.
writeDescriptorSet
(
computeDescriptorSet
,
computeWrites
);
const
auto
&
context
=
core
.
getContext
();
...
...
@@ -222,7 +236,7 @@ int main(int argc, const char** argv) {
{
vkcv
::
DescriptorSetUsage
(
0
,
core
.
getDescriptorSet
(
computeDescriptorSet
).
vulkanHandle
)
},
pushConstantsCompute
);
core
.
recordBufferMemoryBarrier
(
cmdStream
,
safr
Buffer
.
getHandle
());
core
.
recordBufferMemoryBarrier
(
cmdStream
,
lights
Buffer
.
getHandle
());
core
.
recordDrawcallsToCmdStream
(
cmdStream
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment