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 #include "pxr/imaging/hdSt/package.h"
25
26 #include "pxr/base/plug/plugin.h"
27 #include "pxr/base/plug/thisPlugin.h"
28 #include "pxr/base/tf/diagnostic.h"
29 #include "pxr/base/tf/fileUtils.h"
30 #include "pxr/base/tf/stringUtils.h"
31
32 PXR_NAMESPACE_OPEN_SCOPE
33
34
35 static TfToken
_GetShaderPath(char const * shader)36 _GetShaderPath(char const * shader)
37 {
38 static PlugPluginPtr plugin = PLUG_THIS_PLUGIN;
39 const std::string path =
40 PlugFindPluginResource(plugin, TfStringCatPaths("shaders", shader));
41 TF_VERIFY(!path.empty(), "Could not find shader: %s\n", shader);
42
43 return TfToken(path);
44 }
45
46 TfToken
HdStPackageComputeShader()47 HdStPackageComputeShader()
48 {
49 static TfToken s = _GetShaderPath("compute.glslfx");
50 return s;
51 }
52
53 TfToken
HdStPackageDomeLightShader()54 HdStPackageDomeLightShader()
55 {
56 static TfToken s = _GetShaderPath("domeLight.glslfx");
57 return s;
58 }
59
60 TfToken
HdStPackagePtexTextureShader()61 HdStPackagePtexTextureShader()
62 {
63 static TfToken s = _GetShaderPath("ptexTexture.glslfx");
64 return s;
65 }
66
67 TfToken
HdStPackageRenderPassShader()68 HdStPackageRenderPassShader()
69 {
70 static TfToken s = _GetShaderPath("renderPassShader.glslfx");
71 return s;
72 }
73
74 TfToken
HdStPackageFallbackLightingShader()75 HdStPackageFallbackLightingShader()
76 {
77 static TfToken s = _GetShaderPath("fallbackLightingShader.glslfx");
78 return s;
79 }
80
81 TfToken
HdStPackageFallbackMaterialNetworkShader()82 HdStPackageFallbackMaterialNetworkShader()
83 {
84 static TfToken s = _GetShaderPath("fallbackMaterialNetwork.glslfx");
85 return s;
86 }
87
88 TfToken
HdStPackageFallbackVolumeShader()89 HdStPackageFallbackVolumeShader()
90 {
91 static TfToken s = _GetShaderPath("fallbackVolume.glslfx");
92 return s;
93 }
94
95 TfToken
HdStPackageImageShader()96 HdStPackageImageShader()
97 {
98 static TfToken s = _GetShaderPath("imageShader.glslfx");
99 return s;
100 }
101
102 TfToken
HdStPackageSimpleLightingShader()103 HdStPackageSimpleLightingShader()
104 {
105 static TfToken simpleLightingShader =
106 _GetShaderPath("simpleLightingShader.glslfx");
107 return simpleLightingShader;
108 }
109
110 PXR_NAMESPACE_CLOSE_SCOPE
111