|
1 | 1 | // Copyright © 2025 Cory Petkovsek, Roope Palmroos, and Contributors. |
2 | 2 |
|
3 | 3 | R"( |
| 4 | +//INSERT: INDEX_COORD_STANDARD |
| 5 | +ivec3 get_index_coord(const vec2 uv, const int search) { |
| 6 | + vec2 r_uv = round(uv); |
| 7 | + ivec2 pos = ivec2(floor(r_uv * _region_texel_size)) + (_region_map_size / 2); |
| 8 | + int bounds = int(uint(pos.x | pos.y) < uint(_region_map_size)); |
| 9 | + int layer_index = _region_map[pos.y * _region_map_size + pos.x] * bounds - 1; |
| 10 | + return ivec3(ivec2(mod(r_uv, _region_size)), layer_index); |
| 11 | +} |
| 12 | + |
| 13 | +//INSERT: INDEX_COORD_BG_NONE |
| 14 | +ivec3 get_index_coord(const vec2 uv, const int search) { |
| 15 | + vec2 r_uv = round(uv); |
| 16 | + vec2 o_uv = mod(r_uv, _region_size); |
| 17 | + ivec2 pos; |
| 18 | + int bounds, layer_index = -1; |
| 19 | + for (int i = -1; i < clamp(search, SKIP_PASS, FRAGMENT_PASS); i++) { |
| 20 | + if ((layer_index == -1 && _background_mode == 0u ) || i < 0) { |
| 21 | + r_uv -= i == -1 ? vec2(0.0) : vec2(float(o_uv.x <= o_uv.y), float(o_uv.y <= o_uv.x)); |
| 22 | + pos = ivec2(floor((r_uv) * _region_texel_size)) + (_region_map_size / 2); |
| 23 | + bounds = int(uint(pos.x | pos.y) < uint(_region_map_size)); |
| 24 | + layer_index = (_region_map[ pos.y * _region_map_size + pos.x ] * bounds - 1); |
| 25 | + } |
| 26 | + } |
| 27 | + return ivec3(ivec2(mod(r_uv, _region_size)), layer_index); |
| 28 | +} |
| 29 | + |
4 | 30 | //INSERT: FLAT_UNIFORMS |
5 | 31 | uniform float ground_level : hint_range(-1000., 1000.) = 0.0; |
6 | 32 | uniform float region_blend : hint_range(.001, 1., 0.001) = 0.25; |
|
0 commit comments