Add Fractal Voronoi Noise V.2 #106827
|
@ -929,113 +929,129 @@ shader node_voronoi_texture(
|
|||
if (feature == "f1") {
|
||||
voronoi_f1_1d(w, Exponent, randomness, metric, Distance, Color, WOut);
|
||||
|
||||
float max_amplitude = 1.0;
|
||||
if(detail!=0.0&&roughness != 0.0 && Lacunarity != 0.0)
|
||||
{
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_amplitude = roughness;
|
||||
float octave_distance = 0.0;
|
||||
float max_amplitude = 1.0;
|
||||
if (detail != 0.0 && roughness != 0.0 && Lacunarity != 0.0) {
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_amplitude = roughness;
|
||||
float octave_distance = 0.0;
|
||||
|
||||
for(int i = 0; i < int(detail);++i)
|
||||
{
|
||||
voronoi_f1_1d(w*octave_scale, Exponent, randomness, metric, octave_distance, Color, WOut);
|
||||
for (int i = 0; i < int(detail); ++i) {
|
||||
voronoi_f1_1d(
|
||||
w * octave_scale, Exponent, randomness, metric, octave_distance, Color, WOut);
|
||||
max_amplitude += octave_amplitude;
|
||||
Distance += octave_distance * octave_amplitude;
|
||||
octave_scale *= Lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
WOut /= octave_scale / Lacunarity;
|
||||
|
||||
max_amplitude += octave_amplitude;
|
||||
Distance += octave_distance * octave_amplitude;
|
||||
octave_scale *= Lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
float remainder = detail - int(detail);
|
||||
if (remainder != 0.0) {
|
||||
voronoi_f1_1d(
|
||||
w * octave_scale, Exponent, randomness, metric, octave_distance, Color, WOut);
|
||||
max_amplitude += octave_amplitude;
|
||||
float lerp_distance = Distance + octave_distance * octave_amplitude;
|
||||
Distance = (1.0 - remainder) * Distance + remainder * lerp_distance;
|
||||
WOut /= octave_scale;
|
||||
}
|
||||
}
|
||||
if (normalize) {
|
||||
Distance /= max_amplitude;
|
||||
}
|
||||
|
||||
WOut /= octave_scale / Lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
if (remainder != 0.0)
|
||||
{
|
||||
voronoi_f1_1d(w*octave_scale, Exponent, randomness, metric, octave_distance, Color, WOut);
|
||||
max_amplitude += octave_amplitude;
|
||||
float lerp_distance = Distance + octave_distance * octave_amplitude;
|
||||
Distance = (1.0 - remainder) * Distance + remainder * lerp_distance;
|
||||
WOut /= octave_scale;
|
||||
}
|
||||
}
|
||||
if (normalize) {
|
||||
Distance /= max_amplitude;
|
||||
}
|
||||
}
|
||||
else if (feature == "smooth_f1") {
|
||||
voronoi_smooth_f1_1d(w, smoothness, Exponent, randomness, metric, Distance, Color, WOut);
|
||||
|
||||
float max_amplitude = 1.0;
|
||||
if(detail!=0.0&&roughness != 0.0 && Lacunarity != 0.0)
|
||||
{
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_amplitude = roughness;
|
||||
float octave_distance = 0.0;
|
||||
float max_amplitude = 1.0;
|
||||
if (detail != 0.0 && roughness != 0.0 && Lacunarity != 0.0) {
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_amplitude = roughness;
|
||||
float octave_distance = 0.0;
|
||||
|
||||
for(int i = 0; i < int(detail);++i)
|
||||
{
|
||||
voronoi_smooth_f1_1d(w*octave_scale,smoothness, Exponent, randomness, metric, octave_distance, Color, WOut);
|
||||
for (int i = 0; i < int(detail); ++i) {
|
||||
voronoi_smooth_f1_1d(w * octave_scale,
|
||||
smoothness,
|
||||
Exponent,
|
||||
randomness,
|
||||
metric,
|
||||
octave_distance,
|
||||
Color,
|
||||
WOut);
|
||||
max_amplitude += octave_amplitude;
|
||||
Distance += octave_distance * octave_amplitude;
|
||||
octave_scale *= Lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
WOut /= octave_scale / Lacunarity;
|
||||
|
||||
max_amplitude += octave_amplitude;
|
||||
Distance += octave_distance * octave_amplitude;
|
||||
octave_scale *= Lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
float remainder = detail - int(detail);
|
||||
if (remainder != 0.0) {
|
||||
voronoi_smooth_f1_1d(w * octave_scale,
|
||||
smoothness,
|
||||
Exponent,
|
||||
randomness,
|
||||
metric,
|
||||
octave_distance,
|
||||
Color,
|
||||
WOut);
|
||||
max_amplitude += octave_amplitude;
|
||||
float lerp_distance = Distance + octave_distance * octave_amplitude;
|
||||
Distance = (1.0 - remainder) * Distance + remainder * lerp_distance;
|
||||
WOut /= octave_scale;
|
||||
}
|
||||
}
|
||||
if (normalize) {
|
||||
Distance /= max_amplitude;
|
||||
}
|
||||
|
||||
WOut /= octave_scale / Lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
if (remainder != 0.0)
|
||||
{
|
||||
voronoi_smooth_f1_1d(w*octave_scale,smoothness, Exponent, randomness, metric, octave_distance, Color, WOut);
|
||||
max_amplitude += octave_amplitude;
|
||||
float lerp_distance = Distance + octave_distance * octave_amplitude;
|
||||
Distance = (1.0 - remainder) * Distance + remainder * lerp_distance;
|
||||
WOut /= octave_scale;
|
||||
}
|
||||
}
|
||||
if (normalize) {
|
||||
Distance /= max_amplitude;
|
||||
}
|
||||
}
|
||||
else if (feature == "f2") {
|
||||
voronoi_f2_1d(w, Exponent, randomness, metric, Distance, Color, WOut);
|
||||
|
||||
float max_amplitude = 1.0;
|
||||
if(detail!=0.0&&roughness != 0.0 && Lacunarity != 0.0)
|
||||
{
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_amplitude = roughness;
|
||||
float octave_distance = 0.0;
|
||||
float max_amplitude = 1.0;
|
||||
if (detail != 0.0 && roughness != 0.0 && Lacunarity != 0.0) {
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_amplitude = roughness;
|
||||
float octave_distance = 0.0;
|
||||
|
||||
for(int i = 0; i < int(detail);++i)
|
||||
{
|
||||
voronoi_f2_1d(w*octave_scale, Exponent, randomness, metric, octave_distance, Color, WOut);
|
||||
for (int i = 0; i < int(detail); ++i) {
|
||||
voronoi_f2_1d(
|
||||
w * octave_scale, Exponent, randomness, metric, octave_distance, Color, WOut);
|
||||
max_amplitude += octave_amplitude;
|
||||
Distance += octave_distance * octave_amplitude;
|
||||
octave_scale *= Lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
WOut /= octave_scale / Lacunarity;
|
||||
|
||||
max_amplitude += octave_amplitude;
|
||||
Distance += octave_distance * octave_amplitude;
|
||||
octave_scale *= Lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
float remainder = detail - int(detail);
|
||||
if (remainder != 0.0) {
|
||||
voronoi_f2_1d(
|
||||
w * octave_scale, Exponent, randomness, metric, octave_distance, Color, WOut);
|
||||
max_amplitude += octave_amplitude;
|
||||
float lerp_distance = Distance + octave_distance * octave_amplitude;
|
||||
Distance = (1.0 - remainder) * Distance + remainder * lerp_distance;
|
||||
WOut /= octave_scale;
|
||||
}
|
||||
}
|
||||
if (normalize) {
|
||||
Distance /= max_amplitude;
|
||||
}
|
||||
|
||||
WOut /= octave_scale / Lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
if (remainder != 0.0)
|
||||
{
|
||||
voronoi_f2_1d(w*octave_scale, Exponent, randomness, metric, octave_distance, Color, WOut);
|
||||
max_amplitude += octave_amplitude;
|
||||
float lerp_distance = Distance + octave_distance * octave_amplitude;
|
||||
Distance = (1.0 - remainder) * Distance + remainder * lerp_distance;
|
||||
WOut /= octave_scale;
|
||||
}
|
||||
}
|
||||
if (normalize) {
|
||||
Distance /= max_amplitude;
|
||||
}
|
||||
}
|
||||
else if (feature == "distance_to_edge") {
|
||||
voronoi_distance_to_edge_1d(w, randomness, Distance);
|
||||
|
||||
if (detail != 0.0 && Lacunarity != 0.0) {
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_distance = 0.0;
|
||||
for (int i = 0; i < detail; ++i) {
|
||||
voronoi_distance_to_edge_1d(w * octave_scale, randomness, octave_distance);
|
||||
Distance = min(Distance, octave_distance / octave_scale);
|
||||
octave_scale *= Lacunarity;
|
||||
}
|
||||
if (normalize) {
|
||||
Distance *= octave_scale / Lacunarity;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (feature == "n_sphere_radius") {
|
||||
voronoi_n_sphere_radius_1d(w, randomness, Radius);
|
||||
|
@ -1051,117 +1067,156 @@ shader node_voronoi_texture(
|
|||
if (feature == "f1") {
|
||||
voronoi_f1_2d(coord2D, Exponent, randomness, metric, Distance, Color, outPosition2D);
|
||||
|
||||
float max_distance = voronoi_distance(vector2(1.0,1.0), vector2(0.0,0.0), metric, Exponent);
|
||||
float max_distance = voronoi_distance(
|
||||
vector2(1.0, 1.0), vector2(0.0, 0.0), metric, Exponent);
|
||||
float max_amplitude = max_distance;
|
||||
if(detail!=0.0&&roughness != 0.0 && Lacunarity != 0.0)
|
||||
{
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_amplitude = roughness;
|
||||
float octave_distance = 0.0;
|
||||
if (detail != 0.0 && roughness != 0.0 && Lacunarity != 0.0) {
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_amplitude = roughness;
|
||||
float octave_distance = 0.0;
|
||||
|
||||
for(int i = 0; i < int(detail);++i)
|
||||
{
|
||||
voronoi_f1_2d(coord2D*octave_scale, Exponent, randomness, metric, octave_distance, Color, outPosition2D);
|
||||
for (int i = 0; i < int(detail); ++i) {
|
||||
voronoi_f1_2d(coord2D * octave_scale,
|
||||
Exponent,
|
||||
randomness,
|
||||
metric,
|
||||
octave_distance,
|
||||
Color,
|
||||
outPosition2D);
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
Distance += octave_distance * octave_amplitude;
|
||||
octave_scale *= Lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
outPosition2D /= octave_scale / Lacunarity;
|
||||
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
Distance += octave_distance * octave_amplitude;
|
||||
octave_scale *= Lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
float remainder = detail - int(detail);
|
||||
if (remainder != 0.0) {
|
||||
voronoi_f1_2d(coord2D * octave_scale,
|
||||
Exponent,
|
||||
randomness,
|
||||
metric,
|
||||
octave_distance,
|
||||
Color,
|
||||
outPosition2D);
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
float lerp_distance = Distance + octave_distance * octave_amplitude;
|
||||
Distance = (1.0 - remainder) * Distance + remainder * lerp_distance;
|
||||
outPosition2D /= octave_scale;
|
||||
}
|
||||
}
|
||||
if (normalize) {
|
||||
Distance /= max_amplitude;
|
||||
}
|
||||
|
||||
outPosition2D /= octave_scale / Lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
if (remainder != 0.0)
|
||||
{
|
||||
voronoi_f1_2d(coord2D*octave_scale, Exponent, randomness, metric, octave_distance, Color, outPosition2D);
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
float lerp_distance = Distance + octave_distance * octave_amplitude;
|
||||
Distance = (1.0 - remainder) * Distance + remainder * lerp_distance;
|
||||
outPosition2D /= octave_scale;
|
||||
}
|
||||
}
|
||||
if (normalize) {
|
||||
Distance /= max_amplitude;
|
||||
}
|
||||
}
|
||||
else if (feature == "smooth_f1") {
|
||||
voronoi_smooth_f1_2d(
|
||||
coord2D, smoothness, Exponent, randomness, metric, Distance, Color, outPosition2D);
|
||||
|
||||
float max_distance = voronoi_distance(vector2(1.0,1.0), vector2(0.0,0.0), metric, Exponent);
|
||||
float max_distance = voronoi_distance(
|
||||
vector2(1.0, 1.0), vector2(0.0, 0.0), metric, Exponent);
|
||||
float max_amplitude = max_distance;
|
||||
if(detail!=0.0&&roughness != 0.0 && Lacunarity != 0.0)
|
||||
{
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_amplitude = roughness;
|
||||
float octave_distance = 0.0;
|
||||
if (detail != 0.0 && roughness != 0.0 && Lacunarity != 0.0) {
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_amplitude = roughness;
|
||||
float octave_distance = 0.0;
|
||||
|
||||
for(int i = 0; i < int(detail);++i)
|
||||
{
|
||||
voronoi_smooth_f1_2d(coord2D*octave_scale, smoothness,Exponent, randomness, metric, octave_distance, Color, outPosition2D);
|
||||
for (int i = 0; i < int(detail); ++i) {
|
||||
voronoi_smooth_f1_2d(coord2D * octave_scale,
|
||||
smoothness,
|
||||
Exponent,
|
||||
randomness,
|
||||
metric,
|
||||
octave_distance,
|
||||
Color,
|
||||
outPosition2D);
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
Distance += octave_distance * octave_amplitude;
|
||||
octave_scale *= Lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
outPosition2D /= octave_scale / Lacunarity;
|
||||
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
Distance += octave_distance * octave_amplitude;
|
||||
octave_scale *= Lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
float remainder = detail - int(detail);
|
||||
if (remainder != 0.0) {
|
||||
voronoi_smooth_f1_2d(coord2D * octave_scale,
|
||||
smoothness,
|
||||
Exponent,
|
||||
randomness,
|
||||
metric,
|
||||
octave_distance,
|
||||
Color,
|
||||
outPosition2D);
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
float lerp_distance = Distance + octave_distance * octave_amplitude;
|
||||
Distance = (1.0 - remainder) * Distance + remainder * lerp_distance;
|
||||
outPosition2D /= octave_scale;
|
||||
}
|
||||
}
|
||||
if (normalize) {
|
||||
Distance /= max_amplitude;
|
||||
}
|
||||
|
||||
outPosition2D /= octave_scale / Lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
if (remainder != 0.0)
|
||||
{
|
||||
voronoi_smooth_f1_2d(coord2D*octave_scale, smoothness,Exponent, randomness, metric, octave_distance, Color, outPosition2D);
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
float lerp_distance = Distance + octave_distance * octave_amplitude;
|
||||
Distance = (1.0 - remainder) * Distance + remainder * lerp_distance;
|
||||
outPosition2D /= octave_scale;
|
||||
}
|
||||
}
|
||||
if (normalize) {
|
||||
Distance /= max_amplitude;
|
||||
}
|
||||
}
|
||||
else if (feature == "f2") {
|
||||
voronoi_f2_2d(coord2D, Exponent, randomness, metric, Distance, Color, outPosition2D);
|
||||
|
||||
float max_distance = voronoi_distance(vector2(1.0,1.0), vector2(0.0,0.0), metric, Exponent);
|
||||
float max_distance = voronoi_distance(
|
||||
vector2(1.0, 1.0), vector2(0.0, 0.0), metric, Exponent);
|
||||
float max_amplitude = max_distance;
|
||||
if(detail!=0.0&&roughness != 0.0 && Lacunarity != 0.0)
|
||||
{
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_amplitude = roughness;
|
||||
float octave_distance = 0.0;
|
||||
if (detail != 0.0 && roughness != 0.0 && Lacunarity != 0.0) {
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_amplitude = roughness;
|
||||
float octave_distance = 0.0;
|
||||
|
||||
for(int i = 0; i < int(detail);++i)
|
||||
{
|
||||
voronoi_f2_2d(coord2D*octave_scale, Exponent, randomness, metric, octave_distance, Color, outPosition2D);
|
||||
for (int i = 0; i < int(detail); ++i) {
|
||||
voronoi_f2_2d(coord2D * octave_scale,
|
||||
Exponent,
|
||||
randomness,
|
||||
metric,
|
||||
octave_distance,
|
||||
Color,
|
||||
outPosition2D);
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
Distance += octave_distance * octave_amplitude;
|
||||
octave_scale *= Lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
outPosition2D /= octave_scale / Lacunarity;
|
||||
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
Distance += octave_distance * octave_amplitude;
|
||||
octave_scale *= Lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
float remainder = detail - int(detail);
|
||||
if (remainder != 0.0) {
|
||||
voronoi_f2_2d(coord2D * octave_scale,
|
||||
Exponent,
|
||||
randomness,
|
||||
metric,
|
||||
octave_distance,
|
||||
Color,
|
||||
outPosition2D);
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
float lerp_distance = Distance + octave_distance * octave_amplitude;
|
||||
Distance = (1.0 - remainder) * Distance + remainder * lerp_distance;
|
||||
outPosition2D /= octave_scale;
|
||||
}
|
||||
}
|
||||
if (normalize) {
|
||||
Distance /= max_amplitude;
|
||||
}
|
||||
|
||||
outPosition2D /= octave_scale / Lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
if (remainder != 0.0)
|
||||
{
|
||||
voronoi_f2_2d(coord2D*octave_scale, Exponent, randomness, metric, octave_distance, Color, outPosition2D);
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
float lerp_distance = Distance + octave_distance * octave_amplitude;
|
||||
Distance = (1.0 - remainder) * Distance + remainder * lerp_distance;
|
||||
outPosition2D /= octave_scale;
|
||||
}
|
||||
}
|
||||
if (normalize) {
|
||||
Distance /= max_amplitude;
|
||||
}
|
||||
}
|
||||
else if (feature == "distance_to_edge") {
|
||||
voronoi_distance_to_edge_2d(coord2D, randomness, Distance);
|
||||
|
||||
if (detail != 0.0 && Lacunarity != 0.0) {
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_distance = 0.0;
|
||||
for (int i = 0; i < detail; ++i) {
|
||||
voronoi_distance_to_edge_2d(coord2D * octave_scale, randomness, octave_distance);
|
||||
Distance = min(Distance, octave_distance / octave_scale);
|
||||
octave_scale *= Lacunarity;
|
||||
}
|
||||
if (normalize) {
|
||||
Distance *= octave_scale / Lacunarity;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (feature == "n_sphere_radius") {
|
||||
voronoi_n_sphere_radius_2d(coord2D, randomness, Radius);
|
||||
|
@ -1175,118 +1230,157 @@ shader node_voronoi_texture(
|
|||
else if (dimensions == "3D") {
|
||||
if (feature == "f1") {
|
||||
voronoi_f1_3d(coord, Exponent, randomness, metric, Distance, Color, Position);
|
||||
|
||||
float max_distance = voronoi_distance(vector3(1.0,1.0,1.0), vector3(0.0,0.0,0.0), metric, Exponent);
|
||||
|
||||
float max_distance = voronoi_distance(
|
||||
vector3(1.0, 1.0, 1.0), vector3(0.0, 0.0, 0.0), metric, Exponent);
|
||||
float max_amplitude = max_distance;
|
||||
if(detail!=0.0&&roughness != 0.0 && Lacunarity != 0.0)
|
||||
{
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_amplitude = roughness;
|
||||
float octave_distance = 0.0;
|
||||
if (detail != 0.0 && roughness != 0.0 && Lacunarity != 0.0) {
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_amplitude = roughness;
|
||||
float octave_distance = 0.0;
|
||||
|
||||
for(int i = 0; i < int(detail);++i)
|
||||
{
|
||||
voronoi_f1_3d(coord*octave_scale, Exponent, randomness, metric, octave_distance, Color, Position);
|
||||
for (int i = 0; i < int(detail); ++i) {
|
||||
voronoi_f1_3d(coord * octave_scale,
|
||||
Exponent,
|
||||
randomness,
|
||||
metric,
|
||||
octave_distance,
|
||||
Color,
|
||||
Position);
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
Distance += octave_distance * octave_amplitude;
|
||||
octave_scale *= Lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
Position /= octave_scale / Lacunarity;
|
||||
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
Distance += octave_distance * octave_amplitude;
|
||||
octave_scale *= Lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
float remainder = detail - int(detail);
|
||||
if (remainder != 0.0) {
|
||||
voronoi_f1_3d(coord * octave_scale,
|
||||
Exponent,
|
||||
randomness,
|
||||
metric,
|
||||
octave_distance,
|
||||
Color,
|
||||
Position);
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
float lerp_distance = Distance + octave_distance * octave_amplitude;
|
||||
Distance = (1.0 - remainder) * Distance + remainder * lerp_distance;
|
||||
Position /= octave_scale;
|
||||
}
|
||||
}
|
||||
if (normalize) {
|
||||
Distance /= max_amplitude;
|
||||
}
|
||||
|
||||
Position /= octave_scale / Lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
if (remainder != 0.0)
|
||||
{
|
||||
voronoi_f1_3d(coord*octave_scale, Exponent, randomness, metric, octave_distance, Color, Position);
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
float lerp_distance = Distance + octave_distance * octave_amplitude;
|
||||
Distance = (1.0 - remainder) * Distance + remainder * lerp_distance;
|
||||
Position /= octave_scale;
|
||||
}
|
||||
}
|
||||
if (normalize) {
|
||||
Distance /= max_amplitude;
|
||||
}
|
||||
}
|
||||
else if (feature == "smooth_f1") {
|
||||
voronoi_smooth_f1_3d(
|
||||
coord, smoothness, Exponent, randomness, metric, Distance, Color, Position);
|
||||
|
||||
float max_distance = voronoi_distance(vector3(1.0,1.0,1.0), vector3(0.0,0.0,0.0), metric, Exponent);
|
||||
float max_distance = voronoi_distance(
|
||||
vector3(1.0, 1.0, 1.0), vector3(0.0, 0.0, 0.0), metric, Exponent);
|
||||
float max_amplitude = max_distance;
|
||||
if(detail!=0.0&&roughness != 0.0 && Lacunarity != 0.0)
|
||||
{
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_amplitude = roughness;
|
||||
float octave_distance = 0.0;
|
||||
if (detail != 0.0 && roughness != 0.0 && Lacunarity != 0.0) {
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_amplitude = roughness;
|
||||
float octave_distance = 0.0;
|
||||
|
||||
for(int i = 0; i < int(detail);++i)
|
||||
{
|
||||
voronoi_smooth_f1_3d(coord*octave_scale,smoothness, Exponent, randomness, metric, octave_distance, Color, Position);
|
||||
for (int i = 0; i < int(detail); ++i) {
|
||||
voronoi_smooth_f1_3d(coord * octave_scale,
|
||||
smoothness,
|
||||
Exponent,
|
||||
randomness,
|
||||
metric,
|
||||
octave_distance,
|
||||
Color,
|
||||
Position);
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
Distance += octave_distance * octave_amplitude;
|
||||
octave_scale *= Lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
Position /= octave_scale / Lacunarity;
|
||||
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
Distance += octave_distance * octave_amplitude;
|
||||
octave_scale *= Lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
float remainder = detail - int(detail);
|
||||
if (remainder != 0.0) {
|
||||
voronoi_smooth_f1_3d(coord * octave_scale,
|
||||
smoothness,
|
||||
Exponent,
|
||||
randomness,
|
||||
metric,
|
||||
octave_distance,
|
||||
Color,
|
||||
Position);
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
float lerp_distance = Distance + octave_distance * octave_amplitude;
|
||||
Distance = (1.0 - remainder) * Distance + remainder * lerp_distance;
|
||||
Position /= octave_scale;
|
||||
}
|
||||
}
|
||||
if (normalize) {
|
||||
Distance /= max_amplitude;
|
||||
}
|
||||
|
||||
Position /= octave_scale / Lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
if (remainder != 0.0)
|
||||
{
|
||||
voronoi_smooth_f1_3d(coord*octave_scale,smoothness, Exponent, randomness, metric, octave_distance, Color, Position);
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
float lerp_distance = Distance + octave_distance * octave_amplitude;
|
||||
Distance = (1.0 - remainder) * Distance + remainder * lerp_distance;
|
||||
Position /= octave_scale;
|
||||
}
|
||||
}
|
||||
if (normalize) {
|
||||
Distance /= max_amplitude;
|
||||
}
|
||||
}
|
||||
else if (feature == "f2") {
|
||||
voronoi_f2_3d(coord, Exponent, randomness, metric, Distance, Color, Position);
|
||||
|
||||
float max_distance = voronoi_distance(vector3(1.0,1.0,1.0), vector3(0.0,0.0,0.0), metric, Exponent);
|
||||
float max_distance = voronoi_distance(
|
||||
vector3(1.0, 1.0, 1.0), vector3(0.0, 0.0, 0.0), metric, Exponent);
|
||||
float max_amplitude = max_distance;
|
||||
if(detail!=0.0&&roughness != 0.0 && Lacunarity != 0.0)
|
||||
{
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_amplitude = roughness;
|
||||
float octave_distance = 0.0;
|
||||
if (detail != 0.0 && roughness != 0.0 && Lacunarity != 0.0) {
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_amplitude = roughness;
|
||||
float octave_distance = 0.0;
|
||||
|
||||
for(int i = 0; i < int(detail);++i)
|
||||
{
|
||||
voronoi_f2_3d(coord*octave_scale, Exponent, randomness, metric, octave_distance, Color, Position);
|
||||
for (int i = 0; i < int(detail); ++i) {
|
||||
voronoi_f2_3d(coord * octave_scale,
|
||||
Exponent,
|
||||
randomness,
|
||||
metric,
|
||||
octave_distance,
|
||||
Color,
|
||||
Position);
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
Distance += octave_distance * octave_amplitude;
|
||||
octave_scale *= Lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
Position /= octave_scale / Lacunarity;
|
||||
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
Distance += octave_distance * octave_amplitude;
|
||||
octave_scale *= Lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
float remainder = detail - int(detail);
|
||||
if (remainder != 0.0) {
|
||||
voronoi_f2_3d(coord * octave_scale,
|
||||
Exponent,
|
||||
randomness,
|
||||
metric,
|
||||
octave_distance,
|
||||
Color,
|
||||
Position);
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
float lerp_distance = Distance + octave_distance * octave_amplitude;
|
||||
Distance = (1.0 - remainder) * Distance + remainder * lerp_distance;
|
||||
Position /= octave_scale;
|
||||
}
|
||||
}
|
||||
if (normalize) {
|
||||
Distance /= max_amplitude;
|
||||
}
|
||||
|
||||
Position /= octave_scale / Lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
if (remainder != 0.0)
|
||||
{
|
||||
voronoi_f2_3d(coord*octave_scale, Exponent, randomness, metric, octave_distance, Color, Position);
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
float lerp_distance = Distance + octave_distance * octave_amplitude;
|
||||
Distance = (1.0 - remainder) * Distance + remainder * lerp_distance;
|
||||
Position /= octave_scale;
|
||||
}
|
||||
}
|
||||
if (normalize) {
|
||||
Distance /= max_amplitude;
|
||||
}
|
||||
}
|
||||
else if (feature == "distance_to_edge") {
|
||||
voronoi_distance_to_edge_3d(coord, randomness, Distance);
|
||||
|
||||
if (detail != 0.0 && Lacunarity != 0.0) {
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_distance = 0.0;
|
||||
for (int i = 0; i < detail; ++i) {
|
||||
voronoi_distance_to_edge_3d(coord * octave_scale, randomness, octave_distance);
|
||||
Distance = min(Distance, octave_distance / octave_scale);
|
||||
octave_scale *= Lacunarity;
|
||||
}
|
||||
if (normalize) {
|
||||
Distance *= octave_scale / Lacunarity;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (feature == "n_sphere_radius") {
|
||||
voronoi_n_sphere_radius_3d(coord, randomness, Radius);
|
||||
|
@ -1302,117 +1396,156 @@ shader node_voronoi_texture(
|
|||
if (feature == "f1") {
|
||||
voronoi_f1_4d(coord4D, Exponent, randomness, metric, Distance, Color, outPosition4D);
|
||||
|
||||
float max_distance = voronoi_distance(vector4(1.0,1.0,1.0,1.0), vector4(0.0,0.0,0.0,0.0), metric, Exponent);
|
||||
float max_distance = voronoi_distance(
|
||||
vector4(1.0, 1.0, 1.0, 1.0), vector4(0.0, 0.0, 0.0, 0.0), metric, Exponent);
|
||||
float max_amplitude = max_distance;
|
||||
if(detail!=0.0&&roughness != 0.0 && Lacunarity != 0.0)
|
||||
{
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_amplitude = roughness;
|
||||
float octave_distance = 0.0;
|
||||
if (detail != 0.0 && roughness != 0.0 && Lacunarity != 0.0) {
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_amplitude = roughness;
|
||||
float octave_distance = 0.0;
|
||||
|
||||
for(int i = 0; i < int(detail);++i)
|
||||
{
|
||||
voronoi_f1_4d(coord4D * octave_scale, Exponent, randomness, metric, octave_distance, Color, outPosition4D);
|
||||
for (int i = 0; i < int(detail); ++i) {
|
||||
voronoi_f1_4d(coord4D * octave_scale,
|
||||
Exponent,
|
||||
randomness,
|
||||
metric,
|
||||
octave_distance,
|
||||
Color,
|
||||
outPosition4D);
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
Distance += octave_distance * octave_amplitude;
|
||||
octave_scale *= Lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
outPosition4D /= octave_scale / Lacunarity;
|
||||
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
Distance += octave_distance * octave_amplitude;
|
||||
octave_scale *= Lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
float remainder = detail - int(detail);
|
||||
if (remainder != 0.0) {
|
||||
voronoi_f1_4d(coord4D * octave_scale,
|
||||
Exponent,
|
||||
randomness,
|
||||
metric,
|
||||
octave_distance,
|
||||
Color,
|
||||
outPosition4D);
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
float lerp_distance = Distance + octave_distance * octave_amplitude;
|
||||
Distance = (1.0 - remainder) * Distance + remainder * lerp_distance;
|
||||
outPosition4D /= octave_scale;
|
||||
}
|
||||
}
|
||||
if (normalize) {
|
||||
Distance /= max_amplitude;
|
||||
}
|
||||
|
||||
outPosition4D /= octave_scale / Lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
if (remainder != 0.0)
|
||||
{
|
||||
voronoi_f1_4d(coord4D * octave_scale, Exponent, randomness, metric, octave_distance, Color, outPosition4D);
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
float lerp_distance = Distance + octave_distance * octave_amplitude;
|
||||
Distance = (1.0 - remainder) * Distance + remainder * lerp_distance;
|
||||
outPosition4D /= octave_scale;
|
||||
}
|
||||
}
|
||||
if (normalize) {
|
||||
Distance /= max_amplitude;
|
||||
}
|
||||
}
|
||||
else if (feature == "smooth_f1") {
|
||||
voronoi_smooth_f1_4d(
|
||||
coord4D, smoothness, Exponent, randomness, metric, Distance, Color, outPosition4D);
|
||||
|
||||
float max_distance = voronoi_distance(vector4(1.0,1.0,1.0,1.0), vector4(0.0,0.0,0.0,0.0), metric, Exponent);
|
||||
float max_distance = voronoi_distance(
|
||||
vector4(1.0, 1.0, 1.0, 1.0), vector4(0.0, 0.0, 0.0, 0.0), metric, Exponent);
|
||||
float max_amplitude = max_distance;
|
||||
if(detail!=0.0&&roughness != 0.0 && Lacunarity != 0.0)
|
||||
{
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_amplitude = roughness;
|
||||
float octave_distance = 0.0;
|
||||
if (detail != 0.0 && roughness != 0.0 && Lacunarity != 0.0) {
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_amplitude = roughness;
|
||||
float octave_distance = 0.0;
|
||||
|
||||
for(int i = 0; i < int(detail);++i)
|
||||
{
|
||||
voronoi_smooth_f1_4d(coord4D * octave_scale,smoothness, Exponent, randomness, metric, octave_distance, Color, outPosition4D);
|
||||
for (int i = 0; i < int(detail); ++i) {
|
||||
voronoi_smooth_f1_4d(coord4D * octave_scale,
|
||||
smoothness,
|
||||
Exponent,
|
||||
randomness,
|
||||
metric,
|
||||
octave_distance,
|
||||
Color,
|
||||
outPosition4D);
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
Distance += octave_distance * octave_amplitude;
|
||||
octave_scale *= Lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
outPosition4D /= octave_scale / Lacunarity;
|
||||
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
Distance += octave_distance * octave_amplitude;
|
||||
octave_scale *= Lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
float remainder = detail - int(detail);
|
||||
if (remainder != 0.0) {
|
||||
voronoi_smooth_f1_4d(coord4D * octave_scale,
|
||||
smoothness,
|
||||
Exponent,
|
||||
randomness,
|
||||
metric,
|
||||
octave_distance,
|
||||
Color,
|
||||
outPosition4D);
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
float lerp_distance = Distance + octave_distance * octave_amplitude;
|
||||
Distance = (1.0 - remainder) * Distance + remainder * lerp_distance;
|
||||
outPosition4D /= octave_scale;
|
||||
}
|
||||
}
|
||||
if (normalize) {
|
||||
Distance /= max_amplitude;
|
||||
}
|
||||
|
||||
outPosition4D /= octave_scale / Lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
if (remainder != 0.0)
|
||||
{
|
||||
voronoi_smooth_f1_4d(coord4D * octave_scale, smoothness,Exponent, randomness, metric, octave_distance, Color, outPosition4D);
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
float lerp_distance = Distance + octave_distance * octave_amplitude;
|
||||
Distance = (1.0 - remainder) * Distance + remainder * lerp_distance;
|
||||
outPosition4D /= octave_scale;
|
||||
}
|
||||
}
|
||||
if (normalize) {
|
||||
Distance /= max_amplitude;
|
||||
}
|
||||
}
|
||||
else if (feature == "f2") {
|
||||
voronoi_f2_4d(coord4D, Exponent, randomness, metric, Distance, Color, outPosition4D);
|
||||
|
||||
float max_distance = voronoi_distance(vector4(1.0,1.0,1.0,1.0), vector4(0.0,0.0,0.0,0.0), metric, Exponent);
|
||||
float max_distance = voronoi_distance(
|
||||
vector4(1.0, 1.0, 1.0, 1.0), vector4(0.0, 0.0, 0.0, 0.0), metric, Exponent);
|
||||
float max_amplitude = max_distance;
|
||||
if(detail!=0.0&&roughness != 0.0 && Lacunarity != 0.0)
|
||||
{
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_amplitude = roughness;
|
||||
float octave_distance = 0.0;
|
||||
if (detail != 0.0 && roughness != 0.0 && Lacunarity != 0.0) {
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_amplitude = roughness;
|
||||
float octave_distance = 0.0;
|
||||
|
||||
for(int i = 0; i < int(detail);++i)
|
||||
{
|
||||
voronoi_f2_4d(coord4D * octave_scale, Exponent, randomness, metric, octave_distance, Color, outPosition4D);
|
||||
for (int i = 0; i < int(detail); ++i) {
|
||||
voronoi_f2_4d(coord4D * octave_scale,
|
||||
Exponent,
|
||||
randomness,
|
||||
metric,
|
||||
octave_distance,
|
||||
Color,
|
||||
outPosition4D);
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
Distance += octave_distance * octave_amplitude;
|
||||
octave_scale *= Lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
outPosition4D /= octave_scale / Lacunarity;
|
||||
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
Distance += octave_distance * octave_amplitude;
|
||||
octave_scale *= Lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
float remainder = detail - int(detail);
|
||||
if (remainder != 0.0) {
|
||||
voronoi_f2_4d(coord4D * octave_scale,
|
||||
Exponent,
|
||||
randomness,
|
||||
metric,
|
||||
octave_distance,
|
||||
Color,
|
||||
outPosition4D);
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
float lerp_distance = Distance + octave_distance * octave_amplitude;
|
||||
Distance = (1.0 - remainder) * Distance + remainder * lerp_distance;
|
||||
outPosition4D /= octave_scale;
|
||||
}
|
||||
}
|
||||
if (normalize) {
|
||||
Distance /= max_amplitude;
|
||||
}
|
||||
|
||||
outPosition4D /= octave_scale / Lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
if (remainder != 0.0)
|
||||
{
|
||||
voronoi_f2_4d(coord4D * octave_scale, Exponent, randomness, metric, octave_distance, Color, outPosition4D);
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
float lerp_distance = Distance + octave_distance * octave_amplitude;
|
||||
Distance = (1.0 - remainder) * Distance + remainder * lerp_distance;
|
||||
outPosition4D /= octave_scale;
|
||||
}
|
||||
}
|
||||
if (normalize) {
|
||||
Distance /= max_amplitude;
|
||||
}
|
||||
}
|
||||
else if (feature == "distance_to_edge") {
|
||||
voronoi_distance_to_edge_4d(coord4D, randomness, Distance);
|
||||
|
||||
if (detail != 0.0 && Lacunarity != 0.0) {
|
||||
float octave_scale = Lacunarity;
|
||||
float octave_distance = 0.0;
|
||||
for (int i = 0; i < detail; ++i) {
|
||||
voronoi_distance_to_edge_4d(coord4D * octave_scale, randomness, octave_distance);
|
||||
Distance = min(Distance, octave_distance / octave_scale);
|
||||
octave_scale *= Lacunarity;
|
||||
}
|
||||
if (normalize) {
|
||||
Distance *= octave_scale / Lacunarity;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (feature == "n_sphere_radius") {
|
||||
voronoi_n_sphere_radius_4d(coord4D, randomness, Radius);
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
* Copyright 2011-2022 Blender Foundation */
|
||||
|
||||
#pragma once
|
||||
#include "types.h"
|
||||
#include <util/hash.h>
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
|
@ -969,7 +967,7 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
|
|||
smoothness = clamp(smoothness / 2.0f, 0.0f, 0.5f);
|
||||
|
||||
w *= scale;
|
||||
coord *= scale; // Don't forget to remove the headers!!!!!!!
|
||||
coord *= scale;
|
||||
|
||||
switch (dimensions) {
|
||||
case 1: {
|
||||
|
@ -997,7 +995,6 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
|
|||
octave_scale *= lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
|
||||
w_out /= octave_scale / lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
|
@ -1051,7 +1048,6 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
|
|||
octave_scale *= lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
|
||||
w_out /= octave_scale / lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
|
@ -1098,7 +1094,6 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
|
|||
octave_scale *= lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
|
||||
w_out /= octave_scale / lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
|
@ -1121,9 +1116,23 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
|
|||
}
|
||||
break;
|
||||
}
|
||||
case NODE_VORONOI_DISTANCE_TO_EDGE:
|
||||
case NODE_VORONOI_DISTANCE_TO_EDGE: {
|
||||
voronoi_distance_to_edge_1d(w, randomness, &distance_out);
|
||||
|
||||
if (detail != 0.0f && lacunarity != 0.0f) {
|
||||
float octave_scale = lacunarity;
|
||||
float octave_distance = 0.0f;
|
||||
for (int i = 0; i < detail; ++i) {
|
||||
voronoi_distance_to_edge_1d(w * octave_scale, randomness, &octave_distance);
|
||||
distance_out = min(distance_out, octave_distance / octave_scale);
|
||||
octave_scale *= lacunarity;
|
||||
}
|
||||
if (normalize) {
|
||||
distance_out *= octave_scale / lacunarity;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NODE_VORONOI_N_SPHERE_RADIUS:
|
||||
voronoi_n_sphere_radius_1d(w, randomness, &radius_out);
|
||||
break;
|
||||
|
@ -1146,7 +1155,8 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
|
|||
&color_out,
|
||||
&position_out_2d);
|
||||
|
||||
const float max_distance = voronoi_distance_2d(make_float2(1.0f,1.0f), make_float2(0.0f, 0.0f), voronoi_metric, exponent);
|
||||
const float max_distance = voronoi_distance_2d(
|
||||
make_float2(1.0f, 1.0f), make_float2(0.0f, 0.0f), voronoi_metric, exponent);
|
||||
float max_amplitude = max_distance;
|
||||
if (detail != 0.0f && roughness != 0.0f && lacunarity != 0.0f) {
|
||||
float octave_scale = lacunarity;
|
||||
|
@ -1166,7 +1176,6 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
|
|||
octave_scale *= lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
|
||||
position_out_2d /= octave_scale / lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
|
@ -1201,7 +1210,8 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
|
|||
&color_out,
|
||||
&position_out_2d);
|
||||
|
||||
const float max_distance = voronoi_distance_2d(make_float2(1.0f, 1.0f), make_float2(0.0f, 0.0f), voronoi_metric, exponent);
|
||||
const float max_distance = voronoi_distance_2d(
|
||||
make_float2(1.0f, 1.0f), make_float2(0.0f, 0.0f), voronoi_metric, exponent);
|
||||
float max_amplitude = max_distance;
|
||||
if (detail != 0.0f && roughness != 0.0f && lacunarity != 0.0f) {
|
||||
float octave_scale = lacunarity;
|
||||
|
@ -1222,7 +1232,6 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
|
|||
octave_scale *= lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
|
||||
position_out_2d /= octave_scale / lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
|
@ -1255,7 +1264,8 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
|
|||
&color_out,
|
||||
&position_out_2d);
|
||||
|
||||
const float max_distance = voronoi_distance_2d(make_float2(1.0f, 1.0f), make_float2(0.0f, 0.0f), voronoi_metric, exponent);
|
||||
const float max_distance = voronoi_distance_2d(
|
||||
make_float2(1.0f, 1.0f), make_float2(0.0f, 0.0f), voronoi_metric, exponent);
|
||||
float max_amplitude = max_distance;
|
||||
if (detail != 0.0f && roughness != 0.0f && lacunarity != 0.0f) {
|
||||
float octave_scale = lacunarity;
|
||||
|
@ -1275,7 +1285,6 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
|
|||
octave_scale *= lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
|
||||
position_out_2d /= octave_scale / lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
|
@ -1298,9 +1307,23 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
|
|||
}
|
||||
break;
|
||||
}
|
||||
case NODE_VORONOI_DISTANCE_TO_EDGE:
|
||||
case NODE_VORONOI_DISTANCE_TO_EDGE: {
|
||||
voronoi_distance_to_edge_2d(coord_2d, randomness, &distance_out);
|
||||
|
||||
if (detail != 0.0f && lacunarity != 0.0f) {
|
||||
float octave_scale = lacunarity;
|
||||
float octave_distance = 0.0f;
|
||||
for (int i = 0; i < detail; ++i) {
|
||||
voronoi_distance_to_edge_2d(coord_2d * octave_scale, randomness, &octave_distance);
|
||||
distance_out = min(distance_out, octave_distance / octave_scale);
|
||||
octave_scale *= lacunarity;
|
||||
}
|
||||
if (normalize) {
|
||||
distance_out *= octave_scale / lacunarity;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NODE_VORONOI_N_SPHERE_RADIUS:
|
||||
voronoi_n_sphere_radius_2d(coord_2d, randomness, &radius_out);
|
||||
break;
|
||||
|
@ -1322,7 +1345,10 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
|
|||
&color_out,
|
||||
&position_out);
|
||||
|
||||
const float max_distance = voronoi_distance_3d(make_float3(1.0f, 1.0f, 1.0f), make_float3(0.0f, 0.0f, 0.0f), voronoi_metric, exponent);
|
||||
const float max_distance = voronoi_distance_3d(make_float3(1.0f, 1.0f, 1.0f),
|
||||
make_float3(0.0f, 0.0f, 0.0f),
|
||||
voronoi_metric,
|
||||
exponent);
|
||||
float max_amplitude = max_distance;
|
||||
if (detail != 0.0f && roughness != 0.0f && lacunarity != 0.0f) {
|
||||
float octave_scale = lacunarity;
|
||||
|
@ -1342,7 +1368,6 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
|
|||
octave_scale *= lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
|
||||
position_out /= octave_scale / lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
|
@ -1378,7 +1403,10 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
|
|||
&color_out,
|
||||
&position_out);
|
||||
|
||||
const float max_distance = voronoi_distance_3d(make_float3(1.0f, 1.0f, 1.0f), make_float3(0.0f, 0.0f, 0.0f), voronoi_metric, exponent);
|
||||
const float max_distance = voronoi_distance_3d(make_float3(1.0f, 1.0f, 1.0f),
|
||||
make_float3(0.0f, 0.0f, 0.0f),
|
||||
voronoi_metric,
|
||||
exponent);
|
||||
float max_amplitude = max_distance;
|
||||
if (detail != 0.0f && roughness != 0.0f && lacunarity != 0.0f) {
|
||||
float octave_scale = lacunarity;
|
||||
|
@ -1399,7 +1427,6 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
|
|||
octave_scale *= lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
|
||||
position_out /= octave_scale / lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
|
@ -1433,7 +1460,10 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
|
|||
&color_out,
|
||||
&position_out);
|
||||
|
||||
const float max_distance = voronoi_distance_3d(make_float3(1.0f, 1.0f, 1.0f), make_float3(0.0f, 0.0f, 0.0f), voronoi_metric, exponent);
|
||||
const float max_distance = voronoi_distance_3d(make_float3(1.0f, 1.0f, 1.0f),
|
||||
make_float3(0.0f, 0.0f, 0.0f),
|
||||
voronoi_metric,
|
||||
exponent);
|
||||
float max_amplitude = max_distance;
|
||||
if (detail != 0.0f && roughness != 0.0f && lacunarity != 0.0f) {
|
||||
float octave_scale = lacunarity;
|
||||
|
@ -1453,7 +1483,6 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
|
|||
octave_scale *= lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
|
||||
position_out /= octave_scale / lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
|
@ -1477,9 +1506,23 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
|
|||
}
|
||||
break;
|
||||
}
|
||||
case NODE_VORONOI_DISTANCE_TO_EDGE:
|
||||
case NODE_VORONOI_DISTANCE_TO_EDGE: {
|
||||
voronoi_distance_to_edge_3d(coord, randomness, &distance_out);
|
||||
|
||||
if (detail != 0.0f && lacunarity != 0.0f) {
|
||||
float octave_scale = lacunarity;
|
||||
float octave_distance = 0.0f;
|
||||
for (int i = 0; i < detail; ++i) {
|
||||
voronoi_distance_to_edge_3d(coord * octave_scale, randomness, &octave_distance);
|
||||
distance_out = min(distance_out, octave_distance / octave_scale);
|
||||
octave_scale *= lacunarity;
|
||||
}
|
||||
if (normalize) {
|
||||
distance_out *= octave_scale / lacunarity;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NODE_VORONOI_N_SPHERE_RADIUS:
|
||||
voronoi_n_sphere_radius_3d(coord, randomness, &radius_out);
|
||||
break;
|
||||
|
@ -1505,7 +1548,10 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
|
|||
&color_out,
|
||||
&position_out_4d);
|
||||
|
||||
const float max_distance = voronoi_distance_4d(make_float4(1.0f, 1.0f, 1.0f, 1.0f), make_float4(0.0f, 0.0f, 0.0f, 0.0f), voronoi_metric, exponent);
|
||||
const float max_distance = voronoi_distance_4d(make_float4(1.0f, 1.0f, 1.0f, 1.0f),
|
||||
make_float4(0.0f, 0.0f, 0.0f, 0.0f),
|
||||
voronoi_metric,
|
||||
exponent);
|
||||
float max_amplitude = max_distance;
|
||||
if (detail != 0.0f && roughness != 0.0f && lacunarity != 0.0f) {
|
||||
float octave_scale = lacunarity;
|
||||
|
@ -1525,7 +1571,6 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
|
|||
octave_scale *= lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
|
||||
position_out_4d /= octave_scale / lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
|
@ -1558,7 +1603,10 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
|
|||
&color_out,
|
||||
&position_out_4d);
|
||||
|
||||
const float max_distance = voronoi_distance_4d(make_float4(1.0f, 1.0f, 1.0f, 1.0f), make_float4(0.0f, 0.0f, 0.0f, 0.0f), voronoi_metric, exponent);
|
||||
const float max_distance = voronoi_distance_4d(make_float4(1.0f, 1.0f, 1.0f, 1.0f),
|
||||
make_float4(0.0f, 0.0f, 0.0f, 0.0f),
|
||||
voronoi_metric,
|
||||
exponent);
|
||||
float max_amplitude = max_distance;
|
||||
if (detail != 0.0f && roughness != 0.0f && lacunarity != 0.0f) {
|
||||
float octave_scale = lacunarity;
|
||||
|
@ -1579,7 +1627,6 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
|
|||
octave_scale *= lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
|
||||
position_out_4d /= octave_scale / lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
|
@ -1612,7 +1659,10 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
|
|||
&color_out,
|
||||
&position_out_4d);
|
||||
|
||||
const float max_distance = voronoi_distance_4d(make_float4(1.0f, 1.0f, 1.0f, 1.0f), make_float4(0.0f, 0.0f, 0.0f, 0.0f), voronoi_metric, exponent);
|
||||
const float max_distance = voronoi_distance_4d(make_float4(1.0f, 1.0f, 1.0f, 1.0f),
|
||||
make_float4(0.0f, 0.0f, 0.0f, 0.0f),
|
||||
voronoi_metric,
|
||||
exponent);
|
||||
float max_amplitude = max_distance;
|
||||
if (detail != 0.0f && roughness != 0.0f && lacunarity != 0.0f) {
|
||||
float octave_scale = lacunarity;
|
||||
|
@ -1632,7 +1682,6 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
|
|||
octave_scale *= lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
|
||||
position_out_4d /= octave_scale / lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
|
@ -1655,9 +1704,23 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
|
|||
}
|
||||
break;
|
||||
}
|
||||
case NODE_VORONOI_DISTANCE_TO_EDGE:
|
||||
case NODE_VORONOI_DISTANCE_TO_EDGE: {
|
||||
voronoi_distance_to_edge_4d(coord_4d, randomness, &distance_out);
|
||||
|
||||
if (detail != 0.0f && lacunarity != 0.0f) {
|
||||
float octave_scale = lacunarity;
|
||||
float octave_distance = 0.0f;
|
||||
for (int i = 0; i < detail; ++i) {
|
||||
voronoi_distance_to_edge_4d(coord_4d * octave_scale, randomness, &octave_distance);
|
||||
distance_out = min(distance_out, octave_distance / octave_scale);
|
||||
octave_scale *= lacunarity;
|
||||
}
|
||||
if (normalize) {
|
||||
distance_out *= octave_scale / lacunarity;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NODE_VORONOI_N_SPHERE_RADIUS:
|
||||
voronoi_n_sphere_radius_4d(coord_4d, randomness, &radius_out);
|
||||
break;
|
||||
|
|
|
@ -1188,19 +1188,23 @@ void VoronoiTextureNode::compile(SVMCompiler &compiler)
|
|||
compiler.add_node(NODE_TEX_VORONOI, dimensions, feature, metric);
|
||||
compiler.add_node(
|
||||
compiler.encode_uchar4(
|
||||
vector_stack_offset, w_in_stack_offset, scale_stack_offset, detail_stack_offset),
|
||||
compiler.encode_uchar4(roughness_stack_offset, lacunarity_stack_offset, smoothness_stack_offset, exponent_stack_offset),
|
||||
compiler.encode_uchar4(
|
||||
randomness_stack_offset,
|
||||
vector_stack_offset, w_in_stack_offset, scale_stack_offset, detail_stack_offset),
|
||||
compiler.encode_uchar4(roughness_stack_offset,
|
||||
lacunarity_stack_offset,
|
||||
smoothness_stack_offset,
|
||||
exponent_stack_offset),
|
||||
compiler.encode_uchar4(randomness_stack_offset,
|
||||
distance_stack_offset,
|
||||
color_stack_offset, position_stack_offset),
|
||||
compiler.encode_uchar4(w_out_stack_offset, radius_stack_offset, normalize)
|
||||
);
|
||||
color_stack_offset,
|
||||
position_stack_offset),
|
||||
compiler.encode_uchar4(w_out_stack_offset, radius_stack_offset, normalize));
|
||||
|
||||
compiler.add_node( __float_as_int(w), __float_as_int(scale), __float_as_int(detail), __float_as_int(roughness)
|
||||
);
|
||||
compiler.add_node(
|
||||
__float_as_int(w), __float_as_int(scale), __float_as_int(detail), __float_as_int(roughness));
|
||||
compiler.add_node(__float_as_int(lacunarity),
|
||||
__float_as_int(smoothness),__float_as_int(exponent), __float_as_int(randomness));
|
||||
__float_as_int(smoothness),
|
||||
__float_as_int(exponent),
|
||||
__float_as_int(randomness));
|
||||
tex_mapping.compile_end(compiler, vector_in, vector_stack_offset);
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,6 @@ void node_tex_voronoi_f1_1d(vec3 coord,
|
|||
octave_scale *= lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
|
||||
outPosition /= octave_scale / lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
|
@ -217,7 +216,6 @@ void node_tex_voronoi_smooth_f1_1d(vec3 coord,
|
|||
octave_scale *= lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
|
||||
outPosition /= octave_scale / lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
|
@ -354,7 +352,6 @@ void node_tex_voronoi_f2_1d(vec3 coord,
|
|||
octave_scale *= lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
|
||||
outPosition /= octave_scale / lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
|
@ -434,6 +431,32 @@ void node_tex_voronoi_distance_to_edge_1d(vec3 coord,
|
|||
localPosition);
|
||||
|
||||
outDistance = min(distanceToMidLeft, distanceToMidRight);
|
||||
|
||||
if (detail != 0.0 && lacunarity != 0.0) {
|
||||
float octave_scale = lacunarity;
|
||||
float octave_distance = 0.0;
|
||||
for (int i = 0; i < detail; ++i) {
|
||||
scaledCoord = w * scale * octave_scale;
|
||||
cellPosition = floor(scaledCoord);
|
||||
localPosition = scaledCoord - cellPosition;
|
||||
|
||||
float midPointPosition = hash_float_to_float(cellPosition) * randomness;
|
||||
float leftPointPosition = -1.0 + hash_float_to_float(cellPosition - 1.0) * randomness;
|
||||
float rightPointPosition = 1.0 + hash_float_to_float(cellPosition + 1.0) * randomness;
|
||||
float distanceToMidLeft = distance((midPointPosition + leftPointPosition) / 2.0,
|
||||
localPosition);
|
||||
float distanceToMidRight = distance((midPointPosition + rightPointPosition) / 2.0,
|
||||
localPosition);
|
||||
|
||||
octave_distance = min(distanceToMidLeft, distanceToMidRight);
|
||||
|
||||
outDistance = min(outDistance, octave_distance / octave_scale);
|
||||
octave_scale *= lacunarity;
|
||||
}
|
||||
if (bool_normalize != 0.0) {
|
||||
outDistance *= octave_scale / lacunarity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void node_tex_voronoi_n_sphere_radius_1d(vec3 coord,
|
||||
|
@ -558,8 +581,7 @@ void node_tex_voronoi_f1_2d(vec3 coord,
|
|||
outColor.xyz = hash_vec2_to_vec3(cellPosition + targetOffset);
|
||||
outPosition = vec3(safe_divide(targetPosition + cellPosition, scale), 0.0);
|
||||
|
||||
const float max_distance = voronoi_distance(
|
||||
vec2(1.0, 1.0), vec2(0.0, 0.0), metric, exponent);
|
||||
const float max_distance = voronoi_distance(vec2(1.0, 1.0), vec2(0.0, 0.0), metric, exponent);
|
||||
float max_amplitude = max_distance;
|
||||
if (detail != 0.0 && roughness != 0.0 && lacunarity != 0.0) {
|
||||
float octave_scale = lacunarity;
|
||||
|
@ -598,7 +620,6 @@ void node_tex_voronoi_f1_2d(vec3 coord,
|
|||
octave_scale *= lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
|
||||
outPosition /= octave_scale / lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
|
@ -687,8 +708,7 @@ void node_tex_voronoi_smooth_f1_2d(vec3 coord,
|
|||
outColor.xyz = smoothColor;
|
||||
outPosition = vec3(safe_divide(cellPosition + smoothPosition, scale), 0.0);
|
||||
|
||||
const float max_distance = voronoi_distance(
|
||||
vec2(1.0, 1.0), vec2(0.0, 0.0), metric, exponent);
|
||||
const float max_distance = voronoi_distance(vec2(1.0, 1.0), vec2(0.0, 0.0), metric, exponent);
|
||||
float max_amplitude = max_distance;
|
||||
if (detail != 0.0 && roughness != 0.0 && lacunarity != 0.0) {
|
||||
float octave_scale = lacunarity;
|
||||
|
@ -728,7 +748,6 @@ void node_tex_voronoi_smooth_f1_2d(vec3 coord,
|
|||
octave_scale *= lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
|
||||
outPosition /= octave_scale / lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
|
@ -825,8 +844,7 @@ void node_tex_voronoi_f2_2d(vec3 coord,
|
|||
outColor.xyz = hash_vec2_to_vec3(cellPosition + offsetF2);
|
||||
outPosition = vec3(safe_divide(positionF2 + cellPosition, scale), 0.0);
|
||||
|
||||
const float max_distance = voronoi_distance(
|
||||
vec2(1.0, 1.0), vec2(0.0, 0.0), metric, exponent);
|
||||
const float max_distance = voronoi_distance(vec2(1.0, 1.0), vec2(0.0, 0.0), metric, exponent);
|
||||
float max_amplitude = max_distance;
|
||||
if (detail != 0.0 && roughness != 0.0 && lacunarity != 0.0) {
|
||||
float octave_scale = lacunarity;
|
||||
|
@ -873,7 +891,6 @@ void node_tex_voronoi_f2_2d(vec3 coord,
|
|||
octave_scale *= lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
|
||||
outPosition /= octave_scale / lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
|
@ -977,6 +994,55 @@ void node_tex_voronoi_distance_to_edge_2d(vec3 coord,
|
|||
}
|
||||
}
|
||||
outDistance = minDistance;
|
||||
|
||||
if (detail != 0.0 && lacunarity != 0.0) {
|
||||
float octave_scale = lacunarity;
|
||||
float octave_distance = 0.0;
|
||||
for (int i = 0; i < detail; ++i) {
|
||||
scaledCoord = coord.xy * scale * octave_scale;
|
||||
cellPosition = floor(scaledCoord);
|
||||
localPosition = scaledCoord - cellPosition;
|
||||
|
||||
vec2 vectorToClosest;
|
||||
float minDistance = 8.0;
|
||||
for (int j = -1; j <= 1; j++) {
|
||||
for (int i = -1; i <= 1; i++) {
|
||||
vec2 cellOffset = vec2(i, j);
|
||||
vec2 vectorToPoint = cellOffset +
|
||||
hash_vec2_to_vec2(cellPosition + cellOffset) * randomness -
|
||||
localPosition;
|
||||
float distanceToPoint = dot(vectorToPoint, vectorToPoint);
|
||||
if (distanceToPoint < minDistance) {
|
||||
minDistance = distanceToPoint;
|
||||
vectorToClosest = vectorToPoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
minDistance = 8.0;
|
||||
for (int j = -1; j <= 1; j++) {
|
||||
for (int i = -1; i <= 1; i++) {
|
||||
vec2 cellOffset = vec2(i, j);
|
||||
vec2 vectorToPoint = cellOffset +
|
||||
hash_vec2_to_vec2(cellPosition + cellOffset) * randomness -
|
||||
localPosition;
|
||||
vec2 perpendicularToEdge = vectorToPoint - vectorToClosest;
|
||||
if (dot(perpendicularToEdge, perpendicularToEdge) > 0.0001) {
|
||||
float distanceToEdge = dot((vectorToClosest + vectorToPoint) / 2.0,
|
||||
normalize(perpendicularToEdge));
|
||||
minDistance = min(minDistance, distanceToEdge);
|
||||
}
|
||||
}
|
||||
}
|
||||
octave_distance = minDistance;
|
||||
|
||||
outDistance = min(outDistance, octave_distance / octave_scale);
|
||||
octave_scale *= lacunarity;
|
||||
}
|
||||
if (bool_normalize != 0.0) {
|
||||
outDistance *= octave_scale / lacunarity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void node_tex_voronoi_n_sphere_radius_2d(vec3 coord,
|
||||
|
@ -1111,7 +1177,7 @@ void node_tex_voronoi_f1_3d(vec3 coord,
|
|||
outPosition = safe_divide(targetPosition + cellPosition, scale);
|
||||
|
||||
const float max_distance = voronoi_distance(
|
||||
vec3(1.0,1.0,1.0), vec3(0.0, 0.0, 0.0), metric, exponent);
|
||||
vec3(1.0, 1.0, 1.0), vec3(0.0, 0.0, 0.0), metric, exponent);
|
||||
float max_amplitude = max_distance;
|
||||
if (detail != 0.0 && roughness != 0.0 && lacunarity != 0.0) {
|
||||
float octave_scale = lacunarity;
|
||||
|
@ -1150,7 +1216,6 @@ void node_tex_voronoi_f1_3d(vec3 coord,
|
|||
octave_scale *= lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
|
||||
outPosition /= octave_scale / lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
|
@ -1244,7 +1309,7 @@ void node_tex_voronoi_smooth_f1_3d(vec3 coord,
|
|||
outPosition = safe_divide(cellPosition + smoothPosition, scale);
|
||||
|
||||
const float max_distance = voronoi_distance(
|
||||
vec3(1.0, 1.0, 1.0), vec3(0.0, 0.0, 0.0), metric, exponent);
|
||||
vec3(1.0, 1.0, 1.0), vec3(0.0, 0.0, 0.0), metric, exponent);
|
||||
float max_amplitude = max_distance;
|
||||
if (detail != 0.0 && roughness != 0.0 && lacunarity != 0.0) {
|
||||
float octave_scale = lacunarity;
|
||||
|
@ -1287,7 +1352,6 @@ void node_tex_voronoi_smooth_f1_3d(vec3 coord,
|
|||
octave_scale *= lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
|
||||
outPosition /= octave_scale / lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
|
@ -1391,7 +1455,7 @@ void node_tex_voronoi_f2_3d(vec3 coord,
|
|||
outPosition = safe_divide(positionF2 + cellPosition, scale);
|
||||
|
||||
const float max_distance = voronoi_distance(
|
||||
vec3(1.0, 1.0, 1.0), vec3(0.0, 0.0, 0.0), metric, exponent);
|
||||
vec3(1.0, 1.0, 1.0), vec3(0.0, 0.0, 0.0), metric, exponent);
|
||||
float max_amplitude = max_distance;
|
||||
if (detail != 0.0 && roughness != 0.0 && lacunarity != 0.0) {
|
||||
float octave_scale = lacunarity;
|
||||
|
@ -1441,7 +1505,6 @@ void node_tex_voronoi_f2_3d(vec3 coord,
|
|||
octave_scale *= lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
|
||||
outPosition /= octave_scale / lacunarity;
|
||||
|
||||
float remainder = detail - int(detail);
|
||||
|
@ -1554,6 +1617,59 @@ void node_tex_voronoi_distance_to_edge_3d(vec3 coord,
|
|||
}
|
||||
}
|
||||
outDistance = minDistance;
|
||||
|
||||
if (detail != 0.0 && lacunarity != 0.0) {
|
||||
float octave_scale = lacunarity;
|
||||
float octave_distance = 0.0;
|
||||
for (int i = 0; i < detail; ++i) {
|
||||
scaledCoord = coord * scale * octave_scale;
|
||||
cellPosition = floor(scaledCoord);
|
||||
localPosition = scaledCoord - cellPosition;
|
||||
|
||||
vec3 vectorToClosest;
|
||||
float minDistance = 8.0;
|
||||
for (int k = -1; k <= 1; k++) {
|
||||
for (int j = -1; j <= 1; j++) {
|
||||
for (int i = -1; i <= 1; i++) {
|
||||
vec3 cellOffset = vec3(i, j, k);
|
||||
vec3 vectorToPoint = cellOffset +
|
||||
hash_vec3_to_vec3(cellPosition + cellOffset) * randomness -
|
||||
localPosition;
|
||||
float distanceToPoint = dot(vectorToPoint, vectorToPoint);
|
||||
if (distanceToPoint < minDistance) {
|
||||
minDistance = distanceToPoint;
|
||||
vectorToClosest = vectorToPoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
minDistance = 8.0;
|
||||
for (int k = -1; k <= 1; k++) {
|
||||
for (int j = -1; j <= 1; j++) {
|
||||
for (int i = -1; i <= 1; i++) {
|
||||
vec3 cellOffset = vec3(i, j, k);
|
||||
vec3 vectorToPoint = cellOffset +
|
||||
hash_vec3_to_vec3(cellPosition + cellOffset) * randomness -
|
||||
localPosition;
|
||||
vec3 perpendicularToEdge = vectorToPoint - vectorToClosest;
|
||||
if (dot(perpendicularToEdge, perpendicularToEdge) > 0.0001) {
|
||||
float distanceToEdge = dot((vectorToClosest + vectorToPoint) / 2.0,
|
||||
normalize(perpendicularToEdge));
|
||||
minDistance = min(minDistance, distanceToEdge);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
octave_distance = minDistance;
|
||||
|
||||
outDistance = min(outDistance, octave_distance / octave_scale);
|
||||
octave_scale *= lacunarity;
|
||||
}
|
||||
if (bool_normalize != 0.0) {
|
||||
outDistance *= octave_scale / lacunarity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void node_tex_voronoi_n_sphere_radius_3d(vec3 coord,
|
||||
|
@ -1698,7 +1814,7 @@ void node_tex_voronoi_f1_4d(vec3 coord,
|
|||
outW = p.w;
|
||||
|
||||
const float max_distance = voronoi_distance(
|
||||
vec4(1.0, 1.0, 1.0,1.0), vec4(0.0, 0.0, 0.0,0.0), metric, exponent);
|
||||
vec4(1.0, 1.0, 1.0, 1.0), vec4(0.0, 0.0, 0.0, 0.0), metric, exponent);
|
||||
float max_amplitude = max_distance;
|
||||
if (detail != 0.0 && roughness != 0.0 && lacunarity != 0.0) {
|
||||
float octave_scale = lacunarity;
|
||||
|
@ -1741,7 +1857,6 @@ void node_tex_voronoi_f1_4d(vec3 coord,
|
|||
octave_scale *= lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
|
||||
outPosition /= octave_scale / lacunarity;
|
||||
outW /= octave_scale / lacunarity;
|
||||
|
||||
|
@ -1845,7 +1960,7 @@ void node_tex_voronoi_smooth_f1_4d(vec3 coord,
|
|||
outW = p.w;
|
||||
|
||||
const float max_distance = voronoi_distance(
|
||||
vec4(1.0, 1.0, 1.0, 1.0), vec4(0.0, 0.0, 0.0, 0.0), metric, exponent);
|
||||
vec4(1.0, 1.0, 1.0, 1.0), vec4(0.0, 0.0, 0.0, 0.0), metric, exponent);
|
||||
float max_amplitude = max_distance;
|
||||
if (detail != 0.0 && roughness != 0.0 && lacunarity != 0.0) {
|
||||
float octave_scale = lacunarity;
|
||||
|
@ -1892,7 +2007,6 @@ void node_tex_voronoi_smooth_f1_4d(vec3 coord,
|
|||
octave_scale *= lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
|
||||
outPosition /= octave_scale / lacunarity;
|
||||
outW /= octave_scale / lacunarity;
|
||||
|
||||
|
@ -2006,7 +2120,7 @@ void node_tex_voronoi_f2_4d(vec3 coord,
|
|||
outW = p.w;
|
||||
|
||||
const float max_distance = voronoi_distance(
|
||||
vec4(1.0, 1.0, 1.0, 1.0), vec4(0.0, 0.0, 0.0, 0.0), metric, exponent);
|
||||
vec4(1.0, 1.0, 1.0, 1.0), vec4(0.0, 0.0, 0.0, 0.0), metric, exponent);
|
||||
float max_amplitude = max_distance;
|
||||
if (detail != 0.0 && roughness != 0.0 && lacunarity != 0.0) {
|
||||
float octave_scale = lacunarity;
|
||||
|
@ -2060,7 +2174,6 @@ void node_tex_voronoi_f2_4d(vec3 coord,
|
|||
octave_scale *= lacunarity;
|
||||
octave_amplitude *= roughness;
|
||||
}
|
||||
|
||||
outPosition /= octave_scale / lacunarity;
|
||||
outW /= octave_scale / lacunarity;
|
||||
|
||||
|
@ -2183,6 +2296,63 @@ void node_tex_voronoi_distance_to_edge_4d(vec3 coord,
|
|||
}
|
||||
}
|
||||
outDistance = minDistance;
|
||||
|
||||
if (detail != 0.0 && lacunarity != 0.0) {
|
||||
float octave_scale = lacunarity;
|
||||
float octave_distance = 0.0;
|
||||
for (int i = 0; i < detail; ++i) {
|
||||
scaledCoord = vec4(coord, w) * scale * octave_scale;
|
||||
cellPosition = floor(scaledCoord);
|
||||
localPosition = scaledCoord - cellPosition;
|
||||
|
||||
vec4 vectorToClosest;
|
||||
float minDistance = 8.0;
|
||||
for (int u = -1; u <= 1; u++) {
|
||||
for (int k = -1; k <= 1; k++) {
|
||||
for (int j = -1; j <= 1; j++) {
|
||||
for (int i = -1; i <= 1; i++) {
|
||||
vec4 cellOffset = vec4(i, j, k, u);
|
||||
vec4 vectorToPoint = cellOffset +
|
||||
hash_vec4_to_vec4(cellPosition + cellOffset) * randomness -
|
||||
localPosition;
|
||||
float distanceToPoint = dot(vectorToPoint, vectorToPoint);
|
||||
if (distanceToPoint < minDistance) {
|
||||
minDistance = distanceToPoint;
|
||||
vectorToClosest = vectorToPoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
minDistance = 8.0;
|
||||
for (int u = -1; u <= 1; u++) {
|
||||
for (int k = -1; k <= 1; k++) {
|
||||
for (int j = -1; j <= 1; j++) {
|
||||
for (int i = -1; i <= 1; i++) {
|
||||
vec4 cellOffset = vec4(i, j, k, u);
|
||||
vec4 vectorToPoint = cellOffset +
|
||||
hash_vec4_to_vec4(cellPosition + cellOffset) * randomness -
|
||||
localPosition;
|
||||
vec4 perpendicularToEdge = vectorToPoint - vectorToClosest;
|
||||
if (dot(perpendicularToEdge, perpendicularToEdge) > 0.0001) {
|
||||
float distanceToEdge = dot((vectorToClosest + vectorToPoint) / 2.0,
|
||||
normalize(perpendicularToEdge));
|
||||
minDistance = min(minDistance, distanceToEdge);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
octave_distance = minDistance;
|
||||
|
||||
outDistance = min(outDistance, octave_distance / octave_scale);
|
||||
octave_scale *= lacunarity;
|
||||
}
|
||||
if (bool_normalize != 0.0) {
|
||||
outDistance *= octave_scale / lacunarity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void node_tex_voronoi_n_sphere_radius_4d(vec3 coord,
|
||||
|
|
|
@ -77,7 +77,7 @@ static void node_shader_buts_tex_voronoi(uiLayout *layout, bContext * /*C*/, Poi
|
|||
RNA_enum_get(ptr, "voronoi_dimensions") != 1) {
|
||||
uiItemR(layout, ptr, "distance", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
|
||||
}
|
||||
if (!ELEM(feature, SHD_VORONOI_DISTANCE_TO_EDGE, SHD_VORONOI_N_SPHERE_RADIUS)) {
|
||||
if (!ELEM(feature, SHD_VORONOI_N_SPHERE_RADIUS)) {
|
||||
uiItemR(layout, ptr, "normalize", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
|
||||
}
|
||||
}
|
||||
|
@ -446,13 +446,10 @@ class VoronoiMinowskiFunction : public fn::MultiFunction {
|
|||
calc_distance ? &octave_distance : nullptr,
|
||||
calc_color ? &col : nullptr,
|
||||
calc_position ? &pos : nullptr);
|
||||
|
||||
if (calc_distance) {
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
r_distance[i] += octave_distance * octave_amplitude;
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
if (calc_color) {
|
||||
r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f);
|
||||
}
|
||||
|
@ -460,6 +457,8 @@ class VoronoiMinowskiFunction : public fn::MultiFunction {
|
|||
pos = math::safe_divide(pos, scale[i]);
|
||||
r_position[i] = (float3(pos.x, pos.y, 0.0f) / octave_scale) * lacunarity[i];
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
}
|
||||
|
||||
float remainder = detail[i] - int(detail[i]);
|
||||
|
@ -471,7 +470,6 @@ class VoronoiMinowskiFunction : public fn::MultiFunction {
|
|||
calc_distance ? &octave_distance : nullptr,
|
||||
calc_color ? &col : nullptr,
|
||||
calc_position ? &pos : nullptr);
|
||||
|
||||
if (calc_distance) {
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
float lerp_distance = r_distance[i] + octave_distance * octave_amplitude;
|
||||
|
@ -541,13 +539,10 @@ class VoronoiMinowskiFunction : public fn::MultiFunction {
|
|||
calc_distance ? &octave_distance : nullptr,
|
||||
calc_color ? &col : nullptr,
|
||||
calc_position ? &pos : nullptr);
|
||||
|
||||
if (calc_distance) {
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
r_distance[i] += octave_distance * octave_amplitude;
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
if (calc_color) {
|
||||
r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f);
|
||||
}
|
||||
|
@ -555,6 +550,8 @@ class VoronoiMinowskiFunction : public fn::MultiFunction {
|
|||
pos = math::safe_divide(pos, scale[i]);
|
||||
r_position[i] = (float3(pos.x, pos.y, 0.0f) / octave_scale) * lacunarity[i];
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
}
|
||||
|
||||
float remainder = detail[i] - int(detail[i]);
|
||||
|
@ -566,7 +563,6 @@ class VoronoiMinowskiFunction : public fn::MultiFunction {
|
|||
calc_distance ? &octave_distance : nullptr,
|
||||
calc_color ? &col : nullptr,
|
||||
calc_position ? &pos : nullptr);
|
||||
|
||||
if (calc_distance) {
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
float lerp_distance = r_distance[i] + octave_distance * octave_amplitude;
|
||||
|
@ -641,22 +637,20 @@ class VoronoiMinowskiFunction : public fn::MultiFunction {
|
|||
calc_distance ? &octave_distance : nullptr,
|
||||
calc_color ? &col : nullptr,
|
||||
calc_position ? &pos : nullptr);
|
||||
|
||||
if (calc_distance) {
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
r_distance[i] += octave_distance * octave_amplitude;
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
if (calc_color) {
|
||||
r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f);
|
||||
}
|
||||
if (calc_position) {
|
||||
pos = math::safe_divide(pos, scale[i]);
|
||||
r_position[i] = (float3(pos.x, pos.y, 0.0f) / octave_scale) * lacunarity[i];
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
}
|
||||
}
|
||||
|
||||
float remainder = detail[i] - int(detail[i]);
|
||||
if (remainder != 0.0f) {
|
||||
noise::voronoi_smooth_f1(float2(vector[i].x, vector[i].y) * scale[i] *
|
||||
|
@ -668,7 +662,6 @@ class VoronoiMinowskiFunction : public fn::MultiFunction {
|
|||
calc_distance ? &octave_distance : nullptr,
|
||||
calc_color ? &col : nullptr,
|
||||
calc_position ? &pos : nullptr);
|
||||
|
||||
if (calc_distance) {
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
float lerp_distance = r_distance[i] + octave_distance * octave_amplitude;
|
||||
|
@ -747,8 +740,6 @@ class VoronoiMinowskiFunction : public fn::MultiFunction {
|
|||
max_amplitude += max_distance * octave_amplitude;
|
||||
r_distance[i] += octave_distance * octave_amplitude;
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
if (calc_color) {
|
||||
r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f);
|
||||
}
|
||||
|
@ -756,6 +747,8 @@ class VoronoiMinowskiFunction : public fn::MultiFunction {
|
|||
r_position[i] = (math::safe_divide(r_position[i], scale[i]) / octave_scale) *
|
||||
lacunarity[i];
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
}
|
||||
|
||||
float remainder = detail[i] - int(detail[i]);
|
||||
|
@ -839,8 +832,6 @@ class VoronoiMinowskiFunction : public fn::MultiFunction {
|
|||
max_amplitude += max_distance * octave_amplitude;
|
||||
r_distance[i] += octave_distance * octave_amplitude;
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
if (calc_color) {
|
||||
r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f);
|
||||
}
|
||||
|
@ -848,6 +839,8 @@ class VoronoiMinowskiFunction : public fn::MultiFunction {
|
|||
r_position[i] = (math::safe_divide(r_position[i], scale[i]) / octave_scale) *
|
||||
lacunarity[i];
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
}
|
||||
|
||||
float remainder = detail[i] - int(detail[i]);
|
||||
|
@ -935,8 +928,6 @@ class VoronoiMinowskiFunction : public fn::MultiFunction {
|
|||
max_amplitude += max_distance * octave_amplitude;
|
||||
r_distance[i] += octave_distance * octave_amplitude;
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
if (calc_color) {
|
||||
r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f);
|
||||
}
|
||||
|
@ -944,6 +935,8 @@ class VoronoiMinowskiFunction : public fn::MultiFunction {
|
|||
r_position[i] = (math::safe_divide(r_position[i], scale[i]) / octave_scale) *
|
||||
lacunarity[i];
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
}
|
||||
|
||||
float remainder = detail[i] - int(detail[i]);
|
||||
|
@ -1044,8 +1037,6 @@ class VoronoiMinowskiFunction : public fn::MultiFunction {
|
|||
max_amplitude += max_distance * octave_amplitude;
|
||||
r_distance[i] += octave_distance * octave_amplitude;
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
if (calc_color) {
|
||||
r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f);
|
||||
}
|
||||
|
@ -1058,6 +1049,8 @@ class VoronoiMinowskiFunction : public fn::MultiFunction {
|
|||
r_w[i] = (pos.w / octave_scale) * lacunarity[i];
|
||||
}
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
}
|
||||
|
||||
float remainder = detail[i] - int(detail[i]);
|
||||
|
@ -1158,8 +1151,6 @@ class VoronoiMinowskiFunction : public fn::MultiFunction {
|
|||
max_amplitude += max_distance * octave_amplitude;
|
||||
r_distance[i] += octave_distance * octave_amplitude;
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
if (calc_color) {
|
||||
r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f);
|
||||
}
|
||||
|
@ -1172,6 +1163,8 @@ class VoronoiMinowskiFunction : public fn::MultiFunction {
|
|||
r_w[i] = (pos.w / octave_scale) * lacunarity[i];
|
||||
}
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
}
|
||||
|
||||
float remainder = detail[i] - int(detail[i]);
|
||||
|
@ -1276,8 +1269,6 @@ class VoronoiMinowskiFunction : public fn::MultiFunction {
|
|||
max_amplitude += max_distance * octave_amplitude;
|
||||
r_distance[i] += octave_distance * octave_amplitude;
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
if (calc_color) {
|
||||
r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f);
|
||||
}
|
||||
|
@ -1290,6 +1281,8 @@ class VoronoiMinowskiFunction : public fn::MultiFunction {
|
|||
r_w[i] = (pos.w / octave_scale) * lacunarity[i];
|
||||
}
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
}
|
||||
|
||||
float remainder = detail[i] - int(detail[i]);
|
||||
|
@ -1490,14 +1483,14 @@ class VoronoiMetricFunction : public fn::MultiFunction {
|
|||
max_amplitude += octave_amplitude;
|
||||
r_distance[i] += octave_distance * octave_amplitude;
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
if (calc_color) {
|
||||
r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f);
|
||||
}
|
||||
if (calc_w) {
|
||||
r_w[i] = (safe_divide(r_w[i], scale[i]) / octave_scale) * lacunarity[i];
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
}
|
||||
|
||||
float remainder = detail[i] - int(detail[i]);
|
||||
|
@ -1571,14 +1564,14 @@ class VoronoiMetricFunction : public fn::MultiFunction {
|
|||
max_amplitude += octave_amplitude;
|
||||
r_distance[i] += octave_distance * octave_amplitude;
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
if (calc_color) {
|
||||
r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f);
|
||||
}
|
||||
if (calc_w) {
|
||||
r_w[i] = (safe_divide(r_w[i], scale[i]) / octave_scale) * lacunarity[i];
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
}
|
||||
|
||||
float remainder = detail[i] - int(detail[i]);
|
||||
|
@ -1656,14 +1649,14 @@ class VoronoiMetricFunction : public fn::MultiFunction {
|
|||
max_amplitude += octave_amplitude;
|
||||
r_distance[i] += octave_distance * octave_amplitude;
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
if (calc_color) {
|
||||
r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f);
|
||||
}
|
||||
if (calc_w) {
|
||||
r_w[i] = (safe_divide(r_w[i], scale[i]) / octave_scale) * lacunarity[i];
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
}
|
||||
|
||||
float remainder = detail[i] - int(detail[i]);
|
||||
|
@ -1746,13 +1739,10 @@ class VoronoiMetricFunction : public fn::MultiFunction {
|
|||
calc_distance ? &octave_distance : nullptr,
|
||||
calc_color ? &col : nullptr,
|
||||
calc_position ? &pos : nullptr);
|
||||
|
||||
if (calc_distance) {
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
r_distance[i] += octave_distance * octave_amplitude;
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
if (calc_color) {
|
||||
r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f);
|
||||
}
|
||||
|
@ -1760,6 +1750,8 @@ class VoronoiMetricFunction : public fn::MultiFunction {
|
|||
pos = math::safe_divide(pos, scale[i]);
|
||||
r_position[i] = (float3(pos.x, pos.y, 0.0f) / octave_scale) * lacunarity[i];
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
}
|
||||
|
||||
float remainder = detail[i] - int(detail[i]);
|
||||
|
@ -1771,7 +1763,6 @@ class VoronoiMetricFunction : public fn::MultiFunction {
|
|||
calc_distance ? &octave_distance : nullptr,
|
||||
calc_color ? &col : nullptr,
|
||||
calc_position ? &pos : nullptr);
|
||||
|
||||
if (calc_distance) {
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
float lerp_distance = r_distance[i] + octave_distance * octave_amplitude;
|
||||
|
@ -1840,13 +1831,10 @@ class VoronoiMetricFunction : public fn::MultiFunction {
|
|||
calc_distance ? &octave_distance : nullptr,
|
||||
calc_color ? &col : nullptr,
|
||||
calc_position ? &pos : nullptr);
|
||||
|
||||
if (calc_distance) {
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
r_distance[i] += octave_distance * octave_amplitude;
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
if (calc_color) {
|
||||
r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f);
|
||||
}
|
||||
|
@ -1854,6 +1842,8 @@ class VoronoiMetricFunction : public fn::MultiFunction {
|
|||
pos = math::safe_divide(pos, scale[i]);
|
||||
r_position[i] = (float3(pos.x, pos.y, 0.0f) / octave_scale) * lacunarity[i];
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
}
|
||||
|
||||
float remainder = detail[i] - int(detail[i]);
|
||||
|
@ -1865,7 +1855,6 @@ class VoronoiMetricFunction : public fn::MultiFunction {
|
|||
calc_distance ? &octave_distance : nullptr,
|
||||
calc_color ? &col : nullptr,
|
||||
calc_position ? &pos : nullptr);
|
||||
|
||||
if (calc_distance) {
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
float lerp_distance = r_distance[i] + octave_distance * octave_amplitude;
|
||||
|
@ -1939,13 +1928,10 @@ class VoronoiMetricFunction : public fn::MultiFunction {
|
|||
calc_distance ? &octave_distance : nullptr,
|
||||
calc_color ? &col : nullptr,
|
||||
calc_position ? &pos : nullptr);
|
||||
|
||||
if (calc_distance) {
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
r_distance[i] += octave_distance * octave_amplitude;
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
if (calc_color) {
|
||||
r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f);
|
||||
}
|
||||
|
@ -1953,6 +1939,8 @@ class VoronoiMetricFunction : public fn::MultiFunction {
|
|||
pos = math::safe_divide(pos, scale[i]);
|
||||
r_position[i] = (float3(pos.x, pos.y, 0.0f) / octave_scale) * lacunarity[i];
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
}
|
||||
|
||||
float remainder = detail[i] - int(detail[i]);
|
||||
|
@ -1966,7 +1954,6 @@ class VoronoiMetricFunction : public fn::MultiFunction {
|
|||
calc_distance ? &octave_distance : nullptr,
|
||||
calc_color ? &col : nullptr,
|
||||
calc_position ? &pos : nullptr);
|
||||
|
||||
if (calc_distance) {
|
||||
max_amplitude += max_distance * octave_amplitude;
|
||||
float lerp_distance = r_distance[i] + octave_distance * octave_amplitude;
|
||||
|
@ -2042,8 +2029,6 @@ class VoronoiMetricFunction : public fn::MultiFunction {
|
|||
max_amplitude += max_distance * octave_amplitude;
|
||||
r_distance[i] += octave_distance * octave_amplitude;
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
if (calc_color) {
|
||||
r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f);
|
||||
}
|
||||
|
@ -2051,6 +2036,8 @@ class VoronoiMetricFunction : public fn::MultiFunction {
|
|||
r_position[i] = (math::safe_divide(r_position[i], scale[i]) / octave_scale) *
|
||||
lacunarity[i];
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
}
|
||||
|
||||
float remainder = detail[i] - int(detail[i]);
|
||||
|
@ -2131,8 +2118,6 @@ class VoronoiMetricFunction : public fn::MultiFunction {
|
|||
max_amplitude += max_distance * octave_amplitude;
|
||||
r_distance[i] += octave_distance * octave_amplitude;
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
if (calc_color) {
|
||||
r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f);
|
||||
}
|
||||
|
@ -2140,6 +2125,8 @@ class VoronoiMetricFunction : public fn::MultiFunction {
|
|||
r_position[i] = (math::safe_divide(r_position[i], scale[i]) / octave_scale) *
|
||||
lacunarity[i];
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
}
|
||||
|
||||
float remainder = detail[i] - int(detail[i]);
|
||||
|
@ -2225,8 +2212,6 @@ class VoronoiMetricFunction : public fn::MultiFunction {
|
|||
max_amplitude += max_distance * octave_amplitude;
|
||||
r_distance[i] += octave_distance * octave_amplitude;
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
if (calc_color) {
|
||||
r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f);
|
||||
}
|
||||
|
@ -2234,6 +2219,8 @@ class VoronoiMetricFunction : public fn::MultiFunction {
|
|||
r_position[i] = (math::safe_divide(r_position[i], scale[i]) / octave_scale) *
|
||||
lacunarity[i];
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
}
|
||||
|
||||
float remainder = detail[i] - int(detail[i]);
|
||||
|
@ -2334,8 +2321,6 @@ class VoronoiMetricFunction : public fn::MultiFunction {
|
|||
max_amplitude += max_distance * octave_amplitude;
|
||||
r_distance[i] += octave_distance * octave_amplitude;
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
if (calc_color) {
|
||||
r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f);
|
||||
}
|
||||
|
@ -2348,6 +2333,8 @@ class VoronoiMetricFunction : public fn::MultiFunction {
|
|||
r_w[i] = (pos.w / octave_scale) * lacunarity[i];
|
||||
}
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
}
|
||||
|
||||
float remainder = detail[i] - int(detail[i]);
|
||||
|
@ -2445,8 +2432,6 @@ class VoronoiMetricFunction : public fn::MultiFunction {
|
|||
max_amplitude += max_distance * octave_amplitude;
|
||||
r_distance[i] += octave_distance * octave_amplitude;
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
if (calc_color) {
|
||||
r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f);
|
||||
}
|
||||
|
@ -2459,6 +2444,8 @@ class VoronoiMetricFunction : public fn::MultiFunction {
|
|||
r_w[i] = (pos.w / octave_scale) * lacunarity[i];
|
||||
}
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
}
|
||||
|
||||
float remainder = detail[i] - int(detail[i]);
|
||||
|
@ -2560,8 +2547,6 @@ class VoronoiMetricFunction : public fn::MultiFunction {
|
|||
max_amplitude += max_distance * octave_amplitude;
|
||||
r_distance[i] += octave_distance * octave_amplitude;
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
if (calc_color) {
|
||||
r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f);
|
||||
}
|
||||
|
@ -2574,6 +2559,8 @@ class VoronoiMetricFunction : public fn::MultiFunction {
|
|||
r_w[i] = (pos.w / octave_scale) * lacunarity[i];
|
||||
}
|
||||
}
|
||||
octave_scale *= lacunarity[i];
|
||||
octave_amplitude *= roughness[i];
|
||||
}
|
||||
|
||||
float remainder = detail[i] - int(detail[i]);
|
||||
|
@ -2627,9 +2614,11 @@ class VoronoiEdgeFunction : public fn::MultiFunction {
|
|||
private:
|
||||
int dimensions_;
|
||||
int feature_;
|
||||
bool normalize_;
|
||||
|
||||
public:
|
||||
VoronoiEdgeFunction(int dimensions, int feature) : dimensions_(dimensions), feature_(feature)
|
||||
VoronoiEdgeFunction(int dimensions, int feature, bool normalize)
|
||||
: dimensions_(dimensions), feature_(feature), normalize_(normalize)
|
||||
{
|
||||
BLI_assert(dimensions >= 1 && dimensions <= 4);
|
||||
BLI_assert(feature >= 3 && feature <= 4);
|
||||
|
@ -2716,6 +2705,19 @@ class VoronoiEdgeFunction : public fn::MultiFunction {
|
|||
const float rand = std::min(std::max(randomness[i], 0.0f), 1.0f);
|
||||
const float p = w[i] * scale[i];
|
||||
noise::voronoi_distance_to_edge(p, rand, &r_distance[i]);
|
||||
|
||||
if (detail[i] != 0.0f && lacunarity[i] != 0.0f) {
|
||||
float octave_scale = lacunarity[i];
|
||||
float octave_distance = 0.0f;
|
||||
for (int n = 0; n < detail[i]; ++n) {
|
||||
noise::voronoi_distance_to_edge(p * octave_scale, rand, &octave_distance);
|
||||
r_distance[i] = std::min(r_distance[i], octave_distance / octave_scale);
|
||||
octave_scale *= lacunarity[i];
|
||||
}
|
||||
if (normalize_) {
|
||||
r_distance[i] *= octave_scale / lacunarity[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -2745,6 +2747,19 @@ class VoronoiEdgeFunction : public fn::MultiFunction {
|
|||
const float rand = std::min(std::max(randomness[i], 0.0f), 1.0f);
|
||||
const float2 p = float2(vector[i].x, vector[i].y) * scale[i];
|
||||
noise::voronoi_distance_to_edge(p, rand, &r_distance[i]);
|
||||
|
||||
if (detail[i] != 0.0f && lacunarity[i] != 0.0f) {
|
||||
float octave_scale = lacunarity[i];
|
||||
float octave_distance = 0.0f;
|
||||
for (int n = 0; n < detail[i]; ++n) {
|
||||
noise::voronoi_distance_to_edge(p * octave_scale, rand, &octave_distance);
|
||||
r_distance[i] = std::min(r_distance[i], octave_distance / octave_scale);
|
||||
octave_scale *= lacunarity[i];
|
||||
}
|
||||
if (normalize_) {
|
||||
r_distance[i] *= octave_scale / lacunarity[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -2773,6 +2788,20 @@ class VoronoiEdgeFunction : public fn::MultiFunction {
|
|||
for (int64_t i : mask) {
|
||||
const float rand = std::min(std::max(randomness[i], 0.0f), 1.0f);
|
||||
noise::voronoi_distance_to_edge(vector[i] * scale[i], rand, &r_distance[i]);
|
||||
|
||||
if (detail[i] != 0.0f && lacunarity[i] != 0.0f) {
|
||||
float octave_scale = lacunarity[i];
|
||||
float octave_distance = 0.0f;
|
||||
for (int n = 0; n < detail[i]; ++n) {
|
||||
noise::voronoi_distance_to_edge(
|
||||
vector[i] * scale[i] * octave_scale, rand, &octave_distance);
|
||||
r_distance[i] = std::min(r_distance[i], octave_distance / octave_scale);
|
||||
octave_scale *= lacunarity[i];
|
||||
}
|
||||
if (normalize_) {
|
||||
r_distance[i] *= octave_scale / lacunarity[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -2802,6 +2831,19 @@ class VoronoiEdgeFunction : public fn::MultiFunction {
|
|||
const float rand = std::min(std::max(randomness[i], 0.0f), 1.0f);
|
||||
const float4 p = float4(vector[i].x, vector[i].y, vector[i].z, w[i]) * scale[i];
|
||||
noise::voronoi_distance_to_edge(p, rand, &r_distance[i]);
|
||||
|
||||
if (detail[i] != 0.0f && lacunarity[i] != 0.0f) {
|
||||
float octave_scale = lacunarity[i];
|
||||
float octave_distance = 0.0f;
|
||||
for (int n = 0; n < detail[i]; ++n) {
|
||||
noise::voronoi_distance_to_edge(p * octave_scale, rand, &octave_distance);
|
||||
r_distance[i] = std::min(r_distance[i], octave_distance / octave_scale);
|
||||
octave_scale *= lacunarity[i];
|
||||
}
|
||||
if (normalize_) {
|
||||
r_distance[i] *= octave_scale / lacunarity[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -2836,8 +2878,8 @@ static void sh_node_voronoi_build_multi_function(NodeMultiFunctionBuilder &build
|
|||
bool dist_radius = ELEM(
|
||||
storage.feature, SHD_VORONOI_DISTANCE_TO_EDGE, SHD_VORONOI_N_SPHERE_RADIUS);
|
||||
if (dist_radius) {
|
||||
builder.construct_and_set_matching_fn<VoronoiEdgeFunction>(storage.dimensions,
|
||||
storage.feature);
|
||||
builder.construct_and_set_matching_fn<VoronoiEdgeFunction>(
|
||||
storage.dimensions, storage.feature, storage.normalize);
|
||||
}
|
||||
else if (minowski) {
|
||||
builder.construct_and_set_matching_fn<VoronoiMinowskiFunction>(
|
||||
|
|
Loading…
Reference in New Issue