vk: add normal_scale to materials
This commit is contained in:
parent
9116b0268e
commit
1fd9e49f63
|
@ -86,10 +86,9 @@ struct Kusok {
|
|||
|
||||
float roughness;
|
||||
float metalness;
|
||||
float normal_scale;
|
||||
uint flags;
|
||||
|
||||
PAD(1)
|
||||
|
||||
mat4 prev_transform;
|
||||
};
|
||||
|
||||
|
|
|
@ -44,7 +44,9 @@ void primaryRayHit(rayQueryEXT rq, inout RayPayloadPrimary payload) {
|
|||
T = normalize(T - dot(T, geom.normal_shading) * geom.normal_shading);
|
||||
const vec3 B = normalize(cross(geom.normal_shading, T));
|
||||
const mat3 TBN = mat3(T, B, geom.normal_shading);
|
||||
const vec3 tnorm = sampleTexture(tex_normal, geom.uv, geom.uv_lods).xyz * 2. - 1.; // TODO is this sampling correct for normal data?
|
||||
vec3 tnorm = sampleTexture(tex_normal, geom.uv, geom.uv_lods).xyz * 2. - 1.; // TODO is this sampling correct for normal data?
|
||||
tnorm.xy *= kusok.normal_scale;
|
||||
tnorm.z = sqrt(max(0., 1. - dot(tnorm.xy, tnorm.xy)));
|
||||
geom.normal_shading = normalize(TBN * tnorm);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -16,6 +16,7 @@ static xvk_material_t k_default_material = {
|
|||
|
||||
.metalness = 0.f,
|
||||
.roughness = 1.f,
|
||||
.normal_scale = 1.f,
|
||||
.base_color = { 1.f, 1.f, 1.f, 1.f },
|
||||
|
||||
.set = false,
|
||||
|
@ -157,6 +158,8 @@ static void loadMaterialsFromFile( const char *filename, int depth ) {
|
|||
} else if (Q_stricmp(key, "metalness") == 0) {
|
||||
sscanf(value, "%f", ¤t_material.metalness);
|
||||
metalness_set = true;
|
||||
} else if (Q_stricmp(key, "normal_scale") == 0) {
|
||||
sscanf(value, "%f", ¤t_material.normal_scale);
|
||||
} else if (Q_stricmp(key, "base_color") == 0) {
|
||||
sscanf(value, "%f %f %f %f", ¤t_material.base_color[0], ¤t_material.base_color[1], ¤t_material.base_color[2], ¤t_material.base_color[3]);
|
||||
} else {
|
||||
|
|
|
@ -11,6 +11,7 @@ typedef struct {
|
|||
vec4_t base_color;
|
||||
float roughness;
|
||||
float metalness;
|
||||
float normal_scale;
|
||||
|
||||
qboolean set;
|
||||
} xvk_material_t;
|
||||
|
|
|
@ -172,6 +172,7 @@ static void applyMaterialToKusok(vk_kusok_data_t* kusok, const vk_render_geometr
|
|||
|
||||
kusok->roughness = mat->roughness;
|
||||
kusok->metalness = mat->metalness;
|
||||
kusok->normal_scale = mat->normal_scale;
|
||||
|
||||
kusok->flags = 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue