Blender V5.3
eevee_utility_tx.bsl.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
7#include "eevee_defines.hh"
9
12
13 /* Fetch texel. Repeat extend mode if above range. */
14 float4 fetch(float2 texel, float layer) const
15 {
16 return texelFetch(utility_tx, int3(int2(texel) % UTIL_TEX_SIZE, int(layer)), 0);
17 }
18
19 /* Sample at uv position. Filtered & extend mode enabled. */
21 {
22 return textureLod(utility_tx, float3(uv, layer), 0.0f);
23 }
24
25 /* Sample at uv position but with scale and bias so that uv space bounds lie on texel centers. */
26 float4 sample_lut(float2 uv, float layer) const
27 {
28 /* Scale and bias coordinates, for correct filtered lookup. */
30 return textureLod(utility_tx, float3(uv, layer), 0.0f);
31 }
32
33 /* Sample GGX BSDF LUT. */
35 {
36 /* Scale and bias coordinates, for correct filtered lookup. */
39
40 float layer_floored;
41 float interp = modf(layer, layer_floored);
42
43 float4 tex_low = textureLod(utility_tx, float3(uv, layer_floored), 0.0f);
44 float4 tex_high = textureLod(utility_tx, float3(uv, layer_floored + 1.0f), 0.0f);
45
46 /* Manual trilinear interpolation. */
47 return mix(tex_low, tex_high, interp);
48 }
49};
#define RBUFS_UTILITY_TEX_SLOT
#define UTIL_BSDF_LAYER
#define UTIL_TEX_UV_BIAS
#define UTIL_TEX_UV_SCALE
#define UTIL_BSDF_LAYER_COUNT
#define UTIL_TEX_SIZE
#define sampler(slot)
#define layer
#define modf
TEX_TEMPLATE DataVec texelFetch(T, IntCoord, int) RET
TEX_TEMPLATE DataVec textureLod(T, FltCoord, float) RET
SamplerBase< float, 2, false, true > sampler2DArray
ccl_device_inline float interp(const float a, const float b, const float t)
Definition math_base.h:549
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< int32_t, 3 > int3
VecBase< float, 3 > float3
#define mix
float4 sample_lut(float2 uv, float layer) const
float4 sample_extend(float2 uv, float layer) const
float4 sample_bsdf_lut(float2 uv, float layer) const
sampler2DArray utility_tx
float4 fetch(float2 texel, float layer) const