Cleanup: spelling in comments
This commit is contained in:
@@ -3266,7 +3266,7 @@ static Mesh *create_liquid_geometry(FluidDomainSettings *fds,
|
||||
madd_v3fl_v3fl_v3fl_v3i(max, fds->p0, cell_size_scaled, fds->res_max);
|
||||
sub_v3_v3v3(size, max, min);
|
||||
|
||||
/* Biggest dimension will be used for upscaling. */
|
||||
/* Biggest dimension will be used for up-scaling. */
|
||||
float max_size = MAX3(size[0], size[1], size[2]);
|
||||
|
||||
float co_scale[3];
|
||||
|
||||
@@ -2584,7 +2584,7 @@ static bool read_libblock_is_identical(FileData *fd, BHead *bhead)
|
||||
*
|
||||
* NOTE: While in theory Library IDs (and their related linked IDs) are also 'noundo' data, in
|
||||
* practice they need to be handled separately, to ensure that their order in the new bmain list
|
||||
* matches the one from the read blendfile. Reading linked 'placeholder' entries in a memfile
|
||||
* matches the one from the read blend-file. Reading linked 'placeholder' entries in a memfile
|
||||
* relies on current library being the last item in the new main list. */
|
||||
static void read_undo_reuse_noundo_local_ids(FileData *fd)
|
||||
{
|
||||
@@ -3377,7 +3377,7 @@ static void after_liblink_merged_bmain_process(Main *bmain, BlendFileReadReport
|
||||
BKE_report(
|
||||
reports ? reports->reports : nullptr,
|
||||
RPT_ERROR,
|
||||
"Critical blendfile corruption: Conflicts and/or otherwise invalid data-blocks names "
|
||||
"Critical blend-file corruption: Conflicts and/or otherwise invalid data-blocks names "
|
||||
"(see console for details)");
|
||||
}
|
||||
|
||||
@@ -4481,7 +4481,7 @@ void BLO_library_link_end(Main *mainl, BlendHandle **bh, const LibraryLink_Param
|
||||
LISTBASE_FOREACH (Library *, lib, ¶ms->bmain->libraries) {
|
||||
/* Now we can clear this runtime library filedata, it is not needed anymore. */
|
||||
if (lib->filedata == reinterpret_cast<FileData *>(*bh)) {
|
||||
/* The filedata is owned and managed by caller code, only clear matching library ponter. */
|
||||
/* The filedata is owned and managed by caller code, only clear matching library pointer. */
|
||||
lib->filedata = nullptr;
|
||||
}
|
||||
else if (lib->filedata) {
|
||||
@@ -4801,7 +4801,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
|
||||
* do_versions multiple times, which would have bad consequences. */
|
||||
split_main_newid(mainptr, main_newid);
|
||||
|
||||
/* `filedata` can be NULL when loading linked data from inexistant or invalid library
|
||||
/* `filedata` can be NULL when loading linked data from nonexistent or invalid library
|
||||
* reference. Or during linking/appending, when processing data from a library not involved
|
||||
* in the current linking/appending operation.
|
||||
*
|
||||
@@ -4821,7 +4821,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
|
||||
|
||||
/* NOTE: No need to call #do_versions_after_linking() or #BKE_main_id_refcount_recompute()
|
||||
* here, as this function is only called for library 'subset' data handling, as part of
|
||||
* either full blendfile reading (#blo_read_file_internal()), or library-data linking
|
||||
* either full blend-file reading (#blo_read_file_internal()), or library-data linking
|
||||
* (#library_link_end()).
|
||||
*
|
||||
* For this to work reliably, `mainptr->curlib->filedata` also needs to be freed after said
|
||||
|
||||
@@ -16,10 +16,10 @@ void main()
|
||||
* image, so compute its normalized pixel size. */
|
||||
vec2 pixel_size = 1.0 / vec2(imageSize(output_img));
|
||||
|
||||
/* Upsample by applying a 3x3 tent filter on the bi-linearly interpolated values evaluated at the
|
||||
* center of neighbouring output pixels. As more tent filter upsampling passes are applied, the
|
||||
* result approximates a large sized Gaussian filter. This upsampling strategy is described in
|
||||
* the talk:
|
||||
/* Upsample by applying a 3x3 tent filter on the bi-linearly interpolated values evaluated at
|
||||
* the center of neighboring output pixels. As more tent filter upsampling passes are applied,
|
||||
* the result approximates a large sized Gaussian filter. This upsampling strategy is described
|
||||
* in the talk:
|
||||
*
|
||||
* Next Generation Post Processing in Call of Duty: Advanced Warfare
|
||||
* https://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare
|
||||
|
||||
@@ -26,7 +26,7 @@ void main()
|
||||
|
||||
/* The value of the ghost is attenuated by a scalar multiple of the inverse distance to the
|
||||
* center, such that it is maximum at the center and become zero further from the center,
|
||||
* making sure to take the scale into account. The scaler multiple of 1 / 4 is chosen using
|
||||
* making sure to take the scale into account. The scalar multiple of 1 / 4 is chosen using
|
||||
* visual judgment. */
|
||||
float distance_to_center = distance(coordinates, vec2(0.5)) * 2.0;
|
||||
float attenuator = max(0.0, 1.0 - distance_to_center * abs(scale)) / 4.0;
|
||||
|
||||
@@ -3,33 +3,33 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/* Preprocess the input of the blur filter by squaring it in its alpha straight form, assuming the
|
||||
* given color is alpha premultiplied. */
|
||||
* given color is alpha pre-multiplied. */
|
||||
vec4 gamma_correct_blur_input(vec4 color)
|
||||
{
|
||||
/* Unpremultiply alpha. */
|
||||
/* Un-pre-multiply alpha. */
|
||||
color.rgb /= color.a > 0.0 ? color.a : 1.0;
|
||||
|
||||
/* Square color channel if it is positive, otherwise zero it. */
|
||||
color.rgb *= mix(color.rgb, vec3(0.0), lessThan(color.rgb, vec3(0.0)));
|
||||
|
||||
/* Premultiply alpha to undo previous alpha unpremultiplication. */
|
||||
/* Pre-multiply alpha to undo previous alpha un-pre-multiplication. */
|
||||
color.rgb *= color.a > 0.0 ? color.a : 1.0;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
/* Postprocess the output of the blur filter by taking its square root it in its alpha straight
|
||||
* form, assuming the given color is alpha premultiplied. This essential undoes the processing done
|
||||
* by the gamma_correct_blur_input function. */
|
||||
* form, assuming the given color is alpha pre-multiplied. This essential undoes the processing
|
||||
* done by the gamma_correct_blur_input function. */
|
||||
vec4 gamma_uncorrect_blur_output(vec4 color)
|
||||
{
|
||||
/* Unpremultiply alpha. */
|
||||
/* Un-pre-multiply alpha. */
|
||||
color.rgb /= color.a > 0.0 ? color.a : 1.0;
|
||||
|
||||
/* Take the square root of the color channel if it is positive, otherwise zero it. */
|
||||
color.rgb = mix(sqrt(color.rgb), vec3(0.0), lessThan(color.rgb, vec3(0.0)));
|
||||
|
||||
/* Premultiply alpha to undo previous alpha unpremultiplication. */
|
||||
/* Pre-multiply alpha to undo previous alpha un-pre-multiplication. */
|
||||
color.rgb *= color.a > 0.0 ? color.a : 1.0;
|
||||
|
||||
return color;
|
||||
|
||||
@@ -29,7 +29,7 @@ struct ClosureEvalGlossy {
|
||||
float ltc_brdf_scale; /** LTC BRDF scaling. */
|
||||
vec3 probe_sampling_dir; /** Direction to sample probes from. */
|
||||
float spec_occlusion; /** Specular Occlusion. */
|
||||
vec3 raytrace_radiance; /** Raytrace reflection to be accumulated after occlusion. */
|
||||
vec3 raytrace_radiance; /** Ray-trace reflection to be accumulated after occlusion. */
|
||||
};
|
||||
|
||||
/* Stubs. */
|
||||
@@ -76,7 +76,7 @@ ClosureEvalGlossy closure_Glossy_eval_init(inout ClosureInputGlossy cl_in,
|
||||
raytrace_resolve(cl_in, cl_eval, cl_common, cl_out);
|
||||
#endif
|
||||
|
||||
/* The brdf split sum LUT is applied after the radiance accumulation.
|
||||
/* The BRDF split sum LUT is applied after the radiance accumulation.
|
||||
* Correct the LTC so that its energy is constant. */
|
||||
/* TODO(@fclem): Optimize this so that only one scale factor is stored. */
|
||||
vec4 ltc_brdf = texture(utilTex, vec3(lut_uv, LTC_BRDF_LAYER)).barg;
|
||||
@@ -148,11 +148,11 @@ void closure_Glossy_indirect_end(ClosureInputGlossy cl_in,
|
||||
/* Apply occlusion on distant lighting. */
|
||||
cl_out.radiance *= cl_eval.spec_occlusion;
|
||||
#endif
|
||||
/* Apply Raytrace reflections after occlusion since they are direct, local reflections. */
|
||||
/* Apply Ray-trace reflections after occlusion since they are direct, local reflections. */
|
||||
#if defined(RESOLVE_PROBE)
|
||||
/* NO OP - output base radiance*/
|
||||
#elif defined(RESOLVE_SSR)
|
||||
/* Output only raytrace radiance */
|
||||
/* Output only ray-trace radiance. */
|
||||
cl_out.radiance = cl_eval.raytrace_radiance;
|
||||
#else
|
||||
/* Standard resolve */
|
||||
|
||||
@@ -15,7 +15,7 @@ void main()
|
||||
{
|
||||
DEFINE_DOF_QUAD_OFFSETS
|
||||
vec2 halfres_texel_size = 1.0 / vec2(textureSize(colorBuffer, 0).xy);
|
||||
/* Center uv around the 4 halfres pixels. */
|
||||
/* Center uv around the 4 half-resolution pixels. */
|
||||
vec2 quad_center = (floor(gl_FragCoord.xy) * 2.0 + 1.0) * halfres_texel_size;
|
||||
|
||||
vec4 colors[4];
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/**
|
||||
* Tile flatten pass: Takes the halfres CoC buffer and converts it to 8x8 tiles.
|
||||
* Tile flatten pass: Takes the half-resolution CoC buffer and converts it to 8x8 tiles.
|
||||
*
|
||||
* Output min and max values for each tile and for both foreground & background.
|
||||
* Also outputs min intersectable CoC for the background, which is the minimum CoC
|
||||
|
||||
@@ -35,7 +35,7 @@ const float radius_downscale_factor = smaller_kernel_radius / large_kernel_radiu
|
||||
const int change_density_at_ring = (gather_ring_count - gather_density_change_ring + 1);
|
||||
const float coc_radius_error = 2.0;
|
||||
|
||||
/* Radii needs to be halfres CoC sizes. */
|
||||
/* Radii needs to be half-resolution CoC sizes. */
|
||||
bool dof_do_density_change(float base_radius, float min_intersectable_radius)
|
||||
{
|
||||
/* Reduce artifact for very large blur. */
|
||||
|
||||
@@ -129,7 +129,7 @@ vec4 dof_load_scatter_color(sampler2D scatter_input_color_buffer, vec2 uv, float
|
||||
float dof_load_gather_coc(sampler2D gather_input_coc_buffer, vec2 uv, float lod)
|
||||
{
|
||||
float coc = textureLod(gather_input_coc_buffer, uv, lod).r;
|
||||
/* We gather at halfres. CoC must be divided by 2 to be compared against radii. */
|
||||
/* We gather at half-resolution. CoC must be divided by 2 to be compared against radii. */
|
||||
return coc * 0.5;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ float dof_load_gather_coc(sampler2D gather_input_coc_buffer, vec2 uv, float lod)
|
||||
|
||||
float dof_layer_weight(float coc, const bool is_foreground)
|
||||
{
|
||||
/* NOTE: These are fullres pixel CoC value. */
|
||||
/* NOTE: These are full-resolution pixel CoC value. */
|
||||
#ifdef DOF_RESOLVE_PASS
|
||||
return saturate(-abs(coc) + layer_threshold + layer_offset) *
|
||||
float(is_foreground ? (coc <= 0.5) : (coc > -0.5));
|
||||
@@ -161,7 +161,7 @@ vec4 dof_layer_weight(vec4 coc)
|
||||
return saturate(coc - layer_threshold + layer_offset);
|
||||
}
|
||||
|
||||
/* NOTE: This is halfres CoC radius. */
|
||||
/* NOTE: This is half-resolution CoC radius. */
|
||||
float dof_sample_weight(float coc)
|
||||
{
|
||||
/* Full intensity if CoC radius is below the pixel footprint. */
|
||||
|
||||
@@ -45,7 +45,7 @@ float dof_scatter_screen_border_rejection(float coc, vec2 uv, vec2 screen_size)
|
||||
{
|
||||
vec2 screen_pos = uv * screen_size;
|
||||
float min_screen_border_distance = min_v2(min(screen_pos, screen_size - screen_pos));
|
||||
/* Fullres to halfres CoC. */
|
||||
/* Full-resolution to half-resolution CoC. */
|
||||
coc *= 0.5;
|
||||
/* Allow 10px transition. */
|
||||
const float rejection_hardeness = 1.0 / 10.0;
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
* Recombine Pass: Load separate convolution layer and composite with self slight defocus
|
||||
* convolution and in-focus fields.
|
||||
*
|
||||
* The halfres gather methods are fast but lack precision for small CoC areas. To fix this we
|
||||
* do a brute-force gather to have a smooth transition between in-focus and defocus regions.
|
||||
* The half-resolution gather methods are fast but lack precision for small CoC areas. To fix this
|
||||
* we do a brute-force gather to have a smooth transition between in-focus and defocus regions.
|
||||
*/
|
||||
|
||||
#pragma BLENDER_REQUIRE(common_utiltex_lib.glsl)
|
||||
|
||||
@@ -29,7 +29,7 @@ void main()
|
||||
rand.xy = fract(rand.xy * 3.2471795724474602596);
|
||||
|
||||
/* Randomly choose the pixel to start the ray from when tracing at lower resolution.
|
||||
* This method also make sure we always start from the center of a fullres texel. */
|
||||
* This method also make sure we always start from the center of a full-resolution texel. */
|
||||
vec2 uvs = (gl_FragCoord.xy + random_px * randomScale) / (targetSize * ssrUvScale);
|
||||
|
||||
float depth = textureLod(maxzBuffer, uvs * hizUvScale.xy, 0.0).r;
|
||||
|
||||
@@ -137,7 +137,7 @@ float load_visibility_cell(int cell, vec3 L, float dist, float bias, float bleed
|
||||
/* Increase contrast in the weight by squaring it */
|
||||
p_max *= p_max;
|
||||
|
||||
/* Now reduce light-bleeding by removing the [0, x] tail and linearly rescaling (x, 1] */
|
||||
/* Now reduce light-bleeding by removing the [0, x] tail and linearly re-scaling [x, 1]. */
|
||||
p_max = clamp((p_max - bleed_bias) / (1.0 - bleed_bias), 0.0, 1.0);
|
||||
|
||||
return (dist <= moments.x) ? 1.0 : p_max;
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Screen-Space Raytracing functions.
|
||||
* Screen-Space Ray-tracing functions.
|
||||
*/
|
||||
|
||||
struct Ray {
|
||||
vec3 origin;
|
||||
/* Ray direction premultiplied by its maximum length. */
|
||||
/* Ray direction pre-multiplied by its maximum length. */
|
||||
vec3 direction;
|
||||
};
|
||||
|
||||
@@ -164,7 +164,7 @@ bool raytrace(Ray ray,
|
||||
hit = hit && (delta > ss_p.z - ss_p.w || abs(delta) < abs(ssray.direction.z * stride * 2.0));
|
||||
|
||||
#ifdef METAL_AMD_RAYTRACE_WORKAROUND
|
||||
/* For workaround, perform discard backface and background check only within
|
||||
/* For workaround, perform discard back-face and background check only within
|
||||
* the iteration where the first successful ray intersection is registered.
|
||||
* We flag failures to discard ray hits later. */
|
||||
bool hit_valid = !(discard_backface && prev_delta < 0.0) && (depth_sample != 1.0);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/**
|
||||
* Depth of Field Gather accumulator.
|
||||
* We currently have only 2 which are very similar.
|
||||
* One is for the halfres gather passes and the other one for slight in focus regions.
|
||||
* One is for the half-resolution gather passes and the other one for slight in focus regions.
|
||||
*/
|
||||
|
||||
#pragma BLENDER_REQUIRE(common_view_lib.glsl)
|
||||
@@ -376,7 +376,7 @@ void dof_gather_accumulate_resolve(int total_sample_count,
|
||||
float dof_load_gather_coc(sampler2D gather_input_coc_tx, vec2 uv, float lod)
|
||||
{
|
||||
float coc = textureLod(gather_input_coc_tx, uv, lod).r;
|
||||
/* We gather at halfres. CoC must be divided by 2 to be compared against radii. */
|
||||
/* We gather at half-resolution. CoC must be divided by 2 to be compared against radii. */
|
||||
return coc * 0.5;
|
||||
}
|
||||
|
||||
@@ -386,7 +386,7 @@ float dof_load_gather_coc(sampler2D gather_input_coc_tx, vec2 uv, float lod)
|
||||
/** \name Common Gather accumulator.
|
||||
* \{ */
|
||||
|
||||
/* Radii needs to be halfres CoC sizes. */
|
||||
/* Radii needs to be half-resolution CoC sizes. */
|
||||
bool dof_do_density_change(float base_radius, float min_intersectable_radius)
|
||||
{
|
||||
/* Reduce artifact for very large blur. */
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
void main()
|
||||
{
|
||||
vec2 halfres_texel_size = 1.0 / vec2(textureSize(color_tx, 0).xy);
|
||||
/* Center uv around the 4 halfres pixels. */
|
||||
/* Center uv around the 4 half-resolution pixels. */
|
||||
vec2 quad_center = vec2(gl_GlobalInvocationID.xy * 2 + 1) * halfres_texel_size;
|
||||
|
||||
vec4 colors[4];
|
||||
|
||||
@@ -130,7 +130,7 @@ float dof_coc_from_depth(DepthOfFieldData dof_data, vec2 uv, float depth)
|
||||
|
||||
float dof_layer_weight(float coc, const bool is_foreground)
|
||||
{
|
||||
/* NOTE: These are fullres pixel CoC value. */
|
||||
/* NOTE: These are full-resolution pixel CoC value. */
|
||||
if (is_resolve) {
|
||||
return saturate(-abs(coc) + dof_layer_threshold + dof_layer_offset) *
|
||||
float(is_foreground ? (coc <= 0.5) : (coc > -0.5));
|
||||
@@ -149,7 +149,7 @@ vec4 dof_layer_weight(vec4 coc)
|
||||
return saturate(coc - dof_layer_threshold + dof_layer_offset);
|
||||
}
|
||||
|
||||
/* NOTE: This is halfres CoC radius. */
|
||||
/* NOTE: This is half-resolution CoC radius. */
|
||||
float dof_sample_weight(float coc)
|
||||
{
|
||||
#if 1 /* Optimized */
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
* that during the convolution phase.
|
||||
*
|
||||
* Inputs:
|
||||
* - Output of setup pass (halfres) and reduce downsample pass (quarter res).
|
||||
* - Output of setup pass (half-resolution) and reduce downsample pass (quarter res).
|
||||
* Outputs:
|
||||
* - Halfres padded to avoid mipmap misalignment (so possibly not matching input size).
|
||||
* - Half-resolution padded to avoid mipmap misalignment (so possibly not matching input size).
|
||||
* - Gather input color (whole mip chain), Scatter rect list, Signed CoC (whole mip chain).
|
||||
*/
|
||||
|
||||
@@ -52,7 +52,7 @@ float dof_scatter_screen_border_rejection(float coc, ivec2 texel)
|
||||
vec2 uv = (vec2(texel) + 0.5) / screen_size;
|
||||
vec2 screen_pos = uv * screen_size;
|
||||
float min_screen_border_distance = min_v2(min(screen_pos, screen_size - screen_pos));
|
||||
/* Fullres to halfres CoC. */
|
||||
/* Full-resolution to half-resolution CoC. */
|
||||
coc *= 0.5;
|
||||
/* Allow 10px transition. */
|
||||
const float rejection_hardeness = 1.0 / 10.0;
|
||||
@@ -153,7 +153,7 @@ void main()
|
||||
/* NOTE: Since we flipped the quad along (1,-1) line, we need to also swap the (1,1) and
|
||||
* (0,0) values so that quad_offsets is in the right order in the vertex shader. */
|
||||
|
||||
/* Circle of Confusion absolute radius in halfres pixels. */
|
||||
/* Circle of Confusion absolute radius in half-resolution pixels. */
|
||||
rect_fg.color_and_coc[0].a = coc4_fg[0];
|
||||
rect_fg.color_and_coc[1].a = coc4_fg[3];
|
||||
rect_fg.color_and_coc[2].a = coc4_fg[2];
|
||||
@@ -182,7 +182,7 @@ void main()
|
||||
rect_bg.offset = offset;
|
||||
rect_bg.half_extent = half_extent;
|
||||
|
||||
/* Circle of Confusion absolute radius in halfres pixels. */
|
||||
/* Circle of Confusion absolute radius in half-resolution pixels. */
|
||||
rect_bg.color_and_coc[0].a = coc4_bg[0];
|
||||
rect_bg.color_and_coc[1].a = coc4_bg[1];
|
||||
rect_bg.color_and_coc[2].a = coc4_bg[2];
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Recombine Pass: Load separate convolution layer and composite with self
|
||||
* slight defocus convolution and in-focus fields.
|
||||
*
|
||||
* The halfres gather methods are fast but lack precision for small CoC areas.
|
||||
* The half-resolution gather methods are fast but lack precision for small CoC areas.
|
||||
* To fix this we do a brute-force gather to have a smooth transition between
|
||||
* in-focus and defocus regions.
|
||||
*/
|
||||
@@ -52,7 +52,7 @@ vec3 dof_neighborhood_clamp(vec2 frag_coord, vec3 color, float center_coc, float
|
||||
const vec2 corners[4] = vec2[4](vec2(-1, -1), vec2(1, -1), vec2(-1, 1), vec2(1, 1));
|
||||
for (int i = 0; i < 4; i++) {
|
||||
/**
|
||||
* Visit the 4 half-res texels around (and containing) the fullres texel.
|
||||
* Visit the 4 half-res texels around (and containing) the full-resolution texel.
|
||||
* Here a diagram of a full-screen texel (f) in the bottom left corner of a half res texel.
|
||||
* We sample the stable half-resolution texture at the 4 location denoted by (h).
|
||||
* ┌───────┬───────┐
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
void main()
|
||||
{
|
||||
vec2 fullres_texel_size = 1.0 / vec2(textureSize(color_tx, 0).xy);
|
||||
/* Center uv around the 4 fullres pixels. */
|
||||
/* Center uv around the 4 full-resolution pixels. */
|
||||
vec2 quad_center = vec2(gl_GlobalInvocationID.xy * 2 + 1) * fullres_texel_size;
|
||||
|
||||
vec4 colors[4];
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
* - We run this pass at half resolution.
|
||||
* - We store CoC instead of Opacity in the alpha channel of the history.
|
||||
*
|
||||
* This is and adaption of the code found in eevee_film_lib.glsl
|
||||
* This is and adaption of the code found in `eevee_film_lib.glsl`.
|
||||
*
|
||||
* Inputs:
|
||||
* - Output of setup pass (halfres).
|
||||
* - Output of setup pass (half-resolution).
|
||||
* Outputs:
|
||||
* - Stabilized Color and CoC (halfres).
|
||||
* - Stabilized Color and CoC (half-resolution).
|
||||
*/
|
||||
|
||||
#pragma BLENDER_REQUIRE(common_math_geom_lib.glsl)
|
||||
@@ -81,7 +81,7 @@ void dof_cache_init()
|
||||
if (all(lessThan(gl_LocalInvocationID.xy, uvec2(cache_depth_size / 2u)))) {
|
||||
ivec2 offset = ivec2(x, y) * ivec2(cache_depth_size / 2u);
|
||||
ivec2 cache_texel = ivec2(gl_LocalInvocationID.xy) + offset;
|
||||
/* Depth is fullres. Load every 2 pixels. */
|
||||
/* Depth is full-resolution. Load every 2 pixels. */
|
||||
ivec2 load_texel = clamp((texel + offset - 2) * 2, ivec2(0), textureSize(depth_tx, 0) - 1);
|
||||
|
||||
depth_cache[cache_texel.y][cache_texel.x] = texelFetch(depth_tx, load_texel, 0).x;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/**
|
||||
* Tile flatten pass: Takes the halfres CoC buffer and converts it to 8x8 tiles.
|
||||
* Tile flatten pass: Takes the half-resolution CoC buffer and converts it to 8x8 tiles.
|
||||
*
|
||||
* Output min and max values for each tile and for both foreground & background.
|
||||
* Also outputs min intersectable CoC for the background, which is the minimum CoC
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/**
|
||||
* Bilateral filtering of denoised raytraced radiance.
|
||||
* Bilateral filtering of denoised ray-traced radiance.
|
||||
*
|
||||
* Dispatched at fullres using a tile list.
|
||||
* Dispatched at full-resolution using a tile list.
|
||||
*
|
||||
* Input: Temporally Stabilized Radiance, Stabilized Variance
|
||||
* Output: Denoised radiance
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/**
|
||||
* Temporal Reprojection and accumulation of denoised raytraced radiance.
|
||||
* Temporal Reprojection and accumulation of denoised ray-traced radiance.
|
||||
*
|
||||
* Dispatched at fullres using a tile list.
|
||||
* Dispatched at full-resolution using a tile list.
|
||||
*
|
||||
* Input: Spatially denoised radiance, Variance, Hit depth
|
||||
* Output: Stabilized Radiance, Stabilized Variance
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/**
|
||||
* Screen-space raytracing routine.
|
||||
* Screen-space ray-tracing routine.
|
||||
*
|
||||
* Based on "Efficient GPU Screen-Space Ray Tracing"
|
||||
* by Morgan McGuire & Michael Mara
|
||||
@@ -24,16 +24,16 @@ void raytrace_clip_ray_to_near_plane(inout Ray ray)
|
||||
}
|
||||
|
||||
/**
|
||||
* Raytrace against the given HIZ-buffer height-field.
|
||||
* Ray-trace against the given HIZ-buffer height-field.
|
||||
*
|
||||
* \param stride_rand: Random number in [0..1] range. Offset along the ray to avoid banding
|
||||
* artifact when steps are too large.
|
||||
* \param roughness: Determine how lower depth mipmaps are used to make the tracing faster. Lower
|
||||
* roughness will use lower mipmaps.
|
||||
* \param discard_backface: If true, raytrace will return false if we hit a surface from behind.
|
||||
* \param allow_self_intersection: If false, raytrace will return false if the ray is not covering
|
||||
* \param discard_backface: If true, ray-trace will return false if we hit a surface from behind.
|
||||
* \param allow_self_intersection: If false, ray-trace will return false if the ray is not covering
|
||||
* at least one pixel.
|
||||
* \param ray: View-space ray. Direction premultiplied by maximum length.
|
||||
* \param ray: View-space ray. Direction pre-multiplied by maximum length.
|
||||
*
|
||||
* \return True if there is a valid intersection.
|
||||
*/
|
||||
@@ -102,7 +102,7 @@ bool raytrace_screen(RayTraceData rt_data,
|
||||
hit = hit && (delta > ss_p.z - ss_p.w || abs(delta) < abs(ssray.direction.z * stride * 2.0));
|
||||
|
||||
#ifdef METAL_AMD_RAYTRACE_WORKAROUND
|
||||
/* For workaround, perform discard backface and background check only within
|
||||
/* For workaround, perform discard back-face and background check only within
|
||||
* the iteration where the first successful ray intersection is registered.
|
||||
* We flag failures to discard ray hits later. */
|
||||
bool hit_valid = !(discard_backface && prev_delta < 0.0) && (depth_sample != 1.0);
|
||||
@@ -112,7 +112,7 @@ bool raytrace_screen(RayTraceData rt_data,
|
||||
#endif
|
||||
}
|
||||
#ifndef METAL_AMD_RAYTRACE_WORKAROUND
|
||||
/* Discard backface hits. */
|
||||
/* Discard back-face hits. */
|
||||
hit = hit && !(discard_backface && prev_delta < 0.0);
|
||||
/* Reject hit if background. */
|
||||
hit = hit && (depth_sample != 1.0);
|
||||
|
||||
@@ -75,7 +75,7 @@ void init_globals_curves()
|
||||
|
||||
void init_globals_gpencil()
|
||||
{
|
||||
/* Undo backface flip as the gpencil normal is already pointing towards the camera. */
|
||||
/* Undo back-face flip as the grease-pencil normal is already pointing towards the camera. */
|
||||
g_data.N = g_data.Ni = interp.N;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ void main()
|
||||
/* Revealage, how much light passes through. */
|
||||
/* Average for alpha channel. */
|
||||
out_reveal.a = clamp(dot(out_reveal.rgb, vec3(0.333334)), 0.0, 1.0);
|
||||
/* Color buffer is already premultiplied. Just add it to the color. */
|
||||
/* Color buffer is already pre-multiplied. Just add it to the color. */
|
||||
/* Add the alpha. */
|
||||
out_color.a = 1.0 - out_reveal.a;
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@ void blend_mode_output(
|
||||
{
|
||||
switch (blend_mode) {
|
||||
case MODE_REGULAR:
|
||||
/* Reminder: Blending func is premult alpha blend `(dst.rgba * (1 - src.a) + src.rgb)`. */
|
||||
/* Reminder: Blending func is pre-multiply alpha blend
|
||||
* `(dst.rgba * (1 - src.a) + src.rgb)`. */
|
||||
color *= opacity;
|
||||
frag_color = color;
|
||||
frag_revealage = vec4(0.0, 0.0, 0.0, color.a);
|
||||
|
||||
@@ -79,7 +79,7 @@ void main()
|
||||
col.rgb *= col.a;
|
||||
|
||||
/* Composite all other colors on top of texture color.
|
||||
* Everything is premult by col.a to have the stencil effect. */
|
||||
* Everything is pre-multiply by `col.a` to have the stencil effect. */
|
||||
fragColor = col * gp_interp.color_mul + col.a * gp_interp.color_add;
|
||||
|
||||
fragColor.rgb *= gpencil_lighting();
|
||||
|
||||
@@ -8,7 +8,7 @@ void main()
|
||||
{
|
||||
vec4 color;
|
||||
|
||||
/* Remember, this is associated alpha (aka. premult). */
|
||||
/* Remember, this is associated alpha (aka. pre-multiply). */
|
||||
color.rgb = textureLod(colorBuf, uvcoordsvar.xy, 0).rgb;
|
||||
/* Stroke only render mono-chromatic revealage. We convert to alpha. */
|
||||
color.a = 1.0 - textureLod(revealBuf, uvcoordsvar.xy, 0).r;
|
||||
|
||||
@@ -207,7 +207,7 @@ void main()
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Premult by foreground alpha (alpha mask). */
|
||||
/* Pre-multiply by foreground alpha (alpha mask). */
|
||||
float mask = 1.0 - clamp(dot(vec3(0.333334), texture(colorBuf, uvcoordsvar.xy).rgb), 0.0, 1.0);
|
||||
|
||||
/* fragRevealage is blurred shadow. */
|
||||
@@ -251,7 +251,7 @@ void main()
|
||||
}
|
||||
fragRevealage /= weight_accum;
|
||||
|
||||
/* No blending in first pass, alpha over premult in second pass. */
|
||||
/* No blending in first pass, alpha over pre-multiply in second pass. */
|
||||
if (isFirstPass) {
|
||||
/* In first pass we copy the reveal buffer. This let us do alpha under in second pass. */
|
||||
fragColor = texture(revealBuf, uvcoordsvar.xy);
|
||||
@@ -259,7 +259,7 @@ void main()
|
||||
else {
|
||||
/* fragRevealage is blurred shadow. */
|
||||
float shadow_fac = 1.0 - clamp(dot(vec3(0.333334), fragRevealage.rgb), 0.0, 1.0);
|
||||
/* Premult by foreground revealage (alpha under). */
|
||||
/* Pre-multiply by foreground revealage (alpha under). */
|
||||
vec3 original_revealage = texture(colorBuf, uvcoordsvar.xy).rgb;
|
||||
shadow_fac *= clamp(dot(vec3(0.333334), original_revealage), 0.0, 1.0);
|
||||
/* Modulate by opacity */
|
||||
|
||||
@@ -38,7 +38,7 @@ void main()
|
||||
vec4 v1 = drw_view.viewmat * boneEnd_4d;
|
||||
|
||||
/* Clip the bone to the camera origin plane (not the clip plane)
|
||||
* to avoid glitches if one end is behind the camera origin (in persp). */
|
||||
* to avoid glitches if one end is behind the camera origin (in perspective mode). */
|
||||
float clip_dist = (drw_view.winmat[3][3] == 0.0) ?
|
||||
-1e-7 :
|
||||
1e20; /* hard-coded, -1e-8 is giving glitches. */
|
||||
|
||||
@@ -35,7 +35,7 @@ void main()
|
||||
|
||||
vec3 blend_base = (abs(frame - frameCurrent) == 0) ?
|
||||
colorCurrentFrame.rgb :
|
||||
colorBackground.rgb; /* "bleed" cframe color to ease color blending */
|
||||
colorBackground.rgb; /* "bleed" CFRAME color to ease color blending */
|
||||
bool use_custom_color = customColor.x >= 0.0;
|
||||
/* TODO: We might want something more consistent with custom color and standard colors. */
|
||||
if (frame < frameCurrent) {
|
||||
|
||||
@@ -37,7 +37,7 @@ void do_vertex_shader(vec4 pos, int vertex_id, out vec2 out_sspos, out vec4 out_
|
||||
float intensity; /* how faint */
|
||||
vec3 blend_base = (abs(frame - frameCurrent) == 0) ?
|
||||
colorCurrentFrame.rgb :
|
||||
colorBackground.rgb; /* "bleed" cframe color to ease color blending */
|
||||
colorBackground.rgb; /* "bleed" CFRAME color to ease color blending. */
|
||||
bool use_custom_color = customColor.x >= 0.0;
|
||||
/* TODO: We might want something more consistent with custom color and standard colors. */
|
||||
if (frame < frameCurrent) {
|
||||
|
||||
@@ -94,7 +94,7 @@ void main()
|
||||
|
||||
#ifndef CUSTOM_DEPTH_BIAS
|
||||
float facing_ratio = clamp(1.0 - facing * facing, 0.0, 1.0);
|
||||
float flip = sign(facing); /* Flip when not facing the normal (i.e.: backfacing). */
|
||||
float flip = sign(facing); /* Flip when not facing the normal (i.e.: back-facing). */
|
||||
float curvature = (1.0 - wd * 0.75); /* Avoid making things worse for curvy areas. */
|
||||
vec3 wofs = wnor * (facing_ratio * curvature * flip);
|
||||
wofs = normal_world_to_view(wofs);
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
void extrude_edge(bool invert)
|
||||
{
|
||||
/* Reverse order if backfacing the light. */
|
||||
/* Reverse order if back-facing the light. */
|
||||
ivec2 idx = (invert) ? ivec2(1, 2) : ivec2(2, 1);
|
||||
gl_Position = vData[idx.x].frontPosition;
|
||||
EmitVertex();
|
||||
|
||||
@@ -35,7 +35,7 @@ VertexData vData[4];
|
||||
|
||||
void extrude_edge(bool invert, int output_vertex_id)
|
||||
{
|
||||
/* Reverse order if backfacing the light. */
|
||||
/* Reverse order if back-facing the light. */
|
||||
ivec2 idx = (invert) ? ivec2(1, 2) : ivec2(2, 1);
|
||||
|
||||
/* Either outputs first or second quad, depending on double manifold status. */
|
||||
|
||||
@@ -305,6 +305,6 @@ void main()
|
||||
length(vs_ray_dir) * stepLength);
|
||||
#endif
|
||||
|
||||
/* Convert transmitance to alpha so we can use premul blending. */
|
||||
/* Convert transmittance to alpha so we can use pre-multiply blending. */
|
||||
fragColor.a = 1.0 - fragColor.a;
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ void drw_print_value(bool value)
|
||||
|
||||
# endif
|
||||
|
||||
/* NOTE(@fclem): This is homebrew and might not be 100% accurate (accuracy has
|
||||
/* NOTE(@fclem): This is home-brew and might not be 100% accurate (accuracy has
|
||||
* not been tested and might dependent on compiler implementation). If unsure,
|
||||
* use drw_print_value_hex and transcribe the value manually with another tool. */
|
||||
void drw_print_value(float val)
|
||||
|
||||
@@ -39,7 +39,7 @@ void write_draw_call(DrawGroup group, uint group_id)
|
||||
cmd.instance_len = group_buf[group_id].front_facing_counter;
|
||||
command_buf[group_id * 2 + 1] = cmd;
|
||||
|
||||
/* Reset the counters for a next command gen dispatch. Avoids resending the whole data just
|
||||
/* Reset the counters for a next command gen dispatch. Avoids re-sending the whole data just
|
||||
* for this purpose. Only the last thread will execute this so it is thread-safe. */
|
||||
group_buf[group_id].front_facing_counter = 0u;
|
||||
group_buf[group_id].back_facing_counter = 0u;
|
||||
|
||||
@@ -84,7 +84,7 @@ EulerXYZ EulerXYZ_identity()
|
||||
* (quaternions and spherical vector coords).
|
||||
*
|
||||
* \param t: factor in [0..1]
|
||||
* \param cosom: dot product from normalized vectors/quats.
|
||||
* \param cosom: dot product from normalized vectors/quaternions.
|
||||
* \param r_w: calculated weights.
|
||||
*/
|
||||
vec2 interpolate_dot_slerp(float t, float cosom)
|
||||
|
||||
@@ -87,14 +87,14 @@ void main()
|
||||
fragColor.a = 1.0;
|
||||
}
|
||||
else {
|
||||
/* Premultiply here. */
|
||||
/* Pre-multiply here. */
|
||||
fragColor = innerColor * vec4(innerColor.aaa, 1.0);
|
||||
}
|
||||
fragColor *= masks.y;
|
||||
fragColor += masks.x * borderColor;
|
||||
fragColor += masks.z * embossColor;
|
||||
|
||||
/* Un-premult because the blend equation is already doing the mult. */
|
||||
/* Un-pre-multiply because the blend equation is already doing the multiplication. */
|
||||
if (fragColor.a > 0.0) {
|
||||
fragColor.rgb /= fragColor.a;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ using uvec2 = uint2;
|
||||
using uvec3 = uint3;
|
||||
using uvec4 = uint4;
|
||||
/* MTLBOOL is used for native boolean's generated by the Metal backend, to avoid type-emulation
|
||||
* for GLSL bools, which are treated as integers. */
|
||||
* for GLSL booleans, which are treated as integers. */
|
||||
#define MTLBOOL bool
|
||||
#define bool int
|
||||
#define bvec2 bool2
|
||||
|
||||
Reference in New Issue
Block a user