All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
hydraMaterialAdapter.h
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef USDIMAGINGGL_HYDRAMATERIALADAPTER_H
25 #define USDIMAGINGGL_HYDRAMATERIALADAPTER_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usdImaging/usdImagingGL/api.h"
29 #include "pxr/usdImaging/usdImaging/primAdapter.h"
30 #include "pxr/imaging/hd/materialParam.h"
31 
32 PXR_NAMESPACE_OPEN_SCOPE
33 
38 public:
40 
43  {}
44 
45  USDIMAGINGGL_API
47 
48  USDIMAGINGGL_API
49  virtual SdfPath Populate(
50  UsdPrim const& prim,
51  UsdImagingIndexProxy* index,
52  UsdImagingInstancerContext const* instancerContext = NULL) override;
53 
54  USDIMAGINGGL_API
55  virtual bool IsSupported(UsdImagingIndexProxy const* index) const override;
56 
57  // ---------------------------------------------------------------------- //
59  // ---------------------------------------------------------------------- //
60 
62  USDIMAGINGGL_API
63  virtual void TrackVariability(UsdPrim const& prim,
64  SdfPath const& cachePath,
65  HdDirtyBits* timeVaryingBits,
67  instancerContext = NULL) const override;
68 
69 
71  USDIMAGINGGL_API
72  virtual void UpdateForTime(UsdPrim const& prim,
73  SdfPath const& cachePath,
74  UsdTimeCode time,
75  HdDirtyBits requestedBits,
77  instancerContext = NULL) const override;
78 
79  // ---------------------------------------------------------------------- //
81  // ---------------------------------------------------------------------- //
82 
85  USDIMAGINGGL_API
86  virtual HdDirtyBits ProcessPropertyChange(
87  UsdPrim const& prim,
88  SdfPath const& cachePath,
89  TfToken const& propertyName) override;
90 
91  USDIMAGINGGL_API
92  virtual void MarkDirty(UsdPrim const& prim,
93  SdfPath const& cachePath,
94  HdDirtyBits dirty,
95  UsdImagingIndexProxy* index) override;
96 
97  USDIMAGING_API
98  virtual void MarkMaterialDirty(UsdPrim const& prim,
99  SdfPath const& cachePath,
100  UsdImagingIndexProxy* index) override;
101 
102 
103  // ---------------------------------------------------------------------- //
105  // ---------------------------------------------------------------------- //
106 
107  virtual HdTextureResource::ID
108  GetTextureResourceID(UsdPrim const& usdPrim,
109  SdfPath const &id,
110  UsdTimeCode time,
111  size_t salt) const override;
112 
113  virtual HdTextureResourceSharedPtr
114  GetTextureResource(UsdPrim const& usdPrim,
115  SdfPath const &id,
116  UsdTimeCode time) const override;
117 
118 protected:
119  USDIMAGINGGL_API
120  virtual void _RemovePrim(SdfPath const& cachePath,
121  UsdImagingIndexProxy* index) final;
122 
123 private:
128  std::string _GetShaderSource(UsdPrim const& prim,
129  TfToken const& shaderType,
130  VtDictionary * metadataOut = nullptr) const;
131 
137  UsdPrim _GetSurfaceShaderPrim(const UsdShadeMaterial &material) const;
138 
143  UsdPrim _GetDisplacementShaderPrim(const UsdShadeMaterial &material) const;
144 
145  UsdPrim _GetVolumeShaderPrim(const UsdShadeMaterial &material) const;
146 
151  bool _GatherMaterialData(
152  UsdPrim const& materialPrim,
153  UsdPrim *surfaceShaderPrim,
154  UsdPrim *displacementShaderPrim,
155  UsdPrim *volumeShaderPrim,
156  SdfPathVector *textureIDs,
157  TfTokenVector *primvars,
158  HdMaterialParamVector *materialParams,
159  TfToken *materialTag) const;
160 
163  void _WalkShaderNetwork(
164  UsdPrim const& shaderPrim,
165  SdfPathVector *textureIDs,
166  TfTokenVector *primvars,
167  HdMaterialParamVector *materialParams,
168  TfToken *materialTag) const;
169 
172  void _WalkShaderNetworkDeprecated(
173  UsdPrim const &shaderPrim,
174  SdfPathVector *textureIDs,
175  TfTokenVector *primvars,
176  HdMaterialParamVector *materialParams,
177  TfToken *materialTag) const;
178 
180  VtValue _GetMaterialParamValue(UsdPrim const& shaderPrim,
181  TfToken const& paramName,
182  UsdTimeCode time) const;
183 };
184 
185 PXR_NAMESPACE_CLOSE_SCOPE
186 
187 #endif // USDIMAGINGGL_HYDRAMATERIALADAPTER_H
virtual USDIMAGINGGL_API bool IsSupported(UsdImagingIndexProxy const *index) const override
Returns true if the adapter can be populated into the target index.
A map with string keys and VtValue values.
Definition: dictionary.h:61
This proxy class exposes a subset of the private Delegate API to PrimAdapters.
Definition: indexProxy.h:47
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Definition: timeCode.h:85
Base class for all PrimAdapters.
Definition: primAdapter.h:67
virtual USDIMAGINGGL_API void TrackVariability(UsdPrim const &prim, SdfPath const &cachePath, HdDirtyBits *timeVaryingBits, UsdImagingInstancerContext const *instancerContext=NULL) const override
Thread Safe.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:131
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:438
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
virtual USDIMAGINGGL_API void UpdateForTime(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time, HdDirtyBits requestedBits, UsdImagingInstancerContext const *instancerContext=NULL) const override
Thread Safe.
virtual USDIMAGINGGL_API HdDirtyBits ProcessPropertyChange(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &propertyName) override
Returns a bit mask of attributes to be udpated, or HdChangeTracker::AllDirty if the entire prim must ...
Provides information that can be used to generate a surface shader in hydra.
virtual USDIMAGINGGL_API SdfPath Populate(UsdPrim const &prim, UsdImagingIndexProxy *index, UsdImagingInstancerContext const *instancerContext=NULL) override
Called to populate the RenderIndex for this UsdPrim.
A Material provides a container into which multiple &quot;render targets&quot; can add data that defines a &quot;sha...
Definition: material.h:111
Object used by instancer prim adapters to pass along context about the instancer and instance prim to...
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:182