Cleanup: spelling, use C-style in GLSL

This commit is contained in:
Campbell Barton
2023-08-19 17:13:05 +10:00
parent e7c94b35b8
commit add2a656da
36 changed files with 83 additions and 84 deletions

View File

@@ -2,9 +2,9 @@
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/// This file contains all opencl kernels for node-operation implementations
/* This file contains all opencl kernels for node-operation implementations. */
// Global SAMPLERS
/* Global SAMPLERS. */
const sampler_t SAMPLER_NEAREST = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;
const sampler_t SAMPLER_NEAREST_CLAMP = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST;

View File

@@ -17,9 +17,10 @@ void main()
else if (vertex_fetch_get_input_prim_type() == GPU_PRIM_TRI_STRIP) {
base_vertex_id = output_triangle_id;
}
/* NOTE: Triangle fan unsupported in Metal. Will be conveted upfront. */
/* NOTE: Triangle fan unsupported in Metal. Will be converted upfront. */
/* Perform vertex shader calculations per input vertex. */
/** Perform vertex shader calculations per input vertex. **/
/* input pos vertex attribute. */
vec3 in_pos[3];
/* Calculated per-vertex world pos. */
@@ -36,10 +37,10 @@ void main()
pos[i] = ndc_pos[i].xyz / ndc_pos[i].w;
}
/** Geometry Shader equivalent calculation
/* Geometry Shader equivalent calculation
* In this no_geom mode using SSBO vertex fetch, rather than emitting 3 vertices, the vertex
* shader is invocated 3 times, and output is determined based on vertex ID within a triangle
* 0..2. **/
* shader is innovated 3 times, and output is determined based on vertex ID within a triangle
* 0..2. */
vec3 plane = normalize(cross(pos[1] - pos[0], pos[2] - pos[0]));
/* Compute NDC bound box. */
vec4 bbox = vec4(min(min(pos[0].xy, pos[1].xy), pos[2].xy),

View File

@@ -76,7 +76,7 @@ IN_OUT ShaderPointCloudInterface
# endif
#else
/** Checks to ensure create-info is setup correctly. **/
/* Checks to ensure create-info is setup correctly. */
# ifdef HAIR_SHADER
# ifndef USE_SURFACE_LIB_HAIR
# error Ensure CreateInfo eevee_legacy_surface_lib_hair is included if using surface library with a hair shader.

View File

@@ -1,7 +1,7 @@
/**
* BxDF evaluation functions.
**/
*/
#pragma BLENDER_REQUIRE(common_math_lib.glsl)

View File

@@ -1,7 +1,7 @@
/**
* Sampling of Normal Distribution Function for various BxDF.
**/
*/
#pragma BLENDER_REQUIRE(eevee_bxdf_lib.glsl)
#pragma BLENDER_REQUIRE(common_math_geom_lib.glsl)

View File

@@ -1,7 +1,7 @@
/**
* Camera projection / uv functions and utils.
**/
*/
#pragma BLENDER_REQUIRE(common_math_lib.glsl)

View File

@@ -3,7 +3,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.
**/
*/
#pragma BLENDER_REQUIRE(common_view_lib.glsl)
#pragma BLENDER_REQUIRE(eevee_colorspace_lib.glsl)
@@ -166,10 +166,9 @@ void dof_gather_accumulate_sample_pair(DofGatherData pair_data[2],
pair_data[i].coc, pair_data[i].dist, intersection_multiplier);
float weight = inter_weight * layer_weight * sample_weight;
/**
* If a CoC is larger than bordering radius we accumulate it to the general accumulator.
/* If a CoC is larger than bordering radius we accumulate it to the general accumulator.
* If not, we accumulate to the ring bucket. This is to have more consistent sample occlusion.
**/
*/
float accum_weight = dof_gather_accum_weight(pair_data[i].coc, bordering_radius, first_ring);
dof_gather_accumulate_sample(pair_data[i], weight * accum_weight, accum_data);
dof_gather_accumulate_sample(pair_data[i], weight * (1.0 - accum_weight), ring_data);

View File

@@ -10,7 +10,7 @@
*
* Outputs:
* - Color * Weight, Weight, Occlusion 'CoC' Depth (mean and variance)
**/
*/
#pragma BLENDER_REQUIRE(eevee_depth_of_field_accumulator_lib.glsl)

View File

@@ -7,7 +7,7 @@
*
* We sample using an octaweb sampling pattern. We randomize the kernel center and each ring
* rotation to ensure maximum coverage.
**/
*/
#pragma BLENDER_REQUIRE(eevee_depth_of_field_accumulator_lib.glsl)

View File

@@ -1,7 +1,7 @@
/**
* Depth of Field utils.
**/
*/
#pragma BLENDER_REQUIRE(common_view_lib.glsl)
#pragma BLENDER_REQUIRE(common_math_lib.glsl)
@@ -305,7 +305,7 @@ CocTilePrediction dof_coc_tile_prediction_get(CocTile tile)
* . . . . .
*
* Samples are expected to be mirrored to complete the pattern.
**/
*/
ivec2 dof_square_ring_sample_offset(int ring_distance, int sample_id)
{
ivec2 offset;

View File

@@ -10,7 +10,7 @@
* Outputs:
* - Halfres 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).
**/
*/
#pragma BLENDER_REQUIRE(eevee_depth_of_field_lib.glsl)

View File

@@ -4,7 +4,7 @@
*
* We only scatter one triangle per sprite and one sprite per 4 pixels to reduce vertex shader
* invocations and overdraw.
**/
*/
#pragma BLENDER_REQUIRE(eevee_depth_of_field_lib.glsl)

View File

@@ -9,7 +9,7 @@
* Full-resolution color & depth buffer
* Output:
* Half-resolution Color, signed CoC (out_coc.x), and max slight focus abs CoC (out_coc.y).
**/
*/
#pragma BLENDER_REQUIRE(common_math_lib.glsl)
#pragma BLENDER_REQUIRE(common_view_lib.glsl)

View File

@@ -12,7 +12,7 @@
* - Output of setup pass (halfres).
* Outputs:
* - Stabilized Color and CoC (halfres).
**/
*/
#pragma BLENDER_REQUIRE(common_math_geom_lib.glsl)
#pragma BLENDER_REQUIRE(eevee_colorspace_lib.glsl)

View File

@@ -5,7 +5,7 @@
*
* Input & Output:
* - Separated foreground and background CoC. 1/8th of half-res resolution. So 1/16th of full-res.
**/
*/
#pragma BLENDER_REQUIRE(eevee_depth_of_field_lib.glsl)

View File

@@ -1,7 +1,7 @@
/**
* Film accumulation utils functions.
**/
*/
#pragma BLENDER_REQUIRE(common_view_lib.glsl)
#pragma BLENDER_REQUIRE(common_math_geom_lib.glsl)

View File

@@ -1,7 +1,7 @@
/**
* Custom fullscreen triangle with placeholders varyings.
**/
*/
#pragma BLENDER_REQUIRE(common_view_lib.glsl)
#pragma BLENDER_REQUIRE(eevee_nodetree_lib.glsl)

View File

@@ -110,11 +110,10 @@ float light_point_light(LightData ld, const bool is_directional, vec3 L, float d
if (is_directional) {
return 1.0;
}
/**
* Using "Point Light Attenuation Without Singularity" from Cem Yuksel
/* Using "Point Light Attenuation Without Singularity" from Cem Yuksel
* http://www.cemyuksel.com/research/pointlightattenuation/pointlightattenuation.pdf
* http://www.cemyuksel.com/research/pointlightattenuation/
**/
*/
float d_sqr = sqr(dist);
float r_sqr = ld.radius_squared;
/* Using reformulation that has better numerical precision. */

View File

@@ -2,7 +2,7 @@
/**
* Sampling data accessors and random number generators.
* Also contains some sample mapping functions.
**/
*/
#pragma BLENDER_REQUIRE(common_math_lib.glsl)

View File

@@ -9,7 +9,7 @@
*
* But, instead of having all the precomputed weights for all three color primaries,
* we precompute a weight profile texture to be able to support per pixel AND per channel radius.
**/
*/
#pragma BLENDER_REQUIRE(gpu_shader_codegen_lib.glsl)
#pragma BLENDER_REQUIRE(eevee_gbuffer_lib.glsl)

View File

@@ -3,7 +3,7 @@
* Forward lighting evaluation: Lighting is evaluated during the geometry rasterization.
*
* This is used by alpha blended materials and materials using Shader to RGB nodes.
**/
*/
#pragma BLENDER_REQUIRE(common_hair_lib.glsl)
#pragma BLENDER_REQUIRE(common_math_lib.glsl)

View File

@@ -6,7 +6,7 @@
* virtual page it is supposed to go and load the physical page adress.
* If a physical page exists, we then use atomicMin to mimic a less-than depth test and write to
* the destination texel.
**/
*/
#pragma BLENDER_REQUIRE(common_view_lib.glsl)
#pragma BLENDER_REQUIRE(common_math_lib.glsl)

View File

@@ -3,7 +3,7 @@
* Background used to shade the world.
*
* Outputs shading parameter per pixel using a set of randomized BSDFs.
**/
*/
#pragma BLENDER_REQUIRE(common_view_lib.glsl)
#pragma BLENDER_REQUIRE(common_math_lib.glsl)

View File

@@ -5,10 +5,10 @@
/**
* We want to know how much a pixel is covered by a line.
* We replace the square pixel with acircle of the same area and try to find the intersection area.
* We replace the square pixel with a circle of the same area and try to find the intersection area.
* The area we search is the circular segment. https://en.wikipedia.org/wiki/Circular_segment
* The formula for the area uses inverse trig function and is quite complexe. Instead,
* we approximate it by using the smoothstep function and a 1.05 factor to the disc radius.
* The formula for the area uses inverse trig function and is quite complex. Instead,
* we approximate it by using the smooth-step function and a 1.05 factor to the disc radius.
*/
#define DISC_RADIUS (M_1_SQRTPI * 1.05)
#define LINE_SMOOTH_START (0.5 - DISC_RADIUS)

View File

@@ -114,8 +114,8 @@ void main()
offset.x = 0.0;
}
/** Each output vertex falls into 10 possible positions to generate 8 output triangles between 5
* lines. **/
/* Each output vertex falls into 10 possible positions to generate 8 output triangles between 5
* lines. */
/* Discard transparent border quads up-front. */
if (!(is_active_nurb != 0u)) {
if (output_quad_id == 0 || output_quad_id == 3) {

View File

@@ -3,10 +3,10 @@
/**
* We want to know how much a pixel is covered by a line.
* We replace the square pixel with acircle of the same area and try to find the intersection area.
* We replace the square pixel with a circle of the same area and try to find the intersection area.
* The area we search is the circular segment. https://en.wikipedia.org/wiki/Circular_segment
* The formula for the area uses inverse trig function and is quite complexe. Instead,
* we approximate it by using the smoothstep function and a 1.05 factor to the disc radius.
* The formula for the area uses inverse trig function and is quite complex. Instead,
* we approximate it by using the smooth-step function and a 1.05 factor to the disc radius.
*/
#define DISC_RADIUS (M_1_SQRTPI * 1.05)
#define GRID_LINE_SMOOTH_START (0.5 - DISC_RADIUS)

View File

@@ -2,7 +2,7 @@
/**
* We want to know how much a pixel is covered by a line.
* We replace the square pixel with acircle of the same area and try to find the intersection area.
* We replace the square pixel with a circle of the same area and try to find the intersection area.
* The area we search is the circular segment. https://en.wikipedia.org/wiki/Circular_segment
* The formula for the area uses inverse trig function and is quite complex. Instead,
* we approximate it by using the smooth-step function and a 1.05 factor to the disc radius.

View File

@@ -1,8 +1,8 @@
/**
* Infinite grid:
* Draw antialiased grid and axes of different sizes with smooth blending between levels of detail.
* Draw anti-aliased grid and axes of different sizes with smooth blending between levels of detail.
* We draw multiple triangles to avoid float precision issues due to perspective interpolation.
**/
*/
#pragma BLENDER_REQUIRE(common_view_lib.glsl)
#pragma BLENDER_REQUIRE(common_math_lib.glsl)

View File

@@ -1,8 +1,8 @@
/**
* Infinite grid:
* Draw antialiazed grid and axes of different sizes with smooth blending between Level of details.
* Draw anti-aliased grid and axes of different sizes with smooth blending between Level of details.
* We draw multiple triangles to avoid float precision issues due to perspective interpolation.
**/
*/
#pragma BLENDER_REQUIRE(common_view_lib.glsl)
#pragma BLENDER_REQUIRE(common_math_lib.glsl)

View File

@@ -4,7 +4,7 @@
*
* Quick way to draw debug geometry. All input should be in world space and
* will be rendered in the default view. No additional setup required.
**/
*/
/** Global switch option. */
bool drw_debug_draw_enable = true;

View File

@@ -1,7 +1,7 @@
/**
* Display debug edge list.
**/
*/
void main()
{

View File

@@ -1,7 +1,7 @@
/**
* Display debug edge list.
**/
*/
void main()
{

View File

@@ -1,7 +1,7 @@
/**
* Display characters using an ascii table.
**/
*/
#pragma BLENDER_REQUIRE(common_math_lib.glsl)

View File

@@ -1,7 +1,7 @@
/**
* Display characters using an ascii table. Outputs one point per character.
**/
*/
#pragma BLENDER_REQUIRE(common_view_lib.glsl)

View File

@@ -292,8 +292,8 @@
* That's it!
*/
//-----------------------------------------------------------------------------
// SMAA Presets
/* ----------------------------------------------------------------------------
* SMAA Presets */
/**
* Note that if you use one of these presets, the following configuration
@@ -322,8 +322,8 @@
# define SMAA_CORNER_ROUNDING 25
#endif
//-----------------------------------------------------------------------------
// Configurable Defines
/* ----------------------------------------------------------------------------
* Configurable Defines */
/**
* SMAA_THRESHOLD specifies the threshold or sensitivity to edges.
@@ -491,8 +491,8 @@
# define SMAA_INCLUDE_PS 1
#endif
//-----------------------------------------------------------------------------
// Texture Access Defines
/* ----------------------------------------------------------------------------
* Texture Access Defines */
#ifndef SMAA_AREATEX_SELECT
# if defined(SMAA_HLSL_3)
@@ -510,8 +510,8 @@
# define SMAA_DECODE_VELOCITY(sample) sample.rg
#endif
//-----------------------------------------------------------------------------
// Non-Configurable Defines
/* ----------------------------------------------------------------------------
* Non-Configurable Defines */
#define SMAA_AREATEX_MAX_DISTANCE 16
#define SMAA_AREATEX_MAX_DISTANCE_DIAG 20
@@ -521,8 +521,8 @@
#define SMAA_SEARCHTEX_PACKED_SIZE float2(64.0, 16.0)
#define SMAA_CORNER_ROUNDING_NORM (float(SMAA_CORNER_ROUNDING) / 100.0)
//-----------------------------------------------------------------------------
// Porting Functions
/* ----------------------------------------------------------------------------
* Porting Functions */
#if defined(SMAA_HLSL_3)
# define SMAATexture2D(tex) sampler2D tex
@@ -628,8 +628,8 @@ float mad(float a, float b, float c)
#endif
/* clang-format on */
//-----------------------------------------------------------------------------
// Misc functions
/* ----------------------------------------------------------------------------
* Misc functions */
/**
* Gathers current pixel, and the top-left neighbors.
@@ -675,8 +675,8 @@ void SMAAMovc(bool4 cond, inout float4 variable, float4 value)
}
#if SMAA_INCLUDE_VS
//-----------------------------------------------------------------------------
// Vertex Shaders
/* ----------------------------------------------------------------------------
* Vertex Shaders */
/**
* Edge Detection Vertex Shader
@@ -731,8 +731,8 @@ void SMAANeighborhoodBlendingVS(float2 texcoord, out float4 offset)
#endif // SMAA_INCLUDE_VS
#if SMAA_INCLUDE_PS
//-----------------------------------------------------------------------------
// Edge Detection Pixel Shaders (First Pass)
/* ----------------------------------------------------------------------------
* Edge Detection Pixel Shaders (First Pass) */
# ifndef SMAA_LUMA_WEIGHT
# define SMAA_LUMA_WEIGHT float4(0.2126, 0.7152, 0.0722, 0.0)
@@ -909,8 +909,8 @@ float2 SMAADepthEdgeDetectionPS(float2 texcoord, float4 offset[3], SMAATexture2D
return edges;
}
//-----------------------------------------------------------------------------
// Diagonal Search Functions
/* ----------------------------------------------------------------------------
* Diagonal Search Functions */
# if !defined(SMAA_DISABLE_DIAG_DETECTION)
@@ -1081,8 +1081,8 @@ float2 SMAACalculateDiagWeights(SMAATexture2D(edgesTex),
}
# endif
//-----------------------------------------------------------------------------
// Horizontal/Vertical Search Functions
/* ----------------------------------------------------------------------------
* Horizontal/Vertical Search Functions */
/**
* This allows to determine how much length should we add in the last step
@@ -1220,8 +1220,8 @@ float2 SMAAArea(SMAATexture2D(areaTex), float2 dist, float e1, float e2, float o
return SMAA_AREATEX_SELECT(SMAASampleLevelZero(areaTex, texcoord));
}
//-----------------------------------------------------------------------------
// Corner Detection Functions
/* ----------------------------------------------------------------------------
* Corner Detection Functions */
void SMAADetectHorizontalCornerPattern(SMAATexture2D(edgesTex),
inout float2 weights,
@@ -1265,8 +1265,8 @@ void SMAADetectVerticalCornerPattern(SMAATexture2D(edgesTex),
# endif
}
//-----------------------------------------------------------------------------
// Blending Weight Calculation Pixel Shader (Second Pass)
/* ----------------------------------------------------------------------------
* Blending Weight Calculation Pixel Shader (Second Pass) */
float4 SMAABlendingWeightCalculationPS(float2 texcoord,
float2 pixcoord,
@@ -1396,8 +1396,8 @@ float4 SMAABlendingWeightCalculationPS(float2 texcoord,
return weights;
}
//-----------------------------------------------------------------------------
// Neighborhood Blending Pixel Shader (Third Pass)
/* ----------------------------------------------------------------------------
* Neighborhood Blending Pixel Shader (Third Pass) */
float4 SMAANeighborhoodBlendingPS(float2 texcoord,
float4 offset,
@@ -1463,8 +1463,8 @@ float4 SMAANeighborhoodBlendingPS(float2 texcoord,
}
}
//-----------------------------------------------------------------------------
// Temporal Resolve Pixel Shader (Optional Pass)
/* ----------------------------------------------------------------------------
* Temporal Resolve Pixel Shader (Optional Pass) */
float4 SMAAResolvePS(float2 texcoord,
SMAATexture2D(currentColorTex),
@@ -1500,8 +1500,8 @@ float4 SMAAResolvePS(float2 texcoord,
# endif
}
//-----------------------------------------------------------------------------
// Separate Multisamples Pixel Shader (Optional Pass)
/* ----------------------------------------------------------------------------
* Separate Multisamples Pixel Shader (Optional Pass) */
# ifdef SMAALoad
void SMAASeparatePS(float4 position,
@@ -1516,5 +1516,5 @@ void SMAASeparatePS(float4 position,
}
# endif
//-----------------------------------------------------------------------------
/* ---------------------------------------------------------------------------- */
#endif // SMAA_INCLUDE_PS

View File

@@ -132,7 +132,7 @@ void main()
clip_g[1] = dot(ModelMatrix * vec4(in_pos1, 1.0), ClipPlane);
#endif
/*** Geometry Shader Alternative. ***/
/** Geometry Shader Alternative. */
vec4 p0 = clip_line_point_homogeneous_space(out_pos0, out_pos1);
vec4 p1 = clip_line_point_homogeneous_space(out_pos1, out_pos0);
vec2 e = normalize(((p1.xy / p1.w) - (p0.xy / p0.w)) * viewportSize.xy);