Loading...
Searching...
No Matches
shaderMetadataHelpers.h
Go to the documentation of this file.
1//
2// Copyright 2018 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7
8#ifndef PXR_USD_SDR_SHADER_METADATA_HELPERS_H
9#define PXR_USD_SDR_SHADER_METADATA_HELPERS_H
10
12
13#include "pxr/pxr.h"
14#include "pxr/usd/sdr/api.h"
15#include "pxr/base/tf/functionRef.h"
16#include "pxr/base/tf/token.h"
17#include "pxr/base/vt/value.h"
18#include "pxr/usd/sdr/declare.h"
21#include "pxr/usd/sdf/valueTypeName.h"
22
23#include <limits>
24
25PXR_NAMESPACE_OPEN_SCOPE
26
32{
37 SDR_API
38 bool
39 IsTruthy(const TfToken& key, const SdrTokenMap& metadata);
40
43 SDR_API
44 std::string
45 StringVal(const TfToken& key, const SdrTokenMap& metadata,
46 const std::string& defaultValue = std::string());
47
50 SDR_API
52 TokenVal(const TfToken& key, const SdrTokenMap& metadata,
53 const TfToken& defaultValue = TfToken());
54
57 SDR_API
58 int
59 IntVal(const TfToken& key, const SdrTokenMap& metadata,
60 int defaultValue = std::numeric_limits<int>::max());
61
64 SDR_API
65 SdrStringVec
66 StringVecVal(const TfToken& key, const SdrTokenMap& metadata);
67
70 SDR_API
71 SdrTokenVec
72 TokenVecVal(const TfToken& key, const SdrTokenMap& metadata);
73
75 SDR_API
76 SdrOptionVec
77 OptionVecVal(const std::string& optionStr);
78
81 SDR_API
82 std::string
83 CreateStringFromStringVec(const SdrStringVec& stringVec);
84
87 SDR_API
88 bool
89 IsPropertyAnAssetIdentifier(const SdrTokenMap& metadata);
90
93 SDR_API
94 bool
95 IsPropertyATerminal(const SdrTokenMap& metadata);
96
99 SDR_API
100 TfToken
101 GetRoleFromMetadata(const SdrTokenMap& metadata);
102
119 SDR_API
120 VtValue
121 ParseSdfValue(const std::string& valueStr,
122 const SdrShaderPropertyConstPtr& property,
123 std::string* err);
124
130 SDR_API
131 std::string
132 ComputeShownIfFromMetadata(SdrShaderPropertyConstPtr property,
133 const SdrShaderPropertyUniquePtrVec& allProperties,
134 SdrShaderNodeConstPtr shader);
135
142 SDR_API
143 std::string
144 ComputeShownIfFromMetadata(const SdrTokenMap& metadata,
145 const std::string& pageName,
146 const SdrShaderPropertyUniquePtrVec& properties,
147 const std::string& shaderUri);
148}
149
150PXR_NAMESPACE_CLOSE_SCOPE
151
152#endif // PXR_USD_SDR_SHADER_METADATA_HELPERS_H
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:90
Various utilities for parsing metadata contained within shaders.
SDR_API SdrTokenVec TokenVecVal(const TfToken &key, const SdrTokenMap &metadata)
Extracts a vector of tokenized values from the given metadatum.
SDR_API VtValue ParseSdfValue(const std::string &valueStr, const SdrShaderPropertyConstPtr &property, std::string *err)
Parses the VtValue from the given valueStr according to the sdf type expressed by the given property ...
SDR_API std::string ComputeShownIfFromMetadata(SdrShaderPropertyConstPtr property, const SdrShaderPropertyUniquePtrVec &allProperties, SdrShaderNodeConstPtr shader)
Synthesizes a "shownIf" expression from conditional visibility metadata in property,...
SDR_API bool IsPropertyATerminal(const SdrTokenMap &metadata)
Determines if the specified property metadata has a 'renderType' that indicates the property should b...
SDR_API std::string StringVal(const TfToken &key, const SdrTokenMap &metadata, const std::string &defaultValue=std::string())
Extracts the string value from the given metadatum if it exists, otherwise returns defaultValue.
SDR_API TfToken TokenVal(const TfToken &key, const SdrTokenMap &metadata, const TfToken &defaultValue=TfToken())
Extracts the tokenized value from the given metadatum if it exists, otherwise returns defaultValue.
SDR_API SdrStringVec StringVecVal(const TfToken &key, const SdrTokenMap &metadata)
Extracts a vector of strings from the given metadatum.
SDR_API std::string CreateStringFromStringVec(const SdrStringVec &stringVec)
Serializes a vector of strings into a string using the pipe character as the delimiter.
SDR_API TfToken GetRoleFromMetadata(const SdrTokenMap &metadata)
Gets the "role" from metadata if one is provided.
SDR_API bool IsPropertyAnAssetIdentifier(const SdrTokenMap &metadata)
Determines if the specified property metadata has a widget that indicates the property is an asset id...
SDR_API bool IsTruthy(const TfToken &key, const SdrTokenMap &metadata)
Determines if the given metadatum in the metadata dictionary has a truthy value.
SDR_API int IntVal(const TfToken &key, const SdrTokenMap &metadata, int defaultValue=std::numeric_limits< int >::max())
Extracts the int value from the given metadatum if it exists and is a valid integer value,...
SDR_API SdrOptionVec OptionVecVal(const std::string &optionStr)
Extracts an "options" vector from the given string.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...