2
* Copyright 2011, Blender Foundation.
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software Foundation,
16
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2
* Copyright 2011-2013 Blender Foundation
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License
19
17
CCL_NAMESPACE_BEGIN
23
21
__device float voronoi_distance(NodeDistanceMetric distance_metric, float3 d, float e)
25
24
if(distance_metric == NODE_VORONOI_DISTANCE_SQUARED)
27
28
if(distance_metric == NODE_VORONOI_ACTUAL_DISTANCE)
29
30
if(distance_metric == NODE_VORONOI_MANHATTAN)
177
179
return (hard)? fabsf(2.0f*t - 1.0f): t;
182
__device float noise_wave(NodeWaveBasis wave, float a)
184
if(wave == NODE_WAVE_SINE) {
185
return 0.5f + 0.5f * sinf(a);
187
else if(wave == NODE_WAVE_SAW) {
189
int n = float_to_int(a / b);
195
else if(wave == NODE_WAVE_TRI) {
199
return rmax - 2.0f*fabsf(floorf((a*(1.0f/b))+0.5f) - (a*(1.0f/b)));
207
184
__device_noinline float noise_turbulence(float3 p, NodeNoiseBasis basis, float octaves, int hard)