Skip to content

Commit

Permalink
[editor] materials will show an optimized section (yes/no), optimized…
Browse files Browse the repository at this point in the history
… materials can't be modified and a tooltip will show up to let the user now
  • Loading branch information
PanosK92 committed Nov 19, 2024
1 parent fe8a5ec commit 687a561
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 19 deletions.
19 changes: 13 additions & 6 deletions editor/Widgets/Properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,9 +690,19 @@ void Properties::ShowMaterial(Material* material) const
// name
ImGui::NewLine();
ImGui::Text("Name");
ImGui::SameLine(column_pos_x); ImGui::Text(material->GetObjectName().c_str());
ImGui::SameLine(column_pos_x);
ImGui::Text(material->GetObjectName().c_str());

if (material->GetProperty(MaterialProperty::CanBeEdited) == 1.0f)
// optimized
bool optimized = material->GetProperty(MaterialProperty::Optimized) != 0.0f;
{
ImGui::Text("Optimized");
ImGui::SameLine(column_pos_x);
ImGui::Text(optimized ? "Yes" : "No");
ImGuiSp::tooltip("Optimized materials can't be modified");
}

ImGui::BeginDisabled(optimized);
{
// texture slots
{
Expand Down Expand Up @@ -843,10 +853,7 @@ void Properties::ShowMaterial(Material* material) const
ImGui::SameLine(); ImGui::InputFloat("##matOffsetY", &offset.y, 0.01f, 0.1f, "%.2f", ImGuiInputTextFlags_CharsDecimal);
}
}
else
{
ImGui::Text("Can not be edited");
}
ImGui::EndDisabled();

//= MAP ===============================================================================
material->SetProperty(MaterialProperty::TextureTilingX, tiling.x);
Expand Down
16 changes: 8 additions & 8 deletions runtime/RHI/Vulkan/Vulkan_FidelityFX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,7 @@ namespace Spartan
set_ffx_float16(brixelizer_gi::description_dispatch_gi.prevProjection, projection_previous);

// set resources
brixelizer_gi::description_dispatch_gi.environmentMap = to_ffx_resource(tex_skybox, L"brixelizer_environment");
brixelizer_gi::description_dispatch_gi.environmentMap = to_ffx_resource(tex_skybox, L"brixelizer_gi_environment");
brixelizer_gi::description_dispatch_gi.prevLitOutput = to_ffx_resource(tex_frame, L"brixelizer_gi_lit_output_previous");
brixelizer_gi::description_dispatch_gi.depth = to_ffx_resource(tex_depth, L"brixelizer_gi_depth");
brixelizer_gi::description_dispatch_gi.historyDepth = to_ffx_resource(brixelizer_gi::texture_depth_previous.get(), L"brixelizer_gi_depth_previous");
Expand Down Expand Up @@ -1404,15 +1404,15 @@ namespace Spartan
brixelizer_gi::description_dispatch_gi.specularSDFSolveEps = brixelizer_gi::sdf_ray_epsilon;
brixelizer_gi::description_dispatch_gi.tMin = brixelizer_gi::t_min;
brixelizer_gi::description_dispatch_gi.tMax = brixelizer_gi::t_max;
brixelizer_gi::description_dispatch_gi.normalsUnpackMul = 1.0f; // a multiply factor to transform the normal to the space expected by brixelizer gi
brixelizer_gi::description_dispatch_gi.normalsUnpackAdd = 0.0f; // an offset to transform the normal to the space expected by brixelizer gi
brixelizer_gi::description_dispatch_gi.isRoughnessPerceptual = true; // if false, we assume roughness squared was stored in the Gbuffer
brixelizer_gi::description_dispatch_gi.roughnessChannel = 0; // the channel to read the roughness from the roughness texture
brixelizer_gi::description_dispatch_gi.roughnessThreshold = 1.0f; // regions with a roughness value greater than this threshold won't spawn specular rays
brixelizer_gi::description_dispatch_gi.environmentMapIntensity = 0.0f; // value to scale the contribution from the environment map
brixelizer_gi::description_dispatch_gi.normalsUnpackMul = 1.0f;
brixelizer_gi::description_dispatch_gi.normalsUnpackAdd = 0.0f;
brixelizer_gi::description_dispatch_gi.isRoughnessPerceptual = true; // if false, we assume roughness squared was stored in the Gbuffer
brixelizer_gi::description_dispatch_gi.roughnessChannel = 0; // the channel to read the roughness from the roughness texture
brixelizer_gi::description_dispatch_gi.roughnessThreshold = 1.0f; // regions with a roughness value greater than this threshold won't spawn specular rays
brixelizer_gi::description_dispatch_gi.environmentMapIntensity = 1.0f; // value to scale the contribution from the environment map
brixelizer_gi::description_dispatch_gi.motionVectorScale.x = -1.0f;
brixelizer_gi::description_dispatch_gi.motionVectorScale.y = -1.0f;
set_ffx_float3(brixelizer_gi::description_dispatch_gi.cameraPosition, cb_frame->camera_position); // camera position
set_ffx_float3(brixelizer_gi::description_dispatch_gi.cameraPosition, cb_frame->camera_position);

