Blender V5.3
gpu_shader_tiled_image_lookup.bsl.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2026 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
8
10{
11 float2 tile_pos = floor(co.xy);
12
13 if (tile_pos.x < 0 || tile_pos.y < 0 || tile_pos.x >= 10) {
14 return false;
15 }
16 float tile = 10 * tile_pos.y + tile_pos.x;
17 if (tile >= textureSize(map, 0).x) {
18 return false;
19 }
20 /* Fetch tile information. */
21 float tile_layer = texelFetch(map, int2(tile, 0), 0).x;
22 if (tile_layer < 0) {
23 return false;
24 }
25 float4 tile_info = texelFetch(map, int2(tile, 1), 0);
26
27 co = float3(((co.xy - tile_pos) * tile_info.zw) + tile_info.xy, tile_layer);
28 return true;
29}
#define floor
SamplerBase< float, 1, false, true > sampler1DArray
TEX_TEMPLATE DataVec texelFetch(T, IntCoord, int) RET
SamplerBase< float, 2, false, true > sampler2DArray
TEX_TEMPLATE SizeVec textureSize(T, int) RET
bool tiled_image_lookup(float3 &co, sampler2DArray, sampler1DArray map)
const ccl_global KernelWorkTile * tile
float x
float y