Path: blob/master/servers/rendering/renderer_rd/effects/bokeh_dof.h
21520 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/pipeline_deferred_rd.h"34#include "servers/rendering/renderer_rd/shaders/effects/bokeh_dof.glsl.gen.h"35#include "servers/rendering/renderer_rd/shaders/effects/bokeh_dof_raster.glsl.gen.h"3637namespace RendererRD {3839class BokehDOF {40private:41bool prefer_raster_effects;4243struct BokehPushConstant {44uint32_t size[2];45float z_far;46float z_near;4748uint32_t orthogonal;49float blur_size;50float blur_scale;51uint32_t steps;5253uint32_t blur_near_active;54float blur_near_begin;55float blur_near_end;56uint32_t blur_far_active;5758float blur_far_begin;59float blur_far_end;60uint32_t second_pass;61uint32_t half_size;6263uint32_t use_jitter;64float jitter_seed;65uint32_t use_physical_near;66uint32_t use_physical_far;6768float blur_size_near;69float blur_size_far;70uint32_t pad[2];71};7273enum BokehMode {74BOKEH_GEN_BLUR_SIZE,75BOKEH_GEN_BOKEH_BOX,76BOKEH_GEN_BOKEH_BOX_NOWEIGHT,77BOKEH_GEN_BOKEH_HEXAGONAL,78BOKEH_GEN_BOKEH_HEXAGONAL_NOWEIGHT,79BOKEH_GEN_BOKEH_CIRCULAR,80BOKEH_COMPOSITE,81BOKEH_MAX82};8384struct Bokeh {85BokehPushConstant push_constant;86BokehDofShaderRD compute_shader;87BokehDofRasterShaderRD raster_shader;88RID shader_version;89PipelineDeferredRD compute_pipelines[BOKEH_MAX];90PipelineCacheRD raster_pipelines[BOKEH_MAX];91} bokeh;9293public:94struct BokehBuffers {95// bokeh buffers9697// textures98Size2i base_texture_size;99RID base_texture;100RID depth_texture;101RID secondary_texture;102RID half_texture[2];103104// raster only105RID base_fb;106RID secondary_fb; // with weights107RID half_fb[2]; // with weights108RID base_weight_fb;109RID weight_texture[4];110};111112BokehDOF(bool p_prefer_raster_effects);113~BokehDOF();114115void bokeh_dof_compute(const BokehBuffers &p_buffers, RID p_camera_attributes, float p_cam_znear, float p_cam_zfar, bool p_cam_orthogonal);116void bokeh_dof_raster(const BokehBuffers &p_buffers, RID p_camera_attributes, float p_cam_znear, float p_cam_zfar, bool p_cam_orthogonal);117};118119} // namespace RendererRD120121122