Skip to content

Commit b1a61af

Browse files
author
devsh
committed
first material and printing
1 parent d467cee commit b1a61af

File tree

2 files changed

+38
-17
lines changed

2 files changed

+38
-17
lines changed

13_MaterialCompilerTest/CFrontendIR.cpp

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,36 +87,41 @@ auto CFrontendIR::reciprocate(const TypedHandle<const IExprNode> other) -> Typed
8787
void CFrontendIR::printDotGraph(std::ostringstream& str) const
8888
{
8989
str << "digraph {\n";
90-
auto getNodeID = [](TypedHandle<const INode> handle)->core::string
91-
{
92-
return core::string("_")+std::to_string(handle);
93-
};
9490

91+
// TODO: track layering depth and indent accordingly?
9592
core::vector<TypedHandle<const CLayer>> layerStack = m_rootNodes;
9693
core::stack<TypedHandle<const IExprNode>> exprStack;
97-
// TODO : print identifiers for root nodes/materials
9894
while (!layerStack.empty())
9995
{
100-
const auto* layerNode = deref(layerStack.back());
96+
const auto layerHandle = layerStack.back();
10197
layerStack.pop_back();
98+
const auto* layerNode = deref(layerHandle);
99+
//
100+
const auto layerID = getNodeID(layerHandle);
101+
str << "\n\t" << getLabelledNodeID(layerHandle);
102+
//
102103
if (layerNode->coated)
103104
{
104-
// TODO: print coating
105+
str << "\n\t" << layerID << " -> " << getNodeID(layerNode->coated) << "[label=\"coats\"]\n";
105106
layerStack.push_back(layerNode->coated);
106107
}
107-
// TODO: print labelled edges
108-
exprStack.push(layerNode->brdfTop);
109-
exprStack.push(layerNode->btdf);
110-
exprStack.push(layerNode->brdfBottom);
108+
auto pushExprRoot = [&](const TypedHandle<const IExprNode> root, const std::string_view edgeLabel)->void
109+
{
110+
if (!root)
111+
return;
112+
str << "\n\t" << layerID << " -> " << getNodeID(root) << "[label=\"" << edgeLabel << "\"]";
113+
exprStack.push(root);
114+
};
115+
pushExprRoot(layerNode->brdfTop,"Top BRDF");
116+
pushExprRoot(layerNode->btdf,"BTDF");
117+
pushExprRoot(layerNode->brdfBottom,"Bottom BRDF");
111118
while (!exprStack.empty())
112119
{
113120
const auto entry = exprStack.top();
114121
exprStack.pop();
122+
str << "\n\t" << getLabelledNodeID(entry);
123+
str << "\n\t" << getNodeID(entry) << " -> {";
115124
const auto* node = deref(entry);
116-
str << "\t" << getNodeID(entry) << " [label=" << node->getTypeName() << "\\n";
117-
if (const auto* debug = deref(node->debugInfo); debug && !debug->data().empty())
118-
str << std::string_view(reinterpret_cast<const char*>(debug->data().data()),debug->data().size());
119-
str << "]\n\t" << getNodeID(entry) << " -> {";
120125
const auto childCount = node->getChildCount();
121126
for (auto childIx=0; childIx<childCount; childIx++)
122127
{
@@ -131,7 +136,7 @@ void CFrontendIR::printDotGraph(std::ostringstream& str) const
131136
}
132137
}
133138

134-
str << "}\n";
139+
str << "\n}\n";
135140
}
136141

137142
}

13_MaterialCompilerTest/main.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,30 @@ class MaterialCompilerTest final : public application_templates::MonoDeviceAppli
4848

4949
// simple white furnace testing materials
5050
{
51+
// transmission
5152
{
5253
auto layerH = forest->_new<CFrontendIR::CLayer>();
5354
auto* layer = forest->deref(layerH);
54-
// layer->btdf = forest->_new<CFrontendIR::CDeltaTransmission>();
55+
layer->debugInfo = forest->_new<CNodePool::CDebugInfo>("MyWeirdInvisibleMaterial");
56+
layer->btdf = forest->_new<CFrontendIR::CDeltaTransmission>();
5557
ASSERT_VALUE(forest->addMaterial(layerH,logger),true,"Add Material");
5658
}
59+
// delta reflection
60+
// cook torrance GGX
61+
// cook torrance GGX with Fresnel
5762
}
5863

64+
// diffuse
65+
// conductor (smooth and rough)
66+
// thindielectric
67+
// dielectric
68+
// diffuse transmitter
69+
70+
// rough plastic
71+
72+
// coated diffuse transmitter leaf
73+
// with subsurface beer scattering
74+
5975
smart_refctd_ptr<IFile> file;
6076
{
6177
m_system->deleteFile(localOutputCWD/"frontend.dot");

0 commit comments

Comments
 (0)