Blender
V5.3
source
blender
gpu
shaders
material
gpu_shader_material_tex_environment.bsl.hh
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2019-2022 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
5
#pragma once
6
7
#include "
gpu_shader_material_vector_math.bsl.hh
"
8
#include "
gpu_shader_math_base.bsl.hh
"
9
10
[[
node
]]
11
void
node_tex_environment_equirectangular
(
float3
co,
float3
&uv)
12
{
13
float3
nco =
vector_math_safe_normalize
(co);
14
if
(nco.
x
== 0.0f || nco.
y
== 0.0f) {
15
uv =
float3
(0.0f);
16
return
;
17
}
18
uv.
x
= -
atan
(nco.
y
, nco.
x
) / (2.0f *
M_PI
) + 0.5f;
19
uv.
y
=
atan
(nco.
z
,
hypot
(nco.
x
, nco.
y
)) /
M_PI
+ 0.5f;
20
}
21
22
[[
node
]]
23
void
node_tex_environment_mirror_ball
(
float3
co,
float3
&uv)
24
{
25
float3
nco =
vector_math_safe_normalize
(co);
26
nco.
y
-= 1.0f;
27
28
float
div = 2.0f *
sqrt
(
max
(-0.5f * nco.
y
, 0.0f));
29
nco /=
max
(1e-8f, div);
30
31
uv = 0.5f * nco.xzz + 0.5f;
32
}
33
34
[[
node
]]
35
void
node_tex_environment_empty
(
float3
/*co*/
,
float4
&color)
36
{
37
color =
float4
(1.0f, 0.0f, 1.0f, 1.0f);
38
}
M_PI
#define M_PI
Definition
BLI_math_constants.hh:21
max
btScalar max
Definition
btHeightfieldTerrainShape.h:79
node
#define node
Definition
gpu_shader_cxx_attribute.hh:142
atan
#define atan
Definition
gpu_shader_cxx_builtin.hh:125
sqrt
#define sqrt
Definition
gpu_shader_cxx_builtin.hh:118
node_tex_environment_equirectangular
void node_tex_environment_equirectangular(float3 co, float3 &uv)
Definition
gpu_shader_material_tex_environment.bsl.hh:11
node_tex_environment_empty
void node_tex_environment_empty(float3, float4 &color)
Definition
gpu_shader_material_tex_environment.bsl.hh:35
node_tex_environment_mirror_ball
void node_tex_environment_mirror_ball(float3 co, float3 &uv)
Definition
gpu_shader_material_tex_environment.bsl.hh:23
gpu_shader_material_vector_math.bsl.hh
vector_math_safe_normalize
float3 vector_math_safe_normalize(float3 a)
Definition
gpu_shader_material_vector_math.bsl.hh:9
gpu_shader_math_base.bsl.hh
hypot
float hypot(float x, float y)
Definition
gpu_shader_math_base.bsl.hh:73
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
float4
Definition
sky_math.h:224
Generated on
for Blender by
doxygen
1.18.0