-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Organic Noise : Fix uv_scale default (is now 1). Add over-sampling blend. * Organic Noise : Add noise type fractal lines. Allow over-sampling different noise type. Over-sampling blends. * Organic Noise : Blend modes, more options, overall betterer. * wip : Colors, new modes, experiments. * Add GrayscaleToColor, extract library functions. * New build system, with include punching. * More colorize options and things. * Add lines and steps. Start presets. * Moar presets! * Add more entry to reduce tiling. More presets. * Organic Noise presets. Move colorize to experiments.
- Loading branch information
Showing
10 changed files
with
1,117 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// ColorSpace shader | ||
// ColorSpace.osl, by Changsoo Eun, adapted by Zap Andersson, Philippe Groarke | ||
// Modified: 2019-11-22 | ||
// Copyright 2019 Autodesk Inc, All rights reserved. This file is licensed under Apache 2.0 license | ||
// https://github.com/ADN-DevTech/3dsMax-OSL-Shaders/blob/master/LICENSE.txt | ||
|
||
|
||
|
||
|
||
shader ColorSpace | ||
[[ | ||
string help = "Convert RGB / HSV / YIQ / XYZ / xyY / Lab", | ||
string label = "Color Space Lab", | ||
string category = "Math Color" | ||
]] | ||
( | ||
string FromSpace = "hsv" | ||
[[ string widget = "mapper", | ||
string options = "rgb:rgb|hsv (hue, saturation, and value):hsv|hsl (hue, saturation, and lightness):hsl" | ||
"|YIQ (for the NTSC television standard):YIQ|XYZ (CIE XYZ coordinates):XYZ|xyY (CIE xyY coordinates):xyY|Lab (CIE LAB coordinates):Lab", | ||
string label = "From space:"]], | ||
string ToSpace = "rgb" | ||
[[ string widget = "mapper", | ||
string options = "rgb:rgb|hsv (hue, saturation, and value):hsv|hsl (hue, saturation, and lightness):hsl" | ||
"|YIQ (for the NTSC television standard):YIQ|XYZ (CIE XYZ coordinates):XYZ|xyY (CIE xyY coordinates):xyY|Lab (CIE LAB coordinates):Lab", | ||
string label = "To space:"]], | ||
|
||
vector In = 0.0, | ||
output color Out = 0.0 | ||
) | ||
{ | ||
if (FromSpace == "Lab" && ToSpace == "Lab") { | ||
Out = In; | ||
return; | ||
} | ||
|
||
if (FromSpace == "Lab") { | ||
// Convert from LAB to XYZ manually, then use transformc. | ||
float x, y, z; | ||
y = In[0] * (1.0 / 116.0) + 16.0 / 116.0; | ||
x = In[1] * (1.0 / 500.0) + y; | ||
z = In[2] * (-1.0 / 200.0) + y; | ||
|
||
x = x > 6.0 / 29.0 ? x * x * x : x * (108.0 / 841.0) - 432.0 / 24389.0; | ||
y = In[0] > 8.0 ? y * y * y : In[0] * (27.0 / 24389.0); | ||
z = z > 6.0 / 29.0 ? z * z * z : z * (108.0 / 841.0) - 432.0 / 24389.0; | ||
|
||
Out = transformc("XYZ", ToSpace, color(x,y,z)); | ||
return; | ||
} | ||
|
||
if (ToSpace == "Lab") { | ||
// Convert into XYZ first, then convert to LAB manually. | ||
color xyz = transformc(FromSpace, "XYZ", In); | ||
Out[0] = xyz[1] * 116.0 - 16.0; | ||
Out[1] = (xyz[0] - xyz[1]) * 500.0; | ||
Out[2] = (xyz[1] - xyz[2]) * 200.0; | ||
return; | ||
} | ||
|
||
Out = transformc(FromSpace , ToSpace, In); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,268 @@ | ||
// Colorize - Various schemes to convert a float grayscale map to color. | ||
// Colorize by Philippe Groarke | ||
// Copyright 2022 Philippe Groarke, All rights reserved. This file is licensed under Apache 2.0 license | ||
// https://github.com/ADN-DevTech/3dsMax-OSL-Shaders/blob/master/LICENSE.txt | ||
|
||
#include "D:\code\3dsmax-plugins\OSL\FeaOSL\fea.osl" | ||
|
||
#define degs30 0.0833333333333333 | ||
#define degs60 0.1666666666666667 | ||
|
||
// Given a hue and how many levels to output, | ||
// returns the closest multiple. | ||
float flattenize(float hue, float start_hue, int levels) { | ||
if (!levels) { | ||
return hue; | ||
} | ||
|
||
float multiple = 1.0 / float(levels); | ||
return ceil(hue / multiple) * multiple; | ||
} | ||
|
||
float flattenize(float hue, int levels) { | ||
return flattenize(hue, 0.0, levels); | ||
} | ||
|
||
// Returns a value between [0,1] the contour strength. | ||
float contourize(float before_flatten, float after_flatten, float width, int soften, float soften_slope, int levels) { | ||
if (!levels) { | ||
return 0.0; | ||
} | ||
|
||
if (after_flatten == 0.0 || after_flatten == 1.0) { | ||
return 0.0; | ||
} | ||
|
||
float multiple = 1.0 / float(levels); | ||
float diff = after_flatten - before_flatten; | ||
|
||
if (diff > width && diff < multiple - width) { | ||
return 0.0; | ||
} | ||
|
||
if (!soften) { | ||
return 1.0; | ||
} | ||
|
||
// flip "inward" side | ||
if (diff >= multiple - width) { | ||
diff = multiple - diff; | ||
} | ||
|
||
float rectify = 1.0 / width; | ||
diff *= rectify; | ||
|
||
float edge0 = width * soften_slope; | ||
float edge1 = 1.0 - width * soften_slope; | ||
return 1.0 - smoothstep(edge0, edge1, diff); | ||
// return 1.0 - fea_interp(soften_slope, diff); | ||
} | ||
|
||
shader Colorize | ||
[[ | ||
string help = | ||
"<h3>Colorize</h3>" | ||
"Various schemes to convert a float grayscale map to color.\n" | ||
"Expects values between [0, 1], clamps input." | ||
, | ||
string label = "Colorize" | ||
]] | ||
( | ||
float In = 0 | ||
[[ | ||
string label = "In", | ||
string help = "Input grayscale map, expects float.", | ||
]], | ||
|
||
int in_invert = 0 | ||
[[ | ||
string label = "Invert", | ||
string help = "Flips the input values, 1 becomes 0, 0 becomes 1.", | ||
int connectable = 0, | ||
string widget = "checkBox", | ||
]], | ||
|
||
FEA_SPACER(0), | ||
|
||
int in_color_mode = 0 | ||
[[ | ||
string widget = "mapper", | ||
string label = "Color Mode", | ||
string options = | ||
"Simple Hue:0" | ||
"|Heat Map:1" | ||
"|Bright Burn:2" | ||
"|Complements:3" | ||
"|Analogous:4" | ||
"|Split-Complementary:5" | ||
"|Triad:6" | ||
"|Tetradic:7" | ||
"|Square:8" | ||
, | ||
string help = "The output 'Color' algorithm to use.", | ||
int connectable = 0, | ||
string packName = "Color Mode / Hue", | ||
]], | ||
|
||
float in_hue = 0 | ||
[[ | ||
string label = "Hue", | ||
string help = "Cycles through available hues.", | ||
// float min = 0, | ||
// float max = 1, | ||
string packName = "Color Mode / Hue", | ||
int widgetWidth = FEA_RPACK_W, | ||
]], | ||
|
||
int in_flat = 0 | ||
[[ | ||
string label = "Flatten", | ||
string help = "Outputs 'hard' colors, without gradient.", | ||
int connectable = 0, | ||
string widget = "checkBox", | ||
// string packName = "Num Flat Levels / Flatten", | ||
// int widgetWidth = FEA_RPACK_W, | ||
]], | ||
|
||
int in_num_flat_lvls = 6 | ||
[[ | ||
string label = "Num Flat Levels", | ||
string help = "The number of colors to use in 'flat mode'. More colors == more precision.", | ||
int connectable = 0, | ||
int min = 1, | ||
// string packName = "Num Flat Levels / Flatten", | ||
]], | ||
|
||
FEA_SPACER(1), | ||
|
||
int in_contours = 0 | ||
[[ | ||
string label = "Contour Lines", | ||
string help = "Draw contours / edges according to number of levels.", | ||
int connectable = 0, | ||
string widget = "checkBox", | ||
string packName = "Contour Lines / Width", | ||
]], | ||
|
||
float in_contour_width = 1.0 | ||
[[ | ||
string label = "Contour Width", | ||
string help = "The contour width.", | ||
int connectable = 0, | ||
float min = 0.0001, | ||
string packName = "Contour Lines / Width", | ||
int widgetWidth = FEA_RPACK_W, | ||
]], | ||
|
||
int in_smooth_contours = 0 | ||
[[ | ||
string label = "Soften Contour", | ||
string help = "Soften edges of contour lines.", | ||
int connectable = 0, | ||
string widget = "checkBox", | ||
string packName = "Soften Contours / Slope", | ||
]], | ||
|
||
float in_smooth_contour_slope = 1.0 | ||
[[ | ||
string label = "Soften Contour Slope", | ||
string help = "The size of the softening gradient. Positive is exponential, negative is logarithmic and '0' is linear interpolation (none).", | ||
int connectable = 0, | ||
// float min = 0.0001, | ||
string packName = "Soften Contours / Slope", | ||
int widgetWidth = FEA_RPACK_W, | ||
]], | ||
|
||
output color Out = 0 | ||
) | ||
{ | ||
float val = clamp(In, 0.0, 1.0); | ||
val = in_invert ? 1.0 - val : val; | ||
|
||
// float hue = fmod(in_hue, 1.0); | ||
float hue = in_hue; | ||
float hsv_v = 1.0; | ||
float before_flatten = val; | ||
|
||
int flatten_levels = in_num_flat_lvls; | ||
int contour_levels = in_num_flat_lvls; | ||
if (!in_flat) { | ||
flatten_levels = 0; | ||
} | ||
if (!in_contours) { | ||
contour_levels = 0; | ||
} | ||
|
||
val = flattenize(val, flatten_levels); | ||
|
||
hsv_v = 1.0 - contourize(before_flatten, val, in_contour_width * 0.01, in_smooth_contours, in_smooth_contour_slope, contour_levels); | ||
|
||
// float multiple = 1.0 / float(flatten_levels); | ||
// float diff = val - in_val; | ||
|
||
// if (val != 0.0 && val != 1.0 && (diff >= multiple - 0.01 || diff <= 0.01)) { | ||
// if (diff >= multiple - 0.01) { | ||
// diff = multiple - diff; | ||
// } | ||
// hsv_v = smoothstep(0.1, 0.9, diff * 100.0); | ||
// } | ||
|
||
|
||
color out_col; | ||
if (in_color_mode == 0) { | ||
// hsv | ||
// float col = fmod(val + hue, 1); | ||
float col = val + hue; | ||
out_col = color("hsv", col, 1, hsv_v); | ||
} else if (in_color_mode == 1) { | ||
// heat map | ||
float offset = 0.5 + degs60 + hue; | ||
float col = offset + val * 0.5; | ||
out_col = color("hsv", col, 1, hsv_v); | ||
} else if (in_color_mode == 2) { | ||
// bright burn | ||
float g = 0.618033988749895; | ||
float col = val * 0.569 + g + hue; | ||
float s = 1.0 - val; | ||
|
||
s = flattenize(s, flatten_levels); | ||
out_col = color("hsv", col, s, hsv_v); | ||
} else if (in_color_mode == 3) { | ||
// complements | ||
color start_col = color("hsv", hue, 1, 1); | ||
color end_col = color("hsv", 0.5 + hue, 1, 1); | ||
out_col = mix(start_col, end_col, val); | ||
} else if (in_color_mode == 4) { | ||
// analogous | ||
float col = fmod(val * degs60 + hue, 1) ; | ||
out_col = color("hsv", col, 1, 1); | ||
} else if (in_color_mode == 5) { | ||
// split complementary | ||
color c1 = color("hsv", hue, 1, 1); | ||
color c2 = color("hsv", 0.5 + degs30 + hue, 1, 1); | ||
color c3 = color("hsv", 0.5 - degs30 + hue, 1, 1); | ||
out_col = fea_mix(c1, c2, c3, val); | ||
} else if (in_color_mode == 6) { | ||
// triad | ||
color c1 = color("hsv", hue, 1, 1); | ||
color c2 = color("hsv", 0.25 + degs30 + hue, 1, 1); | ||
color c3 = color("hsv", 0.75 - degs30 + hue, 1, 1); | ||
out_col = fea_mix(c1, c3, c2, val); | ||
} else if (in_color_mode == 7) { | ||
// tetradic | ||
color c1 = color("hsv", (1 / 12.0) + hue, 1, 1); | ||
color c2 = color("hsv", 0.5 - degs30 + hue, 1, 1); | ||
color c3 = color("hsv", 0.5 + degs30 + hue, 1, 1); | ||
color c4 = color("hsv", 1.0 - degs30 + hue, 1, 1); | ||
out_col = fea_mix(c1, c4, c2, c3, val); | ||
} else if (in_color_mode == 8) { | ||
// square | ||
color c1 = color("hsv", hue, 1, 1); | ||
color c2 = color("hsv", 0.25 + hue, 1, 1); | ||
color c3 = color("hsv", 0.5 + hue, 1, 1); | ||
color c4 = color("hsv", 0.75 + hue, 1, 1); | ||
out_col = fea_mix(c1, c3, c4, c2, val); | ||
} | ||
|
||
Out = out_col; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name,UUID,category,cmui_swatch,noise_type,noise_effect,line_mode,line_spacing,camo_mode,camo_angle,bubbles_mode,bubbles_strength,crease_mode,crease_angle,over_sampling,oversampling_strength,oversampling_noise_type,overampling_blend,girth_mode,girth_strength,girth_threshold,girth_threshold_strength,step_mode,step_amount,interpolate,clamp_out,sampling_dist,in_phase,in_perturb_phase | ||
Defaults,OrgN-001,Noise,Swatch-Torus,0,0,0,1.0,0,0.0,0,1.0,0,0.0,0,1.0,-1,13,0,1.0,0,0.5,0,10,0.0,TRUE,1.0,0.0,FALSE | ||
Abstract - Cross Contour,OrgN-021,Noise,Swatch-Torus,0,0,0,1.0,13,0.0,0,1.0,0,0.0,2,50.0,-1,23,0,1.0,0,0.5,5,10,0.0,TRUE,1.0,0.0,FALSE | ||
Abstract - Cross Contour 2,OrgN-022,Noise,Swatch-Torus,0,0,0,1.0,13,0.0,0,1.0,23,0.0,2,50.0,-1,23,0,1.0,0,0.5,10,10,0.0,TRUE,1.0,0.0,FALSE | ||
Abstract - Marbley,OrgN-003,Noise,Swatch-Torus,0,5,5,0.4,0,0.0,0,1.0,0,0.0,0,1.0,-1,13,0,1.0,0,0.5,0,10,0.0,TRUE,5.0,0.0,FALSE | ||
Abstract - Portal To Hell,OrgN-006,Noise,Swatch-Torus,0,0,1,0.2,0,0.0,20,1.0,20,0.0,1,1.0,2,13,1,1.0,2,0.5,0,10,0.0,TRUE,1.0,0.0,FALSE | ||
Abstract - Shooting Stars,OrgN-020,Noise,Swatch-Torus,0,0,0,1.0,0,0.0,13,1.0,0,0.0,2,5.0,-1,16,2,1.0,0,0.5,0,10,10.0,TRUE,0.1,0.0,FALSE | ||
Abstract - Starry Night,OrgN-023,Noise,Swatch-Torus,0,0,0,1.0,23,0.0,28,1.0,0,0.0,1,20.0,-1,22,0,1.0,0,0.5,10,2,0.0,TRUE,9.0,0.0,FALSE | ||
Caustics - Bright,OrgN-015,Noise,Swatch-Torus,0,0,0,1.0,0,0.0,22,1.0,22,0.0,2,1.0,-1,8,2,1.0,0,0.5,0,10,0.0,TRUE,1.0,0.0,FALSE | ||
Caustics - Dark,OrgN-016,Noise,Swatch-Torus,0,0,0,1.0,0,0.0,0,1.0,0,0.0,2,1.0,-1,20,2,1.0,0,0.5,0,10,2.0,TRUE,1.0,0.0,FALSE | ||
Caustics - Fractals,OrgN-017,Noise,Swatch-Torus,2,0,0,1.0,0,0.0,22,1.0,22,0.0,2,0.5,-1,8,2,1.0,0,0.5,0,10,2.0,TRUE,1.0,0.0,FALSE | ||
Caustics - Oily,OrgN-018,Noise,Swatch-Torus,2,0,0,1.0,0,0.0,22,1.0,22,0.0,2,0.5,3,8,2,1.0,0,0.5,0,10,2.0,TRUE,1.0,0.0,FALSE | ||
Caustics - Puddle,OrgN-026,Noise,Swatch-Torus,1,0,9,1.0,0,0.0,9,1.0,0,0.0,1,1.0,2,5,2,1.0,0,0.5,0,10,0.0,TRUE,1.0,0.0,TRUE | ||
Cells,OrgN-009,Noise,Swatch-Torus,0,0,0,1.0,0,0.0,3,1.0,0,0.0,0,1.0,-1,13,0,1.0,0,0.5,0,10,0.0,TRUE,0.1,0.2,FALSE | ||
Cells - Mask,OrgN-010,Noise,Swatch-Torus,2,0,0,1.0,0,0.0,19,1.0,0,0.0,0,1.0,-1,13,0,1.0,0,0.5,0,10,0.0,TRUE,0.1,0.2,FALSE | ||
Fabric - Pinholes,OrgN-011,Noise,Swatch-Torus,1,0,0,1.0,0,0.0,4,0.8,0,0.0,2,1.5,-1,14,0,1.0,0,0.5,0,10,0.0,TRUE,0.1,0.0,FALSE | ||
Fabric - Plastic Bumps,OrgN-008,Noise,Swatch-Torus,2,0,0,1.0,0,0.0,0,1.0,0,0.0,0,1.0,-1,13,2,2.0,0,0.5,0,10,0.0,TRUE,0.1,0.0,FALSE | ||
Fabric - Stretch,OrgN-012,Noise,Swatch-Torus,0,0,0,1.0,0,0.0,4,1.0,0,0.0,2,1.0,-1,14,0,1.0,0,0.5,0,10,0.0,TRUE,1.0,0.0,FALSE | ||
Oil - Mask,OrgN-007,Noise,Swatch-Torus,0,0,0,1.0,0,0.0,0,1.0,0,0.0,1,1.0,3,1,0,1.0,0,0.5,0,10,0.0,TRUE,1.0,0.0,FALSE | ||
Oil - Shiny,OrgN-024,Noise,Swatch-Torus,0,0,0,1.0,0,0.0,0,1.0,0,0.0,1,1.0,3,11,2,0.5,2,0.5,0,10,5.0,TRUE,10.0,0.0,FALSE | ||
Membrane,OrgN-014,Noise,Swatch-Torus,0,0,0,1.0,0,0.0,0,1.0,0,0.0,0,1.0,-1,13,2,2.0,1,0.5,0,10,-5.0,TRUE,1.0,0.0,FALSE | ||
Smoke - Gooey,OrgN-025,Noise,Swatch-Torus,0,0,3,2.75,0,0.0,3,1.0,0,0.0,1,0.9,-1,17,1,1.0,2,0.5,0,10,0.0,TRUE,1.0,0.0,TRUE | ||
Smoke - Puffs,OrgN-027,Noise,Swatch-Torus,0,0,0,1.0,0,0.0,4,1.0,6,0.0,2,1.0,-1,16,1,1.0,2,0.5,0,10,0.0,TRUE,1.0,0.0,TRUE | ||
Smoke - Rings,OrgN-028,Noise,Swatch-Torus,0,6,0,1.0,0,0.0,4,1.0,6,0.0,1,1.0,-1,10,1,1.0,0,0.5,9,50,0.0,TRUE,1.0,0.0,TRUE | ||
Splotches - Bright,OrgN-005,Noise,Swatch-Torus,0,3,15,0.25,0,0.0,0,1.0,0,0.0,1,1.0,-1,21,1,1.0,2,0.5,3,5,-5.0,TRUE,1.0,0.0,FALSE | ||
Splotches - Cartoony,OrgN-002,Noise,Swatch-Torus,0,0,0,1.0,0,0.0,0,1.0,0,0.0,2,1.0,-1,5,0,1.0,0,0.5,4,2,0.0,TRUE,1.0,0.0,FALSE | ||
Splotches - Glassy,OrgN-004,Noise,Swatch-Torus,0,0,0,1.0,0,0.0,0,1.0,0,0.0,2,1.0,-1,5,0,1.0,0,0.5,14,2,0.0,TRUE,1.0,0.0,FALSE | ||
Splotches - Tearing,OrgN-013,Noise,Swatch-Torus,1,5,0,1.0,0,0.0,4,1.0,6,0.0,2,1.5,-1,14,1,1.0,0,0.5,0,10,10.0,TRUE,0.2,0.0,FALSE |
Oops, something went wrong.