12 #ifndef hifi_render_BlurTask_h
13 #define hifi_render_BlurTask_h
17 #include "BlurTask_shared.slh"
25 void setWidthHeight(
int width,
int height,
bool isStereo);
27 void setTexcoordTransform(
const glm::vec4 texcoordTransformViewport);
29 void setFilterRadiusScale(
float scale);
30 void setFilterNumTaps(
int count);
32 void setFilterTap(
int index,
float offset,
float value);
33 void setFilterGaussianTaps(
int numHalfTaps,
float sigma = 1.47f);
34 void setOutputAlpha(
float value);
36 void setDepthPerspective(
float oneOverTan2FOV);
37 void setDepthThreshold(
float threshold);
39 void setLinearDepthPosFar(
float farPosDepth);
45 glm::vec4 resolutionInfo{ 0.0f, 0.0f, 0.0f, 0.0f };
48 glm::vec4 texcoordTransform{ 0.0f, 0.0f, 1.0f, 1.0f };
51 glm::vec4 filterInfo{ 1.0f, 0.0f, 0.0f, 0.0f };
54 glm::vec4 depthInfo{ 1.0f, 0.0f, 0.0f, 0.0f };
57 glm::vec4 stereoInfo{ 0.0f };
60 glm::vec4 linearDepthInfo{ 0.0f };
63 glm::vec2 filterTaps[BLUR_MAX_NUM_TAPS];
67 gpu::BufferView _parametersBuffer;
71 using BlurParamsPointer = std::shared_ptr<BlurParams>;
73 class BlurInOutResource {
75 BlurInOutResource() {}
76 BlurInOutResource(
bool generateOutputFramebuffer,
unsigned int downsampleFactor);
79 gpu::TexturePointer sourceTexture;
80 gpu::FramebufferPointer blurringFramebuffer;
81 gpu::TexturePointer blurringTexture;
82 gpu::FramebufferPointer finalFramebuffer;
85 bool updateResources(
const gpu::FramebufferPointer& sourceFramebuffer, Resources& resources);
87 gpu::FramebufferPointer _blurredFramebuffer;
90 gpu::FramebufferPointer _outputFramebuffer;
91 unsigned int _downsampleFactor{ 1U };
92 bool _generateOutputFramebuffer{
false };
96 class BlurGaussianConfig :
public Job::Config {
98 Q_PROPERTY(
bool enabled WRITE setEnabled READ isEnabled NOTIFY dirty)
99 Q_PROPERTY(
float filterScale MEMBER filterScale NOTIFY dirty)
100 Q_PROPERTY(
float mix MEMBER mix NOTIFY dirty)
103 BlurGaussianConfig() : Job::Config(true) {}
105 float filterScale{ 0.2f };
117 using Inputs = VaryingSet5<gpu::FramebufferPointer, bool, unsigned int, int, float>;
118 using Config = BlurGaussianConfig;
119 using JobModel = Job::ModelIO<BlurGaussian, Inputs, gpu::FramebufferPointer, Config>;
123 void configure(
const Config& config);
124 void run(
const RenderContextPointer& renderContext,
const Inputs& inputs, gpu::FramebufferPointer& blurredFramebuffer);
126 BlurParamsPointer getParameters()
const {
return _parameters; }
130 BlurParamsPointer _parameters;
132 gpu::PipelinePointer _blurVPipeline;
133 gpu::PipelinePointer _blurHPipeline;
135 gpu::PipelinePointer getBlurVPipeline();
136 gpu::PipelinePointer getBlurHPipeline();
138 BlurInOutResource _inOutResources;
141 class BlurGaussianDepthAwareConfig :
public BlurGaussianConfig {
143 Q_PROPERTY(
float depthThreshold MEMBER depthThreshold NOTIFY dirty)
145 BlurGaussianDepthAwareConfig() : BlurGaussianConfig() {}
147 float depthThreshold{ 1.0f };
153 class BlurGaussianDepthAware {
155 using Inputs = VaryingSet2<gpu::FramebufferPointer, gpu::TexturePointer>;
156 using Config = BlurGaussianDepthAwareConfig;
157 using JobModel = Job::ModelIO<BlurGaussianDepthAware, Inputs, gpu::FramebufferPointer, Config>;
159 BlurGaussianDepthAware(
bool generateNewOutput =
false,
const BlurParamsPointer& params = BlurParamsPointer());
161 void configure(
const Config& config);
162 void run(
const RenderContextPointer& renderContext,
const Inputs& SourceAndDepth, gpu::FramebufferPointer& blurredFramebuffer);
164 const BlurParamsPointer& getParameters()
const {
return _parameters; }
166 gpu::PipelinePointer getBlurVPipeline();
167 gpu::PipelinePointer getBlurHPipeline();
170 gpu::PipelinePointer _blurVPipeline;
171 gpu::PipelinePointer _blurHPipeline;
173 BlurInOutResource _inOutResources;
174 BlurParamsPointer _parameters;