Use vertex colors, use normal maps

This commit is contained in:
Guillaume Meunier
2025-12-15 19:00:23 +01:00
parent a32a4e4182
commit 06ad530e2f
6 changed files with 86 additions and 15 deletions
+2 -1
View File
@@ -5,7 +5,7 @@ const int nb_clipping = 4;
const int nb_texcoords = 2;
const bool use_pbr = false;
const bool use_normal_maps = false;
const bool use_normal_maps = true;
layout(set = 0, binding = 0) uniform scene_ubo
{
@@ -136,3 +136,4 @@ layout(location = 5) VS_TO_FS vec2 texcoord_metallic_roughness;
layout(location = 6) VS_TO_FS vec2 texcoord_occlusion;
layout(location = 7) VS_TO_FS vec2 texcoord_emissive;
layout(location = 8) VS_TO_FS vec2 texcoord_normal;
layout(location = 9) VS_TO_FS vec4 vertex_color;
+3 -3
View File
@@ -30,7 +30,7 @@ layout(early_fragment_tests) in;
void main()
{
vec4 albedo = material.base_color_factor * texture(base_color_texture, texcoord_base_color);
vec4 albedo = vertex_color * material.base_color_factor * texture(base_color_texture, texcoord_base_color);
vec3 emissive_color = (material.base_emissive_factor * texture(emissive_texture, texcoord_emissive)).rgb;
vec3 normal_unit;
@@ -41,10 +41,10 @@ void main()
// glTF spec §3.7.2.1
vec3 bitangent = cross(normal, tangent.xyz) * tangent.w;
mat3 TBN = mat3(tangent.xyz, bitangent, normal); // View space to tangent space?
mat3 TBN = mat3(tangent.xyz, bitangent, normal);
// Normal in view space
normal_unit = TBN * sampled_normal;
normal_unit = normalize(TBN * sampled_normal);
}
else
normal_unit = normalize(normal);
+1
View File
@@ -58,6 +58,7 @@ void main()
frag_pos = mesh.modelview[gl_ViewIndex] * vec4(in_position, 1.0);
light_pos = scene.view[gl_ViewIndex] * scene.light_position;
vertex_color = in_color;
for (int i = 0; i < nb_clipping; i++)
{
+5 -5
View File
@@ -30,7 +30,7 @@ layout(location = 0) out vec4 out_color;
void main()
{
vec4 albedo = material.base_color_factor * texture(base_color_texture, texcoord_base_color);
vec4 albedo = vertex_color * material.base_color_factor * texture(base_color_texture, texcoord_base_color);
vec3 emissive_color = (material.base_emissive_factor * texture(emissive_texture, texcoord_emissive)).rgb;
vec3 normal_unit;
@@ -41,10 +41,10 @@ void main()
// glTF spec §3.7.2.1
vec3 bitangent = cross(normal, tangent.xyz) * tangent.w;
mat3 TBN = mat3(tangent.xyz, bitangent, normal); // View space to tangent space?
mat3 TBN = mat3(tangent.xyz, bitangent, normal);
// Normal in view space
normal_unit = TBN * sampled_normal;
normal_unit = normalize(TBN * sampled_normal);
}
else
normal_unit = normalize(normal);
@@ -65,8 +65,8 @@ void main()
vec3 light_colour = scene.light_color.rgb;
float attenuation = 1;
vec3 radiance =
per_light_radiance(albedo.rgb, metallic, roughness, light_colour, light_dir, normal_unit, view_dir, half_vec, attenuation) +
vec3(scene.ambient_color) * albedo.rgb * ao;
per_light_radiance(albedo.rgb, metallic, roughness, light_colour, light_dir, normal_unit, view_dir, half_vec, attenuation) +
vec3(scene.ambient_color) * albedo.rgb * ao;
vec3 tmp = radiance + emissive_color;
+1
View File
@@ -67,6 +67,7 @@ void main()
frag_pos = mesh.modelview[gl_ViewIndex] * vec4(in_position, 1.0);
light_pos = scene.view[gl_ViewIndex] * scene.light_position;
vertex_color = in_color;
for(int i = 0; i < nb_clipping; i++)
{