Skip to content

Commit

Permalink
Make reduce interface a render option (#1130)
Browse files Browse the repository at this point in the history
- Update to set the correct option on all context options so all languages are affected.
- Call to re-generate and rebuild the property editor.
- Move option from load to render.
  • Loading branch information
kwokcb authored Oct 31, 2022
1 parent 60dbde8 commit f16ee06
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
29 changes: 22 additions & 7 deletions source/MaterialXView/Viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,14 @@ void Viewer::createAdvancedSettings(Widget* parent)
reloadShaders();
});

ng::CheckBox* shaderInterfaceBox = new ng::CheckBox(advancedPopup, "Reduce Shader Interface");
shaderInterfaceBox->set_checked(_genContext.getOptions().shaderInterfaceType == mx::SHADER_INTERFACE_REDUCED);
shaderInterfaceBox->set_callback([this](bool enable)
{
mx::ShaderInterfaceType interfaceType = enable ? mx::SHADER_INTERFACE_REDUCED : mx::SHADER_INTERFACE_COMPLETE;
setShaderInterfaceType(interfaceType);
});

Widget* albedoGroup = new Widget(advancedPopup);
albedoGroup->set_layout(new ng::BoxLayout(ng::Orientation::Horizontal));
new ng::Label(albedoGroup, "Albedo Method:");
Expand Down Expand Up @@ -897,13 +905,6 @@ void Viewer::createAdvancedSettings(Widget* parent)
_showAllInputs = enable;
});

ng::CheckBox* shaderInterfaceBox = new ng::CheckBox(advancedPopup, "Reduce Shader Interface");
shaderInterfaceBox->set_checked(_genContext.getOptions().shaderInterfaceType == mx::SHADER_INTERFACE_REDUCED);
shaderInterfaceBox->set_callback([this](bool enable)
{
_genContext.getOptions().shaderInterfaceType = enable ? mx::SHADER_INTERFACE_REDUCED : mx::SHADER_INTERFACE_COMPLETE;
});

ng::CheckBox* flattenBox = new ng::CheckBox(advancedPopup, "Flatten Subgraphs");
flattenBox->set_checked(_flattenSubgraphs);
flattenBox->set_callback([this](bool enable)
Expand Down Expand Up @@ -2714,3 +2715,17 @@ void Viewer::toggleTurntable(bool enable)
invalidateShadowMap();
_turntableStep = 0;
}

void Viewer::setShaderInterfaceType(mx::ShaderInterfaceType interfaceType)
{
_genContext.getOptions().shaderInterfaceType = interfaceType;
_genContextEssl.getOptions().shaderInterfaceType = interfaceType;
#if MATERIALX_BUILD_GEN_OSL
_genContextOsl.getOptions().shaderInterfaceType = interfaceType;
#endif
#if MATERIALX_BUILD_GEN_MDL
_genContextMdl.getOptions().shaderInterfaceType = interfaceType;
#endif
reloadShaders();
updateDisplayedProperties();
}
3 changes: 3 additions & 0 deletions source/MaterialXView/Viewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ class Viewer : public ng::Screen
// Toggle turntable
void toggleTurntable(bool enable);

// Set shader interface type
void setShaderInterfaceType(mx::ShaderInterfaceType interfaceType);

private:
ng::Window* _window;

Expand Down

0 comments on commit f16ee06

Please sign in to comment.