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::VaryingSet3<render::ShapeBounds, HighlightResourcesPointer, glm::vec2>;
118 using Outputs = glm::ivec4;
119 using JobModel = render::Job::ModelIO<DrawHighlightMask, Inputs, Outputs>;
121 DrawHighlightMask(
unsigned int highlightIndex, render::ShapePlumberPointer shapePlumber, HighlightSharedParametersPointer parameters);
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;
132 static gpu::PipelinePointer _stencilMaskPipeline;
133 static gpu::PipelinePointer _stencilMaskFillPipeline;
136 class DrawHighlight {
139 using Inputs = render::VaryingSet5<DeferredFrameTransformPointer, HighlightResourcesPointer, DeferredFramebufferPointer, glm::ivec4, gpu::FramebufferPointer>;
140 using Config = render::Job::Config;
141 using JobModel = render::Job::ModelI<DrawHighlight, Inputs, Config>;
143 DrawHighlight(
unsigned int highlightIndex, HighlightSharedParametersPointer parameters);
145 void run(
const render::RenderContextPointer& renderContext,
const Inputs& inputs);
149 #include "Highlight_shared.slh"
151 using HighlightConfigurationBuffer = gpu::StructBuffer<HighlightParameters>;
153 static const gpu::PipelinePointer& getPipeline(
const render::HighlightStyle& style);
155 static gpu::PipelinePointer _pipeline;
156 static gpu::PipelinePointer _pipelineFilled;
158 unsigned int _highlightPassIndex;
159 HighlightParameters _parameters;
160 HighlightSharedParametersPointer _sharedParameters;
161 HighlightConfigurationBuffer _configuration;
164 class DebugHighlightConfig :
public render::Job::Config {
166 Q_PROPERTY(
bool viewMask MEMBER viewMask NOTIFY dirty)
169 bool viewMask {
false };
175 class DebugHighlight {
177 using Inputs = render::VaryingSet4<HighlightResourcesPointer, glm::ivec4, glm::vec2, gpu::FramebufferPointer>;
178 using Config = DebugHighlightConfig;
179 using JobModel = render::Job::ModelI<DebugHighlight, Inputs, Config>;
184 void configure(
const Config& config);
185 void run(
const render::RenderContextPointer& renderContext,
const Inputs& inputs);
189 gpu::PipelinePointer _depthPipeline;
190 int _geometryDepthId{ 0 };
191 bool _isDisplayEnabled{
false };
193 const gpu::PipelinePointer& getDepthPipeline();
194 void initializePipelines();
197 class DrawHighlightTask {
200 using Inputs = render::VaryingSet5<RenderFetchCullSortTask::BucketList, DeferredFramebufferPointer, gpu::FramebufferPointer, DeferredFrameTransformPointer, glm::vec2>;
201 using Config = render::Task::Config;
202 using JobModel = render::Task::ModelI<DrawHighlightTask, Inputs, Config>;
206 void configure(
const Config& config);
207 void build(JobModel& task,
const render::Varying& inputs, render::Varying& outputs);
210 static const render::Varying addSelectItemJobs(JobModel& task,
const render::Varying& selectionName,
const RenderFetchCullSortTask::BucketList& items);
214 class AppendNonMetaOutlines {
216 using Inputs = render::VaryingSet2<render::ItemIDs, render::ItemBounds>;
217 using Outputs = render::ItemIDs;
218 using JobModel = render::Job::ModelIO<AppendNonMetaOutlines, Inputs, Outputs>;
220 AppendNonMetaOutlines() {}
222 void run(
const render::RenderContextPointer& renderContext,
const Inputs& inputs, Outputs& outputs);
225 class HighlightCleanup {
227 using Inputs = render::VaryingSet2<std::vector<render::HighlightStage::Index>, render::Args::RenderMode>;
228 using JobModel = render::Job::ModelI<HighlightCleanup, Inputs>;
230 HighlightCleanup() {}
232 void run(
const render::RenderContextPointer& renderContext,
const Inputs& inputs);