Specular map used
This commit is contained in:
parent
f2f5ef5340
commit
418c42a645
@ -269,6 +269,12 @@ PipelineHands create_graphics_pipeline_0(
|
||||
.descriptorCount = 1,
|
||||
.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
},
|
||||
{
|
||||
.binding = 3,
|
||||
.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||
.descriptorCount = 1,
|
||||
.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
},
|
||||
};
|
||||
VkDescriptorSetLayoutCreateInfo descriptor_set_layout_crinfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
|
||||
@ -1796,7 +1802,7 @@ int main() {
|
||||
const GenericMeshInSceneTemplate* M = VecGenericMeshInSceneTemplate_at(&vk_ctx->scene_template.generic_models, i);
|
||||
TextureDataR8G8B8A8 reading_diffuse = TextureDataR8G8B8A8_read_from_png_nofail(VecU8_to_span(&M->diffuse_texture_path));
|
||||
TextureDataR8G8B8A8 reading_normal = TextureDataR8G8B8A8_read_from_png_nofail(VecU8_to_span(&M->normal_texture_path));
|
||||
TextureDataR8 reading_specular = TextureDataR8_read_from_png_nofail(VecU8_to_span(&M->diffuse_texture_path));
|
||||
TextureDataR8 reading_specular = TextureDataR8_read_from_png_nofail(VecU8_to_span(&M->specular_texture_path));
|
||||
VecGenericModelTopAndTexInMemoryInfo_append(&vk_ctx->device_generic_models_top_and_tex,
|
||||
(GenericModelTopAndTexInMemoryInfo){
|
||||
.vbo = GenericMeshVertex_buffer_crinfo_of_gpu_vbo(M->topology.vertices.len),
|
||||
@ -2084,6 +2090,11 @@ int main() {
|
||||
.imageView = M->normal_view,
|
||||
.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||
};
|
||||
VkDescriptorImageInfo image_info_for_descriptor_3_in_set_0a = {
|
||||
.sampler = vk_ctx->nearest_sampler,
|
||||
.imageView = M->specular_view,
|
||||
.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||
};
|
||||
// todo: add a third binding (for specular shading)
|
||||
VkWriteDescriptorSet writes_in_descriptor_set[] = {
|
||||
{
|
||||
@ -2113,6 +2124,15 @@ int main() {
|
||||
.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||
.pImageInfo = &image_info_for_descriptor_2_in_set_0a,
|
||||
},
|
||||
{
|
||||
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||
.dstSet = M->p_0a_set_0,
|
||||
.dstBinding = 3,
|
||||
.dstArrayElement = 0,
|
||||
.descriptorCount = 1,
|
||||
.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||
.pImageInfo = &image_info_for_descriptor_3_in_set_0a,
|
||||
},
|
||||
};
|
||||
vkUpdateDescriptorSets(vk_ctx->device, ARRAY_SIZE(writes_in_descriptor_set), writes_in_descriptor_set, 0, NULL);
|
||||
}
|
||||
|
||||
@ -3,11 +3,12 @@
|
||||
layout(location = 0) in vec2 fsin_tex;
|
||||
layout(location = 1) in vec3 fsin_pos;
|
||||
|
||||
/* Righ now all in set 0 */
|
||||
layout(location = 0) out vec4 fin_color;
|
||||
|
||||
/* Yes, even these guys */
|
||||
layout(binding = 1) uniform sampler2D color_tex;
|
||||
|
||||
layout(binding = 2) uniform sampler2D normal_map;
|
||||
layout(binding = 3) uniform sampler2D specular_map;
|
||||
|
||||
layout(push_constant, std430) uniform pc {
|
||||
layout(offset = 64) vec3 camera_pos;
|
||||
@ -57,7 +58,8 @@ void main(){
|
||||
Pipeline0Spotlight lamp = spotlight_arr[i];
|
||||
}
|
||||
vec3 natural_color = texture(color_tex, fsin_tex).xyz;
|
||||
// todo: add specular map texture
|
||||
vec3 color = natural_color * diffuse_illumination + 0.5 * specular_illumination;
|
||||
float specular_c = texture(specular_map, fsin_tex).x;
|
||||
vec3 color = natural_color * diffuse_illumination + specular_c * specular_illumination;
|
||||
fin_color = vec4(color, 1);
|
||||
// fin_color = vec4(specular_c, 0, 0, 1);
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 76 KiB |
Loading…
x
Reference in New Issue
Block a user