Skip to content

Commit 407c9bb

Browse files
authored
Updated material editor to only show relevant shader settings (#519)
* Settings that aren't available to the currently selected variant (based off the enabled shader features), are now hidden * Material serialization flow updated to skip properties that aren't used by the current variant * Added warning when a shadow receiver doesn't have the right uniforms * Cleaned up material editor and renamed sections * Cleaned up atmospheric scattering shader (removed unused code)
1 parent f55aea1 commit 407c9bb

File tree

8 files changed

+225
-162
lines changed

8 files changed

+225
-162
lines changed

Resources/Engine/Materials/Default.ovmat

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,9 @@
1111
<receive_shadows>true</receive_shadows>
1212
<user_interface>false</user_interface>
1313
<gpu_instances>1</gpu_instances>
14+
<draw_order>1000</draw_order>
1415
</settings>
1516
<uniforms>
16-
<uniform>
17-
<name>_LightSpaceMatrix</name>
18-
</uniform>
19-
<uniform>
20-
<name>_ShadowMap</name>
21-
<value>?</value>
22-
</uniform>
2317
<uniform>
2418
<name>u_Albedo</name>
2519
<value>
@@ -33,22 +27,10 @@
3327
<name>u_AlbedoMap</name>
3428
<value>?</value>
3529
</uniform>
36-
<uniform>
37-
<name>u_AlphaClippingThreshold</name>
38-
<value>0.1</value>
39-
</uniform>
4030
<uniform>
4131
<name>u_AmbientOcclusionMap</name>
4232
<value>?</value>
4333
</uniform>
44-
<uniform>
45-
<name>u_HeightMap</name>
46-
<value>?</value>
47-
</uniform>
48-
<uniform>
49-
<name>u_HeightScale</name>
50-
<value>0.050000001</value>
51-
</uniform>
5234
<uniform>
5335
<name>u_MaskMap</name>
5436
<value>?</value>
@@ -61,14 +43,6 @@
6143
<name>u_MetallicMap</name>
6244
<value>?</value>
6345
</uniform>
64-
<uniform>
65-
<name>u_NormalMap</name>
66-
<value>?</value>
67-
</uniform>
68-
<uniform>
69-
<name>u_ParallaxClipEdges</name>
70-
<value>0</value>
71-
</uniform>
7246
<uniform>
7347
<name>u_Roughness</name>
7448
<value>0.5</value>
@@ -77,10 +51,6 @@
7751
<name>u_RoughnessMap</name>
7852
<value>?</value>
7953
</uniform>
80-
<uniform>
81-
<name>u_ShadowClippingThreshold</name>
82-
<value>0.5</value>
83-
</uniform>
8454
<uniform>
8555
<name>u_TextureOffset</name>
8656
<value>

Resources/Engine/Shaders/Atmosphere.ovfx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66
#version 450 core
77

88
#include ":Shaders/Common/Buffers/EngineUBO.ovfxh"
9-
#include ":Shaders/Common/Utils.ovfxh"
109
#include ":Shaders/Common/Buffers/LightsSSBO.ovfxh"
1110

1211
layout (location = 0) in vec3 geo_Pos;
13-
layout (location = 1) in vec2 geo_TexCoords;
1412

1513
out VS_OUT
1614
{
@@ -56,7 +54,6 @@ void main()
5654
#version 450 core
5755

5856
#include ":Shaders/Common/Buffers/EngineUBO.ovfxh"
59-
#include ":Shaders/Common/Utils.ovfxh"
6057

6158
in VS_OUT
6259
{

Sources/Overload/OvCore/src/OvCore/Rendering/ShadowRenderFeature.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,17 @@ void OvCore::Rendering::ShadowRenderFeature::OnBeforeDraw(OvRendering::Data::Pip
4242
if (light.type == OvRendering::Settings::ELightType::DIRECTIONAL)
4343
{
4444
const auto shadowTex = light.GetShadowBuffer().GetAttachment<OvRendering::HAL::Texture>(OvRendering::Settings::EFramebufferAttachment::DEPTH);
45-
material.SetProperty("_ShadowMap", &shadowTex.value(), true); // Single use material property
46-
material.SetProperty("_LightSpaceMatrix", light.GetLightSpaceMatrix(), true);
45+
46+
if (!material.TrySetProperty("_ShadowMap", &shadowTex.value(), true))
47+
{
48+
OVLOG_WARNING("ShadowRenderFeature: Material does not have a _ShadowMap property");
49+
}
50+
51+
if (!material.TrySetProperty("_LightSpaceMatrix", light.GetLightSpaceMatrix(), true))
52+
{
53+
OVLOG_WARNING("ShadowRenderFeature: Material does not have a _LightSpaceMatrix property");
54+
}
55+
4756
++lightIndex;
4857
}
4958
}

Sources/Overload/OvCore/src/OvCore/Resources/Material.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,28 @@ void OvCore::Resources::Material::OnSerialize(tinyxml2::XMLDocument& p_doc, tiny
3636
tinyxml2::XMLNode* uniformsNode = p_doc.NewElement("uniforms");
3737
p_node->InsertEndChild(uniformsNode);
3838

39+
const auto program = GetProgram();
40+
41+
// If the material has no valid program for the current feature set, we skip serialization of properties.
42+
if (!program)
43+
{
44+
return;
45+
}
46+
3947
for (const auto& [name, prop] : m_properties)
4048
{
49+
// Skip serialization of this property if the current program isn't using its associated uniform
50+
if (!program->GetUniformInfo(name))
51+
{
52+
continue;
53+
}
54+
55+
// Skip serialization of this property if it is marked as single-use
56+
if (prop.singleUse)
57+
{
58+
continue;
59+
}
60+
4161
auto& value = prop.value;
4262
tinyxml2::XMLNode* uniform = p_doc.NewElement("uniform");
4363
uniformsNode->InsertEndChild(uniform);

Sources/Overload/OvEditor/include/OvEditor/Panels/MaterialEditor.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,30 +71,30 @@ namespace OvEditor::Panels
7171
void CreateMaterialSelector();
7272
void CreateShaderSelector();
7373
void CreateMaterialSettings();
74-
void CreateShaderSettings();
75-
void CreateFeatureSettings();
74+
void CreateMaterialFeatures();
75+
void CreateMaterialProperties();
7676

77-
void GenerateShaderSettingsContent();
7877
void GenerateMaterialSettingsContent();
7978
void GenerateMaterialFeaturesContent();
79+
void GenerateMaterialPropertiesContent();
8080

8181
private:
82-
OvCore::Resources::Material* m_target = nullptr;
83-
OvRendering::Resources::Shader* m_shader = nullptr;
82+
OvCore::Resources::Material* m_target = nullptr;
83+
OvRendering::Resources::Shader* m_shader = nullptr;
8484

85-
OvUI::Widgets::Texts::Text* m_targetMaterialText = nullptr;
86-
OvUI::Widgets::Texts::Text* m_shaderText = nullptr;
85+
OvUI::Widgets::Texts::Text* m_targetMaterialText = nullptr;
86+
OvUI::Widgets::Texts::Text* m_shaderText = nullptr;
8787

8888
OvTools::Eventing::Event<> m_materialDroppedEvent;
8989
OvTools::Eventing::Event<> m_shaderDroppedEvent;
9090

91-
OvUI::Widgets::Layout::Group* m_settings = nullptr;
92-
OvUI::Widgets::Layout::Group* m_materialSettings = nullptr;
93-
OvUI::Widgets::Layout::Group* m_shaderSettings = nullptr;
94-
OvUI::Widgets::Layout::Group* m_featureSettings = nullptr;
91+
OvUI::Widgets::Layout::Group* m_settings = nullptr;
92+
OvUI::Widgets::Layout::Group* m_materialSettings = nullptr;
93+
OvUI::Widgets::Layout::Group* m_materialFeatures = nullptr;
94+
OvUI::Widgets::Layout::Group* m_materialProperties = nullptr;
9595

96-
OvUI::Widgets::Layout::Columns<2>* m_shaderSettingsColumns = nullptr;
9796
OvUI::Widgets::Layout::Columns<2>* m_materialSettingsColumns = nullptr;
98-
OvUI::Widgets::Layout::Columns<2>* m_featureSettingsColumns = nullptr;
97+
OvUI::Widgets::Layout::Columns<2>* m_materialFeaturesColumns = nullptr;
98+
OvUI::Widgets::Layout::Columns<2>* m_materialPropertiesColumns = nullptr;
9999
};
100100
}

0 commit comments

Comments
 (0)