2019-11-05 11:01:00 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* rasterizer_effects_rd.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/*************************************************************************/
|
2020-02-11 13:01:43 +00:00
|
|
|
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
2019-11-05 11:01:00 +00:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2019-08-18 22:40:52 +00:00
|
|
|
#ifndef RASTERIZER_EFFECTS_RD_H
|
|
|
|
#define RASTERIZER_EFFECTS_RD_H
|
2019-07-27 13:23:24 +00:00
|
|
|
|
2019-08-26 20:43:58 +00:00
|
|
|
#include "core/math/camera_matrix.h"
|
2020-03-27 18:21:27 +00:00
|
|
|
#include "servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h"
|
|
|
|
#include "servers/rendering/rasterizer_rd/shaders/bokeh_dof.glsl.gen.h"
|
|
|
|
#include "servers/rendering/rasterizer_rd/shaders/copy.glsl.gen.h"
|
2020-04-11 17:43:12 +00:00
|
|
|
#include "servers/rendering/rasterizer_rd/shaders/copy_to_fb.glsl.gen.h"
|
|
|
|
#include "servers/rendering/rasterizer_rd/shaders/cube_to_dp.glsl.gen.h"
|
2020-03-27 18:21:27 +00:00
|
|
|
#include "servers/rendering/rasterizer_rd/shaders/cubemap_downsampler.glsl.gen.h"
|
|
|
|
#include "servers/rendering/rasterizer_rd/shaders/cubemap_filter.glsl.gen.h"
|
|
|
|
#include "servers/rendering/rasterizer_rd/shaders/cubemap_roughness.glsl.gen.h"
|
|
|
|
#include "servers/rendering/rasterizer_rd/shaders/luminance_reduce.glsl.gen.h"
|
2020-06-25 13:33:28 +00:00
|
|
|
#include "servers/rendering/rasterizer_rd/shaders/resolve.glsl.gen.h"
|
2020-03-27 18:21:27 +00:00
|
|
|
#include "servers/rendering/rasterizer_rd/shaders/roughness_limiter.glsl.gen.h"
|
2020-04-02 02:24:52 +00:00
|
|
|
#include "servers/rendering/rasterizer_rd/shaders/screen_space_reflection.glsl.gen.h"
|
|
|
|
#include "servers/rendering/rasterizer_rd/shaders/screen_space_reflection_filter.glsl.gen.h"
|
|
|
|
#include "servers/rendering/rasterizer_rd/shaders/screen_space_reflection_scale.glsl.gen.h"
|
|
|
|
#include "servers/rendering/rasterizer_rd/shaders/specular_merge.glsl.gen.h"
|
2020-03-27 18:21:27 +00:00
|
|
|
#include "servers/rendering/rasterizer_rd/shaders/ssao.glsl.gen.h"
|
|
|
|
#include "servers/rendering/rasterizer_rd/shaders/ssao_blur.glsl.gen.h"
|
|
|
|
#include "servers/rendering/rasterizer_rd/shaders/ssao_minify.glsl.gen.h"
|
2020-04-04 02:42:26 +00:00
|
|
|
#include "servers/rendering/rasterizer_rd/shaders/subsurface_scattering.glsl.gen.h"
|
2020-03-27 18:21:27 +00:00
|
|
|
#include "servers/rendering/rasterizer_rd/shaders/tonemap.glsl.gen.h"
|
|
|
|
|
|
|
|
#include "servers/rendering_server.h"
|
2019-07-27 13:23:24 +00:00
|
|
|
|
2019-08-18 22:40:52 +00:00
|
|
|
class RasterizerEffectsRD {
|
2020-04-11 17:43:12 +00:00
|
|
|
enum CopyMode {
|
|
|
|
COPY_MODE_GAUSSIAN_COPY,
|
|
|
|
COPY_MODE_GAUSSIAN_COPY_8BIT,
|
|
|
|
COPY_MODE_GAUSSIAN_GLOW,
|
|
|
|
COPY_MODE_GAUSSIAN_GLOW_AUTO_EXPOSURE,
|
|
|
|
COPY_MODE_SIMPLY_COPY,
|
|
|
|
COPY_MODE_SIMPLY_COPY_8BIT,
|
|
|
|
COPY_MODE_SIMPLY_COPY_DEPTH,
|
|
|
|
COPY_MODE_MIPMAP,
|
|
|
|
COPY_MODE_LINEARIZE_DEPTH,
|
2020-05-01 12:34:23 +00:00
|
|
|
COPY_MODE_CUBE_TO_PANORAMA,
|
|
|
|
COPY_MODE_CUBE_ARRAY_TO_PANORAMA,
|
2020-04-11 17:43:12 +00:00
|
|
|
COPY_MODE_MAX,
|
2019-07-27 13:23:24 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2020-04-11 17:43:12 +00:00
|
|
|
COPY_FLAG_HORIZONTAL = (1 << 0),
|
|
|
|
COPY_FLAG_USE_COPY_SECTION = (1 << 1),
|
|
|
|
COPY_FLAG_USE_ORTHOGONAL_PROJECTION = (1 << 2),
|
|
|
|
COPY_FLAG_DOF_NEAR_FIRST_TAP = (1 << 3),
|
|
|
|
COPY_FLAG_GLOW_FIRST_PASS = (1 << 4),
|
|
|
|
COPY_FLAG_FLIP_Y = (1 << 5),
|
|
|
|
COPY_FLAG_FORCE_LUMINANCE = (1 << 6),
|
|
|
|
COPY_FLAG_ALL_SOURCE = (1 << 7)
|
2019-07-27 13:23:24 +00:00
|
|
|
};
|
|
|
|
|
2020-04-11 17:43:12 +00:00
|
|
|
struct CopyPushConstant {
|
|
|
|
int32_t section[4];
|
|
|
|
int32_t target[2];
|
2019-07-27 13:23:24 +00:00
|
|
|
uint32_t flags;
|
|
|
|
uint32_t pad;
|
2020-04-11 17:43:12 +00:00
|
|
|
// Glow.
|
2019-07-27 13:23:24 +00:00
|
|
|
float glow_strength;
|
|
|
|
float glow_bloom;
|
|
|
|
float glow_hdr_threshold;
|
|
|
|
float glow_hdr_scale;
|
2020-04-11 17:43:12 +00:00
|
|
|
|
2019-07-27 13:23:24 +00:00
|
|
|
float glow_exposure;
|
|
|
|
float glow_white;
|
|
|
|
float glow_luminance_cap;
|
|
|
|
float glow_auto_exposure_grey;
|
2020-04-11 17:43:12 +00:00
|
|
|
// DOF.
|
2019-07-27 13:23:24 +00:00
|
|
|
float camera_z_far;
|
|
|
|
float camera_z_near;
|
2020-04-11 17:43:12 +00:00
|
|
|
uint32_t pad2[2];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Copy {
|
|
|
|
CopyPushConstant push_constant;
|
|
|
|
CopyShaderRD shader;
|
|
|
|
RID shader_version;
|
|
|
|
RID pipelines[COPY_MODE_MAX];
|
|
|
|
|
|
|
|
} copy;
|
|
|
|
|
2020-04-14 03:05:21 +00:00
|
|
|
enum CopyToFBMode {
|
|
|
|
COPY_TO_FB_COPY,
|
2020-04-14 20:05:45 +00:00
|
|
|
COPY_TO_FB_COPY_PANORAMA_TO_DP,
|
2020-06-25 13:33:28 +00:00
|
|
|
COPY_TO_FB_COPY2,
|
2020-04-14 03:05:21 +00:00
|
|
|
COPY_TO_FB_MAX,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2020-04-11 17:43:12 +00:00
|
|
|
struct CopyToFbPushConstant {
|
|
|
|
float section[4];
|
|
|
|
float pixel_size[2];
|
|
|
|
uint32_t flip_y;
|
|
|
|
uint32_t use_section;
|
2020-04-14 03:05:21 +00:00
|
|
|
|
2020-04-11 17:43:12 +00:00
|
|
|
uint32_t force_luminance;
|
2020-04-14 03:05:21 +00:00
|
|
|
uint32_t alpha_to_zero;
|
2020-06-25 13:33:28 +00:00
|
|
|
uint32_t srgb;
|
|
|
|
uint32_t pad;
|
2019-07-27 13:23:24 +00:00
|
|
|
};
|
|
|
|
|
2020-04-11 17:43:12 +00:00
|
|
|
struct CopyToFb {
|
|
|
|
CopyToFbPushConstant push_constant;
|
|
|
|
CopyToFbShaderRD shader;
|
2019-07-27 13:23:24 +00:00
|
|
|
RID shader_version;
|
2020-04-14 03:05:21 +00:00
|
|
|
RenderPipelineVertexFormatCacheRD pipelines[COPY_TO_FB_MAX];
|
2019-07-27 13:23:24 +00:00
|
|
|
|
2020-04-11 17:43:12 +00:00
|
|
|
} copy_to_fb;
|
2019-07-27 13:23:24 +00:00
|
|
|
|
2019-08-26 20:43:58 +00:00
|
|
|
struct CubemapRoughnessPushConstant {
|
|
|
|
uint32_t face_id;
|
|
|
|
uint32_t sample_count;
|
|
|
|
float roughness;
|
|
|
|
uint32_t use_direct_write;
|
2020-03-01 01:16:50 +00:00
|
|
|
float face_size;
|
|
|
|
float pad[3];
|
2019-08-26 20:43:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct CubemapRoughness {
|
|
|
|
CubemapRoughnessPushConstant push_constant;
|
|
|
|
CubemapRoughnessShaderRD shader;
|
|
|
|
RID shader_version;
|
2020-03-20 00:32:19 +00:00
|
|
|
RID pipeline;
|
2019-08-26 20:43:58 +00:00
|
|
|
} roughness;
|
|
|
|
|
2019-08-27 18:27:35 +00:00
|
|
|
enum TonemapMode {
|
|
|
|
TONEMAP_MODE_NORMAL,
|
|
|
|
TONEMAP_MODE_BICUBIC_GLOW_FILTER,
|
|
|
|
TONEMAP_MODE_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TonemapPushConstant {
|
|
|
|
float bcs[3];
|
|
|
|
uint32_t use_bcs;
|
|
|
|
|
|
|
|
uint32_t use_glow;
|
|
|
|
uint32_t use_auto_exposure;
|
|
|
|
uint32_t use_color_correction;
|
|
|
|
uint32_t tonemapper;
|
|
|
|
|
|
|
|
uint32_t glow_texture_size[2];
|
|
|
|
|
|
|
|
float glow_intensity;
|
|
|
|
uint32_t glow_level_flags;
|
|
|
|
uint32_t glow_mode;
|
|
|
|
|
|
|
|
float exposure;
|
|
|
|
float white;
|
|
|
|
float auto_exposure_grey;
|
2020-04-12 04:49:10 +00:00
|
|
|
|
|
|
|
float pixel_size[2];
|
|
|
|
uint32_t use_fxaa;
|
|
|
|
uint32_t pad;
|
2019-08-27 18:27:35 +00:00
|
|
|
};
|
|
|
|
|
2020-04-11 17:43:12 +00:00
|
|
|
/* tonemap actually writes to a framebuffer, which is
|
|
|
|
* better to do using the raster pipeline rather than
|
|
|
|
* comptute, as that framebuffer might be in different formats
|
|
|
|
*/
|
2019-08-27 18:27:35 +00:00
|
|
|
struct Tonemap {
|
|
|
|
TonemapPushConstant push_constant;
|
|
|
|
TonemapShaderRD shader;
|
|
|
|
RID shader_version;
|
|
|
|
RenderPipelineVertexFormatCacheRD pipelines[TONEMAP_MODE_MAX];
|
|
|
|
} tonemap;
|
|
|
|
|
2020-01-12 01:26:52 +00:00
|
|
|
enum LuminanceReduceMode {
|
|
|
|
LUMINANCE_REDUCE_READ,
|
|
|
|
LUMINANCE_REDUCE,
|
|
|
|
LUMINANCE_REDUCE_WRITE,
|
|
|
|
LUMINANCE_REDUCE_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
struct LuminanceReducePushConstant {
|
|
|
|
int32_t source_size[2];
|
|
|
|
float max_luminance;
|
|
|
|
float min_luminance;
|
|
|
|
float exposure_adjust;
|
|
|
|
float pad[3];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct LuminanceReduce {
|
|
|
|
LuminanceReducePushConstant push_constant;
|
|
|
|
LuminanceReduceShaderRD shader;
|
|
|
|
RID shader_version;
|
|
|
|
RID pipelines[LUMINANCE_REDUCE_MAX];
|
|
|
|
} luminance_reduce;
|
|
|
|
|
2019-09-07 01:51:27 +00:00
|
|
|
struct CopyToDPPushConstant {
|
2020-04-11 17:43:12 +00:00
|
|
|
int32_t screen_size[2];
|
|
|
|
int32_t dest_offset[2];
|
2019-09-07 01:51:27 +00:00
|
|
|
float bias;
|
|
|
|
float z_far;
|
|
|
|
float z_near;
|
|
|
|
uint32_t z_flip;
|
|
|
|
};
|
|
|
|
|
2020-04-11 17:43:12 +00:00
|
|
|
struct CoptToDP {
|
|
|
|
CubeToDpShaderRD shader;
|
2019-09-07 01:51:27 +00:00
|
|
|
RID shader_version;
|
2020-04-11 17:43:12 +00:00
|
|
|
RID pipeline;
|
|
|
|
} cube_to_dp;
|
2019-09-07 01:51:27 +00:00
|
|
|
|
2020-01-13 18:37:24 +00:00
|
|
|
struct BokehPushConstant {
|
|
|
|
uint32_t size[2];
|
|
|
|
float z_far;
|
|
|
|
float z_near;
|
|
|
|
|
|
|
|
uint32_t orthogonal;
|
|
|
|
float blur_size;
|
|
|
|
float blur_scale;
|
2020-01-16 00:23:21 +00:00
|
|
|
uint32_t steps;
|
2020-01-13 18:37:24 +00:00
|
|
|
|
|
|
|
uint32_t blur_near_active;
|
|
|
|
float blur_near_begin;
|
|
|
|
float blur_near_end;
|
|
|
|
uint32_t blur_far_active;
|
2020-01-16 00:23:21 +00:00
|
|
|
|
2020-01-13 18:37:24 +00:00
|
|
|
float blur_far_begin;
|
|
|
|
float blur_far_end;
|
2020-01-16 00:23:21 +00:00
|
|
|
uint32_t second_pass;
|
|
|
|
uint32_t half_size;
|
|
|
|
|
|
|
|
uint32_t use_jitter;
|
|
|
|
float jitter_seed;
|
|
|
|
uint32_t pad[2];
|
2020-01-13 18:37:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum BokehMode {
|
|
|
|
BOKEH_GEN_BLUR_SIZE,
|
2020-01-16 00:23:21 +00:00
|
|
|
BOKEH_GEN_BOKEH_BOX,
|
|
|
|
BOKEH_GEN_BOKEH_HEXAGONAL,
|
|
|
|
BOKEH_GEN_BOKEH_CIRCULAR,
|
2020-01-13 18:37:24 +00:00
|
|
|
BOKEH_COMPOSITE,
|
|
|
|
BOKEH_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Bokeh {
|
|
|
|
BokehPushConstant push_constant;
|
|
|
|
BokehDofShaderRD shader;
|
|
|
|
RID shader_version;
|
|
|
|
RID pipelines[BOKEH_MAX];
|
|
|
|
} bokeh;
|
|
|
|
|
2020-01-25 10:18:55 +00:00
|
|
|
enum SSAOMode {
|
|
|
|
SSAO_MINIFY_FIRST,
|
|
|
|
SSAO_MINIFY_MIPMAP,
|
|
|
|
SSAO_GATHER_LOW,
|
|
|
|
SSAO_GATHER_MEDIUM,
|
|
|
|
SSAO_GATHER_HIGH,
|
|
|
|
SSAO_GATHER_ULTRA,
|
|
|
|
SSAO_GATHER_LOW_HALF,
|
|
|
|
SSAO_GATHER_MEDIUM_HALF,
|
|
|
|
SSAO_GATHER_HIGH_HALF,
|
|
|
|
SSAO_GATHER_ULTRA_HALF,
|
|
|
|
SSAO_BLUR_PASS,
|
|
|
|
SSAO_BLUR_PASS_HALF,
|
|
|
|
SSAO_BLUR_UPSCALE,
|
|
|
|
SSAO_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SSAOMinifyPushConstant {
|
|
|
|
float pixel_size[2];
|
|
|
|
float z_far;
|
|
|
|
float z_near;
|
|
|
|
int32_t source_size[2];
|
|
|
|
uint32_t orthogonal;
|
|
|
|
uint32_t pad;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SSAOGatherPushConstant {
|
|
|
|
int32_t screen_size[2];
|
|
|
|
float z_far;
|
|
|
|
float z_near;
|
|
|
|
|
|
|
|
uint32_t orthogonal;
|
|
|
|
float intensity_div_r6;
|
|
|
|
float radius;
|
|
|
|
float bias;
|
|
|
|
|
|
|
|
float proj_info[4];
|
|
|
|
float pixel_size[2];
|
|
|
|
float proj_scale;
|
|
|
|
uint32_t pad;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SSAOBlurPushConstant {
|
|
|
|
float edge_sharpness;
|
|
|
|
int32_t filter_scale;
|
|
|
|
float z_far;
|
|
|
|
float z_near;
|
|
|
|
uint32_t orthogonal;
|
|
|
|
uint32_t pad[3];
|
|
|
|
int32_t axis[2];
|
|
|
|
int32_t screen_size[2];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SSAO {
|
|
|
|
SSAOMinifyPushConstant minify_push_constant;
|
|
|
|
SsaoMinifyShaderRD minify_shader;
|
|
|
|
RID minify_shader_version;
|
|
|
|
|
|
|
|
SSAOGatherPushConstant gather_push_constant;
|
|
|
|
SsaoShaderRD gather_shader;
|
|
|
|
RID gather_shader_version;
|
|
|
|
|
|
|
|
SSAOBlurPushConstant blur_push_constant;
|
|
|
|
SsaoBlurShaderRD blur_shader;
|
|
|
|
RID blur_shader_version;
|
|
|
|
|
|
|
|
RID pipelines[SSAO_MAX];
|
|
|
|
} ssao;
|
|
|
|
|
2020-01-26 23:09:40 +00:00
|
|
|
struct RoughnessLimiterPushConstant {
|
|
|
|
int32_t screen_size[2];
|
|
|
|
float curve;
|
|
|
|
uint32_t pad;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RoughnessLimiter {
|
|
|
|
RoughnessLimiterPushConstant push_constant;
|
|
|
|
RoughnessLimiterShaderRD shader;
|
|
|
|
RID shader_version;
|
|
|
|
RID pipeline;
|
|
|
|
|
|
|
|
} roughness_limiter;
|
|
|
|
|
2020-02-20 23:27:34 +00:00
|
|
|
struct CubemapDownsamplerPushConstant {
|
|
|
|
uint32_t face_size;
|
|
|
|
float pad[3];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CubemapDownsampler {
|
|
|
|
CubemapDownsamplerPushConstant push_constant;
|
|
|
|
CubemapDownsamplerShaderRD shader;
|
|
|
|
RID shader_version;
|
2020-03-20 00:32:19 +00:00
|
|
|
RID pipeline;
|
2020-02-20 23:27:34 +00:00
|
|
|
|
|
|
|
} cubemap_downsampler;
|
|
|
|
|
|
|
|
enum CubemapFilterMode {
|
|
|
|
FILTER_MODE_HIGH_QUALITY,
|
|
|
|
FILTER_MODE_LOW_QUALITY,
|
|
|
|
FILTER_MODE_HIGH_QUALITY_ARRAY,
|
|
|
|
FILTER_MODE_LOW_QUALITY_ARRAY,
|
|
|
|
FILTER_MODE_MAX,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CubemapFilter {
|
|
|
|
CubemapFilterShaderRD shader;
|
|
|
|
RID shader_version;
|
|
|
|
RID pipelines[FILTER_MODE_MAX];
|
|
|
|
RID uniform_set;
|
2020-02-28 17:06:22 +00:00
|
|
|
RID image_uniform_set;
|
2020-02-20 23:27:34 +00:00
|
|
|
RID coefficient_buffer;
|
|
|
|
bool use_high_quality;
|
|
|
|
|
|
|
|
} filter;
|
|
|
|
|
2020-03-20 00:32:19 +00:00
|
|
|
struct SkyPushConstant {
|
|
|
|
float orientation[12];
|
|
|
|
float proj[4];
|
|
|
|
float position[3];
|
|
|
|
float multiplier;
|
|
|
|
float time;
|
|
|
|
float pad[3];
|
|
|
|
};
|
|
|
|
|
2020-04-02 02:24:52 +00:00
|
|
|
enum SpecularMergeMode {
|
|
|
|
SPECULAR_MERGE_ADD,
|
|
|
|
SPECULAR_MERGE_SSR,
|
|
|
|
SPECULAR_MERGE_ADDITIVE_ADD,
|
|
|
|
SPECULAR_MERGE_ADDITIVE_SSR,
|
|
|
|
SPECULAR_MERGE_MAX
|
|
|
|
};
|
|
|
|
|
2020-04-11 17:43:12 +00:00
|
|
|
/* Specular merge must be done using raster, rather than compute
|
|
|
|
* because it must continue the existing color buffer
|
|
|
|
*/
|
|
|
|
|
2020-04-02 02:24:52 +00:00
|
|
|
struct SpecularMerge {
|
|
|
|
SpecularMergeShaderRD shader;
|
|
|
|
RID shader_version;
|
|
|
|
RenderPipelineVertexFormatCacheRD pipelines[SPECULAR_MERGE_MAX];
|
|
|
|
|
|
|
|
} specular_merge;
|
|
|
|
|
|
|
|
enum ScreenSpaceReflectionMode {
|
|
|
|
SCREEN_SPACE_REFLECTION_NORMAL,
|
|
|
|
SCREEN_SPACE_REFLECTION_ROUGH,
|
|
|
|
SCREEN_SPACE_REFLECTION_MAX,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ScreenSpaceReflectionPushConstant {
|
|
|
|
float proj_info[4];
|
|
|
|
|
|
|
|
int32_t screen_size[2];
|
|
|
|
float camera_z_near;
|
|
|
|
float camera_z_far;
|
|
|
|
|
|
|
|
int32_t num_steps;
|
|
|
|
float depth_tolerance;
|
|
|
|
float distance_fade;
|
|
|
|
float curve_fade_in;
|
|
|
|
|
|
|
|
uint32_t orthogonal;
|
|
|
|
float filter_mipmap_levels;
|
|
|
|
uint32_t use_half_res;
|
|
|
|
uint8_t metallic_mask[4];
|
|
|
|
|
|
|
|
float projection[16];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ScreenSpaceReflection {
|
|
|
|
ScreenSpaceReflectionPushConstant push_constant;
|
|
|
|
ScreenSpaceReflectionShaderRD shader;
|
|
|
|
RID shader_version;
|
|
|
|
RID pipelines[SCREEN_SPACE_REFLECTION_MAX];
|
|
|
|
|
|
|
|
} ssr;
|
|
|
|
|
|
|
|
struct ScreenSpaceReflectionFilterPushConstant {
|
|
|
|
float proj_info[4];
|
|
|
|
|
|
|
|
uint32_t orthogonal;
|
|
|
|
float edge_tolerance;
|
|
|
|
int32_t increment;
|
|
|
|
uint32_t pad;
|
|
|
|
|
|
|
|
int32_t screen_size[2];
|
|
|
|
uint32_t vertical;
|
|
|
|
uint32_t steps;
|
|
|
|
};
|
|
|
|
enum {
|
|
|
|
SCREEN_SPACE_REFLECTION_FILTER_HORIZONTAL,
|
|
|
|
SCREEN_SPACE_REFLECTION_FILTER_VERTICAL,
|
|
|
|
SCREEN_SPACE_REFLECTION_FILTER_MAX,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ScreenSpaceReflectionFilter {
|
|
|
|
ScreenSpaceReflectionFilterPushConstant push_constant;
|
|
|
|
ScreenSpaceReflectionFilterShaderRD shader;
|
|
|
|
RID shader_version;
|
|
|
|
RID pipelines[SCREEN_SPACE_REFLECTION_FILTER_MAX];
|
|
|
|
} ssr_filter;
|
|
|
|
|
|
|
|
struct ScreenSpaceReflectionScalePushConstant {
|
|
|
|
int32_t screen_size[2];
|
|
|
|
float camera_z_near;
|
|
|
|
float camera_z_far;
|
|
|
|
|
|
|
|
uint32_t orthogonal;
|
|
|
|
uint32_t filter;
|
|
|
|
uint32_t pad[2];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ScreenSpaceReflectionScale {
|
|
|
|
ScreenSpaceReflectionScalePushConstant push_constant;
|
|
|
|
ScreenSpaceReflectionScaleShaderRD shader;
|
|
|
|
RID shader_version;
|
|
|
|
RID pipeline;
|
|
|
|
} ssr_scale;
|
|
|
|
|
2020-04-04 02:42:26 +00:00
|
|
|
struct SubSurfaceScatteringPushConstant {
|
|
|
|
int32_t screen_size[2];
|
|
|
|
float camera_z_far;
|
|
|
|
float camera_z_near;
|
|
|
|
|
|
|
|
uint32_t vertical;
|
|
|
|
uint32_t orthogonal;
|
|
|
|
float unit_size;
|
|
|
|
float scale;
|
|
|
|
|
|
|
|
float depth_scale;
|
|
|
|
uint32_t pad[3];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SubSurfaceScattering {
|
|
|
|
SubSurfaceScatteringPushConstant push_constant;
|
|
|
|
SubsurfaceScatteringShaderRD shader;
|
|
|
|
RID shader_version;
|
|
|
|
RID pipelines[3]; //3 quality levels
|
|
|
|
} sss;
|
|
|
|
|
2020-06-25 13:33:28 +00:00
|
|
|
struct ResolvePushConstant {
|
|
|
|
int32_t screen_size[2];
|
|
|
|
int32_t samples;
|
|
|
|
uint32_t pad;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ResolveMode {
|
|
|
|
RESOLVE_MODE_GI,
|
|
|
|
RESOLVE_MODE_GI_GIPROBE,
|
|
|
|
RESOLVE_MODE_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Resolve {
|
|
|
|
ResolvePushConstant push_constant;
|
|
|
|
ResolveShaderRD shader;
|
|
|
|
RID shader_version;
|
|
|
|
RID pipelines[RESOLVE_MODE_MAX]; //3 quality levels
|
|
|
|
} resolve;
|
|
|
|
|
2019-07-27 13:23:24 +00:00
|
|
|
RID default_sampler;
|
2020-01-10 00:40:26 +00:00
|
|
|
RID default_mipmap_sampler;
|
2019-07-27 13:23:24 +00:00
|
|
|
RID index_buffer;
|
|
|
|
RID index_array;
|
|
|
|
|
|
|
|
Map<RID, RID> texture_to_uniform_set_cache;
|
|
|
|
|
2020-01-12 01:26:52 +00:00
|
|
|
Map<RID, RID> image_to_uniform_set_cache;
|
2020-04-02 02:24:52 +00:00
|
|
|
|
|
|
|
struct TexturePair {
|
|
|
|
RID texture1;
|
|
|
|
RID texture2;
|
|
|
|
_FORCE_INLINE_ bool operator<(const TexturePair &p_pair) const {
|
|
|
|
if (texture1 == p_pair.texture1) {
|
|
|
|
return texture2 < p_pair.texture2;
|
|
|
|
} else {
|
|
|
|
return texture1 < p_pair.texture1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-01-12 01:26:52 +00:00
|
|
|
Map<RID, RID> texture_to_compute_uniform_set_cache;
|
2020-04-02 02:24:52 +00:00
|
|
|
Map<TexturePair, RID> texture_pair_to_compute_uniform_set_cache;
|
|
|
|
Map<TexturePair, RID> image_pair_to_compute_uniform_set_cache;
|
2020-01-12 01:26:52 +00:00
|
|
|
|
|
|
|
RID _get_uniform_set_from_image(RID p_texture);
|
2020-01-10 00:40:26 +00:00
|
|
|
RID _get_uniform_set_from_texture(RID p_texture, bool p_use_mipmaps = false);
|
2020-01-12 01:26:52 +00:00
|
|
|
RID _get_compute_uniform_set_from_texture(RID p_texture, bool p_use_mipmaps = false);
|
2020-04-02 02:24:52 +00:00
|
|
|
RID _get_compute_uniform_set_from_texture_pair(RID p_texture, RID p_texture2, bool p_use_mipmaps = false);
|
|
|
|
RID _get_compute_uniform_set_from_image_pair(RID p_texture, RID p_texture2);
|
2019-07-27 13:23:24 +00:00
|
|
|
|
|
|
|
public:
|
2020-06-25 13:33:28 +00:00
|
|
|
void copy_to_fb_rect(RID p_source_rd_texture, RID p_dest_framebuffer, const Rect2i &p_rect, bool p_flip_y = false, bool p_force_luminance = false, bool p_alpha_to_zero = false, bool p_srgb = false, RID p_secondary = RID());
|
2020-04-11 17:43:12 +00:00
|
|
|
void copy_to_rect(RID p_source_rd_texture, RID p_dest_texture, const Rect2i &p_rect, bool p_flip_y = false, bool p_force_luminance = false, bool p_all_source = false, bool p_8_bit_dst = false);
|
2020-05-01 12:34:23 +00:00
|
|
|
void copy_cubemap_to_panorama(RID p_source_cube, RID p_dest_panorama, const Size2i &p_panorama_size, float p_lod, bool p_is_array);
|
2020-04-11 17:43:12 +00:00
|
|
|
void copy_depth_to_rect(RID p_source_rd_texture, RID p_dest_framebuffer, const Rect2i &p_rect, bool p_flip_y = false);
|
|
|
|
void copy_depth_to_rect_and_linearize(RID p_source_rd_texture, RID p_dest_texture, const Rect2i &p_rect, bool p_flip_y, float p_z_near, float p_z_far);
|
2020-04-14 20:05:45 +00:00
|
|
|
void copy_to_atlas_fb(RID p_source_rd_texture, RID p_dest_framebuffer, const Rect2 &p_uv_rect, RD::DrawListID p_draw_list, bool p_flip_y = false, bool p_panorama = false);
|
2020-04-11 17:43:12 +00:00
|
|
|
void gaussian_blur(RID p_source_rd_texture, RID p_texture, RID p_back_texture, const Rect2i &p_region, bool p_8bit_dst = false);
|
|
|
|
void gaussian_glow(RID p_source_rd_texture, RID p_texture, RID p_back_texture, const Size2i &p_size, float p_strength = 1.0, bool p_first_pass = false, float p_luminance_cap = 16.0, float p_exposure = 1.0, float p_bloom = 0.0, float p_hdr_bleed_treshold = 1.0, float p_hdr_bleed_scale = 1.0, RID p_auto_exposure = RID(), float p_auto_exposure_grey = 1.0);
|
2020-01-10 00:40:26 +00:00
|
|
|
|
2020-03-20 00:32:19 +00:00
|
|
|
void cubemap_roughness(RID p_source_rd_texture, RID p_dest_framebuffer, uint32_t p_face_id, uint32_t p_sample_count, float p_roughness, float p_size);
|
2020-04-11 17:43:12 +00:00
|
|
|
void make_mipmap(RID p_source_rd_texture, RID p_dest_texture, const Size2i &p_size);
|
|
|
|
void copy_cubemap_to_dp(RID p_source_rd_texture, RID p_dest_texture, const Rect2i &p_rect, float p_z_near, float p_z_far, float p_bias, bool p_dp_flip);
|
2020-01-12 01:26:52 +00:00
|
|
|
void luminance_reduction(RID p_source_texture, const Size2i p_source_size, const Vector<RID> p_reduce, RID p_prev_luminance, float p_min_luminance, float p_max_luminance, float p_adjust, bool p_set = false);
|
2020-03-27 18:21:27 +00:00
|
|
|
void bokeh_dof(RID p_base_texture, RID p_depth_texture, const Size2i &p_base_texture_size, RID p_secondary_texture, RID p_bokeh_texture1, RID p_bokeh_texture2, bool p_dof_far, float p_dof_far_begin, float p_dof_far_size, bool p_dof_near, float p_dof_near_begin, float p_dof_near_size, float p_bokeh_size, RS::DOFBokehShape p_bokeh_shape, RS::DOFBlurQuality p_quality, bool p_use_jitter, float p_cam_znear, float p_cam_zfar, bool p_cam_orthogonal);
|
2019-07-27 13:23:24 +00:00
|
|
|
|
2019-08-27 18:27:35 +00:00
|
|
|
struct TonemapSettings {
|
|
|
|
bool use_glow = false;
|
|
|
|
enum GlowMode {
|
|
|
|
GLOW_MODE_ADD,
|
|
|
|
GLOW_MODE_SCREEN,
|
|
|
|
GLOW_MODE_SOFTLIGHT,
|
2020-01-10 00:40:26 +00:00
|
|
|
GLOW_MODE_REPLACE,
|
|
|
|
GLOW_MODE_MIX
|
2019-08-27 18:27:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
GlowMode glow_mode = GLOW_MODE_ADD;
|
|
|
|
float glow_intensity = 1.0;
|
|
|
|
uint32_t glow_level_flags = 0;
|
|
|
|
Vector2i glow_texture_size;
|
|
|
|
bool glow_use_bicubic_upscale = false;
|
|
|
|
RID glow_texture;
|
|
|
|
|
2020-03-27 18:21:27 +00:00
|
|
|
RS::EnvironmentToneMapper tonemap_mode = RS::ENV_TONE_MAPPER_LINEAR;
|
2019-08-27 18:27:35 +00:00
|
|
|
float exposure = 1.0;
|
|
|
|
float white = 1.0;
|
|
|
|
|
|
|
|
bool use_auto_exposure = false;
|
|
|
|
float auto_exposure_grey = 0.5;
|
|
|
|
RID exposure_texture;
|
|
|
|
|
|
|
|
bool use_bcs = false;
|
|
|
|
float brightness = 1.0;
|
|
|
|
float contrast = 1.0;
|
|
|
|
float saturation = 1.0;
|
|
|
|
|
|
|
|
bool use_color_correction = false;
|
|
|
|
RID color_correction_texture;
|
2020-04-12 04:49:10 +00:00
|
|
|
|
|
|
|
bool use_fxaa = false;
|
|
|
|
Vector2i texture_size;
|
2019-08-27 18:27:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void tonemapper(RID p_source_color, RID p_dst_framebuffer, const TonemapSettings &p_settings);
|
|
|
|
|
2020-03-27 18:21:27 +00:00
|
|
|
void generate_ssao(RID p_depth_buffer, RID p_normal_buffer, const Size2i &p_depth_buffer_size, RID p_depth_mipmaps_texture, const Vector<RID> &depth_mipmaps, RID p_ao1, bool p_half_size, RID p_ao2, RID p_upscale_buffer, float p_intensity, float p_radius, float p_bias, const CameraMatrix &p_projection, RS::EnvironmentSSAOQuality p_quality, RS::EnvironmentSSAOBlur p_blur, float p_edge_sharpness);
|
2020-01-25 10:18:55 +00:00
|
|
|
|
2020-01-26 23:09:40 +00:00
|
|
|
void roughness_limit(RID p_source_normal, RID p_roughness, const Size2i &p_size, float p_curve);
|
2020-03-20 00:32:19 +00:00
|
|
|
void cubemap_downsample(RID p_source_cubemap, RID p_dest_cubemap, const Size2i &p_size);
|
2020-02-20 23:27:34 +00:00
|
|
|
void cubemap_filter(RID p_source_cubemap, Vector<RID> p_dest_cubemap, bool p_use_array);
|
2020-03-20 00:32:19 +00:00
|
|
|
void render_sky(RD::DrawListID p_list, float p_time, RID p_fb, RID p_samplers, RID p_lights, RenderPipelineVertexFormatCacheRD *p_pipeline, RID p_uniform_set, RID p_texture_set, const CameraMatrix &p_camera, const Basis &p_orientation, float p_multiplier, const Vector3 &p_position);
|
2020-01-26 23:09:40 +00:00
|
|
|
|
2020-06-25 13:33:28 +00:00
|
|
|
void screen_space_reflection(RID p_diffuse, RID p_normal_roughness, RS::EnvironmentSSRRoughnessQuality p_roughness_quality, RID p_blur_radius, RID p_blur_radius2, RID p_metallic, const Color &p_metallic_mask, RID p_depth, RID p_scale_depth, RID p_scale_normal, RID p_output, RID p_output_blur, const Size2i &p_screen_size, int p_max_steps, float p_fade_in, float p_fade_out, float p_tolerance, const CameraMatrix &p_camera);
|
2020-04-02 02:24:52 +00:00
|
|
|
void merge_specular(RID p_dest_framebuffer, RID p_specular, RID p_base, RID p_reflection);
|
2020-04-04 02:42:26 +00:00
|
|
|
void sub_surface_scattering(RID p_diffuse, RID p_diffuse2, RID p_depth, const CameraMatrix &p_camera, const Size2i &p_screen_size, float p_scale, float p_depth_scale, RS::SubSurfaceScatteringQuality p_quality);
|
2020-04-02 02:24:52 +00:00
|
|
|
|
2020-06-25 13:33:28 +00:00
|
|
|
void resolve_gi(RID p_source_depth, RID p_source_normal_roughness, RID p_source_giprobe, RID p_dest_depth, RID p_dest_normal_roughness, RID p_dest_giprobe, Vector2i p_screen_size, int p_samples);
|
|
|
|
|
2019-08-18 22:40:52 +00:00
|
|
|
RasterizerEffectsRD();
|
|
|
|
~RasterizerEffectsRD();
|
2019-07-27 13:23:24 +00:00
|
|
|
};
|
|
|
|
|
2019-09-15 09:58:38 +00:00
|
|
|
#endif // !RASTERIZER_EFFECTS_RD_H
|