Blender V5.3
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
9
10[[node]]
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}
#define M_PI
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
Definition btQuadWord.h:117
#define sin
#define cos
VecBase< float, D > constexpr mod(VecOp< float, D >, VecOp< float, D >) RET
void node_tex_magic(float3 co, float scale, float distortion, float depth, float4 &color, float &fac)
float3x3 scale(float3x3 mat, float2 scale)
float z
Definition sky_math.h:136
float y
Definition sky_math.h:136
float x
Definition sky_math.h:136
float y
Definition sky_math.h:225
float z
Definition sky_math.h:225
float x
Definition sky_math.h:225