13 #ifndef hifi_render_utils_HighlightEffect_h
14 #define hifi_render_utils_HighlightEffect_h
16 #include <render/Engine.h>
17 #include <render/HighlightStage.h>
18 #include <render/RenderFetchCullSortTask.h>
20 #include "DeferredFramebuffer.h"
21 #include "DeferredFrameTransform.h"
23 class HighlightResources {
27 gpu::FramebufferPointer getDepthFramebuffer();
28 gpu::TexturePointer getDepthTexture();
30 gpu::FramebufferPointer getColorFramebuffer();
33 void update(
const gpu::FramebufferPointer& primaryFrameBuffer);
34 const glm::ivec2& getSourceFrameSize()
const {
return _frameSize; }
38 gpu::FramebufferPointer _depthFrameBuffer;
39 gpu::FramebufferPointer _colorFrameBuffer;
40 gpu::TexturePointer _depthStencilTexture;
42 glm::ivec2 _frameSize;
44 void allocateColorBuffer(
const gpu::FramebufferPointer& primaryFrameBuffer);
45 void allocateDepthBuffer(
const gpu::FramebufferPointer& primaryFrameBuffer);
48 using HighlightResourcesPointer = std::shared_ptr<HighlightResources>;
50 class HighlightSharedParameters {
57 HighlightSharedParameters();
59 std::array<render::HighlightStage::Index, MAX_PASS_COUNT> _highlightIds;
61 static float getBlurPixelWidth(
const render::HighlightStyle& style,
int frameBufferHeight);
64 using HighlightSharedParametersPointer = std::shared_ptr<HighlightSharedParameters>;
66 class PrepareDrawHighlight {
68 using Inputs = gpu::FramebufferPointer;
69 using Outputs = render::VaryingSet2<HighlightResourcesPointer, render::Args::RenderMode>;
70 using JobModel = render::Job::ModelIO<PrepareDrawHighlight, Inputs, Outputs>;
72 PrepareDrawHighlight();
74 void run(
const render::RenderContextPointer& renderContext,
const Inputs& inputs, Outputs& outputs);
78 HighlightResourcesPointer _resources;
82 class SelectionToHighlight {
85 using Inputs = render::VaryingSet2<render::ItemBounds, gpu::FramebufferPointer>;
86 using Outputs = render::VaryingSet2<std::vector<std::string>, std::vector<render::HighlightStage::Index>>;
87 using JobModel = render::Job::ModelIO<SelectionToHighlight, Inputs, Outputs>;
89 SelectionToHighlight(HighlightSharedParametersPointer parameters) : _sharedParameters{ parameters } {}
91 void run(
const render::RenderContextPointer& renderContext,
const Inputs& inputs, Outputs& outputs);
95 HighlightSharedParametersPointer _sharedParameters;
98 class ExtractSelectionName {
101 using Inputs = std::vector<std::string>;
102 using Outputs = std::string;
103 using JobModel = render::Job::ModelIO<ExtractSelectionName, Inputs, Outputs>;
105 ExtractSelectionName(
unsigned int highlightIndex) : _highlightPassIndex{ highlightIndex } {}
107 void run(
const render::RenderContextPointer& renderContext,
const Inputs& inputs, Outputs& outputs);
111 unsigned int _highlightPassIndex;
115 class DrawHighlightMask {
117 using Inputs = render::VaryingSet2<render::ShapeBounds, HighlightResourcesPointer>;
118 using Outputs = glm::ivec4;
119 using JobModel = render::Job::ModelIO<DrawHighlightMask, Inputs, Outputs>;
121 DrawHighlightMask(
unsigned int highlightIndex, render::ShapePlumberPointer shapePlumber, HighlightSharedParametersPointer parameters, uint transformSlot);
123 void run(
const render::RenderContextPointer& renderContext,
const Inputs& inputs, Outputs& outputs);
126 unsigned int _highlightPassIndex;
127 render::ShapePlumberPointer _shapePlumber;
128 HighlightSharedParametersPointer _sharedParameters;
129 gpu::BufferPointer _boundsBuffer;
130 gpu::StructBuffer<glm::vec2> _outlineWidth;
131 uint _transformSlot { 0 };
133 static gpu::PipelinePointer _stencilMaskPipeline;
134 static gpu::PipelinePointer _stencilMaskFillPipeline;
137 class DrawHighlight {
140 using Inputs = render::VaryingSet4<DeferredFrameTransformPointer, HighlightResourcesPointer, DeferredFramebufferPointer, glm::ivec4>;
141 using Config = render::Job::Config;
142 using JobModel = render::Job::ModelI<DrawHighlight, Inputs, Config>;
144 DrawHighlight(
unsigned int highlightIndex, HighlightSharedParametersPointer parameters);
146 void run(
const render::RenderContextPointer& renderContext,
const Inputs& inputs);
150 #include "Highlight_shared.slh"
152 using HighlightConfigurationBuffer = gpu::StructBuffer<HighlightParameters>;
154 static const gpu::PipelinePointer& getPipeline(
const render::HighlightStyle& style);
156 static gpu::PipelinePointer _pipeline;
157 static gpu::PipelinePointer _pipelineFilled;
159 unsigned int _highlightPassIndex;
160 HighlightParameters _parameters;
161 HighlightSharedParametersPointer _sharedParameters;
162 HighlightConfigurationBuffer _configuration;
165 class DebugHighlightConfig :
public render::Job::Config {
167 Q_PROPERTY(
bool viewMask MEMBER viewMask NOTIFY dirty)
170 bool viewMask {
false };
176 class DebugHighlight {
178 using Inputs = render::VaryingSet2<HighlightResourcesPointer, glm::ivec4>;
179 using Config = DebugHighlightConfig;
180 using JobModel = render::Job::ModelI<DebugHighlight, Inputs, Config>;
182 DebugHighlight(uint transformSlot);
185 void configure(
const Config& config);
186 void run(
const render::RenderContextPointer& renderContext,
const Inputs& inputs);
190 static gpu::PipelinePointer _depthPipeline;
191 int _geometryDepthId { 0 };
192 bool _isDisplayEnabled {
false };
193 uint _transformSlot { 0 };
195 static gpu::PipelinePointer& getDepthPipeline();
196 static void initializePipelines();
199 class DrawHighlightTask {
202 using Inputs = render::VaryingSet4<RenderFetchCullSortTask::BucketList, DeferredFramebufferPointer, gpu::FramebufferPointer, DeferredFrameTransformPointer>;
using Config = render::Task::Config;
203 using JobModel = render::Task::ModelI<DrawHighlightTask, Inputs, Config>;
207 void configure(
const Config& config);
208 void build(JobModel& task,
const render::Varying& inputs, render::Varying& outputs, uint transformSlot);
211 static const render::Varying addSelectItemJobs(JobModel& task,
const render::Varying& selectionName,
const RenderFetchCullSortTask::BucketList& items);
215 class AppendNonMetaOutlines {
217 using Inputs = render::VaryingSet2<render::ItemIDs, render::ItemBounds>;
218 using Outputs = render::ItemIDs;
219 using JobModel = render::Job::ModelIO<AppendNonMetaOutlines, Inputs, Outputs>;
221 AppendNonMetaOutlines() {}
223 void run(
const render::RenderContextPointer& renderContext,
const Inputs& inputs, Outputs& outputs);
226 class HighlightCleanup {
228 using Inputs = render::VaryingSet2<std::vector<render::HighlightStage::Index>, render::Args::RenderMode>;
229 using JobModel = render::Job::ModelI<HighlightCleanup, Inputs>;
231 HighlightCleanup() {}
233 void run(
const render::RenderContextPointer& renderContext,
const Inputs& inputs);