Skip to content

Commit

Permalink
vk: read alpha for material base_color, fixes #308
Browse files Browse the repository at this point in the history
  • Loading branch information
w23 committed Apr 12, 2023
1 parent 4f4c5d3 commit 23cbbab
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
11 changes: 3 additions & 8 deletions ref/vk/vk_materials.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static const xvk_material_t k_default_material = {

.metalness = 0.f,
.roughness = 1.f,
.base_color = { 1.f, 1.f, 1.f },
.base_color = { 1.f, 1.f, 1.f, 1.f },

.set = false,
};
Expand Down Expand Up @@ -58,12 +58,7 @@ static void loadMaterialsFromFile( const char *filename, int depth ) {
const char *path_end = Q_strrchr(filename, '/');
byte *data = gEngine.fsapi->LoadFile( filename, 0, false );
char *pos = (char*)data;
xvk_material_t current_material = {
.base_color = -1,
.metalness = tglob.blackTexture,
.roughness = tglob.whiteTexture,
.tex_normalmap = 0,
};
xvk_material_t current_material = k_default_material;
int current_material_index = -1;
qboolean force_reload = false;
qboolean create = false;
Expand Down Expand Up @@ -150,7 +145,7 @@ static void loadMaterialsFromFile( const char *filename, int depth ) {
} else if (Q_stricmp(key, "metalness") == 0) {
sscanf(value, "%f", &current_material.metalness);
} else if (Q_stricmp(key, "base_color") == 0) {
sscanf(value, "%f %f %f", &current_material.base_color[0], &current_material.base_color[1], &current_material.base_color[2]);
sscanf(value, "%f %f %f %f", &current_material.base_color[0], &current_material.base_color[1], &current_material.base_color[2], &current_material.base_color[3]);
} else {
gEngine.Con_Printf(S_ERROR "Unknown material key %s\n", key);
continue;
Expand Down
2 changes: 1 addition & 1 deletion ref/vk/vk_materials.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ typedef struct {
int tex_metalness;
int tex_normalmap;

vec3_t base_color;
vec4_t base_color;
float roughness;
float metalness;

Expand Down
2 changes: 1 addition & 1 deletion ref/vk/vk_ray_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ static void applyMaterialToKusok(vk_kusok_data_t* kusok, const vk_render_geometr
gcolor[0] = color[0] * mat->base_color[0];
gcolor[1] = color[1] * mat->base_color[1];
gcolor[2] = color[2] * mat->base_color[2];
gcolor[3] = color[3];
gcolor[3] = color[3] * mat->base_color[3];
Vector4Copy(gcolor, kusok->color);
}

Expand Down

0 comments on commit 23cbbab

Please sign in to comment.