Loading...
Searching...
No Matches
domeLightComputations.h
1//
2// Copyright 2019 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_HD_ST_DOME_LIGHT_COMPUTATIONS_H
8#define PXR_IMAGING_HD_ST_DOME_LIGHT_COMPUTATIONS_H
9
10#include "pxr/pxr.h"
11#include "pxr/imaging/hdSt/api.h"
12#include "pxr/imaging/hdSt/computation.h"
13
14#include "pxr/base/gf/vec3i.h"
15#include "pxr/base/tf/token.h"
16
17PXR_NAMESPACE_OPEN_SCOPE
18
22
23using HdStSimpleLightingShaderPtr =
24 std::weak_ptr<class HdStSimpleLightingShader>;
25struct HgiTextureDesc;
26
37class HdSt_DomeLightComputationGPU : public HdStComputation
38{
39public:
41 HDST_API
42 HdSt_DomeLightComputationGPU(
43 // Name of computation shader to use, also used as texture name.
44 const TfToken & shaderToken,
45 // Whether to use the dome light cubemap texture or the dome light
46 // latlong texture as the input for the computation.
47 bool useCubemapAsSourceTexture,
48 // Lighting shader for accessing any referenced textures.
49 HdStSimpleLightingShaderPtr const &lightingShader,
50 // Dimension of the dome light cubemap texture. NOTE: this is only used
51 // when the latlong texture is input for the compuation.
52 unsigned int computedCubeMapDim,
53 // Number of mip levels.
54 unsigned int numLevels = 1,
55 // Level to be filled (0 means also to allocate texture).
56 unsigned int level = 0,
57 // Roughness associated with the texture level.
58 float roughness = -1.0);
59
60 HDST_API
61 void GetBufferSpecs(HdBufferSpecVector *specs) const override {}
62
63 HDST_API
64 void Execute(HdBufferArrayRangeSharedPtr const &range,
65 HdResourceRegistry *resourceRegistry) override;
66
70 int GetNumOutputElements() const override { return 0; }
71
72private:
73 const TfToken _shaderToken;
74 const bool _useCubemapAsSourceTexture;
75 const HdStSimpleLightingShaderPtr _lightingShader;
76 const unsigned int _computedCubeMapDim;
77 const unsigned int _numLevels;
78 const unsigned int _level;
79 const float _roughness;
80};
81
87class HdSt_DomeLightMipmapComputationGPU : public HdStComputation
88{
89public:
90 HDST_API
91 HdSt_DomeLightMipmapComputationGPU(
92 // Lighting shader for accessing textures.
93 HdStSimpleLightingShaderPtr const &lightingShader);
94
95 HDST_API
96 void GetBufferSpecs(HdBufferSpecVector *specs) const override {}
97
98 HDST_API
99 void Execute(HdBufferArrayRangeSharedPtr const &range,
100 HdResourceRegistry *resourceRegistry) override;
101
102 int GetNumOutputElements() const override { return 0; }
103
104private:
105 const HdStSimpleLightingShaderPtr _lightingShader;
106};
107
108// For the given 2D dome light texture, compute the resulting dimensions of
109// the cubemap.
110HDST_API
111int HdSt_ComputeDomeLightCubemapWidth(
112 const std::string& domeLightFilePath,
113 const HgiTextureDesc& domelightTextureDesc,
114 const unsigned int cubemapTargetMemoryMB);
115
116PXR_NAMESPACE_CLOSE_SCOPE
117
118#endif // PXR_IMAGING_HD_ST_DOME_LIGHT_COMPUTATIONS_H
A central registry for resources.
An interface class for GPU computation.
Definition: computation.h:36
virtual void Execute(HdBufferArrayRangeSharedPtr const &range, HdResourceRegistry *resourceRegistry)=0
Execute computation.
virtual void GetBufferSpecs(HdBufferSpecVector *specs) const =0
Add the buffer spec for this computation into given bufferspec vector.
virtual int GetNumOutputElements() const =0
Returns the size of its destination buffer (located by range argument of Execute()).
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Describes the properties needed to create a GPU texture.
Definition: texture.h:91
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...