Path: blob/master/servers/rendering/renderer_rd/effects/bokeh_dof.h
10279 views
/**************************************************************************/1/* bokeh_dof.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "servers/rendering/renderer_rd/pipeline_cache_rd.h"33#include "servers/rendering/renderer_rd/shaders/effects/bokeh_dof.glsl.gen.h"34#include "servers/rendering/renderer_rd/shaders/effects/bokeh_dof_raster.glsl.gen.h"3536namespace RendererRD {3738class BokehDOF {39private:40bool prefer_raster_effects;4142struct BokehPushConstant {43uint32_t size[2];44float z_far;45float z_near;4647uint32_t orthogonal;48float blur_size;49float blur_scale;50uint32_t steps;5152uint32_t blur_near_active;53float blur_near_begin;54float blur_near_end;55uint32_t blur_far_active;5657float blur_far_begin;58float blur_far_end;59uint32_t second_pass;60uint32_t half_size;6162uint32_t use_jitter;63float jitter_seed;64uint32_t use_physical_near;65uint32_t use_physical_far;6667float blur_size_near;68float blur_size_far;69uint32_t pad[2];70};7172enum BokehMode {73BOKEH_GEN_BLUR_SIZE,74BOKEH_GEN_BOKEH_BOX,75BOKEH_GEN_BOKEH_BOX_NOWEIGHT,76BOKEH_GEN_BOKEH_HEXAGONAL,77BOKEH_GEN_BOKEH_HEXAGONAL_NOWEIGHT,78BOKEH_GEN_BOKEH_CIRCULAR,79BOKEH_COMPOSITE,80BOKEH_MAX81};8283struct Bokeh {84BokehPushConstant push_constant;85BokehDofShaderRD compute_shader;86BokehDofRasterShaderRD raster_shader;87RID shader_version;88RID compute_pipelines[BOKEH_MAX];89PipelineCacheRD raster_pipelines[BOKEH_MAX];90} bokeh;9192public:93struct BokehBuffers {94// bokeh buffers9596// textures97Size2i base_texture_size;98RID base_texture;99RID depth_texture;100RID secondary_texture;101RID half_texture[2];102103// raster only104RID base_fb;105RID secondary_fb; // with weights106RID half_fb[2]; // with weights107RID base_weight_fb;108RID weight_texture[4];109};110111BokehDOF(bool p_prefer_raster_effects);112~BokehDOF();113114void bokeh_dof_compute(const BokehBuffers &p_buffers, RID p_camera_attributes, float p_cam_znear, float p_cam_zfar, bool p_cam_orthogonal);115void bokeh_dof_raster(const BokehBuffers &p_buffers, RID p_camera_attributes, float p_cam_znear, float p_cam_zfar, bool p_cam_orthogonal);116};117118} // namespace RendererRD119120121