Blender
V5.3
source
blender
gpu
shaders
material
gpu_shader_material_tex_magic.bsl.hh
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2019-2021 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
5
#pragma once
6
7
#include "
gpu_shader_compat.hh
"
8
#include "
gpu_shader_math_constants.bsl.hh
"
9
10
[[
node
]]
11
void
node_tex_magic
(
12
float3
co,
float
scale
,
float
distortion,
float
depth,
float4
&color,
float
&fac)
13
{
14
float3
p =
mod
(co *
scale
, 2.0f *
M_PI
);
15
16
float
x
=
sin
((p.
x
+ p.
y
+ p.
z
) * 5.0f);
17
float
y
=
cos
((-p.
x
+ p.
y
- p.
z
) * 5.0f);
18
float
z
= -
cos
((-p.
x
- p.
y
+ p.
z
) * 5.0f);
19
20
if
(depth > 0) {
21
x
*= distortion;
22
y
*= distortion;
23
z
*= distortion;
24
y
= -
cos
(
x
-
y
+
z
);
25
y
*= distortion;
26
if
(depth > 1) {
27
x
=
cos
(
x
-
y
-
z
);
28
x
*= distortion;
29
if
(depth > 2) {
30
z
=
sin
(-
x
-
y
-
z
);
31
z
*= distortion;
32
if
(depth > 3) {
33
x
= -
cos
(-
x
+
y
-
z
);
34
x
*= distortion;
35
if
(depth > 4) {
36
y
= -
sin
(-
x
+
y
+
z
);
37
y
*= distortion;
38
if
(depth > 5) {
39
y
= -
cos
(-
x
+
y
+
z
);
40
y
*= distortion;
41
if
(depth > 6) {
42
x
=
cos
(
x
+
y
+
z
);
43
x
*= distortion;
44
if
(depth > 7) {
45
z
=
sin
(
x
+
y
-
z
);
46
z
*= distortion;
47
if
(depth > 8) {
48
x
= -
cos
(-
x
-
y
+
z
);
49
x
*= distortion;
50
if
(depth > 9) {
51
y
= -
sin
(
x
-
y
+
z
);
52
y
*= distortion;
53
}
54
}
55
}
56
}
57
}
58
}
59
}
60
}
61
}
62
}
63
if
(distortion != 0.0f) {
64
distortion *= 2.0f;
65
x
/= distortion;
66
y
/= distortion;
67
z
/= distortion;
68
}
69
70
color =
float4
(0.5f -
x
, 0.5f -
y
, 0.5f -
z
, 1.0f);
71
fac = (color.
x
+ color.
y
+ color.
z
) / 3.0f;
72
}
M_PI
#define M_PI
Definition
BLI_math_constants.hh:21
z
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
Definition
btQuadWord.h:117
y
y
Definition
compositor_morphological_blur_infos.hh:32
gpu_shader_compat.hh
node
#define node
Definition
gpu_shader_cxx_attribute.hh:142
sin
#define sin
Definition
gpu_shader_cxx_builtin.hh:129
cos
#define cos
Definition
gpu_shader_cxx_builtin.hh:127
mod
VecBase< float, D > constexpr mod(VecOp< float, D >, VecOp< float, D >) RET
node_tex_magic
void node_tex_magic(float3 co, float scale, float distortion, float depth, float4 &color, float &fac)
Definition
gpu_shader_material_tex_magic.bsl.hh:11
gpu_shader_math_constants.bsl.hh
scale
float3x3 scale(float3x3 mat, float2 scale)
Definition
gpu_shader_math_matrix.bsl.hh:100
x
uint x
Definition
kernel/device/gpu/kernel.h:142
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
float4::y
float y
Definition
sky_math.h:225
float4::z
float z
Definition
sky_math.h:225
float4::x
float x
Definition
sky_math.h:225
Generated on
for Blender by
doxygen
1.18.0