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
0f9acb80
Commit
0f9acb80
authored
3 years ago
by
Katharina Krämer
Browse files
Options
Downloads
Patches
Plain Diff
[
#94
] worked on raycast computation in comp shader
status: only backgound colour
parent
e096a06c
No related branches found
No related tags found
1 merge request
!77
Resolve "SAF-R Module"
Pipeline
#27090
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
+13
-9
13 additions, 9 deletions
projects/saf_r/shaders/raytracing.comp
projects/saf_r/src/main.cpp
+13
-10
13 additions, 10 deletions
projects/saf_r/src/main.cpp
with
26 additions
and
19 deletions
projects/saf_r/shaders/raytracing.comp
+
13
−
9
View file @
0f9acb80
#version 450 core
#version 450 core
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_separate_shader_objects : enable
#define M_PI 3.1415926535897932384626433832795
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
struct Material {
struct Material {
...
@@ -135,19 +137,21 @@ vec3 castRay(const vec3 orig, const vec3 dir, int max_depth) {
...
@@ -135,19 +137,21 @@ vec3 castRay(const vec3 orig, const vec3 dir, int max_depth) {
vec3 computeDirection(ivec2 coord){
vec3 computeDirection(ivec2 coord){
ivec2 outImageRes = imageSize(outImage);
float fov = M_PI / 2.f;
//float x = (2 * (i + 0.5f) / (float)width - 1) * tan(fov / 2.f) * width / (float)height;
//float x = (2 * (i + 0.5f) / (float)width - 1) * tan(fov / 2.f) * width / (float)height;
float x = (2 * (float(coord.x) + 0.5f) / float(outImageRes.x) - 1) * tan(fov / 2.f) * outImageRes.x / float(outImageRes.y);
//float y = -(2 * (j + 0.5f) / (float)height - 1) * tan(fov / 2.f);
//float y = -(2 * (j + 0.5f) / (float)height - 1) * tan(fov / 2.f);
//glm::vec3 dir = glm::normalize(glm::vec3(x, y,
-1));
float y = -(2 * (float(coord.y) + 0.5f) / float(outImageRes.y)
-
1)
* tan(fov / 2.f
);
vec3 dir = normalize(vec3(x, y, -1));
return
vec3(1,1,1)
;
return
dir
;
}
}
void main(){
void main(){
//ivec2 coord = ivec2(gl_GlobalInvocationID.xy);
ivec2 coord = ivec2(gl_GlobalInvocationID.xy);
// int max_depth = 4;
int max_depth = 4;
//vec3 direction = computeDirection(coord);
vec3 direction = computeDirection(coord);
//vec3 color = castRay(vec3(0,0,0), direction, max_depth);
vec3 color = castRay(vec3(0,0,0), direction, max_depth);
// vec3 color = vec3(1,0,0);
imageStore(outImage, coord, vec4(color, 0.f));
//imageStore(outImage, coord, vec4(color, 0));
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
projects/saf_r/src/main.cpp
+
13
−
10
View file @
0f9acb80
...
@@ -144,13 +144,9 @@ int main(int argc, const char** argv) {
...
@@ -144,13 +144,9 @@ int main(int argc, const char** argv) {
core
.
writeDescriptorSet
(
descriptorSet
,
setWrites
);
core
.
writeDescriptorSet
(
descriptorSet
,
setWrites
);
vkcv
::
DescriptorWrites
computeWrites
;
vkcv
::
DescriptorWrites
computeWrites
;
computeWrites
.
storageBufferWrites
=
{
vkcv
::
BufferDescriptorWrite
(
0
,
lightsBuffer
.
getHandle
())
};
computeWrites
.
storageBufferWrites
=
{
vkcv
::
BufferDescriptorWrite
(
0
,
lightsBuffer
.
getHandle
()),
core
.
writeDescriptorSet
(
computeDescriptorSet
,
computeWrites
);
vkcv
::
BufferDescriptorWrite
(
1
,
materialBuffer
.
getHandle
()),
computeWrites
.
storageBufferWrites
=
{
vkcv
::
BufferDescriptorWrite
(
1
,
materialBuffer
.
getHandle
())
};
vkcv
::
BufferDescriptorWrite
(
2
,
sphereBuffer
.
getHandle
())};
core
.
writeDescriptorSet
(
computeDescriptorSet
,
computeWrites
);
computeWrites
.
storageBufferWrites
=
{
vkcv
::
BufferDescriptorWrite
(
2
,
sphereBuffer
.
getHandle
())
};
core
.
writeDescriptorSet
(
computeDescriptorSet
,
computeWrites
);
computeWrites
.
storageImageWrites
=
{
vkcv
::
StorageImageDescriptorWrite
(
3
,
swapchainInput
)};
core
.
writeDescriptorSet
(
computeDescriptorSet
,
computeWrites
);
core
.
writeDescriptorSet
(
computeDescriptorSet
,
computeWrites
);
const
auto
&
context
=
core
.
getContext
();
const
auto
&
context
=
core
.
getContext
();
...
@@ -238,7 +234,14 @@ int main(int argc, const char** argv) {
...
@@ -238,7 +234,14 @@ int main(int argc, const char** argv) {
vkcv
::
PushConstants
pushConstantsCompute
(
0
);
vkcv
::
PushConstants
pushConstantsCompute
(
0
);
//pushConstantsCompute.appendDrawcall(pushData);
//pushConstantsCompute.appendDrawcall(pushData);
uint32_t
computeDispatchCount
[
3
]
=
{
static_cast
<
uint32_t
>
(
std
::
ceil
(
windowWidth
/
16.
f
)),
static_cast
<
uint32_t
>
(
std
::
ceil
(
windowHeight
/
16.
f
)),
1
};
// Anzahl workgroups
computeWrites
.
storageImageWrites
=
{
vkcv
::
StorageImageDescriptorWrite
(
3
,
swapchainInput
)};
core
.
writeDescriptorSet
(
computeDescriptorSet
,
computeWrites
);
core
.
prepareImageForStorage
(
cmdStream
,
swapchainInput
);
uint32_t
computeDispatchCount
[
3
]
=
{
static_cast
<
uint32_t
>
(
std
::
ceil
(
windowWidth
/
16.
f
)),
static_cast
<
uint32_t
>
(
std
::
ceil
(
windowHeight
/
16.
f
)),
1
};
// Anzahl workgroups
core
.
recordComputeDispatchToCmdStream
(
cmdStream
,
core
.
recordComputeDispatchToCmdStream
(
cmdStream
,
computePipeline
,
computePipeline
,
computeDispatchCount
,
computeDispatchCount
,
...
@@ -247,13 +250,13 @@ int main(int argc, const char** argv) {
...
@@ -247,13 +250,13 @@ int main(int argc, const char** argv) {
core
.
recordBufferMemoryBarrier
(
cmdStream
,
lightsBuffer
.
getHandle
());
core
.
recordBufferMemoryBarrier
(
cmdStream
,
lightsBuffer
.
getHandle
());
core
.
recordDrawcallsToCmdStream
(
/*
core.recordDrawcallsToCmdStream(
cmdStream,
cmdStream,
safrPass,
safrPass,
safrPipeline,
safrPipeline,
pushConstants,
pushConstants,
{ drawcall },
{ drawcall },
{
swapchainInput
});
{ swapchainInput });
*/
core
.
prepareSwapchainImageForPresent
(
cmdStream
);
core
.
prepareSwapchainImageForPresent
(
cmdStream
);
core
.
submitCommandStream
(
cmdStream
);
core
.
submitCommandStream
(
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