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
a18ad02b
Commit
a18ad02b
authored
3 years ago
by
Trevor Hollmann
Browse files
Options
Downloads
Patches
Plain Diff
[
#79
] Make hasTexture() a method of Material.
parent
da3d6a4d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!69
Resolve "Rework Asset Loader API"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/asset_loader/include/vkcv/asset/asset_loader.hpp
+24
-25
24 additions, 25 deletions
modules/asset_loader/include/vkcv/asset/asset_loader.hpp
modules/asset_loader/src/vkcv/asset/asset_loader.cpp
+2
-3
2 additions, 3 deletions
modules/asset_loader/src/vkcv/asset/asset_loader.cpp
with
26 additions
and
28 deletions
modules/asset_loader/include/vkcv/asset/asset_loader.hpp
+
24
−
25
View file @
a18ad02b
...
...
@@ -84,22 +84,6 @@ typedef struct {
std
::
vector
<
uint8_t
>
data
;
// binary data of the decoded texture
}
Texture
;
/**
* The asset loader module only supports the PBR-MetallicRoughness model for
* materials.
*/
typedef
struct
{
uint16_t
textureMask
;
// bit mask with active texture targets
// Indices into the Scene.textures vector
int
baseColor
,
metalRough
,
normal
,
occlusion
,
emissive
;
// Scaling factors for each texture target
struct
{
float
r
,
g
,
b
,
a
;
}
baseColorFactor
;
float
metallicFactor
,
roughnessFactor
;
float
normalScale
;
float
occlusionStrength
;
struct
{
float
r
,
g
,
b
;
}
emissiveFactor
;
}
Material
;
/**
* Flags for the bit-mask in the Material struct. To check if a material has a
* certain texture target, you can use the hasTexture() function below, passing
...
...
@@ -122,16 +106,31 @@ enum class PBRTextureTarget {
#define bitflag(ENUM) (0x1u << ((unsigned)(ENUM)))
/**
* To signal that a certain texture target is active in a Material struct, its
* bit is set in the textureMask. You can use this function to check that:
* Material mat = ...;
* if (materialHasTexture(&mat, baseColor)) {...}
* @param m The material to query
* @param t The target to query for
* @return Boolean to signal whether the texture target is active in the
* material.
* The asset loader module only supports the PBR-MetallicRoughness model for
* materials.
*/
bool
materialHasTexture
(
const
Material
*
const
m
,
const
PBRTextureTarget
t
);
typedef
struct
{
uint16_t
textureMask
;
// bit mask with active texture targets
// Indices into the Scene.textures vector
int
baseColor
,
metalRough
,
normal
,
occlusion
,
emissive
;
// Scaling factors for each texture target
struct
{
float
r
,
g
,
b
,
a
;
}
baseColorFactor
;
float
metallicFactor
,
roughnessFactor
;
float
normalScale
;
float
occlusionStrength
;
struct
{
float
r
,
g
,
b
;
}
emissiveFactor
;
/**
* To signal that a certain texture target is active in this Material
* struct, its bit is set in the textureMask. You can use this function
* to check that:
* if (myMaterial.hasTexture(baseColor)) {...}
* @param t The target to query for
* @return Boolean to signal whether the texture target is active in
* the material.
*/
bool
hasTexture
(
const
PBRTextureTarget
t
)
const
;
}
Material
;
/* With these enums, 0 is reserved to signal uninitialized or invalid data. */
enum
class
PrimitiveType
:
uint32_t
{
...
...
This diff is collapsed.
Click to expand it.
modules/asset_loader/src/vkcv/asset/asset_loader.cpp
+
2
−
3
View file @
a18ad02b
...
...
@@ -246,10 +246,9 @@ std::array<float, 16> computeModelMatrix(std::array<float, 3> translation, std::
}
/* TODO Should probably be a member function of vkcv::asset::Material */
bool
materialHasTexture
(
const
Material
*
const
m
,
const
PBRTextureTarget
t
)
bool
Material
::
hasTexture
(
const
PBRTextureTarget
t
)
const
{
return
m
->
textureMask
&
bitflag
(
t
);
return
textureMask
&
bitflag
(
t
);
}
/**
...
...
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