This replace the previous square rings approach by sampling a disk the footprint of the search area. This avoids sampling in areas in corners where there isn't any weight. This results in much less samples needed to acheive a good enough result. The max number of samples for an area of 11x11 px is hard coded to 16 and still gives good results with the final clamp. The number of samples is adaptative and is scaled by the search area (max CoC). The High Quality Slight Defocus is not required anymore. If there is a quality parameter to add, it would be sample count option. But I consider the temporal stability enough for viewport work and render can still render many full scene samples. So I don't see a need for that yet.
97 lines
2.4 KiB
C++
97 lines
2.4 KiB
C++
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
* Copyright 2021 Blender Foundation.
|
|
*/
|
|
|
|
/** \file
|
|
* \ingroup eevee
|
|
*
|
|
* Shader module that manage shader libraries, deferred compilation,
|
|
* and static shader usage.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <array>
|
|
#include <string>
|
|
|
|
#include "BLI_string_ref.hh"
|
|
#include "DRW_render.h"
|
|
#include "GPU_material.h"
|
|
#include "GPU_shader.h"
|
|
|
|
#include "eevee_material.hh"
|
|
#include "eevee_sync.hh"
|
|
|
|
namespace blender::eevee {
|
|
|
|
/* Keep alphabetical order and clean prefix. */
|
|
enum eShaderType {
|
|
FILM_FRAG = 0,
|
|
FILM_COMP,
|
|
|
|
DOF_BOKEH_LUT,
|
|
DOF_DOWNSAMPLE,
|
|
DOF_FILTER,
|
|
DOF_GATHER_BACKGROUND_LUT,
|
|
DOF_GATHER_BACKGROUND,
|
|
DOF_GATHER_FOREGROUND_LUT,
|
|
DOF_GATHER_FOREGROUND,
|
|
DOF_GATHER_HOLE_FILL,
|
|
DOF_REDUCE,
|
|
DOF_RESOLVE_LUT,
|
|
DOF_RESOLVE,
|
|
DOF_SCATTER,
|
|
DOF_SETUP,
|
|
DOF_STABILIZE,
|
|
DOF_TILES_DILATE_MINABS,
|
|
DOF_TILES_DILATE_MINMAX,
|
|
DOF_TILES_FLATTEN,
|
|
|
|
MOTION_BLUR_GATHER,
|
|
MOTION_BLUR_TILE_DILATE,
|
|
MOTION_BLUR_TILE_FLATTEN_RENDER,
|
|
MOTION_BLUR_TILE_FLATTEN_VIEWPORT,
|
|
|
|
MAX_SHADER_TYPE,
|
|
};
|
|
|
|
/**
|
|
* Shader module. shared between instances.
|
|
*/
|
|
class ShaderModule {
|
|
private:
|
|
std::array<GPUShader *, MAX_SHADER_TYPE> shaders_;
|
|
|
|
/** Shared shader module across all engine instances. */
|
|
static ShaderModule *g_shader_module;
|
|
|
|
public:
|
|
ShaderModule();
|
|
~ShaderModule();
|
|
|
|
GPUShader *static_shader_get(eShaderType shader_type);
|
|
GPUMaterial *material_shader_get(::Material *blender_mat,
|
|
struct bNodeTree *nodetree,
|
|
eMaterialPipeline pipeline_type,
|
|
eMaterialGeometry geometry_type,
|
|
bool deferred_compilation);
|
|
GPUMaterial *world_shader_get(::World *blender_world, struct bNodeTree *nodetree);
|
|
GPUMaterial *material_shader_get(const char *name,
|
|
ListBase &materials,
|
|
struct bNodeTree *nodetree,
|
|
eMaterialPipeline pipeline_type,
|
|
eMaterialGeometry geometry_type,
|
|
bool is_lookdev);
|
|
|
|
void material_create_info_ammend(GPUMaterial *mat, GPUCodegenOutput *codegen);
|
|
|
|
/** Only to be used by Instance constructor. */
|
|
static ShaderModule *module_get();
|
|
static void module_free();
|
|
|
|
private:
|
|
const char *static_shader_create_info_name_get(eShaderType shader_type);
|
|
};
|
|
|
|
} // namespace blender::eevee
|