MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / renderUI

Method renderUI

Source/Falcor/Scene/Material/BasicMaterial.cpp:68–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66 }
67
68 bool BasicMaterial::renderUI(Gui::Widgets& widget)
69 {
70 // Render the base class UI first.
71 bool changed = Material::renderUI(widget);
72
73 // We're re-using the material's update flags here to track changes.
74 // Cache the previous flag so we can restore it before returning.
75 UpdateFlags prevUpdates = mUpdates;
76 mUpdates = UpdateFlags::None;
77
78 if (auto pTexture = getBaseColorTexture())
79 {
80 bool hasAlpha = isAlphaSupported() && doesFormatHaveAlpha(pTexture->getFormat());
81 bool alphaConst = mIsTexturedAlphaConstant && hasAlpha;
82 bool colorConst = mIsTexturedBaseColorConstant;
83
84 std::string str = fmt::format("Texture info: {}x{} ({})", pTexture->getWidth(), pTexture->getHeight(), to_string(pTexture->getFormat()));
85 if (colorConst && !alphaConst) str += " (color constant)";
86 else if (!colorConst && alphaConst) str += " (alpha constant)";
87 else if (colorConst && alphaConst) str += " (color and alpha constant)"; // Shouldn't happen
88
89 widget.text("Base color: " + pTexture->getSourcePath().string());
90 widget.text(str);
91
92 if (colorConst || alphaConst)
93 {
94 float4 baseColor = getBaseColor();
95 if (widget.var("Base color", baseColor, 0.f, 1.f, 0.01f)) setBaseColor(baseColor);
96 }
97
98 widget.image("Base color", pTexture.get(), float2(100.f));
99 if (widget.button("Remove texture##BaseColor")) setBaseColorTexture(nullptr);
100 }
101 else
102 {
103 float4 baseColor = getBaseColor();
104 if (widget.var("Base color", baseColor, 0.f, 1.f, 0.01f)) setBaseColor(baseColor);
105 }
106
107 if (auto pTexture = getSpecularTexture())
108 {
109 widget.text("Specular params: " + pTexture->getSourcePath().string());
110 widget.text("Texture info: " + std::to_string(pTexture->getWidth()) + "x" + std::to_string(pTexture->getHeight()) + " (" + to_string(pTexture->getFormat()) + ")");
111 widget.image("Specular params", pTexture.get(), float2(100.f));
112 if (widget.button("Remove texture##Specular")) setSpecularTexture(nullptr);
113 }
114 else
115 {
116 float4 specularParams = getSpecularParams();
117 if (widget.var("Specular params", specularParams, 0.f, 1.f, 0.01f)) setSpecularParams(specularParams);
118 widget.tooltip("The encoding depends on the material type");
119
120 renderSpecularUI(widget); // Let derived classes draw additional UI elements.
121 }
122
123 if (auto pTexture = getNormalMap())
124 {
125 widget.text("Normal map: " + pTexture->getSourcePath().string());

Callers

nothing calls this directly

Calls 15

getBaseColorTextureFunction · 0.85
doesFormatHaveAlphaFunction · 0.85
getBaseColorFunction · 0.85
setBaseColorTextureFunction · 0.85
getSpecularTextureFunction · 0.85
setSpecularTextureFunction · 0.85
getSpecularParamsFunction · 0.85
renderSpecularUIFunction · 0.85
getDisplacementMapFunction · 0.85
setDisplacementMapFunction · 0.85
getDisplacementScaleFunction · 0.85
getDisplacementOffsetFunction · 0.85

Tested by

no test coverage detected