GCC Code Coverage Report


ernie/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
16 / 16
100.0%
Branches:
5 / 10
50.0%
Functions:
12 / 12, 1 excl
100.0%

scene/schema/shade.h
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2 /// @file shade.h
3 /// @brief UsdShade's schemas.
4 ///
5 /// References:
6 /// - Pixar, UsdShade, https://openusd.org/release/api/usd_shade_page_front.html
7 #pragma once
8
9 #include "ernie/scene/view.h"
10
11 #include <optional>
12 #include <string>
13 #include <string_view>
14
15 // clang-format off
16 #define ERNIE_MATERIAL_BINDING_API_ATTRIBUTES(X) \
17 X(Path, MaterialBinding, "material:binding", Path(), \
18 "The Material the prim and its descendants are drawn with.", .label = "Material", \
19 .group = "Material", .dirty = Dirty::Material, .inherited = true)
20
21 #define ERNIE_SHADER_ATTRIBUTES(X) \
22 X(std::string, Id, "info:id", "", \
23 "The node it is: UsdPreviewSurface, UsdUVTexture, a primvar reader or an Ernie model.", \
24 .group = "Shader", .dirty = Dirty::Material) \
25 X(std::string, ImplementationSource, "info:implementationSource", "id", \
26 "Where its definition comes from: its id, a source asset or source code.", \
27 .group = "Shader", .options = {"id", "sourceAsset", "sourceCode"}, .dirty = Dirty::Material) \
28 X(std::string, SourceAsset, "info:sourceAsset", "", "A file defining it, as a MaterialX one.", \
29 .group = "Shader", .asset = true, .dirty = Dirty::Material) \
30 X(std::string, SourceCode, "info:sourceCode", "", "Code defining it, as a Slang model's.", \
31 .group = "Shader", .dirty = Dirty::Material)
32 // clang-format on
33
34 namespace ernie {
35
36
2/4
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
28 ERNIE_API_SCHEMA(MaterialBindingAPI, ERNIE_MATERIAL_BINDING_API_ATTRIBUTES,
37 "Binds a material to a prim and its descendants; material:binding:<purpose> "
38 "binds one for a purpose.");
39 4 ERNIE_CONCRETE_SCHEMA(NodeGraph, SchemaView, ERNIE_NO_ATTRIBUTES,
40 "A network of shaders with inputs its users set and outputs connected "
41 "inside it.");
42 8 ERNIE_CONCRETE_SCHEMA(Material, NodeGraph, ERNIE_NO_ATTRIBUTES,
43 "What prims are drawn with: its terminals outputs:surface, "
44 "outputs:displacement and outputs:volume, and Ernie's outputs:ernie:thermal, "
45 "outputs:ernie:lidar and outputs:ernie:radar, connect to the shaders "
46 "computing them.");
47 20 ERNIE_CONCRETE_SCHEMA(Shader, SchemaView, ERNIE_SHADER_ATTRIBUTES,
48 "One node of a network, a model or a texture, by its info:id, with its "
49 "inputs and outputs.");
50
51 /// @brief The source of a connection: a shader or graph and one of its outputs.
52
1/2
✗ Branch 4 not taken.
✓ Branch 5 taken 1 time.
9 struct Connection {
53 1 Path prim;
54 1 std::string output;
55
2/4
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 time.
1 bool operator==(const Connection&) const = default;
56 };
57
58 /// @brief Connects an input or output of a Material, NodeGraph or Shader to another's output, as
59 /// USD's `<input>.connect` holds it: `/Looks/Red/Surface.outputs:surface`.
60 void Connect(Scene& scene, const Path& path, std::string_view input, const Connection& source);
61 /// @return The input's connection, or none.
62 /// @throws std::invalid_argument if its text is not a prim path, a dot and a property name.
63 std::optional<Connection> FindConnection(const Scene& scene, const Path& path,
64 std::string_view input);
65
66 } // namespace ernie
67