Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gpu_shader_compositor_texture_utilities.glsl « library « compositor « shaders « gpu « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 00e9a3910970487e9d9a357a701f1fbcdb375b93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* A shorthand for 1D textureSize with a zero LOD. */
int texture_size(sampler1D sampler)
{
  return textureSize(sampler, 0);
}

/* A shorthand for 1D texelFetch with zero LOD and bounded access clamped to border. */
vec4 texture_load(sampler1D sampler, int x)
{
  const int texture_bound = texture_size(sampler) - 1;
  return texelFetch(sampler, clamp(x, 0, texture_bound), 0);
}

/* A shorthand for 2D textureSize with a zero LOD. */
ivec2 texture_size(sampler2D sampler)
{
  return textureSize(sampler, 0);
}

/* A shorthand for 2D texelFetch with zero LOD and bounded access clamped to border. */
vec4 texture_load(sampler2D sampler, ivec2 texel)
{
  const ivec2 texture_bounds = texture_size(sampler) - ivec2(1);
  return texelFetch(sampler, clamp(texel, ivec2(0), texture_bounds), 0);
}