1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#include "stdcycles.h"
shader node_voxel_texture(string filename = "",
string interpolation = "linear",
int use_mapping = 0,
matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
point Vector = P,
output float Density = 0,
output color Color = 0)
{
point p = Vector;
if (use_mapping) {
p = transform(mapping, p);
}
else {
p = transform("object", Vector);
matrix tfm;
if (getattribute("geom:generated_transform", tfm))
p = transform(tfm, p);
}
if (p[0] < 0.0 || p[1] < 0.0 || p[2] < 0.0 || p[0] > 1.0 || p[1] > 1.0 || p[2] > 1.0) {
Density = 0;
Color = color(0, 0, 0);
}
else {
Color = (color)texture3d(
filename, p, "wrap", "periodic", "interp", interpolation, "alpha", Density);
}
}
|