Skip to content

Commit

Permalink
Add simple debug interface
Browse files Browse the repository at this point in the history
Fixes #96
  • Loading branch information
kanerogers committed Oct 25, 2021
1 parent fd1bb2a commit 1cb4845
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
Binary file modified hotham/shaders/pbr.frag.spv
Binary file not shown.
12 changes: 11 additions & 1 deletion hotham/src/resources/vulkan_context.rs
Expand Up @@ -1082,12 +1082,22 @@ fn vulkan_init_legacy(
.application_name(&app_name)
.api_version(vk::make_api_version(0, 1, 2, 0));

let validation_features_enables = [
// vk::ValidationFeatureEnableEXT::BEST_PRACTICES,
];
let validation_features_disables = [];
let mut validation_features = vk::ValidationFeaturesEXT::builder()
.enabled_validation_features(&validation_features_enables)
.disabled_validation_features(&validation_features_disables);

// TODO: Disable validation in release
let instance = entry
.create_instance(
&vk::InstanceCreateInfo::builder()
.application_info(&app_info)
.enabled_extension_names(&vk_instance_ext_ptrs)
.enabled_layer_names(&layer_names),
.enabled_layer_names(&layer_names)
.push_next(&mut validation_features),
None,
)
.expect("Vulkan error creating Vulkan instance");
Expand Down
32 changes: 32 additions & 0 deletions hotham/src/shaders/pbr.frag
Expand Up @@ -354,6 +354,37 @@ void main()
outColor = vec4(color, baseColor.a);

// Debugging

// Shader inputs debug visualization
// "none", "Base Color Texture", "Normal Texture", "Occlusion Texture", "Emissive Texture", "Metalic (?)", "Roughness (?)"
if (uboParams.debugViewInputs > 0.0) {
int index = int(uboParams.debugViewInputs);
switch (index) {
case 1:
outColor.rgba = material.baseColorTextureSet > -1 ? texture(colorMap, material.baseColorTextureSet == 0 ? inUV0 : inUV1) : vec4(1.0f);
break;
case 2:
outColor.rgb = (material.normalTextureSet > -1) ? texture(normalMap, material.normalTextureSet == 0 ? inUV0 : inUV1).rgb : normalize(inNormal);
break;
case 3:
outColor.rgb = (material.occlusionTextureSet > -1) ? texture(aoMap, material.occlusionTextureSet == 0 ? inUV0 : inUV1).rrr : vec3(0.0f);
break;
case 4:
outColor.rgb = (material.emissiveTextureSet > -1) ? texture(emissiveMap, material.emissiveTextureSet == 0 ? inUV0 : inUV1).rgb : vec3(0.0f);
break;
case 5:
outColor.rgb = texture(physicalDescriptorMap, inUV0).bbb;
break;
case 6:
outColor.rgb = texture(physicalDescriptorMap, inUV0).ggg;
break;
case 7:
outColor.rgba = material.baseColorTextureSet > -1 ? texture(colorMap, material.baseColorTextureSet == 0 ? inUV0 : inUV1) * material.baseColorFactor: vec4(1.0f);
break;
}
outColor = SRGBtoLINEAR(outColor);
}

// "none", "Diff (l,n)", "F (l,h)", "G (l,v,h)", "D (h)", "Specular"
if (uboParams.debugViewEquation > 0.0) {
int index = int(uboParams.debugViewEquation);
Expand All @@ -375,4 +406,5 @@ void main()
break;
}
}

}
Binary file modified hotham/src/shaders/pbr.frag.spv
Binary file not shown.

0 comments on commit 1cb4845

Please sign in to comment.