Skip to content

Commit bf494af

Browse files
committed
-Change: Added Use Normal texture option to PBR material
1 parent e6e171a commit bf494af

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

include/engine/core/materials/physically_based.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@ class PhysicallyBasedMaterial : public IMaterial
3939
float m_emisionWeight = 1.0f; // Weight between parameter and emi texture
4040
float m_emissionIntensity = 1.0f;
4141

42-
//Whether to if casts SSR
42+
// Whether to if casts SSR
4343
bool m_isReflective = false;
4444

4545
// Query
4646
bool m_hasAlbedoTexture = false;
4747
bool m_hasNormalTexture = false;
48+
bool m_useNormalTexture = true;
4849
bool m_hasRoughnessTexture = false;
4950
bool m_hasMetallicTexture = false;
5051
bool m_hasAOTexture = false;
@@ -286,6 +287,12 @@ class PhysicallyBasedMaterial : public IMaterial
286287
inline MaskType get_mask_type() const {
287288
return (MaskType)m_maskType;
288289
}
290+
inline void use_normal_texture(bool op) {
291+
m_useNormalTexture = op;
292+
}
293+
inline bool use_normal_texture() const {
294+
return m_useNormalTexture;
295+
}
289296
};
290297
} // namespace Core
291298
VULKAN_ENGINE_NAMESPACE_END

src/core/materials/physically_based.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Graphics::MaterialUniforms PhysicallyBasedMaterial::get_uniforms() const {
99
uniforms.dataSlot2 = {m_tileUV.x, m_tileUV.y, m_settings.alphaTest, m_settings.blending};
1010
uniforms.dataSlot3 = {m_albedoWeight, m_metalness, m_metalnessWeight, m_roughness};
1111
uniforms.dataSlot4 = {m_roughnessWeight, m_occlusion, m_occlusionWeight, m_hasAlbedoTexture};
12-
uniforms.dataSlot5 = {m_hasNormalTexture, m_hasRoughnessTexture, m_hasMetallicTexture, m_hasAOTexture};
12+
uniforms.dataSlot5 = {m_hasNormalTexture && m_useNormalTexture, m_hasRoughnessTexture, m_hasMetallicTexture, m_hasAOTexture};
1313
uniforms.dataSlot6 = {m_hasMaskTexture, m_maskType, m_opacityWeight, m_hasEmissiveTexture};
1414
uniforms.dataSlot7 = {m_emissionColor, m_emisionWeight};
1515
uniforms.dataSlot8 = Vec4{m_emissionIntensity, m_isReflective, 0.0f, 0.0f}; // W = Material ID

src/tools/widgets.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,11 @@ void ObjectExplorerWidget::render() {
518518
if (mat->get_normal_texture())
519519
{
520520
ImGui::Image(get_image(mat->get_normal_texture())->GUIReadHandle, texSize);
521+
bool useNormal = mat->use_normal_texture();
522+
if (ImGui::Checkbox("Use Normal Texture", &useNormal))
523+
{
524+
mat->use_normal_texture(useNormal);
525+
}
521526
}
522527
ImGui::Spacing();
523528

0 commit comments

Comments
 (0)