Files
test2/source/blender/draw/engines/eevee/shaders/eevee_bxdf_lib.glsl

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

87 lines
2.2 KiB
Plaintext
Raw Normal View History

/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
EEVEE-Next: Ray-tracing Denoise Pipeline This is a full rewrite of the raytracing denoise pipeline. It uses the same principle as before but now uses compute shaders for every stages and a tile base approach. More aggressive filtering is needed since we are moving towards having no prefiltered screen radiance buffer. Thus we introduce a temporal denoise and a bilateral denoise stage to the denoising. These are optionnal and can be disabled. Note that this patch does not include any tracing part and only samples the reflection probes. It is focused on denoising only. Tracing will come in another PR. The motivation for this is that having hardware raytracing support means we can't prefilter the radiance in screen space so we have to have better denoising. Also this means we can have better surface appearance with support for other BxDF model than GGX. Also GGX support is improved. Technically, the new denoising fixes some implementation mistake the old pipeline did. It separates all 3 stages (spatial, temporal, bilateral) and use random sampling for all stages hoping to create a noisy enough (but still stable) output so that the TAA soaks the remaining noise. However that's not always the case. Depending on the nature of the scene, the input can be very high frequency and might create lots of flickering. That why another solution needs to be found for the higher roughness material as denoising them becomes expensive and low quality. Pull Request: https://projects.blender.org/blender/blender/pulls/110117
2023-08-03 15:32:06 +02:00
#pragma once
#include "infos/eevee_common_infos.hh"
EEVEE-Next: Ray-tracing Denoise Pipeline This is a full rewrite of the raytracing denoise pipeline. It uses the same principle as before but now uses compute shaders for every stages and a tile base approach. More aggressive filtering is needed since we are moving towards having no prefiltered screen radiance buffer. Thus we introduce a temporal denoise and a bilateral denoise stage to the denoising. These are optionnal and can be disabled. Note that this patch does not include any tracing part and only samples the reflection probes. It is focused on denoising only. Tracing will come in another PR. The motivation for this is that having hardware raytracing support means we can't prefilter the radiance in screen space so we have to have better denoising. Also this means we can have better surface appearance with support for other BxDF model than GGX. Also GGX support is improved. Technically, the new denoising fixes some implementation mistake the old pipeline did. It separates all 3 stages (spatial, temporal, bilateral) and use random sampling for all stages hoping to create a noisy enough (but still stable) output so that the TAA soaks the remaining noise. However that's not always the case. Depending on the nature of the scene, the input can be very high frequency and might create lots of flickering. That why another solution needs to be found for the higher roughness material as denoising them becomes expensive and low quality. Pull Request: https://projects.blender.org/blender/blender/pulls/110117
2023-08-03 15:32:06 +02:00
/**
* BxDF evaluation functions.
2023-08-19 17:13:05 +10:00
*/
EEVEE-Next: Ray-tracing Denoise Pipeline This is a full rewrite of the raytracing denoise pipeline. It uses the same principle as before but now uses compute shaders for every stages and a tile base approach. More aggressive filtering is needed since we are moving towards having no prefiltered screen radiance buffer. Thus we introduce a temporal denoise and a bilateral denoise stage to the denoising. These are optionnal and can be disabled. Note that this patch does not include any tracing part and only samples the reflection probes. It is focused on denoising only. Tracing will come in another PR. The motivation for this is that having hardware raytracing support means we can't prefilter the radiance in screen space so we have to have better denoising. Also this means we can have better surface appearance with support for other BxDF model than GGX. Also GGX support is improved. Technically, the new denoising fixes some implementation mistake the old pipeline did. It separates all 3 stages (spatial, temporal, bilateral) and use random sampling for all stages hoping to create a noisy enough (but still stable) output so that the TAA soaks the remaining noise. However that's not always the case. Depending on the nature of the scene, the input can be very high frequency and might create lots of flickering. That why another solution needs to be found for the higher roughness material as denoising them becomes expensive and low quality. Pull Request: https://projects.blender.org/blender/blender/pulls/110117
2023-08-03 15:32:06 +02:00
struct BsdfSample {
packed_float3 direction;
float pdf;
};
struct BsdfEval {
float throughput;
float pdf;
/* `throughput / pdf`. */
float weight;
};
struct ClosureLight {
/* LTC matrix. */
packed_float4 ltc_mat;
/* Shading normal. */
packed_float3 N;
/* Enum used as index to fetch which light intensity to use [0..3]. */
LightingType type;
/* Output both shadowed and unshadowed for shadow denoising. */
packed_float3 light_shadowed;
packed_float3 light_unshadowed;
METAL_CONSTRUCTOR_5(ClosureLight,
packed_float4,
ltc_mat,
packed_float3,
N,
LightingType,
type,
packed_float3,
light_shadowed,
packed_float3,
light_unshadowed)
static ClosureLight zero()
{
return ClosureLight(float4(0), float3(0), LIGHT_DIFFUSE, float3(0), float3(0));
}
};
/* Represent an approximation of a bunch of rays from a BSDF. */
struct LightProbeRay {
/* Average direction of sampled rays or its approximation.
2024-05-27 12:07:03 +10:00
* Magnitude will reduce directionality of spherical harmonic evaluation. */
packed_float3 dominant_direction;
/* Perceptual roughness in [0..1] range.
* Modulate blur level of spherical probe and blend between sphere probe and spherical harmonic
* evaluation at higher roughness. */
float perceptual_roughness;
};
/* -------------------------------------------------------------------- */
/** \name Utils
* \{ */
/* Fresnel monochromatic, perfect mirror */
float F_eta(float eta, float cos_theta)
{
/* Compute fresnel reflectance without explicitly computing
* the refracted direction. */
float c = abs(cos_theta);
float g = eta * eta - 1.0f + c * c;
if (g > 0.0f) {
g = sqrt(g);
float A = (g - c) / (g + c);
float B = (c * (g + c) - 1.0f) / (c * (g - c) + 1.0f);
return 0.5f * A * A * (1.0f + B * B);
}
/* Total internal reflections. */
return 1.0f;
}
/** \} */