This patch refactors the texture samples code by mainly splitting the eGPUSamplerState enum into multiple smaller enums and packing them inside a GPUSamplerState struct. This was done because many members of the enum were mutually exclusive, which was worked around during setting up the samplers in the various backends, and additionally made the API confusing, like the GPU_texture_wrap_mode function, which had two mutually exclusive parameters. The new structure also improved and clarified the backend sampler cache, reducing the cache size from 514 samplers to just 130 samplers, which also slightly improved the initialization time. Further, the GPU_SAMPLER_MAX signal value was naturally incorporated into the structure using the GPU_SAMPLER_STATE_TYPE_INTERNAL type. The only expected functional change is in the realtime compositor, which now supports per-axis repetition control, utilizing new API functions for that purpose. This patch is loosely based on an older patch D14366 by Ethan Hall. Pull Request: https://projects.blender.org/blender/blender/pulls/105642
47 lines
1.7 KiB
GLSL
47 lines
1.7 KiB
GLSL
/**
|
|
* Draw the icons, leaving a semi-transparent rectangle on top of the icon.
|
|
*
|
|
* The top-left corner of the rectangle is rounded and drawned with anti-alias.
|
|
* The anti-alias is done by transitioning from the outer to the inner radius of
|
|
* the rounded corner, and the rectangle sides.
|
|
*/
|
|
|
|
void main()
|
|
{
|
|
/* Sample texture with LOD BIAS. Used instead of custom lod bias in GPU_SAMPLER_CUSTOM_ICON. */
|
|
fragColor = texture(image, texCoord_interp, -0.5) * finalColor;
|
|
|
|
#ifdef DO_CORNER_MASKING
|
|
/* Top-left rounded corner parameters. */
|
|
const float circle_radius_outer = 0.1;
|
|
const float circle_radius_inner = 0.075;
|
|
|
|
/**
|
|
* Add a bit transparency to see a bit of the icon, without
|
|
* getting on the way of readability. */
|
|
const float mask_transparency = 0.25;
|
|
|
|
vec2 circle_center = vec2(circle_radius_outer - text_width, 0.5);
|
|
|
|
/* Radius in icon space (1 is the icon width). */
|
|
float radius = length(mask_coord_interp - circle_center);
|
|
float mask = smoothstep(circle_radius_inner, circle_radius_outer, radius);
|
|
|
|
bool lower_half = mask_coord_interp.y < circle_center.y;
|
|
bool right_half = mask_coord_interp.x > circle_center.x;
|
|
|
|
if (right_half && mask_coord_interp.y < circle_center.y + circle_radius_outer) {
|
|
mask = smoothstep(circle_center.y + circle_radius_inner,
|
|
circle_center.y + circle_radius_outer,
|
|
mask_coord_interp.y);
|
|
}
|
|
if (lower_half && mask_coord_interp.x > circle_center.x - circle_radius_outer) {
|
|
mask = smoothstep(circle_center.x - circle_radius_inner,
|
|
circle_center.x - circle_radius_outer,
|
|
mask_coord_interp.x);
|
|
}
|
|
|
|
fragColor = mix(vec4(0.0), fragColor, max(mask_transparency, mask));
|
|
#endif
|
|
}
|