Blender
V5.3
source
blender
gpu
shaders
common
gpu_shader_ray_utils.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 "
gpu_shader_compat.hh
"
8
17
float3
offset_ray
(
float3
P
,
float3
Ng)
18
{
19
constexpr
float
origin = 1.0f / 32.0f;
20
constexpr
float
float_scale = 1.0f / 65536.0f;
21
constexpr
float
int_scale = 256.0f;
22
23
int3
of_i =
int3
(int_scale * Ng);
24
of_i =
int3
((
P
.x < 0.0f) ? -of_i.
x
: of_i.
x
,
25
(
P
.y < 0.0f) ? -of_i.
y
: of_i.
y
,
26
(
P
.z < 0.0f) ? -of_i.
z
: of_i.
z
);
27
float3
P_i =
intBitsToFloat
(
floatBitsToInt
(
P
) + of_i);
28
29
float3
uf =
P
+ float_scale * Ng;
30
return
float3
((
abs
(
P
.x) < origin) ? uf.
x
: P_i.
x
,
31
(
abs
(
P
.y) < origin) ? uf.
y
: P_i.
y
,
32
(
abs
(
P
.z) < origin) ? uf.
z
: P_i.
z
);
33
}
gpu_shader_compat.hh
floatBitsToInt
VecBase< int, D > floatBitsToInt(VecOp< float, D >) RET
intBitsToFloat
VecBase< float, D > intBitsToFloat(VecOp< int, D >) RET
abs
#define abs
Definition
gpu_shader_cxx_builtin.hh:104
offset_ray
float3 offset_ray(float3 P, float3 Ng)
Definition
gpu_shader_ray_utils.bsl.hh:17
float3
Definition
sky_math.h:135
float3::z
float z
Definition
sky_math.h:136
float3::y
float y
Definition
sky_math.h:136
float3::x
float x
Definition
sky_math.h:136
int3
Definition
int_vector_types.h:58
int3::x
int x
Definition
int_vector_types.h:59
int3::z
int z
Definition
int_vector_types.h:61
int3::y
int y
Definition
int_vector_types.h:60
P
#define P
Definition
uvedit_clipboard_graph_iso.cc:30
Generated on
for Blender by
doxygen
1.18.0