forked from blender/blender
main sync #3
@ -13,9 +13,9 @@ void cubic_bspline_coefficients(vec2 f, out vec2 w0, out vec2 w1, out vec2 w2, o
|
||||
/* Samples the given 2D sampler at the given coordinates using Bicubic interpolation. This function
|
||||
* uses an optimized algorithm which assumes a linearly filtered sampler, so the caller needs to
|
||||
* take that into account when setting up the sampler. */
|
||||
vec4 texture_bicubic(sampler2D sampler, vec2 coordinates)
|
||||
vec4 texture_bicubic(sampler2D sampler_2d, vec2 coordinates)
|
||||
{
|
||||
vec2 texture_size = vec2(textureSize(sampler, 0).xy);
|
||||
vec2 texture_size = vec2(textureSize(sampler_2d, 0).xy);
|
||||
coordinates.xy *= texture_size;
|
||||
|
||||
vec2 w0, w1, w2, w3;
|
||||
@ -35,33 +35,33 @@ vec4 texture_bicubic(sampler2D sampler, vec2 coordinates)
|
||||
|
||||
sampling_coordinates /= texture_size.xyxy;
|
||||
|
||||
vec4 sampled_color = textureLod(sampler, sampling_coordinates.xy, 0.0) * s0.x * s0.y;
|
||||
sampled_color += textureLod(sampler, sampling_coordinates.zy, 0.0) * s1.x * s0.y;
|
||||
sampled_color += textureLod(sampler, sampling_coordinates.xw, 0.0) * s0.x * s1.y;
|
||||
sampled_color += textureLod(sampler, sampling_coordinates.zw, 0.0) * s1.x * s1.y;
|
||||
vec4 sampled_color = textureLod(sampler_2d, sampling_coordinates.xy, 0.0) * s0.x * s0.y;
|
||||
sampled_color += textureLod(sampler_2d, sampling_coordinates.zy, 0.0) * s1.x * s0.y;
|
||||
sampled_color += textureLod(sampler_2d, sampling_coordinates.xw, 0.0) * s0.x * s1.y;
|
||||
sampled_color += textureLod(sampler_2d, sampling_coordinates.zw, 0.0) * s1.x * s1.y;
|
||||
|
||||
return sampled_color;
|
||||
|
||||
#else /* Reference brute-force 16 taps. */
|
||||
vec4 color = texelFetch(sampler, ivec2(texel_center + vec2(-1.0, -1.0)), 0) * w0.x * w0.y;
|
||||
color += texelFetch(sampler, ivec2(texel_center + vec2(0.0, -1.0)), 0) * w1.x * w0.y;
|
||||
color += texelFetch(sampler, ivec2(texel_center + vec2(1.0, -1.0)), 0) * w2.x * w0.y;
|
||||
color += texelFetch(sampler, ivec2(texel_center + vec2(2.0, -1.0)), 0) * w3.x * w0.y;
|
||||
vec4 color = texelFetch(sampler_2d, ivec2(texel_center + vec2(-1.0, -1.0)), 0) * w0.x * w0.y;
|
||||
color += texelFetch(sampler_2d, ivec2(texel_center + vec2(0.0, -1.0)), 0) * w1.x * w0.y;
|
||||
color += texelFetch(sampler_2d, ivec2(texel_center + vec2(1.0, -1.0)), 0) * w2.x * w0.y;
|
||||
color += texelFetch(sampler_2d, ivec2(texel_center + vec2(2.0, -1.0)), 0) * w3.x * w0.y;
|
||||
|
||||
color += texelFetch(sampler, ivec2(texel_center + vec2(-1.0, 0.0)), 0) * w0.x * w1.y;
|
||||
color += texelFetch(sampler, ivec2(texel_center + vec2(0.0, 0.0)), 0) * w1.x * w1.y;
|
||||
color += texelFetch(sampler, ivec2(texel_center + vec2(1.0, 0.0)), 0) * w2.x * w1.y;
|
||||
color += texelFetch(sampler, ivec2(texel_center + vec2(2.0, 0.0)), 0) * w3.x * w1.y;
|
||||
color += texelFetch(sampler_2d, ivec2(texel_center + vec2(-1.0, 0.0)), 0) * w0.x * w1.y;
|
||||
color += texelFetch(sampler_2d, ivec2(texel_center + vec2(0.0, 0.0)), 0) * w1.x * w1.y;
|
||||
color += texelFetch(sampler_2d, ivec2(texel_center + vec2(1.0, 0.0)), 0) * w2.x * w1.y;
|
||||
color += texelFetch(sampler_2d, ivec2(texel_center + vec2(2.0, 0.0)), 0) * w3.x * w1.y;
|
||||
|
||||
color += texelFetch(sampler, ivec2(texel_center + vec2(-1.0, 1.0)), 0) * w0.x * w2.y;
|
||||
color += texelFetch(sampler, ivec2(texel_center + vec2(0.0, 1.0)), 0) * w1.x * w2.y;
|
||||
color += texelFetch(sampler, ivec2(texel_center + vec2(1.0, 1.0)), 0) * w2.x * w2.y;
|
||||
color += texelFetch(sampler, ivec2(texel_center + vec2(2.0, 1.0)), 0) * w3.x * w2.y;
|
||||
color += texelFetch(sampler_2d, ivec2(texel_center + vec2(-1.0, 1.0)), 0) * w0.x * w2.y;
|
||||
color += texelFetch(sampler_2d, ivec2(texel_center + vec2(0.0, 1.0)), 0) * w1.x * w2.y;
|
||||
color += texelFetch(sampler_2d, ivec2(texel_center + vec2(1.0, 1.0)), 0) * w2.x * w2.y;
|
||||
color += texelFetch(sampler_2d, ivec2(texel_center + vec2(2.0, 1.0)), 0) * w3.x * w2.y;
|
||||
|
||||
color += texelFetch(sampler, ivec2(texel_center + vec2(-1.0, 2.0)), 0) * w0.x * w3.y;
|
||||
color += texelFetch(sampler, ivec2(texel_center + vec2(0.0, 2.0)), 0) * w1.x * w3.y;
|
||||
color += texelFetch(sampler, ivec2(texel_center + vec2(1.0, 2.0)), 0) * w2.x * w3.y;
|
||||
color += texelFetch(sampler, ivec2(texel_center + vec2(2.0, 2.0)), 0) * w3.x * w3.y;
|
||||
color += texelFetch(sampler_2d, ivec2(texel_center + vec2(-1.0, 2.0)), 0) * w0.x * w3.y;
|
||||
color += texelFetch(sampler_2d, ivec2(texel_center + vec2(0.0, 2.0)), 0) * w1.x * w3.y;
|
||||
color += texelFetch(sampler_2d, ivec2(texel_center + vec2(1.0, 2.0)), 0) * w2.x * w3.y;
|
||||
color += texelFetch(sampler_2d, ivec2(texel_center + vec2(2.0, 2.0)), 0) * w3.x * w3.y;
|
||||
|
||||
return color;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user