46 float local_abs_max = 0.0f;
49 for (
int i = 0; i < 4; i++) {
56 local_abs_max =
max(local_abs_max,
abs(coc));
60 if (local_index == 0u) {
75 float3 neighbor_min, neighbor_max;
77 for (
int i = 0; i < 4; i++) {
96 neighbor_min = (i == 0) ? ycocg_sample :
min(neighbor_min, ycocg_sample);
97 neighbor_max = (i == 0) ? ycocg_sample :
max(neighbor_max, ycocg_sample);
101 neighbor_max +=
abs(neighbor_min) * padding;
102 neighbor_min -=
abs(neighbor_min) * padding;
107 color =
mix(color,
clamp(color, neighbor_min, neighbor_max), fac);
131 float slight_focus_max_coc = 0.0f;
133 slight_focus_max_coc = srt.slight_focus_coc_tile_get(
frag_coord, local_index);
152 constexpr float3 hole_fill_color =
float3(0.2f, 0.1f, 1.0f);
153 constexpr float3 background_color =
float3(0.1f, 0.2f, 1.0f);
154 constexpr float3 slight_focus_color =
float3(1.0f, 0.2f, 0.1f);
155 constexpr float3 focus_color =
float3(1.0f, 1.0f, 0.1f);
156 constexpr float3 foreground_color =
float3(0.2f, 1.0f, 0.1f);
159 layer_color =
textureLod(srt.color_hole_fill_tx, uv_halfres, 0.0f);
160 layer_weight =
textureLod(srt.weight_hole_fill_tx, uv_halfres, 0.0f).r;
161 if (srt.do_debug_color) {
162 layer_color.rgb *= hole_fill_color;
164 out_color = layer_color *
safe_rcp(layer_weight);
165 weight =
float(layer_weight > 0.0f);
169 layer_color =
textureLod(srt.color_bg_tx, uv_halfres, 0.0f);
170 layer_weight =
textureLod(srt.weight_bg_tx, uv_halfres, 0.0f).r;
171 if (srt.do_debug_color) {
172 layer_color.rgb *= background_color;
175 layer_color *=
safe_rcp(layer_weight);
176 layer_weight =
float(layer_weight > 0.0f);
178 out_color = out_color * (1.0f - layer_weight) + layer_color;
179 weight = weight * (1.0f - layer_weight) + layer_weight;
182 weight =
float(weight > 0.0f);
192 slight_focus_max_coc,
202 slight_focus_max_coc,
208 if (srt.do_debug_color) {
209 layer_color.rgb *= slight_focus_color;
213 out_color = out_color * (1.0f - layer_weight) + layer_color;
214 weight = weight * (1.0f - layer_weight) + layer_weight;
222 if (srt.do_debug_color) {
223 layer_color.rgb *= focus_color;
226 out_color = out_color * (1.0f - layer_weight) + layer_color;
227 weight = weight * (1.0f - layer_weight) + layer_weight;
231 layer_color =
textureLod(srt.color_fg_tx, uv_halfres, 0.0f);
232 layer_weight =
textureLod(srt.weight_fg_tx, uv_halfres, 0.0f).r;
233 if (srt.do_debug_color) {
234 layer_color.rgb *= foreground_color;
237 out_color = out_color * (1.0f - layer_weight) + layer_color;
241 if (out_color.a > 0.99f) {
246 out_color.rgb *=
float3(1.0f, 0.1f, 0.1f);
256 .is_hole_fill =
false,
258 .is_foreground =
false,
263 .is_hole_fill =
false,
265 .is_foreground =
false,
#define no_foreground_pass
#define dof_max_slight_focus_radius
CocTilePrediction dof_coc_tile_prediction_get(CocTile tile, const bool is_resolve)
#define no_hole_fill_pass
CocTile dof_coc_tile_load(image2D tiles_fg_img, image2D tiles_bg_img, int2 texel)
const float2 quad_offsets[4]
#define debug_resolve_perf
#define no_background_pass
#define no_slight_focus_pass
float dof_coc_from_depth(const draw::View &views, DepthOfFieldData dof_data, float2 uv, float depth)
PipelineCompute eevee_depth_of_field_resolve_lut(eevee::dof::resolve::comp_main, eevee::dof::AccumulatorConstants{ .is_hole_fill=false,.is_resolve=true,.is_foreground=false,.use_lut=true, })
PipelineCompute eevee_depth_of_field_resolve_no_lut(eevee::dof::resolve::comp_main, eevee::dof::AccumulatorConstants{ .is_hole_fill=false,.is_resolve=true,.is_foreground=false,.use_lut=false, })
#define local_invocation_index
#define image(slot, qualifiers, format)
#define specialization_constant(default_value)
#define global_invocation_id
int atomicMax(int &, int) RET
VecBase< uint, D > floatBitsToUint(VecOp< float, D >) RET
VecBase< float, D > uintBitsToFloat(VecOp< uint, D >) RET
constexpr T clamp(T, U, U) RET
ImageBase< float, 2 > image2D
IMG_TEMPLATE void imageStore(T &, IntCoord, DataVec)
TEX_TEMPLATE DataVec textureLod(T, FltCoord, float) RET
SamplerBase< float, 2, false, false, false, true > sampler2DDepth
SamplerBase< float, 2 > sampler2D
TEX_TEMPLATE SizeVec textureSize(T, int) RET
ccl_gpu_kernel_postfix ccl_global KernelWorkTile * tiles
float4 safe_color(float4 c)
float3 scene_linear_from_YCoCg(float3 ycocg_color)
float3 YCoCg_from_scene_linear(float3 rgb_color)
void comp_main(Resources &srt, const draw::View &views, Tiles &tiles, const uint3 global_id, const uint local_index)
T read(T depth_buffer_value)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
void dof_slight_focus_gather(float2 frag_coord, sampler2DDepth depth_tx, sampler2D color_tx, sampler2D bkh_lut_tx, float radius, float4 &out_color, float &out_weight, float &out_center_coc)
AccumulatorConstants consts
const DepthOfFieldData & dof_buf
uint shared_max_slight_focus_abs_coc
sampler2D stable_color_tx
float slight_focus_coc_tile_get(float2 frag_coord, uint local_index)
const bool do_debug_color
sampler2D color_hole_fill_tx
sampler2D weight_hole_fill_tx
float3 dof_neighborhood_clamp(float2 frag_coord, float3 color, float center_coc, float weight)