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
8027e6a4
Commit
8027e6a4
authored
3 years ago
by
Alexander Gauggel
Browse files
Options
Downloads
Patches
Plain Diff
[
#82
] Load normal and specular textures
parent
848c1d2a
No related branches found
No related tags found
1 merge request
!70
Resolve "Voxel cone tracing"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
projects/voxelization/resources/shaders/perMeshResources.inc
+3
-1
3 additions, 1 deletion
projects/voxelization/resources/shaders/perMeshResources.inc
projects/voxelization/src/main.cpp
+39
-8
39 additions, 8 deletions
projects/voxelization/src/main.cpp
with
42 additions
and
9 deletions
projects/voxelization/resources/shaders/perMeshResources.inc
+
3
−
1
View file @
8027e6a4
layout
(
set
=
1
,
binding
=
0
)
uniform
texture2D
albedoTexture
;
layout
(
set
=
1
,
binding
=
1
)
uniform
sampler
textureSampler
;
\ No newline at end of file
layout
(
set
=
1
,
binding
=
1
)
uniform
sampler
textureSampler
;
layout
(
set
=
1
,
binding
=
2
)
uniform
texture2D
normalTexture
;
layout
(
set
=
1
,
binding
=
3
)
uniform
texture2D
specularTexture
;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
projects/voxelization/src/main.cpp
+
39
−
8
View file @
8027e6a4
...
...
@@ -186,24 +186,55 @@ int main(int argc, const char** argv) {
std
::
vector
<
vkcv
::
Image
>
sceneImages
;
for
(
const
auto
&
material
:
scene
.
materials
)
{
int
baseColorIndex
=
material
.
baseColor
;
if
(
baseColorIndex
<
0
)
{
vkcv_log
(
vkcv
::
LogLevel
::
WARNING
,
"Material lacks base color"
);
baseColorIndex
=
0
;
int
albedoIndex
=
material
.
baseColor
;
int
normalIndex
=
material
.
normal
;
int
specularIndex
=
material
.
metalRough
;
if
(
albedoIndex
<
0
)
{
vkcv_log
(
vkcv
::
LogLevel
::
WARNING
,
"Material lacks albedo"
);
albedoIndex
=
0
;
}
if
(
normalIndex
<
0
)
{
vkcv_log
(
vkcv
::
LogLevel
::
WARNING
,
"Material lacks normal"
);
normalIndex
=
0
;
}
if
(
specularIndex
<
0
)
{
vkcv_log
(
vkcv
::
LogLevel
::
WARNING
,
"Material lacks specular"
);
specularIndex
=
0
;
}
materialDescriptorSets
.
push_back
(
core
.
createDescriptorSet
(
forwardProgram
.
getReflectedDescriptors
()[
1
]));
vkcv
::
asset
::
Texture
&
sceneTexture
=
scene
.
textures
[
baseColorIndex
];
vkcv
::
asset
::
Texture
&
albedoTexture
=
scene
.
textures
[
albedoIndex
];
vkcv
::
asset
::
Texture
&
normalTexture
=
scene
.
textures
[
normalIndex
];
vkcv
::
asset
::
Texture
&
specularTexture
=
scene
.
textures
[
specularIndex
];
// albedo texture
sceneImages
.
push_back
(
core
.
createImage
(
vk
::
Format
::
eR8G8B8A8Srgb
,
albedoTexture
.
w
,
albedoTexture
.
h
,
1
,
true
));
sceneImages
.
back
().
fill
(
albedoTexture
.
data
.
data
());
sceneImages
.
back
().
generateMipChainImmediate
();
sceneImages
.
back
().
switchLayout
(
vk
::
ImageLayout
::
eShaderReadOnlyOptimal
);
const
vkcv
::
ImageHandle
albedoHandle
=
sceneImages
.
back
().
getHandle
();
// normal texture
sceneImages
.
push_back
(
core
.
createImage
(
vk
::
Format
::
eR8G8B8A8Srgb
,
normalTexture
.
w
,
normalTexture
.
h
,
1
,
true
));
sceneImages
.
back
().
fill
(
normalTexture
.
data
.
data
());
sceneImages
.
back
().
generateMipChainImmediate
();
sceneImages
.
back
().
switchLayout
(
vk
::
ImageLayout
::
eShaderReadOnlyOptimal
);
const
vkcv
::
ImageHandle
normalHandle
=
sceneImages
.
back
().
getHandle
();
sceneImages
.
push_back
(
core
.
createImage
(
vk
::
Format
::
eR8G8B8A8Srgb
,
sceneTexture
.
w
,
sceneTexture
.
h
,
1
,
true
));
sceneImages
.
back
().
fill
(
sceneTexture
.
data
.
data
());
// specular texture
sceneImages
.
push_back
(
core
.
createImage
(
vk
::
Format
::
eR8G8B8A8Srgb
,
specularTexture
.
w
,
specularTexture
.
h
,
1
,
true
));
sceneImages
.
back
().
fill
(
specularTexture
.
data
.
data
());
sceneImages
.
back
().
generateMipChainImmediate
();
sceneImages
.
back
().
switchLayout
(
vk
::
ImageLayout
::
eShaderReadOnlyOptimal
);
const
vkcv
::
ImageHandle
specularHandle
=
sceneImages
.
back
().
getHandle
();
vkcv
::
DescriptorWrites
setWrites
;
setWrites
.
sampledImageWrites
=
{
vkcv
::
SampledImageDescriptorWrite
(
0
,
sceneImages
.
back
().
getHandle
())
vkcv
::
SampledImageDescriptorWrite
(
0
,
albedoHandle
),
vkcv
::
SampledImageDescriptorWrite
(
2
,
normalHandle
),
vkcv
::
SampledImageDescriptorWrite
(
3
,
specularHandle
)
};
setWrites
.
samplerWrites
=
{
vkcv
::
SamplerDescriptorWrite
(
1
,
colorSampler
),
...
...
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