Welcome to mirror list, hosted at ThFree Co, Russian Federation.

node_voxel_texture.osl « shaders « osl « kernel « cycles « intern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d98e6ee9ea695e3b6ecc1108fb4eca25d891c047 (plain)
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);
  }
}