Loading...
Searching...
No Matches
materialOverrideResolvingSceneIndex.h
1//
2// Copyright 2024 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_IMAGING_HDSI_MATERIAL_OVERRIDE_RESOLVING_SCENE_INDEX_H
8#define PXR_IMAGING_HDSI_MATERIAL_OVERRIDE_RESOLVING_SCENE_INDEX_H
9
11#include "pxr/imaging/hd/filteringSceneIndex.h"
12#include "pxr/imaging/hdsi/api.h"
13
14PXR_NAMESPACE_OPEN_SCOPE
15
16TF_DECLARE_WEAK_AND_REF_PTRS(HdsiMaterialOverrideResolvingSceneIndex);
17
18/*
19HdsiMaterialOverrideResolvingSceneIndex applies material overrides in the form
20of edits to a material's interface or directly to parameters of its shader nodes.
21
22Overrides to a material's interface are only applied if their interface mappings
23are found.
24The overrides for a particular 'publicUIName' are specified at path like this:
25
26materialOverride.interfaceValues.<publicUIName>.value
27 -> overrideValueDataSource
28
29The 'overrideValueDataSource' is copied over a network node parameter's original
30'valueDataSource' at paths like this:
31
32material.<renderContext>.nodes.<nodePath>.parameters.<inputName>.value
33 -> valueDataSource
34
35The scene index identifies which network node parameter to override by using
36the material's interface mappings which are defined at paths like this:
37
38material.<renderContext>.interface.parameters.<publicUIName>.mappings
39 -> [(nodePath, inputName), (nodePath, inputName), ...]
40
41Edits of input parameters of shaders within the material are specified at a path
42like this:
43materialOverride.parameterValues.<shaderNodeName>.<parameterName>.value ->
44 paramEditValueDataSource
45
46The 'paramEditValueDataSource' is copied over a network node parameter's original
47'valueDataSource' at paths like this:
48
49material.<renderContext>.nodes.<nodePath>.parameters.<inputName>.value
50 -> valueDataSource
51
52If the same input parameter is overridden both by an edit to the material
53interface and by a direct parameter edit, the interface override will take
54precedence.
55
56Below is a diagram of the expected attributes needed for material interface
57and parameter edits on a scene index prim of type 'material':
58
59MaterialPrim
60|
61+------materialOverride
62| |
63| +----interfaceValues
64| | |
65| | +-publicUIName
66| | | |
67| | | +---value -> overrideValueDataSource
68| | |
69| | +-publicUIName
70| | | |
71| | | +---value -> overrideValueDataSource
72| | |
73| | +-...
74| |
75| +----parameterValues
76| |
77| +-nodePath
78| | |
79| | +---inputName
80| | | |
81| | | +---value -> paramEditValueDataSource
82| | |
83| | +---inputName
84| | | |
85| | | +---value -> paramEditValueDataSource
86| | |
87| | +---...
88| |
89| +-...
90|
91+------material
92 |
93 +----ri
94 |
95 +--nodes
96 | |
97 | +-nodePath
98 | | |
99 | | +-parameters
100 | | |
101 | | +-inputName
102 | | | |
103 | | | +-value -> valueDataSource
104 | | |
105 | | +-inputName
106 | | |
107 | | +-value -> valueDataSource
108 | |
109 | +-nodePath
110 | |
111 | +-parameters
112 | |
113 | +-...
114 |
115 +--interface
116 |
117 +-parameters
118 | |
119 | +-publicUIName
120 | | |
121 | | +-mappings
122 | | +-i0
123 | | | |
124 | | | +----nodePath
125 | | | |
126 | | | +----inputName
127 | | |
128 | | +-i1
129 | | | |
130 | | | +----nodePath
131 | | | |
132 | | | +----inputName
133 | | |
134 | | +-...
135 | |
136 | +-publicUIName
137 | | |
138 | | +-mappings
139 | | +-i0
140 | | | |
141 | | | +----nodePath
142 | | | |
143 | | | +----inputName
144 | | |
145 | | +-i1
146 | | | |
147 | | | +----nodePath
148 | | | |
149 | | | +----inputName
150 | | |
151 | | +-...
152 | +-...
153 |
154 +-parameterOrder = ...
155*/
156
157class HdsiMaterialOverrideResolvingSceneIndex final :
159{
160public:
161 static HdsiMaterialOverrideResolvingSceneIndexRefPtr New(
162 const HdSceneIndexBaseRefPtr &inputScene)
163 {
164 return TfCreateRefPtr(
165 new HdsiMaterialOverrideResolvingSceneIndex(inputScene));
166 }
167
168 // HdSceneIndexBase overrides
169 HDSI_API
170 HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override;
171
172 HDSI_API
173 SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override;
174
175protected:
176
177 HDSI_API
178 HdsiMaterialOverrideResolvingSceneIndex(
179 const HdSceneIndexBaseRefPtr &inputScene);
180
181 // HdSingleInputFilteringSceneIndexBase overrides
182 void _PrimsAdded(
183 const HdSceneIndexBase &sender,
184 const HdSceneIndexObserver::AddedPrimEntries &entries) override;
185
186 void _PrimsRemoved(
187 const HdSceneIndexBase &sender,
188 const HdSceneIndexObserver::RemovedPrimEntries &entries) override;
189
190 void _PrimsDirtied(
191 const HdSceneIndexBase &sender,
192 const HdSceneIndexObserver::DirtiedPrimEntries &entries) override;
193};
194
195PXR_NAMESPACE_CLOSE_SCOPE
196
197#endif // PXR_IMAGING_HDSI_MATERIAL_OVERRIDE_RESOLVING_SCENE_INDEX_H
Abstract interface to scene data.
Definition: sceneIndex.h:54
virtual SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const =0
Returns the paths of all scene index prims located immediately below primPath.
virtual HdSceneIndexPrim GetPrim(const SdfPath &primPath) const =0
Returns a pair of (prim type, datasource).
An abstract base class for a filtering scene index that observes a single input scene index.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Standard pointer typedefs.
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:72
Small struct representing a 'prim' in the Hydra scene index.
Definition: sceneIndex.h:35