// dispatch
SP_ASSERT(ffxBrixelizerGetRawContext(&brixelizer_gi::context, &brixelizer_gi::description_dispatch_gi.brixelizerContext) == FFX_OK);
Expand Down
4 changes: 2 additions & 2 deletions runtime/Rendering/Material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace Spartan
{
switch (material_property)
{
case MaterialProperty::CanBeEdited: return "can_be_edited";
case MaterialProperty::Optimized: return "optimzied";
case MaterialProperty::WorldSpaceHeight: return "world_space_height";
case MaterialProperty::Clearcoat: return "clearcoat";
case MaterialProperty::Clearcoat_Roughness: return "clearcoat_roughness";
Expand Down Expand Up @@ -129,7 +129,6 @@ namespace Spartan
m_properties.fill(0.0f);

SetProperty(MaterialProperty::CullMode, static_cast<float>(RHI_CullMode::Back));
SetProperty(MaterialProperty::CanBeEdited, 1.0f);
SetProperty(MaterialProperty::ColorR, 1.0f);
SetProperty(MaterialProperty::ColorG, 1.0f);
SetProperty(MaterialProperty::ColorB, 1.0f);
Expand Down Expand Up @@ -442,6 +441,7 @@ namespace Spartan
}

m_is_gpu_ready = true;
SetProperty(MaterialProperty::Optimized, GetTexture(MaterialTextureType::Packed) == nullptr ? 0.0f : 1.0f);
}

uint32_t Material::GetUsedSlotCount() const
Expand Down
3 changes: 1 addition & 2 deletions runtime/Rendering/Material.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace Spartan

enum class MaterialProperty
{
CanBeEdited, // indicates if the material properties can be modified
Optimized, // indicates if the material has been optimized (textures packed and compressed)
WorldSpaceHeight, // height of the mesh to which the material is applied
Clearcoat, // additional specular layer on top of the base specular
Clearcoat_Roughness, // roughness level of the clearcoat layer
Expand Down Expand Up @@ -107,7 +107,6 @@ namespace Spartan
std::vector<std::string> GetTexturePaths();
RHI_Texture* GetTexture(const MaterialTextureType texture_type, const uint8_t slot = 0);


// index of refraction
static float EnumToIor(const MaterialIor ior);
static MaterialIor IorToEnum(const float ior);
Expand Down
1 change: 0 additions & 1 deletion runtime/Rendering/Renderer_Resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,6 @@ namespace Spartan

standard_material = make_shared<Material>();
standard_material->SetResourceFilePath(ResourceCache::GetProjectDirectory() + "standard" + EXTENSION_MATERIAL); // set resource file path so it can be used by the resource cache
standard_material->SetProperty(MaterialProperty::CanBeEdited, 0.0f);
standard_material->SetProperty(MaterialProperty::TextureTilingX, 10.0f);
standard_material->SetProperty(MaterialProperty::TextureTilingY, 10.0f);
standard_material->SetProperty(MaterialProperty::ColorR, 1.0f);
Expand Down

0 comments on commit 687a561

Please sign in to comment.