├── ACESGamutConvert.jpg ├── ACESGamutConvert.osl ├── Blackbody.jpg ├── Blackbody.osl ├── Blur.jpg ├── Blur.osl ├── Clamp.jpg ├── ColorJitter.jpg ├── ColorJitter.osl ├── ColorKeyer.jpg ├── ColorKeyer.osl ├── ColorShuffle.osl ├── DegreesToRadians.osl ├── Diffraction.jpg ├── Diffraction.osl ├── DiffractionGrating.jpg ├── DiffractionGrating.osl ├── Dots.jpg ├── Dots.osl ├── EnvironmentGradient.jpg ├── EnvironmentGradient.osl ├── FakeCaustics.jpg ├── FakeCaustics.osl ├── Flakes.jpg ├── Flakes.osl ├── HDRIEnviron.jpg ├── HDRIEnviron.osl ├── HSVsplitter.osl ├── HagelslagNoise.osl ├── Halftone.osl ├── HeightWeights.jpg ├── HeightWeights.osl ├── HexTileCoordinates.jpg ├── HexTileCoordinates.osl ├── Hexagon.jpg ├── Hexagon.osl ├── JawbreakerNoise.jpg ├── JawbreakerNoise.osl ├── Jitter.jpg ├── Jitter.osl ├── LiftGammaGain.jpg ├── LiftGammaGain.osl ├── Luma_Shader.osl ├── MarbleShader.jpg ├── MarbleShader.osl ├── MarbleVeinNoise.jpg ├── MarbleVeinNoise.osl ├── Matcap.jpg ├── Matcap.osl ├── MatrixMath.osl ├── MelaninColor.jpg ├── MelaninColor.osl ├── NishitaSky.jpg ├── NishitaSky.osl ├── NormalRotation.osl ├── ParallaxOcclusionMapping.jpg ├── ParallaxOcclusionMapping.osl ├── README.md ├── RadiansToDegrees.osl ├── RandomBitmaps.jpg ├── RandomBitmaps.osl ├── RandomTiles.jpg ├── RandomTiles.osl ├── ReflectanceToIOR.jpg ├── ReflectanceToIOR.osl ├── ShaderSwitch32.osl ├── Shapes.jpg ├── Shapes.osl ├── SimpleTiles.jpg ├── SimpleTiles.osl ├── SlopeMask.jpg ├── SlopeMask.osl ├── SpaceTransform.osl ├── Starfield.jpg ├── Starfield.osl ├── SubstanceFlow.jpg ├── SubstanceFlow.osl ├── TextureNoTile.jpg ├── TextureNoTile.osl ├── TextureNoTile_Example.jpg ├── TextureSampleScreenSpace.jpg ├── TextureSampleScreenSpace.osl ├── ThinFilmInterference.jpg ├── ThinFilmInterference.osl ├── ToonOutlines.osl ├── ToonStylizedPass.osl ├── TransformTangentNormal.osl ├── TriplanarCoordinates.jpg ├── TriplanarCoordinates.osl ├── TurbulentColor.jpg ├── TurbulentColor.osl ├── UVWTransform.jpg ├── UVWTransform.osl ├── UberColorCorrect.osl ├── UberColorCorrect.png ├── UberConstant.jpg ├── UberConstant.osl ├── UberScalarMath.jpg ├── UberScalarMath.osl ├── UberTexture.jpg ├── UberTexture.osl ├── UberVectorMath.jpg ├── UberVectorMath.osl ├── Wavelength.jpg ├── Wavelength.osl ├── Weave.jpg ├── Weave.osl ├── WoodGrain.jpg └── WoodGrain.osl /ACESGamutConvert.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/ACESGamutConvert.jpg -------------------------------------------------------------------------------- /ACESGamutConvert.osl: -------------------------------------------------------------------------------- 1 | // ACES AP1 Gamut convert from other Color Gamuts conversion V.3.1 node by Saul Espinosa for Redshift 2 | // Updated 6/21/2021 - V3.2 - Added ACEScg inversion Matrices 3 | // This file is licensed under Apache 2.0 license 4 | 5 | #define NUM_MODES 7 6 | 7 | shader ACESconvert 8 | [[ string help = "Converts an input color gamut to ACEScg", 9 | string label = "ACES Gamut Convert" ]] 10 | ( 11 | color input = 0.5 12 | [[ string label = "Input" ]], 13 | int mode = 0 14 | [[ string label = "Color Space", 15 | string widget = "mapper", 16 | string options = "sRGB:0|Rec. 709:1|Rec. 2020:2|Display P3:3|DCI-P3:4|V-Gamut:5|S-Gamut:6"]], 17 | int invert = 0 18 | [[ string widget = "checkBox", 19 | string label = "Inverse", 20 | int connectable = 0 ]], 21 | output color outColor = 0 22 | [[ string label = "Color" ]] 23 | ) 24 | { 25 | matrix aces_tm[NUM_MODES] = { 26 | // sRGB 27 | { 0.61313, 0.07012, 0.02058, 0, 28 | 0.33953, 0.91639, 0.10957, 0, 29 | 0.04741, 0.01345, 0.86985, 0, 30 | 0, 0, 0, 1 }, 31 | // Rec. 709 32 | { 0.61309, 0.07019, 0.02061, 0, 33 | 0.33952, 0.91635, 0.10956, 0, 34 | 0.04737, 0.01345, 0.86981, 0, 35 | 0, 0, 0, 1 }, 36 | // Rec. 2020 37 | { 0.97489, 0.00217, 0.00479, 0, 38 | 0.01959, 0.99553, 0.02453, 0, 39 | 0.05505, 0.00228, 0.97067, 0, 40 | 0, 0, 0, 1 }, 41 | // Display P3 D65 42 | { 0.73579, 0.04717, 0.00356, 0, 43 | 0.21216, 0.93804, 0.04114, 0, 44 | 0.05203, 0.014774, 0.95529, 0, 45 | 0, 0, 0, 1 }, 46 | // DCI-P3 D60 47 | { 0.69472, 0.04297, 0.00361, 0, 48 | 0.25626, 0.94617, 0.04301, 0, 49 | 0.04901, 0.01084, 0.95336, 0, 50 | 0, 0, 0, 1 }, 51 | // V-Gamut 52 | { 1.04866, -0.02939, -0.00331, 0, 53 | 0.00955, 1.14580, -0.00560, 0, 54 | -0.05821, -0.11641, 1.00892, 0, 55 | 0, 0, 0, 1 }, 56 | // S-Gamut 57 | { 1.09007, -0.03055, -0.00344, 0, 58 | -0.03523, 1.18025, -0.00255, 0, 59 | -0.05843, -0.14969, 1.00089, 0, 60 | 0, 0, 0, 1 } 61 | }; 62 | 63 | matrix aces_tm_inv[NUM_MODES] = { 64 | // invert ACES sRGB 65 | { 1.70487, -0.130101, -0.0239479, 0, 66 | -0.621708, 1.1407, -0.128979, 0, 67 | -0.0833087, -0.0105471, 1.15292, 0, 68 | 0, 0, 0, 1 }, 69 | // invert ACES Rec. 709 70 | { 1.70507, -0.130251, -0.023995, 0, 71 | -0.621798, 1.14081, -0.128961, 0, 72 | -0.0832433, -0.010547, 1.15298, 0, 73 | 0, 0, 0, 1 }, 74 | // invert ACES Rec. 2020 75 | { 1.02608, -0.00222513, -0.00500722, 0, 76 | -0.0187585, 1.00459, -0.0252946, 0, 77 | -0.0581487, -0.00223348, 1.03056, 0, 78 | 0, 0, 0, 1 }, 79 | // invert ACES Display P3 D65 80 | { 1.37922, -0.069321, -0.0021545, 0, 81 | -0.30886, 1.08230, -0.045459, 0, 82 | -0.070343, -0.012963, 1.04762, 0, 83 | 0, 0, 0, 1 }, 84 | // invert ACES DCI-P3 D60 85 | { 1.46412, -0.0664636, -0.00254562, 0, 86 | -0.393324, 1.07529, -0.0470216, 0, 87 | -0.070795, -0.00880969, 1.04959, 0, 88 | 0, 0, 0, 1 }, 89 | // invert ACES V-Gamut 90 | { 0.953553, 0.0247907, 0.00326596, 0, 91 | -0.00768311, 0.873045, 0.00482062, 0, 92 | 0.0541291, 0.102163, 0.991903, 0, 93 | 0, 0, 0, 1 }, 94 | // invert ACES S-Gamut 95 | { 0.918326, 0.0241784, 0.00321783, 0, 96 | 0.0275364, 0.848277, 0.00225582, 0, 97 | 0.0577284, 0.128277, 0.999636, 0, 98 | 0, 0, 0, 1 } 99 | }; 100 | 101 | if (mode >= 0 && mode < NUM_MODES) 102 | { 103 | float r = input[0], g = input[1], b = input[2]; 104 | outColor = transform(invert ? aces_tm_inv[mode] : aces_tm[mode], vector(r, g, b)); 105 | } 106 | else 107 | { 108 | outColor = 0; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /Blackbody.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/Blackbody.jpg -------------------------------------------------------------------------------- /Blackbody.osl: -------------------------------------------------------------------------------- 1 | // Blackbody Color Shader 2 | // Blackbody.osl, by Zap Andersson 3 | // Modified: 2021-03-17 by Saul Espinosa for Redshift 3D 4 | // Copyright 2019 Autodesk Inc, All rights reserved. This file is licensed under Apache 2.0 license 5 | // https://github.com/ADN-DevTech/3dsMax-OSL-Shaders/blob/master/LICENSE.txt 6 | 7 | shader Blackbody 8 | [[ string help = "Modulates a color between two Kelvin temperatures", 9 | string category = "Utility", 10 | string label = "Blackbody Emission" 11 | ]] 12 | ( 13 | float Input = 1.0 [[string page = "1 : Input", float min = 0, float max = 5]], 14 | float Min = 0.0 [[ float min = 0.0, float max = 10000.0, string page = "1 : Input" ]], 15 | float Max = 5000.0 [[ float min = 0.0, float max = 10000.0, string page = "1 : Input" ]], 16 | float Intensity = 1.0 [[ float min = 0, float max = 100, string page = "1 : Input" ]], 17 | int aces = 0 18 | [[ string widget = "checkBox", 19 | string page = "2 : Extra", 20 | string label = "ACES", 21 | int connectable = 0 ]], 22 | output color outColor = 0.0, 23 | ) 24 | { 25 | // ACES sRGB Transform 26 | matrix aces_tm = matrix( 27 | 0.6131, 0.0701, 0.0206, 0, 28 | 0.3395, 0.9164, 0.1096, 0, 29 | 0.0474, 0.0135, 0.8698, 0, 30 | 0, 0, 0, 1); 31 | 32 | color Col = blackbody(mix(Min, Max, Input)); 33 | color Out = Col * Intensity; 34 | float r = Out[0], g = Out[1], b = Out[2]; 35 | 36 | // ACES Output 37 | if (aces == 0) 38 | outColor = Out; 39 | else 40 | { 41 | outColor = transform(aces_tm, vector(r,g,b)); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Blur.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/Blur.jpg -------------------------------------------------------------------------------- /Blur.osl: -------------------------------------------------------------------------------- 1 | // Blur Shader - the output of this OSL shader can be attached to a Redshift Texture's Offset port to create a blur 2 | // Written by Darby Edelen based on work by Patrick Letourneau 3 | /* 4 | Copyright 2023 Edward Darby Edelen 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | */ 18 | 19 | vector powerFromUniform(vector vec_in, float power){ 20 | float u2_sin; 21 | float u2_cos; 22 | 23 | float r = pow(sqrt(vec_in.x), power); 24 | sincos(M_2PI * vec_in.y, u2_sin, u2_cos); 25 | return vector(r * u2_cos, r * u2_sin, 0); 26 | } 27 | 28 | vector exponentialFromUniform(vector vec_in){ 29 | float u2_sin; 30 | float u2_cos; 31 | 32 | float r = -log(vec_in.x); 33 | sincos(M_2PI * vec_in.y, u2_sin, u2_cos); 34 | return vector(r * u2_cos, r * u2_sin, 0); 35 | } 36 | 37 | vector lorentzianFromUniform(vector vec_in){ 38 | float u2_sin; 39 | float u2_cos; 40 | 41 | float r = tan(M_PI * (vec_in.x - 0.5)); 42 | sincos(M_2PI * vec_in.y, u2_sin, u2_cos); 43 | return vector(r * u2_cos, r * u2_sin, 0); 44 | } 45 | 46 | vector gaussianFromUniform(vector vec_in){ 47 | float u2_sin; 48 | float u2_cos; 49 | 50 | float r = sqrt(-2 * log(vec_in.x)); 51 | sincos(M_2PI * vec_in.y, u2_sin, u2_cos); 52 | return vector(r * u2_cos, r * u2_sin, 0); 53 | } 54 | 55 | vector samplePoints(vector vec_in, float power, int mode){ 56 | if(mode==0) return gaussianFromUniform(vec_in); 57 | if(mode==1) return powerFromUniform(vec_in, power); 58 | if(mode==2) return exponentialFromUniform(vec_in); 59 | if(mode==3) return lorentzianFromUniform(vec_in); 60 | } 61 | 62 | shader Blur( 63 | float strength = 10 [[string label="Strength", string page="Blur", string widget="number", int slider=1, float slidermin = 0, float slidermax=100, float min=0, float max=1000000000, float sensitivity = 0.1]], 64 | int space_select = 0 [[string label="Space", string page="Blur", string widget="mapper", string options="UV:0|Object:1|World:2"]], 65 | int kernel_select = 0 [[string label="Blur", string page="Blur", string widget="mapper", string options="Gaussian:0|Power:1|Exponential:2|Lorentzian:3"]], 66 | float power = 1 [[string label="Power", string page="Blur", int slider=1, float min = -10000.0, float max = 10000.0, float slidermin = 0.0, float slidermax = 10.0]], 67 | int dir_mode = 0 [[string label="Direction Mode", string page="Blur", 68 | string widget="mapper", string options="Anisotropy:0|Vector Blur:1", int connectable=0]], 69 | float aniso = 0 [[string label="Anisotropy", string page="Anisotropy", string widget = "number", int slider=1,float min=-1,float max=1]], 70 | float rotation = 0 [[string label="Rotation", string page="Anisotropy", string widget = "number", int slider=1, float slidermin=-180, float slidermax=180]], 71 | int direction_space = 0 [[string label="Space", string page="Vector Blur", 72 | string widget="mapper", string options="UV:0|World:1"]], 73 | vector direction = vector(0,1,0) [[string label="Direction Vector", string widget = "number", string page="Vector Blur"]], 74 | float center = 0 [[string label="Center", string page="Vector Blur", string widget = "number", int slider=1, float slidermin = -1, float slidermax = 1]], 75 | vector tangent_in = 0 [[string label="Tangent Input", string widget = "number", string page="Vector Blur"]], 76 | output vector UV_offset = 0, 77 | output vector object_offset = 0, 78 | output vector world_offset = 0 79 | ) 80 | { 81 | vector tangent = select(normalize(dPdu), tangent_in, isconnected(tangent_in)); 82 | vector bitangent = cross(tangent, N); 83 | matrix TBN = matrix(tangent.x, tangent.y, tangent.z, 0, 84 | bitangent.x, bitangent.y, bitangent.z, 0, 85 | Ng.x, Ng.y, Ng.z, 0, 86 | 0, 0, 0, 0); 87 | 88 | float obj_scale = space_select == 1 ? length(transform(matrix("object","world"), normalize(vector(1)))) : 1; 89 | vector a = vector(1 + aniso, 1 - aniso, 0); 90 | vector zrnd = samplePoints(noise("hash", vector(1) - P), power, kernel_select); 91 | vector off = samplePoints(noise("hash", P), power, kernel_select) + vector(0,0,zrnd.x); 92 | vector uv_blur_direct = select(direction * vector(1,1,0), 93 | vector(dot(direction, normalize(tangent)), dot(direction, normalize(bitangent)), 0), 94 | direction_space); 95 | 96 | vector world_blur_direct = select(transform(TBN, direction), direction, direction_space); 97 | vector world_blur_vec = select(transform(TBN, a * off), (off.x + center) * world_blur_direct, dir_mode); 98 | vector obj_blur_vec = transform(matrix("world", "object"), world_blur_vec); 99 | 100 | float uv_blur_length = length(uv_blur_direct); 101 | vector uv_space = select(vector(0.001), vector(0.1/length(dPdu), 0.1/length(dPdv), 0.), space_select); 102 | vector xyz_space = select(vector(0.01), vector(0.01), space_select); 103 | 104 | uv_blur_direct /= uv_blur_length; 105 | 106 | float uv_blur_rotate = select(radians(rotation), atan2(uv_blur_direct.y, uv_blur_direct.x), dir_mode); 107 | vector uv_blur_vec = select(off * a, (off.x + center) * vector(uv_blur_length,0,0), dir_mode); 108 | 109 | UV_offset = rotate(uv_blur_vec, uv_blur_rotate, vector(0,0,1)) * strength * uv_space * obj_scale; 110 | object_offset = select(rotate(obj_blur_vec, radians(rotation), Ng), obj_blur_vec, dir_mode) * strength * xyz_space; 111 | world_offset = select(rotate(world_blur_vec, radians(rotation), Ng), world_blur_vec, dir_mode) * strength * xyz_space; 112 | } -------------------------------------------------------------------------------- /Clamp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/Clamp.jpg -------------------------------------------------------------------------------- /ColorJitter.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/ColorJitter.jpg -------------------------------------------------------------------------------- /ColorJitter.osl: -------------------------------------------------------------------------------- 1 | // Index based Randomizer created Joseph Nickson 2 | // Recreation of Arnold's alJitter for redshift, built off Saul Espinosa's shader 3 | // This file is licensed under Apache 2.0 license 4 | // Modified 06.13.2022 to add page data by Saul Espinosa. 5 | 6 | shader rsInputJitter 7 | [[ string help = "Randomizes an inputs colour using UserData.", 8 | string label = "ColorJitter" ]] 9 | ( 10 | // Defube Inputs 11 | color Input = 0 [[string page = "Input"]], 12 | int Data = 0 [[string label = "UserData", string page = "Input"]], 13 | float ValMin = 0.0 [[string label = "Value Min", float min = -1, float max = 1, string page = "Value"]], 14 | float ValMax = 0.0 [[string label = "Value Max", float min = -1, float max = 1, string page = "Value"]], 15 | float HueMin = 0.0 [[string label = "Hue Min", float min = -1, float max = 1, string page = "Hue"]], 16 | float HueMax = 0.0 [[string label = "Hue Max", float min = -1, float max = 1, string page = "Hue"]], 17 | float SatMin = 0.0[[string label = "Saturation Min", float min = -1, float max = 1, string page = "Saturation"]], 18 | float SatMax = 0.0[[string label = "Saturation Max", float min = -1, float max = 1, string page = "Saturation"]], 19 | float TempMin = 0.0[[string label = "Temperature Min", float min = -.5, float max = .5, string page = "Temperature"]], 20 | float TempMax = 0.0[[string label = "Temperature Max", float min = -.5, float max = .5, string page = "Temperature"]], 21 | float TintMin = 0.0[[string label = "Tint Min", float min = -.5, float max = .5, string page = "Tint"]], 22 | float TintMax = 0.0[[string label = "Tint Max", float min = -.5, float max = .5, string page = "Tint"]], 23 | int Seed = 1[[int min = 0,int max = 100,string page = "Seed"]], 24 | 25 | /// Define Outputs 26 | output color ColorOut = Input, 27 | ) 28 | { 29 | // Output Values 30 | float ratio1 = noise("cell", vector(abs(Data), abs(Seed), 10)); 31 | float ratio2 = noise("cell", vector(abs(Data), abs(Seed), 11)); 32 | float ratio3 = noise("cell", vector(abs(Data), abs(Seed), 12)); 33 | float ratio4 = noise("cell", vector(abs(Data), abs(Seed), 13)); 34 | float ratio5 = noise("cell", vector(abs(Data), abs(Seed), 14)); 35 | float HueShift = mix(HueMin, HueMax, ratio1); 36 | float SatShift = mix(SatMin, SatMax, ratio2); 37 | float ValShift = mix(ValMin, ValMax, ratio3); 38 | float TempShift = mix(TempMin, TempMax, ratio4); 39 | float TintShift = mix(TintMin, TintMax, ratio5); 40 | 41 | color Out = transformc("rgb", "hsv", Input); 42 | Out[0] += HueShift; 43 | Out[1] += SatShift; 44 | Out[2] += ValShift; 45 | Out = transformc("hsv", "rgb", Out); 46 | 47 | // Temp & Tint Shifts 48 | Out[0] += TempShift; 49 | Out[1] += TintShift; 50 | Out[2] -= TempShift; 51 | ColorOut = Out; 52 | } -------------------------------------------------------------------------------- /ColorKeyer.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/ColorKeyer.jpg -------------------------------------------------------------------------------- /ColorKeyer.osl: -------------------------------------------------------------------------------- 1 | /* 2 | * colorKeyer.osl by Fabricio Chamon 3 | * Created for Redshift 4 | * Date Mar-27-2021 5 | * http://www.patreon.com/fchamon 6 | * This file is licensed under Apache 2.0 license 7 | */ 8 | 9 | float changeRange(float val, float from_min, float from_max, float to_min, float to_max){ 10 | return clamp(to_min + (val - from_min) * (to_max - to_min) / (from_max - from_min), 0, 1); 11 | } 12 | 13 | shader ColorKeyer 14 | [[ string help = "Keys Specific Colors", 15 | string label = "Color Keyer" ]] 16 | ( 17 | int Bypass = 0 18 | [[string widget = "checkBox"]], 19 | color Texture = color(0,0,0), 20 | color ColorToExtract = color(1,0,0), 21 | float HueTolerance = 0.01 22 | [[float min=0, float max=1]], 23 | float SatTolerance = 0.0 24 | [[float min=0, float max=1]], 25 | float ValTolerance = 1.0 26 | [[float min=0, float max=1]], 27 | int InvertMatte = 0 28 | [[string widget = "checkBox"]], 29 | float Contrast = 0 30 | [[float min=0, float max=1]], 31 | float Factor = 1 32 | [[float min=0, float max=10]], 33 | output color Matte = color(0,0,0) 34 | ) 35 | { 36 | float errorMargin = 0.0001; 37 | color TextureHSV = transformc("hsv", Texture); 38 | color ColorHSV = transformc("hsv", ColorToExtract); 39 | float hue = changeRange(abs(TextureHSV[0]-ColorHSV[0]), 0, HueTolerance+errorMargin, 1, 0); 40 | float sat = changeRange(abs(TextureHSV[1]-ColorHSV[1]), 0, SatTolerance+errorMargin, 1, 0); 41 | float val = changeRange(abs(TextureHSV[2]-ColorHSV[2]), 0, ValTolerance+errorMargin, 1, 0); 42 | float mask = hue*sat*val; 43 | 44 | float contrast_remapped = changeRange(Contrast, 0, 1, 0.5, 0); 45 | float contrast_min = 0.5-contrast_remapped; 46 | float contrast_max = 0.5+contrast_remapped; 47 | float contrast_mask = changeRange(mask, contrast_min, contrast_max, 0, 1); 48 | mask = contrast_mask * Factor; 49 | if (InvertMatte){mask = 1-mask;} 50 | 51 | Matte = (Bypass)?Texture:mask; 52 | } 53 | -------------------------------------------------------------------------------- /ColorShuffle.osl: -------------------------------------------------------------------------------- 1 | // Adrian Cruceru 2 | // Redshift Rendering Technologies 2020 3 | // channel shuffler 4 | // This file is licensed under Apache 2.0 license 5 | 6 | shader ColorShuffle 7 | [[ string help = "Shuffles Channels", 8 | string label = "Shuffle Channels", 9 | string category = "Color" ]] 10 | ( 11 | color inColor = color(0,0,0) 12 | [[ string label="Input" ]], 13 | int inR = 0 14 | [[ string label= "Red Channel", 15 | string widget = "mapper", 16 | string options = "Red:0|Green:1|Blue:2" ]], 17 | float redScale = 1 18 | [[ string label = "Red Scale", 19 | float min = 0, 20 | float max = 1]], 21 | int inG = 1 22 | [[ string label= "Green Channel", 23 | string widget = "mapper", 24 | string options = "Red:0|Green:1|Blue:2" ]], 25 | float greenScale = 1 26 | [[ string label = "Green Scale", 27 | float min = 0, 28 | float max = 1]], 29 | int inB = 2 30 | [[ string label= "Blue Channel", 31 | string widget = "mapper", 32 | string options = "Red:0|Green:1|Blue:2" ]], 33 | float blueScale = 1 34 | [[ string label = "Blue Scale", 35 | float min = 0, 36 | float max = 1]], 37 | output float outRed = 1 38 | [[ string label = "Red Output"]], 39 | output float outGreen = 1 40 | [[ string label = "Green Output"]], 41 | output float outBlue = 1 42 | [[ string label = "Blue Output"]], 43 | output color outColor = 1 44 | [[ string label = "Out Color"]] 45 | ) 46 | { 47 | outRed = inColor[inR]*redScale; 48 | outGreen = inColor[inG]*greenScale; 49 | outBlue = inColor[inB]*blueScale; 50 | outColor = color(outRed,outGreen,outBlue); 51 | } 52 | -------------------------------------------------------------------------------- /DegreesToRadians.osl: -------------------------------------------------------------------------------- 1 | // Convert degrees to Radians 2 | // DegToRad.osl, by Zap Andersson 3 | // Modified: 2019-11-26 4 | // Modified: 2021-03-04 by Saul Espinosa, Added Meta Data for Redshift 3D 5 | // Copyright 2019 Autodesk Inc, All rights reserved. This file is licensed under Apache 2.0 license 6 | // https://github.com/ADN-DevTech/3dsMax-OSL-Shaders/blob/master/LICENSE.txt 7 | 8 | shader DegToRad 9 | [[ string help = "Convert degrees to radians", 10 | string label= "Degrees-to-Radians", 11 | string category = "Math Float" ]] 12 | ( 13 | float Input = 0.0 [[ string label="Angle (degrees)", float min = 0, float max = 360 ]], 14 | output float Out = 0.0 [[ string label="Angle (radians)" ]], 15 | ) 16 | { 17 | Out = radians(Input); 18 | } 19 | -------------------------------------------------------------------------------- /Diffraction.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/Diffraction.jpg -------------------------------------------------------------------------------- /DiffractionGrating.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/DiffractionGrating.jpg -------------------------------------------------------------------------------- /DiffractionGrating.osl: -------------------------------------------------------------------------------- 1 | // Modified 3/03/22 by Saul Espinosa for Redshift3d 2 | // Psuedo Diffraction Grating Uber Shader using 3 shifted RGB Microfacets 3 | // This file is licensed under Apache 2.0 license 4 | 5 | shader DiffractionGrating 6 | [[ string help = "Psuedo Diffraction Grating Material", 7 | string label = "Diffraction Grating" ]] 8 | ( 9 | color diffuse_color = 0.025 10 | [[ 11 | string page = "Diffuse", 12 | string label = "Diffuse Color" 13 | ]], 14 | float diffuse_weight = 1.0 15 | [[ 16 | string label = "Diffuse Weight" , 17 | string page = "Diffuse", 18 | float min = 0, float max = 1 19 | ]], 20 | float diffuse_roughness = 0.0 21 | [[ 22 | string label = "Diffuse Roughness" , 23 | string page = "Diffuse", 24 | float min = 0, float max = 1 25 | ]], 26 | 27 | // Refraction Layer 28 | color refract_color = color(1.0) 29 | [[ 30 | string label = "Refraction Color", 31 | string page = "Refraction", 32 | ]], 33 | float refract_weight = 0.0 34 | [[ 35 | string label = "Refraction Weight" , 36 | string page = "Refraction", 37 | float min = 0, float max = 1 38 | ]], 39 | float refract_roughness = 0.0 40 | [[ 41 | string label = "Refraction Roughness" , 42 | string page = "Refraction", 43 | float min = 0, float max = 1 44 | ]], 45 | float refract_IOR = 1.5 46 | [[ 47 | string label = "Refraction IOR" , 48 | string page = "Refraction", 49 | float min = 0, float max = 25 50 | ]], 51 | 52 | // Diffraction 53 | float diffraction_weight = 1.0 54 | [[ 55 | string label = "Diffraction Weight" , 56 | string page = "Diffraction", 57 | float min = 0, float max = 1 58 | ]], 59 | float roughness = 0.5 60 | [[ 61 | string label = "Roughness" , 62 | string page = "Diffraction", 63 | float min = 0, float max = 1 64 | ]], 65 | float separation = 0.9 66 | [[ 67 | string label = "Separation" , 68 | string page = "Diffraction", 69 | float min = 0, float max = 1 70 | ]], 71 | float anisotropy = 0.45 72 | [[ 73 | string label = "Anisotropy" , 74 | string page = "Diffraction", 75 | float min = -1, float max = 1 76 | ]], 77 | float rotation = 0.3 78 | [[ 79 | string label = "Rotation" , 80 | string page = "Diffraction", 81 | float min = 0, float max = 1 82 | ]], 83 | float IOR = 1.6 84 | [[ 85 | string page = "Diffraction", 86 | string label = "Diffraction IOR", 87 | float min = 1, 88 | float max = 5 89 | ]], 90 | 91 | 92 | 93 | // Coating Layer 94 | color coat_color = color(1.0) 95 | [[ 96 | string label = "Coat Color", 97 | string page = "Coat", 98 | ]], 99 | float coat_weight = 0.0 100 | [[ 101 | string label = "Coat Weight" , 102 | string page = "Coat", 103 | float min = 0, float max = 1 104 | ]], 105 | float coat_roughness = 0.0 106 | [[ 107 | string label = "Coat Roughness" , 108 | string page = "Coat", 109 | float min = 0, float max = 1 110 | ]], 111 | float coat_IOR = 1.52 112 | [[ 113 | string label = "Coat IOR" , 114 | string page = "Coat", 115 | float min = 0, float max = 25 116 | ]], 117 | normal Tangent = normalize(dPdu), 118 | // [[ 119 | // string widget = "null" 120 | // ]], 121 | 122 | 123 | output closure color outColor = 0.0 124 | ) 125 | 126 | { 127 | vector Normal = normalize(N); 128 | vector T = Tangent; 129 | float a = (anisotropy + 1.0) / 2.0; 130 | float delta = mix(roughness * separation, 0.001, abs(anisotropy)); 131 | 132 | vector rot = rotate(T, (rotation * M_2PI), Normal); 133 | 134 | float x_alpha = mix(0.001, roughness * 2, a); 135 | float y_alpha = mix(roughness * 2, 0.001, a); 136 | 137 | closure color diffuseBRDF = diffuse_color * diffuse_weight * oren_nayar(Normal, diffuse_roughness); 138 | closure color refractionBSDF = refract_color * refract_weight * microfacet("ggx", Normal, refract_roughness, refract_IOR, 1); 139 | closure color microfacetR = microfacet("ggx", Normal, delta - rot, x_alpha, y_alpha, IOR, 0) * color(1,0,0); 140 | closure color microfacetG = microfacet("ggx", Normal, rot, x_alpha, y_alpha, IOR, 0) * color(0,1,0); 141 | closure color microfacetB = microfacet("ggx", Normal, delta + rot, x_alpha, y_alpha, IOR, 0) * color(0,0,1); 142 | closure color coat_layer = coat_color * coat_weight * microfacet("ggx", Normal, coat_roughness, coat_IOR, 0); 143 | outColor = diffuseBRDF + refractionBSDF + (diffraction_weight * (microfacetR + microfacetG + microfacetB)) + coat_layer; 144 | 145 | } 146 | -------------------------------------------------------------------------------- /Dots.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/Dots.jpg -------------------------------------------------------------------------------- /Dots.osl: -------------------------------------------------------------------------------- 1 | // Random circles (or spheres, really) with outputs 2 | // for bump, random factor, etc. Can be made to make 3 | // very cool random candy cover, paint flakes... 4 | // 5 | // Dots.osl, by Zap Andersson 6 | // Modified: 2019-11-10 7 | // Copyright 2019 Autodesk Inc, All rights reserved. This file is licensed under Apache 2.0 license 8 | // https://github.com/ADN-DevTech/3dsMax-OSL-Shaders/blob/master/LICENSE.txt 9 | // Modified: 2020-1-15 by Saul Espinosa for Redshift 3D 10 | 11 | shader Candy 12 | [[ string help="Random circles with random colors and a tunable bump output. For random dots or candy sprinkles.", 13 | string category = "Textures", 14 | string label = "Random Dots" 15 | ]] 16 | ( 17 | // For convenience, default to object space 18 | // You can connect any other coordinate space 19 | // as input anyway... 20 | point UVW = transform("object", P) [[ string help = "The position input, defaulting to object space. Connect an UVW shader for other alternatives." ]], 21 | float Scale = 0.01 [[float min = 0, float max = 25]], 22 | float Radius = 0.5 [[ float min=0.0, float max=2.0 ]], 23 | int RandomOverlap = 0 [[ string widget = "checkBox" ]], 24 | float BumpAmount = 1.0 [[float min = 0, float max = 5]], 25 | float BumpShape = 1.0 [[float min = 0, float max = 25]], 26 | 27 | output color Col = 0, 28 | output float Fac = 0, 29 | output float Bump = 0, 30 | output float Dist = 0, 31 | output float Rnd = 0 32 | ) 33 | { 34 | point pnt = UVW / Scale; 35 | float pri = -1; 36 | 37 | // Standard method for randomization: 38 | // Go through a 3x3x3 grid that we offset 39 | for (float x = -1; x <= 1; x++) 40 | { 41 | for (float y = -1; y <= 1; y++) 42 | { 43 | for(float z = -1; z <= 1; z++) 44 | { 45 | // Point that sources all our randomization 46 | // We run these through cell noises to get 47 | // random values 48 | // MAXX-44914 fix: Adds the 0.001 offset and floor() 49 | point rndpoint = floor(pnt) + point(x, y, z) + 0.001; 50 | // Compute a center 51 | point dotcenter = rndpoint + noise("cell", rndpoint, 1); 52 | float dist = distance(dotcenter, pnt); 53 | // Randomize the priority, all they all look "stacked" in 54 | // the same direction if they overlap 55 | float priority = noise("cell", rndpoint, 2); 56 | 57 | // If within the radius, and priority is higher 58 | if (dist < Radius && priority > pri) 59 | { 60 | pri = priority; 61 | 62 | Col = noise("cell", rndpoint, 3); 63 | Dist = dist / Radius; 64 | Bump = pow(sin((1.0 - Dist) * 1.58), BumpShape) * BumpAmount; 65 | Fac = 1.0; 66 | Rnd = priority; 67 | 68 | // If we exit early, shader is more efficient, 69 | // but any "overlap" becomes completely sorted 70 | // in an X/Y/Z order and looks fake. 71 | if (!RandomOverlap) 72 | return; 73 | } 74 | } 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /EnvironmentGradient.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/EnvironmentGradient.jpg -------------------------------------------------------------------------------- /EnvironmentGradient.osl: -------------------------------------------------------------------------------- 1 | // environment_gradient - Various ways to drive an environment gradient ramp 2 | // Michael Abrahams, 3/23/2021 3 | // MIT license 4 | 5 | shader env_gradient 6 | [[ string help = "Spherical Gradient for Redshift Environment Mapping", 7 | string label = "Environment Gradient" ]] 8 | ( 9 | int gradient_type = 0 10 | [[ string label= "Gradient type", 11 | string widget = "mapper", 12 | string options = "World (Linear):0|World (Polar Angle):1|Camera Space:2" ]], 13 | int out_dimension = 0 14 | [[ string label= "Output coordinate", 15 | string widget = "mapper", 16 | string options = "V:0|U:1" ]], 17 | int zUpAxis = 0 [[ string widget = "checkBox", string label = "Z is Up" ]], 18 | output float out = 0.0, 19 | output vector outUV = 0.0 20 | ) 21 | { 22 | float outU; 23 | float outV; 24 | float incline; 25 | float azimuth; 26 | 27 | vector shadingI = I; 28 | if (zUpAxis) { 29 | shadingI = vector(I.x,I.z,I.y); 30 | } 31 | 32 | // World (linear/cylindrical) 33 | if (gradient_type == 0) { 34 | outUV.y = shadingI.y / 2.0 + 0.5; 35 | azimuth = atan(shadingI.z / shadingI.x); 36 | outUV.x = azimuth / M_PI + 0.5; 37 | } 38 | 39 | // World (Polar angle) 40 | if (gradient_type == 1) { 41 | incline = acos(shadingI.y); 42 | outUV.y = 1.0 - incline / M_PI; 43 | azimuth = atan(shadingI.z / shadingI.x); 44 | outUV.x = azimuth / M_PI + 0.5; 45 | } 46 | 47 | // Screen space 48 | if (gradient_type == 2) { 49 | vector shadingP = transform("NDC", P); 50 | outUV.x = shadingP.x; 51 | outUV.y = shadingP.y; 52 | } 53 | 54 | if (out_dimension == 0) { 55 | out = outUV.y; 56 | } 57 | else { 58 | out = outUV.x; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /FakeCaustics.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/FakeCaustics.jpg -------------------------------------------------------------------------------- /FakeCaustics.osl: -------------------------------------------------------------------------------- 1 | // Found this on GLSL sandbox. I really liked it, changed a few things and made it tileable. 2 | // by David Hoskins. 3 | // Water turbulence effect by joltz0r 2013-07-04, improved 2013-07-07 4 | // Updated 1/4/2020 by Saul Espinosa for Redshift 3D 5 | // This file is licensed under Apache 2.0 license 6 | 7 | 8 | // Redefine below to see the tiling... 9 | //#define SHOW_TILING 10 | 11 | #define TAU 6.28318530718 12 | 13 | 14 | shader FakeCaustics 15 | [[ string help = "generates a psuedo caustic like noise pattern", 16 | string label = "Fake Caustics" ]] 17 | ( 18 | 19 | point Po = P, 20 | float Time = 0 21 | [[ 22 | float min = 0, float max = 100 23 | ]], 24 | int iterations = 5 25 | [[ 26 | int min = 0, int max = 20 27 | ]], 28 | output color Out = 0, 29 | 30 | ) 31 | { 32 | float tt = Time * .5+23.0; 33 | // uv should be the 0-1 uv of texture... 34 | vector uv = Po; 35 | 36 | vector p = mod(uv*TAU*2.0, TAU)-250.0; 37 | 38 | // vector p = mod(uv*TAU, TAU)-250.0; 39 | 40 | vector i = vector(p); 41 | float c = 1.0; 42 | float inten = .005; 43 | 44 | for (int n = 0; n < iterations; n++) 45 | { 46 | float t = tt * (1.0 - (3.5 / float(n+1))); 47 | i = p + vector(cos(t - i[0]) + sin(t + i[1]), sin(t - i[1]) + cos(t + i[0]),0); 48 | c += 1.0/length(vector(p[0] / (sin(i[0]+t)/inten),p[1] / (cos(i[1]+t)/inten),0)); 49 | } 50 | c /= float(iterations); 51 | c = 1.17-pow(c, 1.4); 52 | vector colour = vector(pow(abs(c), 8.0)); 53 | colour = clamp(colour + vector(0.0, 0.35, 0.5), 0.0, 1.0); 54 | 55 | /* 56 | #ifdef SHOW_TILING 57 | // Flash tile borders... 58 | vec2 pixel = 2.0 / iResolution.xy; 59 | uv *= 2.0; 60 | 61 | float f = floor(mod(iTime*.5, 2.0)); // Flash value. 62 | vec2 first = step(pixel, uv) * f; // Rule out first screen pixels and flash. 63 | uv = step(fract(uv), pixel); // Add one line of pixels per tile. 64 | colour = mix(colour, vec3(1.0, 1.0, 0.0), (uv.x + uv.y) * first.x * first.y); // Yellow line 65 | 66 | */ 67 | Out = vector(colour); 68 | Out = pow(Out,2.2); 69 | } 70 | -------------------------------------------------------------------------------- /Flakes.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/Flakes.jpg -------------------------------------------------------------------------------- /Flakes.osl: -------------------------------------------------------------------------------- 1 | // Make glint reflections, ice, snow, and car shaders for example. 2 | // Flakes.osl, by Mads Drøschler 3 | // Modified: 2021-02-31 4 | // License MIT Copyright Mads Drøschler 5 | // https://github.com/gkmotu/OSL-Shaders 6 | // Modified: 2022-06-28 by Saul Espinosa for Redshift 3D. Added Page Metadata + Mapper Menu for Coordinate Space 7 | 8 | vector TileHash ( output vector x, int tileSize ) { 9 | 10 | x = mod(x,tileSize); 11 | return noise("hash",x); 12 | } 13 | 14 | vector ID(vector x, int seed,int Tiling,int tileSize) 15 | { 16 | vector n = floor(x); 17 | vector f = x-floor(x); 18 | vector m = vector(8); 19 | vector o; 20 | for( int k=-1; k<=1; k++ ){ 21 | for( int j=-1; j<=1; j++ ){ 22 | for( int i=-1; i<=1; i++ ){ 23 | 24 | vector g = vector( float(i), float(j),float(k) ); 25 | Tiling? o = TileHash(n+g,tileSize) : o = noise("hash",n+g,seed); 26 | vector r = g - f + (0.5+0.5*sin(M_2PI*o)); 27 | float s = dot(r, r); 28 | s Rehash ? outColor = outColor : outColor = Base_Normal; 159 | 160 | // outAlpha 161 | outColor[0] > 0.5 or outColor[0] < 0.5 ? outAlpha = 1 : outAlpha = 0; 162 | 163 | // Randomize 164 | outColor = mix(Base_Normal,outColor,randomize); 165 | //outColor = vector(1, 1, 0); 166 | 167 | //outColor = outColor*2-1; 168 | } 169 | -------------------------------------------------------------------------------- /HDRIEnviron.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/HDRIEnviron.jpg -------------------------------------------------------------------------------- /HDRIEnviron.osl: -------------------------------------------------------------------------------- 1 | // HDRI Loader 2 | // HDRIEnviron2.osl, by Zap Andersson 3 | // Modified: 2020-01-27 4 | // Modified: 2021-03-17 by Saul Espinosa for Redshift 3d 5 | // Copyright 2020 Autodesk Inc, All rights reserved. This file is licensed under Apache 2.0 license 6 | // https://github.com/ADN-DevTech/3dsMax-OSL-Shaders/blob/master/LICENSE.txt 7 | 8 | shader HDRIenv 9 | [[ string help = 10 | "

HDRI Environment

Environment shader with exposure " 11 | "adjustments,
ground projection mode, and separation between
" 12 | "Background and Environment", 13 | string version = "1.0.0", 14 | string category = "Environment", 15 | string label = "HDRI Environment" ]] 16 | ( 17 | string HDRI="" 18 | [[ string widget="filename", 19 | string label ="HDRI", 20 | string page = "1 : Texture" 21 | ]], 22 | int Flip = 0 23 | [[ string widget = "checkBox", 24 | int connectable = 0, 25 | string page = "1 : Texture"]], 26 | int zup = 0 27 | [[ string widget = "checkBox", 28 | string label = "Z-Up", 29 | string page = "1 : Texture", 30 | int connectable = 0 ]], 31 | float Rotation = 0 32 | [[ float min = -360.0, float max = 360.0, 33 | int connectable=0, float step = 1.0, 34 | string page = "2 : Position" 35 | ]], 36 | float Height = 0 37 | [[ float min = -1.0, float max = 1.0, 38 | int connectable=0, float step = 0.001, 39 | string page = "2 : Position" 40 | ]], 41 | float TiltX = 0 + 0 42 | [[ float min = -360.0, float max = 360.0, 43 | int connectable=0, float step = 0.1, 44 | string page = "2 : Position" 45 | ]], 46 | float TiltY = 0 47 | [[ float min = -360.0, float max = 360.0, 48 | int connectable=0, float step = 0.1, 49 | string page = "2 : Position" 50 | ]], 51 | float Exposure = 0 52 | [[ float min = -10, float max = 10, 53 | string page = "3 : Adjustments", 54 | int connectable=0 55 | ]], 56 | float Gamma = 1 57 | [[ float min = -3, float max = 3, 58 | string page = "3 : Adjustments", 59 | int connectable=0 60 | ]], 61 | color Tint = 1.0 62 | [[ 63 | string page = "3 : Adjustments", 64 | int connectable=0 65 | ]], 66 | color AdditionalLight = 0.0 67 | [[ string label = "Additional Light", 68 | string page = "4 : Extra Light", 69 | ]], 70 | float AdditionalLightMul = 1.0 71 | [[ string label = "Additional Light Multiplier", int connectable=0, 72 | string page = "4 : Extra Light", 73 | ]], 74 | int GroundProjection=0 75 | [[ string widget="checkBox", 76 | string page = "5 : Ground Projection", 77 | int connectable=0 78 | ]], 79 | point GroundCenter=0 80 | [[ int connectable=0 , 81 | string page = "5 : Ground Projection" 82 | ]], 83 | float GroundRadius=1.5 // Default is in meters 84 | [[ int connectable=0, int worldunits=1, 85 | string page = "5 : Ground Projection" 86 | ]], 87 | int UseBackground= 0 88 | [[ string widget="checkBox", 89 | string page = "6 : Back-Plate", 90 | string label = "Use Background", 91 | int connectable = 0 92 | ]], 93 | color Background = 0.0 94 | [[string page = "6 : Back-Plate"]], 95 | float BackgroundMultiplier = 1.0 96 | [[ string label = "Background Multiplier", 97 | string page = "6 : Back-Plate", 98 | int connectable=0 ]], 99 | int Blur = 0 100 | [[ string widget = "checkBox", 101 | string page = "7 : Blur", 102 | int connectable = 0 ]], 103 | float BlurAmount = 1.0 104 | [[ float min = 0.0, float max = 25.0, int connectable=0, 105 | string page = "7 : Blur" 106 | ]], 107 | int BlurSamples = 16 108 | [[ int min = 1, int max = 256, int connectable=0, 109 | string page = "7 : Blur", 110 | ]], 111 | int aces = 0 112 | [[ string widget = "checkBox", 113 | string page = "8 : Extra", 114 | string label = "ACES", 115 | int connectable = 0 ]], 116 | int Clamp = 1 117 | [[ string widget = "checkBox", 118 | string page = "8 : Extra", 119 | int connectable = 0 ]], 120 | float ClampStops = 10.0 121 | [[ float min = -10.0, float max = 30.0, float step = 0.1, int connectable=0, 122 | string page = "8 : Extra", 123 | ]], 124 | 125 | // Output 126 | output color Out = 0 127 | ) 128 | { 129 | 130 | matrix rs_transform = 131 | { 1, 0, 0, 0, 132 | 0, 1*zup,1-zup, 0, 133 | 0, 1-zup, 1*zup, 0, 134 | 0, 0, 0, 1 }; 135 | 136 | if (UseBackground && raytype("camera")) 137 | { 138 | Out = Background * BackgroundMultiplier; 139 | return; 140 | } 141 | 142 | float U = 0.0, V = 0.0; 143 | 144 | // Change Direction World space Y up to Z up 145 | vector Direction = transform(rs_transform, I); 146 | 147 | vector OrgDir = Direction; 148 | point CP = transform("camera", point(0,0,0)); 149 | 150 | // Change position world space Y up to Z up 151 | point Position = transform(rs_transform, P); 152 | 153 | // Workaround for Arnolds odd P behaviour in environments.... 154 | if (Position == 0.0) 155 | Position = transform("camera", "world", point(0)); 156 | 157 | int doBlur = Blur && BlurAmount > 0.0?raytype("camera"):0; 158 | 159 | int samples = doBlur?BlurSamples:1; 160 | 161 | for (int i = 0; i < samples; i++) 162 | { 163 | if (doBlur) 164 | Direction = OrgDir + (noise("hash", I, i) - 0.5) * BlurAmount / 100.0; 165 | 166 | // Ground Projection mode is on, and direction is pointing down? 167 | if (GroundProjection == 1 && Direction[2] < 0.0) 168 | { 169 | // Compute intersection with virtual ground plane 170 | float t = (GroundCenter[2] - Position[2])/Direction[2]; 171 | point GP = Position + Direction * t; 172 | 173 | // Assume we are doing the ground 174 | int doGround = 1; 175 | 176 | if (doGround) 177 | { 178 | // Compute virtual projection point rays are projecting from 179 | point TP = GroundCenter + vector(0, 0, GroundRadius); 180 | // Use direction from that point to the groundplane as the 181 | // new virtual direction 182 | Direction = normalize(GP-TP); 183 | 184 | // Smoothen out the joint a bit.... 185 | // Thanks to Vlado for suggestion! 186 | if (Direction[2] > -0.1) 187 | { 188 | float fac = 1.0 - Direction[2] * -10.0; 189 | fac *= fac; 190 | 191 | Direction = mix(Direction, OrgDir, fac); 192 | } 193 | } 194 | } 195 | 196 | if (TiltX != 0.0) 197 | Direction = rotate(Direction, radians(TiltX), vector(0.0), vector(1,0,0)); 198 | if (TiltY != 0.0) 199 | Direction = rotate(Direction, radians(TiltY), vector(0.0), vector(0,1,0)); 200 | 201 | // Compute texture UV's in a spherical environment map... 202 | U = (Rotation / 360.0) + atan2(Direction[0],Direction[1]) / (M_PI * 2.0); 203 | V = 0.5 + (asin(Direction[2]) / M_PI); 204 | 205 | // Adjust the height by sin(z) 206 | V -= Height * sqrt((1.0 - (Direction[2]*Direction[2]))); 207 | 208 | // Look up the texture 209 | Out += texture(HDRI, Flip?-U:U, 1.0-V, "wrap", "periodic") * Tint; 210 | } 211 | 212 | Out /= samples; 213 | 214 | if (Clamp) 215 | Out = clamp(Out, 0.0, pow(2.0, ClampStops)); 216 | else 217 | { 218 | // Just avoid negative numbers 219 | if (Out[0] < 0.0) Out[0] = 0.0; 220 | if (Out[1] < 0.0) Out[1] = 0.0; 221 | if (Out[2] < 0.0) Out[2] = 0.0; 222 | } 223 | // Gamma 2.2 for sRGB approx) 224 | float gammapower = Gamma; 225 | 226 | // Apply overall Exposure and Contrast 227 | Out = pow(Out, gammapower) * pow(2.0, Exposure) + (AdditionalLight * AdditionalLightMul); 228 | 229 | // ACES sRGB Transform 230 | matrix aces_tm = matrix( 231 | 0.6131, 0.0701, 0.0206, 0, 232 | 0.3395, 0.9164, 0.1096, 0, 233 | 0.0474, 0.0135, 0.8698, 0, 234 | 0, 0, 0, 1); 235 | 236 | float r = Out[0], g = Out[1], b = Out[2]; 237 | 238 | // Add Additional Light or ACES Output 239 | if (aces == 0) 240 | Out = pow(Out, gammapower) * pow(2.0, Exposure) + (AdditionalLight * AdditionalLightMul); 241 | else 242 | { 243 | Out = transform(aces_tm, vector(r,g,b)); 244 | } 245 | } 246 | -------------------------------------------------------------------------------- /HSVsplitter.osl: -------------------------------------------------------------------------------- 1 | /* 2 | * original script from - 3 | * http://www.openshading.com/osl/example-shaders/ 4 | * New/3-clause BSD" license 5 | */ 6 | 7 | shader HSVSplitter 8 | [[ string help = "Splits the RGB input into HSV Outputs", 9 | string label = "HSV Splitter" ]] 10 | ( 11 | color Color = 0.8, 12 | output float H = 0.0, 13 | output float S = 0.0, 14 | output float V = 0.0) 15 | { 16 | color HSV = transformc("hsv", Color); 17 | H = HSV[0]; 18 | S = HSV[1]; 19 | V = HSV[2]; 20 | } 21 | -------------------------------------------------------------------------------- /HagelslagNoise.osl: -------------------------------------------------------------------------------- 1 | /* 2 | * Hagelslag.osl by Michel J. Anders (c)2012 3 | * from https://github.com/sambler/osl-shaders 4 | * 5 | * license: cc-by-sa 6 | * 7 | * original script from - 8 | * http://blenderthings.blogspot.com.au/2012/12/a-hagelslag-sprinkles-osl-shader-for.html 9 | * 10 | * 11 | * In blender's homeland hagelslag is the name used for sprinkles. 12 | * Enjoy sprinkling blender's hagelslag on all your materials 13 | * to make them as delicious as can be ;) 14 | * Modified 1/4/2020 by Saul Espinosa for Redshift 3D 15 | */ 16 | 17 | 18 | // replacement for the missing distance(a, b, q) function 19 | float minimum_distance(point v, point w, point p) { 20 | vector s = w - v; 21 | float l2 = dot(s,s); 22 | if (l2 == 0.0) return distance(p, v); 23 | float t = dot(p - v, s) / l2; 24 | if (t < 0.0) return distance(p, v); 25 | else if (t > 1.0) return distance(p, w); 26 | vector projection = v + t * (s); 27 | return distance(p, projection); 28 | } 29 | 30 | shader MAHagelslag 31 | [[ string help = "Hagelslag Noise Pattern", 32 | string label = "Hagelslag Noise" ]] 33 | ( 34 | vector Vector = P, 35 | float Scale = 1.0 36 | [[ 37 | float min = 0, float max = 25 38 | ]], 39 | int Density = 1 40 | [[ 41 | float min = 0, float max = 25 42 | ]], 43 | int Seed = 0 44 | [[ 45 | int min = 0, int max = 100 46 | ]], 47 | float Radius = 0.05 48 | [[ 49 | float min = 0, float max = 1 50 | ]], 51 | float Size = 1.0 52 | [[ 53 | float min = 0, float max = 25 54 | ]], 55 | 56 | output float Fac = 0 ) 57 | { 58 | point p = Vector * Scale; 59 | point f = floor(p); 60 | 61 | int xx,yy,np; 62 | vector one = 1; 63 | 64 | for( xx=-1; xx<=1; xx++){ 65 | for( yy=-1; yy<=1; yy++){ 66 | point ff = f + vector(xx,yy,0); 67 | 68 | vector dp = vector(5,7,11); 69 | 70 | for( np=0; np < Density; np++){ 71 | vector pd1 = 2*cellnoise(ff+dp)-one; 72 | vector pd2 = 2*cellnoise(ff+dp+Seed)-one; 73 | 74 | dp *= 17; 75 | 76 | point p1 = ff + pd1; 77 | point p2 = ff + pd2; 78 | 79 | p2 = (p2 - p1)*Size+p1; 80 | 81 | // reduce to 2D 82 | p1[2]=0; 83 | p2[2]=0; 84 | p [2]=0; 85 | 86 | float r = minimum_distance(p1,p2,p); 87 | if ( r < Radius ) { 88 | Fac = 1 - r/Radius; 89 | } 90 | } 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /Halftone.osl: -------------------------------------------------------------------------------- 1 | // A simple Halftone shader 2 | // Halftone.osl, by Zap Andersson 3 | // Modified: 2019-11-25 4 | // Modified: 202-1-11 by Saul Espinosa for Redshift 3D 5 | // Copyright 2019 Autodesk Inc, All rights reserved. This file is licensed under Apache 2.0 license 6 | // https://github.com/ADN-DevTech/3dsMax-OSL-Shaders/blob/master/LICENSE.txt 7 | 8 | shader HalftoneDots 9 | [[ string help="Halftone Dots (by default i screen space)
" 10 | "Works well together with toon shaders.", 11 | string category = "Textures", 12 | string label = "Halftone Dots" ]] 13 | ( 14 | // Inputs 15 | vector UVW = transform("raster", P) 16 | [[ string help = "The input coordinate. If not connected, uses screen pixel space" ]], 17 | vector Scale = vector(8.0,8.0,8.0) 18 | [[ string help = "This size of the dots. In the default screen space mapping, this is in pixels." ]], 19 | float Angle = 45.0 20 | [[ string help = "Angle of the Halftoning" , 21 | float min = -180, float max = 180 22 | ]], 23 | color InputValue = 0.25 24 | [[ string help = "The input value defining the size of the dots to yield the right halftone density. " ]], 25 | int U_Input = 0 26 | [[ string help = "If checked, adds the U coordinate as the input value. This works " 27 | "well when connected in a 'base_tonemap' input of an Arnold Toon shader.", 28 | string widget = "checkBox" ]], 29 | float Fuzz = 0.1 [[ float min = 0.0, float max = 2.0 ]], 30 | color BlackDots = 0.0 31 | [[ string help = "The color of the dots" ]], 32 | color WhiteDots = 1.0 33 | [[ string help = "The color of the space between the dots" ]], 34 | // Outputs 35 | output color Out = 0.0 36 | ) 37 | { 38 | vector pos = rotate(UVW, radians(Angle), 0.0, vector(0.0,0.0,1.0)); 39 | pos = vector(pos[0] / Scale[0], pos[1] / Scale[1], 0.0); 40 | if (Scale[0] == 0.0) 41 | pos[0] = 0.5; 42 | if (Scale[1] == 0.0) 43 | pos[1] = 0.5; 44 | 45 | color inputV = InputValue; 46 | 47 | if (U_Input) 48 | inputV += u; 49 | 50 | pos = pos - floor(pos); 51 | 52 | float dist = 1.0 - (distance(vector(0.5,0.5,0.0), pos) / (sqrt(2.0) / 2.5)); 53 | color factor = smoothstep(-Fuzz, 0.0, inputV - sqrt(max(0,dist))); 54 | 55 | Out = mix(BlackDots, WhiteDots, factor); 56 | } 57 | -------------------------------------------------------------------------------- /HeightWeights.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/HeightWeights.jpg -------------------------------------------------------------------------------- /HeightWeights.osl: -------------------------------------------------------------------------------- 1 | // Height Blend Weights Shader - Blend height maps to generate weights for texture/material blending 2 | /* 3 | Copyright (c) 2023 Edward Darby Edelen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | */ 23 | 24 | #include 25 | 26 | vector4 soft_threshold(vector4 a, vector4 threshold, vector4 delta) 27 | { 28 | vector4 soft = clamp(delta * 0.5, 0.0001, 10000); 29 | return clamp((a - threshold + soft) / soft, 0, 1); 30 | } 31 | 32 | shader HeightBlendWeights( 33 | int height_mode = 0 34 | [[string label="Height From", string widget="mapper", string options = "ACEScg Luminance:0|Rec.709 Luminance:1|Average:2|Red:3|Green:4|Blue:5"]], 35 | float base_height = 0.0 36 | [[string label="Base Height", string widget="number", string page="Base Height", float min=0, float max=1]], 37 | float base_height_offset = 0.0 38 | [[string label="Base Height Offset", string widget="number", string page="Base Height", float slidermin=-1, float slidermax=1]], 39 | float base_height_scale = 1.0 40 | [[string label="Base Height Scale", string widget="number", string page="Base Height", float slidermin=0, float slidermax=2]], 41 | float height_01 = 0.0 42 | [[string label="Height 01", string widget="number", string page="Height Layer 1", float slidermin=0, float slidermax=1]], 43 | float height_soft_01 = 0.0 44 | [[string label="Height 01 Soft", string widget="number", string page="Height Layer 1", float slidermin=0, float slidermax=1]], 45 | float height_offset_01 = 0.0 46 | [[string label="Height 01 Offset", string widget="number", string page="Height Layer 1", float slidermin=-1, float slidermax=1]], 47 | float height_scale_01 = 1.0 48 | [[string label="Height 01 Scale", string widget="number", string page="Height Layer 1", float slidermin=0, float slidermax=2]], 49 | float height_02 = 0.0 50 | [[string label="Height 02", string widget="number", string page="Height Layer 2", float slidermin=0, float slidermax=1]], 51 | float height_soft_02 = 0.0 52 | [[string label="Height 02 Soft", string widget="number", string page="Height Layer 2", float slidermin=0, float slidermax=1]], 53 | float height_offset_02 = 0.0 54 | [[string label="Height 02 Offset", string widget="number", string page="Height Layer 2", float slidermin=-1, float slidermax=1]], 55 | float height_scale_02 = 1.0 56 | [[string label="Height 02 Scale", string widget="number", string page="Height Layer 2", float slidermin=0, float slidermax=2]], 57 | float height_03 = 0.0 58 | [[string label="Height 03", string widget="number", string page="Height Layer 3", float slidermin=0, float slidermax=1]], 59 | float height_soft_03 = 0.0 60 | [[string label="Height 03 Soft", string widget="number", string page="Height Layer 3", float slidermin=0, float slidermax=1]], 61 | float height_offset_03 = 0.0 62 | [[string label="Height 03 Offset", string widget="number", string page="Height Layer 3", float slidermin=-1, float slidermax=1]], 63 | float height_scale_03 = 1.0 64 | [[string label="Height 03 Scale", string widget="number", string page="Height Layer 3", float slidermin=0, float slidermax=2]], 65 | output float Height_01_Blend=0, 66 | output float Height_02_Blend=0, 67 | output float Height_03_Blend=0 68 | ) 69 | { 70 | // luminance_weights - acescg, rec.709, average, red, green, blue 71 | vector luminance_weights[6] = { vector(0.3439664498, 0.7281660966, -0.0721325464), vector(0.21264936, 0.71516907, 0.07218152), vector(1.0/3.0), vector(1,0,0), vector(0,1,0), vector(0,0,1) }; 72 | 73 | float total_base_height = ((dot(base_height, luminance_weights[height_mode]) - 0.5) * base_height_scale + 0.5) + base_height_offset; 74 | float total_height_01 = ((dot(height_01, luminance_weights[height_mode]) - 0.5) * height_scale_01 + 0.5) + height_offset_01; 75 | float total_height_02 = ((dot(height_02, luminance_weights[height_mode]) - 0.5) * height_scale_02 + 0.5) + height_offset_02; 76 | float total_height_03 = ((dot(height_03, luminance_weights[height_mode]) - 0.5) * height_scale_03 + 0.5) + height_offset_03; 77 | 78 | vector4 total_heights = vector4(total_base_height, total_height_01, total_height_02, total_height_03); 79 | vector4 deltas = vector4(0.0, height_soft_01, height_soft_02, height_soft_03); 80 | total_heights -= 0.5 * deltas; 81 | float max_height = max(total_base_height, max(total_height_01, max(total_height_02, total_height_03))); 82 | vector4 thresholds = vector4(max_height,max_height,max_height,max_height) - 0.5 * deltas; 83 | vector4 total_weights = soft_threshold(total_heights, thresholds, deltas); 84 | 85 | Height_01_Blend = total_weights.y; 86 | Height_02_Blend = total_weights.z; 87 | Height_03_Blend = total_weights.w; 88 | } -------------------------------------------------------------------------------- /HexTileCoordinates.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/HexTileCoordinates.jpg -------------------------------------------------------------------------------- /HexTileCoordinates.osl: -------------------------------------------------------------------------------- 1 | /* 2 | Hex Tile Coordinates Shader - hexagonal tile coordinates with randomization to breakup repeating textures 3 | 4 | This shader is based on "Practical Real-Time Hex-Tiling" by Morten S. Mikkelsen (2022) 5 | Paper: https://jcgt.org/published/0011/03/05/paper-lowres.pdf 6 | See also: https://github.com/mmikk/hextile-demo 7 | */ 8 | 9 | /* 10 | Copyright (c) 2023 Edward Darby Edelen 11 | Copyright (c) 2022 mmikk 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a copy 14 | of this software and associated documentation files (the "Software"), to deal 15 | in the Software without restriction, including without limitation the rights 16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | copies of the Software, and to permit persons to whom the Software is 18 | furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included in all 21 | copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 | SOFTWARE. 30 | */ 31 | 32 | #define M_SQRT3 1.7320508075688772935274463415059 33 | 34 | point center_uv(point vertex) 35 | { 36 | return point(0.25 * vertex.x, 0.125 * vertex.x + 0.25 * vertex.y, 0); 37 | } 38 | 39 | vector hex_weights(vector blend_weights, point vertex1, point vertex2, point vertex3) 40 | { 41 | float va = mod(vertex1.x - vertex1.y, 3.0); 42 | va = select(va, mod(va, 2.0) + 1, (va > 0)&&(vertex3.x < vertex1.x)); 43 | float vh = mod(va + 1, 3.0); 44 | float vl = mod(va - 1, 3.0); 45 | 46 | float vb = select(vh, vl, vertex1.x < vertex3.x); 47 | float vc = select(vl, vh, vertex1.x < vertex3.x); 48 | 49 | vector selector = vector(va, vb, vc); 50 | 51 | vector result; 52 | 53 | result.x = blend_weights[(int)round(selector.x)]; 54 | result.y = blend_weights[(int)round(selector.y)]; 55 | result.z = blend_weights[(int)round(selector.z)]; 56 | 57 | return result; 58 | } 59 | 60 | void generate_triangle_data(output float w1, output float w2, output float w3, 61 | output point v1, output point v2, output point v3, 62 | point uv) 63 | { 64 | point skewed_uv = point(4 * uv.x, 4 * uv.y - 2 * uv.x, 0); 65 | 66 | point base_coord = floor(skewed_uv); 67 | point bary = mod(skewed_uv, point(1.0)); 68 | bary.z = 1.0 - bary.x - bary.y; 69 | 70 | float flip = step(0.0, -bary.z); 71 | float sign = (2 * flip) - 1; 72 | 73 | w1 = -bary.z * sign; 74 | w2 = flip - bary.y * sign; 75 | w3 = flip - bary.x * sign; 76 | 77 | v1 = base_coord + point(flip, flip, 0 ); 78 | v2 = base_coord + point(flip, 1 - flip, 0); 79 | v3 = base_coord + point(1 - flip, flip, 0); 80 | } 81 | 82 | 83 | float soft_threshold(float a, float threshold, float delta) 84 | { 85 | return clamp((a - threshold + delta) / (clamp(delta, 0.0001, 10000)), 0, 1); 86 | } 87 | 88 | float soft_twin_threshold(float a, float thresh_a, float thresh_b, float delta) 89 | { 90 | return min(soft_threshold(a, thresh_a, delta), soft_threshold(a, thresh_b, delta)); 91 | } 92 | 93 | vector hex_heightblend(vector heights, float delta) 94 | { 95 | vector blend = vector( 96 | soft_twin_threshold(heights.x, heights.y, heights.z, delta), 97 | soft_twin_threshold(heights.y, heights.x, heights.z, delta), 98 | soft_twin_threshold(heights.z, heights.x, heights.y, delta) 99 | ); 100 | 101 | return blend; 102 | } 103 | 104 | vector hex_blend_weights(vector heights, float delta) 105 | { 106 | vector blend = hex_heightblend(heights + vector(1), delta); 107 | return blend / dot(blend, vector(1)); 108 | } 109 | 110 | 111 | shader HexTileCoordinates( 112 | float grid_tiles = 1 113 | [[string label="Grid Repetitions", float min=.25, float max=1000, float slidermin=0.25, float slidermax=10]], 114 | float blend = 0.2 115 | [[string label="Blend Amount", string page="Blending", float min=0, float max=1, float slidermin=0, float slidermax=1]], 116 | float gamma = 2 117 | [[string label="Blend Curve", string widget="number", string page="Blending", float min=0.5, float max=50, float slidermin=0.5, float slidermax=10]], 118 | float height_weight = 1 119 | [[string label="Height Weight", string page="Height", float min = 0, float max = 2, float slidermin=0, float slidermax=1]], 120 | string height_texture = "" 121 | [[string label="Height Texture", string widget="filename", string page="Height"]], 122 | float noise_weight = 0 123 | [[string label="Noise Weight", string widget="number", string page="Noise", float min=0, float max=2, float slidermin=0, float slidermax=1]], 124 | float noise_uniform_scale = 1 125 | [[string label="Noise Uniform Scale", string widget="number", string page="Noise", float min=0.0001, float slidermin=0.1, float slidermax=10]], 126 | vector noise_scale = 1 127 | [[string label="Noise Scale", string page="Noise", float sensitivity=0.1]], 128 | vector noise_offset = 0 129 | [[string label="Noise Offset", string widget="number", string page="Noise"]], 130 | int noise_seed = 12345 131 | [[string label="Noise Random Seed", string widget="number", string page="Noise"]], 132 | int seed = 12345 133 | [[string label="Random Seed", string page="Random"]], 134 | point translation=1 135 | [[string label="Random Translate", string page="Random", float sensitivity=0.01]], 136 | float rotation=180 137 | [[string label="Random Rotate", string page="Random", float slidermin=0, float slidermax=360]], 138 | int rotation_steps=0 139 | [[string label="Rotation Steps", string page="Random", string widget="number", int min=0, int max=360, int slidermin=0, int slidermax=6]], 140 | float scaling=0.2 141 | [[string label="Random Scale", string page="Random", float min = 0, float max = 2, float slidermin=0, float slidermax=1]], 142 | point triplanar_uv = 0 143 | [[string label="Triplanar UV", string page = "Coordinates"]], 144 | vector tangent_in = 0 145 | [[string label="Tangent In", string page = "Coordinates"]],, 146 | output point UV_Offset=0, 147 | output point HexTile_UV=0, 148 | output vector Cell_Weight=0, 149 | output matrix Tangent_Space=matrix(1) 150 | ) 151 | { 152 | vector T = select(normalize(dPdu), tangent_in, isconnected(tangent_in)); 153 | float tiling = grid_tiles / M_SQRT3; 154 | point uv = isconnected(triplanar_uv) ? triplanar_uv : point(u, v, 0); 155 | 156 | float rads = radians(rotation); 157 | vector w = vector(0,0,1); 158 | float w1, w2, w3; 159 | point v1, v2, v3; 160 | 161 | generate_triangle_data(w1, w2, w3, v1, v2, v3, tiling * uv); 162 | 163 | point center1 = center_uv(v1) / tiling; 164 | point center2 = center_uv(v2) / tiling; 165 | point center3 = center_uv(v3) / tiling; 166 | 167 | point rnd1 = (2 * noise("hash", v1 + seed) - 1); 168 | point rnd2 = (2 * noise("hash", v2 + seed) - 1); 169 | point rnd3 = (2 * noise("hash", v3 + seed) - 1); 170 | float rnd_selector = noise("hash", P); 171 | 172 | float scale1 = mix(1, 0.5 * rnd1.z + 1, scaling); 173 | float scale2 = mix(1, 0.5 * rnd2.z + 1, scaling); 174 | float scale3 = mix(1, 0.5 * rnd3.z + 1, scaling); 175 | 176 | float rot1 = select(rnd1.x * rads, (round(rnd1.x * rotation_steps) * rads) / rotation_steps, rotation_steps); 177 | float rot2 = select(rnd2.x * rads, (round(rnd2.x * rotation_steps) * rads) / rotation_steps, rotation_steps); 178 | float rot3 = select(rnd3.x * rads, (round(rnd3.x * rotation_steps) * rads) / rotation_steps, rotation_steps); 179 | 180 | point uv1 = tiling * (scale1 * M_SQRT3 * rotate(uv - center1, rot1, w)) + translation * point(rnd1.y, rnd1.z, 0); 181 | point uv2 = tiling * (scale2 * M_SQRT3 * rotate(uv - center2, rot2, w)) + translation * point(rnd2.y, rnd2.z, 0); 182 | point uv3 = tiling * (scale3 * M_SQRT3 * rotate(uv - center3, rot3, w)) + translation * point(rnd3.y, rnd3.z, 0); 183 | 184 | vector T1 = rotate(T, rot1, Ng); 185 | vector T2 = rotate(T, rot2, Ng); 186 | vector T3 = rotate(T, rot3, Ng); 187 | 188 | float height1 = (texture(height_texture, uv1.x, uv1.y, "missingcolor", color(0.5)) * 2 - 1); 189 | float height2 = (texture(height_texture, uv2.x, uv2.y, "missingcolor", color(0.5)) * 2 - 1); 190 | float height3 = (texture(height_texture, uv3.x, uv3.y, "missingcolor", color(0.5)) * 2 - 1); 191 | 192 | float noise1 = noise("perlin", 10 * (uv1 + rnd1) / (noise_uniform_scale * noise_scale) + noise_offset, noise_seed); 193 | float noise2 = noise("perlin", 10 * (uv2 + rnd2) / (noise_uniform_scale * noise_scale) + noise_offset, noise_seed); 194 | float noise3 = noise("perlin", 10 * (uv3 + rnd3) / (noise_uniform_scale * noise_scale) + noise_offset, noise_seed); 195 | 196 | vector weights = vector(w1, w2, w3); 197 | 198 | vector noise_height = clamp(0.5 * (1 - vector(noise1, noise2, noise3)), 0 , 1); 199 | 200 | vector height = vector(height1, height2, height3); 201 | 202 | weights += height_weight * height + mix(0, noise_height, noise_weight); 203 | 204 | vector blend_weights = hex_blend_weights(weights, blend * M_SQRT1_2); 205 | 206 | blend_weights = pow(blend_weights, gamma); 207 | blend_weights /= dot(blend_weights, vector(1)); 208 | 209 | point tex_uv = select(uv3, select(uv1, uv2, rnd_selector < blend_weights.y), rnd_selector < (blend_weights.x + blend_weights.y)); 210 | 211 | vector tT = select(T3, select(T1, T2, rnd_selector < blend_weights.y), rnd_selector < (blend_weights.x + blend_weights.y)); 212 | vector tB = cross(tT, Ng); 213 | 214 | UV_Offset = (tex_uv + point(0.5,0.5,0)) - point(u,v,0); 215 | HexTile_UV = tex_uv + point(0.5,0.5,0); 216 | Cell_Weight = hex_weights(blend_weights, v1, v2, v3); 217 | Tangent_Space = matrix( 218 | tT.x, tT.y, tT.z, 0, 219 | tB.x, tB.y, tB.z, 0, 220 | Ng.x, Ng.y, Ng.z, 0, 221 | 0, 0, 0, 1 222 | ); 223 | } -------------------------------------------------------------------------------- /Hexagon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/Hexagon.jpg -------------------------------------------------------------------------------- /Hexagon.osl: -------------------------------------------------------------------------------- 1 | /* 2 | * Hexagon.osl by Michel J. Anders (c)2012 3 | * from https://github.com/sambler/osl-shaders 4 | * 5 | * license: cc-by-sa 6 | * 7 | * original script from - 8 | * http://blenderthings.blogspot.co.uk/2012/11/a-hexagon-osl-shader.html 9 | * Modified 1/4/2020 by Saul Espinosa for Redshift 3D 10 | */ 11 | 12 | 13 | #define A 0.86602540378443864676372317075294 // sqrt(3)/2 14 | #define A2 (2*A) 15 | #define A4 (4*A) 16 | #define SY (1/A) 17 | 18 | shader MAhexagon 19 | [[ string help = "Generates an RGB Hexagon Pattern", 20 | string label = "Hexagons" ]] 21 | ( 22 | vector Vector = 0, 23 | color Diffuse_Color1 = color(0.2, 0.8, 0.2), 24 | color Diffuse_Color2 = color(0.8, 0.2, 0.2), 25 | color Diffuse_Color3 = color(0.2, 0.2, 0.8), 26 | output color Color = 0, 27 | output int Index = 1, 28 | output float Distance = 0) 29 | { 30 | // calculate the color 31 | 32 | color colors[3] = {Diffuse_Color1, 33 | Diffuse_Color2, 34 | Diffuse_Color3}; 35 | 36 | // we warp the grid so that two adjacent equilateral triangles 37 | // are mapped to two triangles that fit in a square 38 | float syc = Vector[1] * SY; 39 | float sxc = Vector[0] + 0.5 * syc; 40 | 41 | int ind[18] = {1,1,3,3,3,1, 2,2,2,3,3,3, 1,2,2,2,1,1}; 42 | 43 | int iy = int(mod(syc,3.0)); 44 | int ix = int(mod(sxc,3.0)); 45 | ix = iy * 6 + ix * 2 + ( mod(sxc,1.0) > mod(syc,1.0) ); 46 | Index = ind[ix]; 47 | Color = colors[Index-1]; 48 | 49 | // calculate the distance to the center of the hexagon 50 | 51 | float sx = mod(Vector[0],3); 52 | float sy = mod(Vector[1]+0.75,A4); 53 | 54 | // map everthing to a single quadrant 55 | if ( sx > 1.5 ) sx = 3 - sx; 56 | if ( sy > A2 ) sy = A4 - sy; 57 | 58 | // the distance were interested in is the distance to 59 | // the *closest* center point 60 | float d1 = distance(vector(sx,sy,0),vector(1.5,A2,0)); 61 | float d2 = distance(vector(sx,sy,0),vector(0,A,0)); 62 | float d6 = distance(vector(sx,sy,0),vector(1.5,0,0)); 63 | 64 | Distance = min(min(d1,d2), d6); 65 | 66 | } 67 | -------------------------------------------------------------------------------- /JawbreakerNoise.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/JawbreakerNoise.jpg -------------------------------------------------------------------------------- /JawbreakerNoise.osl: -------------------------------------------------------------------------------- 1 | // Created by Jerome Stephan (@jstephan828) 22/08/2021 for Redshift3D 2 | // Modified by Saul Espinosa 09/23/2021 to add OCIO Color Management & Page Meta Data 3 | // Using colors based on https://github.com/redshift3d/RedshiftOSLShaders/blob/main/NoiseColor.osl 4 | // This file is licensed under Apache 2.0 license 5 | 6 | #include 7 | #define vec2 vector2 8 | #define vec3 vector 9 | #include 10 | #define vec4 vector4 11 | 12 | float fract(float x){return mod(x, 1.0);} 13 | vec3 fract(point x){return vec3(mod(x.x, 1.0),mod(x.y, 1.0),mod(x.z, 1.0)) ;} 14 | 15 | point matrix_mul(point matx, point maty, point matz, point px){ 16 | point result; 17 | result.x = matx[0]*px.x+matx[1]*px.y+matx[2]*px.z; 18 | result.y = maty[0]*px.x+maty[1]*px.y+maty[2]*px.z; 19 | result.z = matz[0]*px.x+matz[1]*px.y+matz[2]*px.z; 20 | return result; 21 | } 22 | 23 | float def_turbulence(point x){ 24 | point px = x; 25 | point mx = point( 1.6, 1.2, -1.2); 26 | point my = point( -1.6, 1.5, 1.2); 27 | point mz = point( 1.6, -1.2, 1.8); 28 | float f = 0.0; 29 | f = 0.5000*noise( px ); px = matrix_mul(mx, my, mz, px); 30 | f += 0.2500*noise( px ); px = matrix_mul(mx, my, mz, px); 31 | f += 0.1250*noise( px ); px = matrix_mul(mx, my, mz, px); 32 | f += 0.0625*noise( px ); px = matrix_mul(mx, my, mz, px); 33 | f += 0.0313*noise( px ); px = matrix_mul(mx, my, mz, px); 34 | 35 | //f = 0.5 + 0.5*f; 36 | return f; 37 | } 38 | 39 | shader JawbreakerNoise 40 | [[ string help = "Jawbreaker-like color layer Noise", 41 | string label = "Jawbreaker Noise" ]] 42 | ( 43 | point Po = P 44 | [[ string label = "Position", string page = "Position" ]], 45 | 46 | point Pcent = vec3(0) 47 | [[string label = "Center", string page = "Position"]], 48 | 49 | float Scale = 1.0 50 | [[ string label = "Overall Scale", float min = 0.0, float max = 20.0, string page = "Noise Color"]], 51 | 52 | float Time = 1.0 53 | [[ string label = "Color Time", float min = 0.0, float max = 1000.0, string page = "Noise Color"]], 54 | 55 | float ColIntens = 0.5 56 | [[ string label = "Color Brightness", float min = 0.0, float max = 10.0, string page = "Noise Color"]], 57 | 58 | float ColComplex = 1.0 59 | [[ string label = "Color Complexity", float min = 0.0, float max = 5.0, string page = "Noise Color"]], 60 | 61 | float NoiseTime = 0.0 62 | [[ string label = "Noise Time", float min = 0.0, float max = 10.0, string page = "Noise Shape"]], 63 | 64 | float NoiseAmount = 8.0 65 | [[ string label = "Noise Amount", float min = 0.0, float max = 80.0, string page = "Noise Shape"]], 66 | 67 | float Layers = 15.0 68 | [[ string label = "Layers", float min = 1.0, float max = 150.0, string page = "Noise Shape"]], 69 | 70 | string toSpace = "" 71 | [[ string label = "Output Color Space", string widget = "colorspace", string page = "OCIO Colorspace"]], 72 | 73 | output color outColor = 0 74 | ) 75 | 76 | { 77 | float Pi = 10.; 78 | int complexity = 10; // More points of color. 79 | float fluid_speed = 600.0; // Drives speed, higher number will make it slower. 80 | float color_intensity = ColIntens; 81 | point puv = Po*Scale; 82 | point p = Po*Scale; 83 | p.x += (def_turbulence(p*0.1+NoiseTime)-0.5)*NoiseAmount; 84 | p.y += (def_turbulence(p*0.1+NoiseTime+0.5)-0.5)*NoiseAmount; 85 | p.z += (def_turbulence(p*0.1+NoiseTime+1.5)-0.5)*NoiseAmount; 86 | float layers_adj = Layers/10.0; 87 | float steps = floor(layers_adj*distance(Pcent, p)); 88 | steps = mix(steps, layers_adj*distance(Pcent, p), 0.2); 89 | 90 | p = vec3(steps); 91 | p+=noise(puv*0.005); 92 | for(int i=1;i -GW && grout[0] < GW && 130 | grout[1] > -GH && grout[1] < GH) 131 | 132 | Out_Color = tile_color; 133 | 134 | else 135 | Out_Color = Grout_Color; 136 | } -------------------------------------------------------------------------------- /ReflectanceToIOR.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/ReflectanceToIOR.jpg -------------------------------------------------------------------------------- /ReflectanceToIOR.osl: -------------------------------------------------------------------------------- 1 | /* 2 | Reflectance to IOR by Saul Espinosa for Redshift 3D 3 | OSL node to allow for the older rsMaterial Reflectivity style Input 4 | for the RS Standard Surface. Outputs a Specular Reflection Color and IOR output. 5 | This file is licensed under Apache 2.0 license 6 | Last Modified : 5/16/2022 7 | */ 8 | shader ReflectanceToIOR 9 | [[ string help = "Convert Reflectivity Value to Reflection Color and IOR", 10 | string label = "Reflectance To IOR" 11 | ]] 12 | ( 13 | color Reflectivity = 0.04 14 | [[ string page = "Input", 15 | float min = 0, 16 | float max = 1 17 | ]], 18 | 19 | output color ReflectionColor = 0.0, 20 | output float IOR = 0.0, 21 | ) 22 | { 23 | 24 | // Reflection Color = RGB to Hue Saturation and 1.0 Value 25 | color convert = transformc ("hsv", Reflectivity ); 26 | float r = convert[0], g = convert[1], b = convert[2]; 27 | color conversion = transformc ("hsv", "rgb", vector(r,g,1.0)); 28 | ReflectionColor = conversion; 29 | 30 | // IOR=(SQRT(Reflectance Value)+1)/(1-SQRT(Reflectance Value)) 31 | 32 | IOR = (sqrt(b)+1) / (1-sqrt(b)); 33 | } 34 | -------------------------------------------------------------------------------- /ShaderSwitch32.osl: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // Shader Switch (32-way) 3 | // 4 | // An extension on Redshift's built-in 10-way RS Shader Switch. Instead of 5 | // chaining shaders to achieve more slots, you can use this OSL shader. It 6 | // utilizes a decision tree to perform the switch with 5 comparisons. One 7 | // additional comparison is performed only for the first and last input. 8 | // 9 | // Author: Geoff Bolton 10 | // Created: 2023-04-24 11 | // 12 | // This work is licensed under a Creative Commons Attribution 3.0 Unported 13 | // License: https://creativecommons.org/licenses/by/3.0/deed.en_US 14 | //////////////////////////////////////////////////////////////////////////// 15 | #define INPUT_ID(id) shader ## id 16 | #define INPUT_DEF(id) color INPUT_ID(id) = 1 [[ string label="Shader "#id ]] 17 | 18 | #define CHOOSE2(id0, id1) \ 19 | outColor = (index < id1) \ 20 | ? INPUT_ID(id0) \ 21 | : INPUT_ID(id1) 22 | 23 | #define CHOOSE(id0, id1, id2, id3) \ 24 | if (index < id2) { \ 25 | CHOOSE2(id0, id1); \ 26 | } else { \ 27 | CHOOSE2(id2, id3); \ 28 | } 29 | 30 | // Left-bounded at id0 31 | #define CHOOSE_L(id0, id1, id2, id3) \ 32 | if (index < id2) { \ 33 | outColor = (index < id1) \ 34 | ? (index == id0 \ 35 | ? INPUT_ID(id0) \ 36 | : default_shader) \ 37 | : INPUT_ID(id1); \ 38 | } else { \ 39 | CHOOSE2(id2, id3); \ 40 | } 41 | 42 | // Right-bounded at id3 43 | #define CHOOSE_R(id0, id1, id2, id3) \ 44 | if (index < id2) { \ 45 | CHOOSE2(id0, id1); \ 46 | } else { \ 47 | outColor = (index < id3) \ 48 | ? INPUT_ID(id2) \ 49 | : (index == id3 \ 50 | ? INPUT_ID(id3) \ 51 | : default_shader); \ 52 | } 53 | //////////////////////////////////////////////////////////////////////////// 54 | 55 | shader ShaderSwitch32( 56 | int selector = 0 [[ string label="Shader Selector" ]], 57 | int selector_offset = 0 [[ string label="Offset", int connectable=0 ]], 58 | INPUT_DEF(0), INPUT_DEF(1), INPUT_DEF(2), INPUT_DEF(3), 59 | INPUT_DEF(4), INPUT_DEF(5), INPUT_DEF(6), INPUT_DEF(7), 60 | INPUT_DEF(8), INPUT_DEF(9), INPUT_DEF(10), INPUT_DEF(11), 61 | INPUT_DEF(12), INPUT_DEF(13), INPUT_DEF(14), INPUT_DEF(15), 62 | INPUT_DEF(16), INPUT_DEF(17), INPUT_DEF(18), INPUT_DEF(19), 63 | INPUT_DEF(20), INPUT_DEF(21), INPUT_DEF(22), INPUT_DEF(23), 64 | INPUT_DEF(24), INPUT_DEF(25), INPUT_DEF(26), INPUT_DEF(27), 65 | INPUT_DEF(28), INPUT_DEF(29), INPUT_DEF(30), INPUT_DEF(31), 66 | color default_shader = 1 [[ string label="Default Shader" ]], 67 | output color outColor = 0, 68 | output int outIndex = 0) 69 | { 70 | int index = selector - selector_offset; 71 | outIndex = index; 72 | 73 | if (index < 16) { 74 | if (index < 8) { 75 | if (index < 4) { 76 | CHOOSE_L(0, 1, 2, 3); 77 | } else { 78 | CHOOSE(4, 5, 6, 7); 79 | } 80 | } else { 81 | if (index < 12) { 82 | CHOOSE(8, 9, 10, 11); 83 | } else { 84 | CHOOSE(12, 13, 14, 15); 85 | } 86 | } 87 | } else { 88 | if (index < 24) { 89 | if (index < 20) { 90 | CHOOSE(16, 17, 18, 19); 91 | } else { 92 | CHOOSE(20, 21, 22, 23); 93 | } 94 | } else { 95 | if (index < 28) { 96 | CHOOSE(24, 25, 26, 27); 97 | } else { 98 | CHOOSE_R(28, 29, 30, 31); 99 | } 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Shapes.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/Shapes.jpg -------------------------------------------------------------------------------- /Shapes.osl: -------------------------------------------------------------------------------- 1 | // Compiled after a small session between Martin Breidt & Mads Drøschler Based on a WebGL function. 2 | // 14.10.2018 3 | // License: https://creativecommons.org/licenses/by-nc-sa/3.0/ 4 | // Modified : 03.22.2021 by Saul Espinosa For Redshift 3d 5 | 6 | 7 | float lPolygon(vector p, int n) 8 | { 9 | float a = atan2(p[0], p[1]) + M_PI; 10 | float r = 2*M_PI/float(n); 11 | return cos(floor(0.5 + a/r) * r - a) * length(p); 12 | } 13 | 14 | shader Shapes 15 | [[ string help = "Generates Procedural Shapes", 16 | string label = "Shapes" ]] 17 | ( 18 | point Po = point(u, v, 0), 19 | int nSides = 3 20 | [[ string help = "Number of polygon sides", 21 | string label = "UVW", 22 | int max = 25, 23 | int min = 3 24 | ]], 25 | float Softness = 0.09 26 | [[ 27 | float min = 0.0, 28 | float max = 2.0 29 | ]], 30 | float Radius = 0.4 31 | [[ 32 | float min = 0.001, 33 | float max = 1 34 | ]], 35 | float Stretch_U = 1.0 36 | [[ 37 | float min = 0, 38 | float max = 2 39 | ]], 40 | float Stretch_V = 1.0 41 | [[ 42 | float min = 0, 43 | float max = 2 44 | ]], 45 | float Star_Effect = 1.0 46 | [[ string help = "A value > 0 will cause the shape to become more star-like along the W coordinate", 47 | float min = 0, 48 | float max = 2 49 | ]], 50 | vector Offset = 0.0 51 | [[ string help = "Translation of pattern. Use a Z value > 0 to move towards a star-like pattern" ]], 52 | 53 | color Color_Shape = color(1), 54 | color Color_Background = color(0), 55 | 56 | output color Out = 0, 57 | 58 | ) 59 | { 60 | vector p = abs(Po-floor(Po)); 61 | p = p - vector(0.5, 0.5, 0); 62 | 63 | p = (p - Offset) * vector(Stretch_U, Stretch_V, Star_Effect )/ Radius; 64 | float d = lPolygon(p, int(mod(nSides-3, 60.)+3.)); 65 | Out = color(smoothstep(Radius, Radius+Softness, d)); 66 | Out = (1-Out)*Color_Shape+(Out*Color_Background); // added colors for shape and background //Mads 67 | 68 | } 69 | -------------------------------------------------------------------------------- /SimpleTiles.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/SimpleTiles.jpg -------------------------------------------------------------------------------- /SimpleTiles.osl: -------------------------------------------------------------------------------- 1 | // Tiles, Bricks and other Patterns 2 | // SimpleTiles.osl, by Zap Andersson 3 | // Modified: 2019-11-25 4 | // Copyright 2019 Autodesk Inc, All rights reserved. This file is licensed under Apache 2.0 license 5 | // https://github.com/ADN-DevTech/3dsMax-OSL-Shaders/blob/master/LICENSE.txt 6 | 7 | 8 | #define PARAM lookup,fluvw+point(xx,0,0),GapWidth*0.05,Tiling,Edge*0.1,Bump,HitIdx 9 | 10 | // Do a single rectangle 11 | int doRect(float loX, float hiX, float loY, float hiY, int Tile, int InIdx, float Radius, 12 | // Layout of these match the PARAM macro above 13 | point uvw, point baseuvw, float GapWidth, vector Tiling, float Edge, output float Bump, output int Index 14 | ) 15 | { 16 | float x = uvw[0] / Tiling[0], y = uvw[1] / Tiling[1]; 17 | 18 | float lox = loX / Tiling[0]; 19 | float hix = hiX / Tiling[0]; 20 | float loy = loY / Tiling[1]; 21 | float hiy = hiY / Tiling[1]; 22 | 23 | 24 | // First quick rejection when being outside the rectangle 25 | if (x < lox + GapWidth || 26 | x > hix - GapWidth || 27 | y < loy + GapWidth || 28 | y > hiy - GapWidth) 29 | return 0; 30 | 31 | // Turn coordinate into circle 32 | float gwr = GapWidth + Radius; 33 | 34 | float lx = x - (lox + gwr); 35 | float ly = y - (loy + gwr); 36 | float hx = x - (hix - gwr); 37 | float hy = y - (hiy - gwr); 38 | 39 | // Now compute special-circle-coordinate 40 | // which is really the edges around the rectangle 41 | vector dp = vector(lx<0?lx:(hx>0?hx:0.0), ly<0?ly:(hy>0.0?hy:0.0), 0.0); 42 | float d = length(dp); 43 | // Outside the radius - we missed 44 | if (d > Radius) return 0; 45 | 46 | // Inside? Compute the bump as a Smoothstep 47 | if (Radius > Edge) 48 | Bump = 1.0 - smoothstep(Radius-Edge, Radius+Edge, d); 49 | else 50 | { 51 | // If there is an Edge but the radius is smaller, we 52 | // need to compute the bump differently... 53 | float lx = x - (lox + GapWidth); 54 | float ly = y - (loy + GapWidth); 55 | float hx = x - (hix - GapWidth); 56 | float hy = y - (hiy - GapWidth); 57 | Bump = smoothstep(-Edge, Edge, lx); 58 | Bump *= smoothstep(-Edge, Edge, -hx); 59 | Bump *= smoothstep(-Edge, Edge, ly); 60 | Bump *= smoothstep(-Edge, Edge, -hy); 61 | } 62 | 63 | // Set index to inIdx 64 | Index = InIdx; 65 | // Return the tile ID we are in 66 | return Tile; 67 | } 68 | 69 | shader SimpleTiles 70 | [[ string help = "Simple Tiles
" 71 | "Allows various kinds of Tiling. The Tiling Offset
" 72 | "modifies the base parameter of the tiling layout,
" 73 | "and can generate different effects. ", 74 | string category = "Textures", 75 | string label = "Simple Tiles" ]] 76 | ( 77 | // Inputs 78 | point UVW = point(u,v,0), 79 | 80 | float Scale = 1.0 81 | [[ float min=0.000001, float max=1000000.0 ]], 82 | int TileMode = 0 83 | [[ string widget = "mapper", 84 | string label = "Tiling Mode", 85 | string options = 86 | "Checker Tiles:1" 87 | "|Running/Stack Bond:0" 88 | "|English Bond:2" 89 | "|Fine Running/Stack Bond:3" 90 | "|Twist Box:4", 91 | string help="Choose the kind of tile pattern to use. " 92 | "The 'TilingOffset' parameter adjusts the " 93 | "appearance of the tiles." 94 | ]], 95 | float U_Count = 2.0 96 | [[ string label = "Tiles in U", 97 | float min=0.000001, float max=1000000.0 ]], 98 | float V_Count = 2.0 99 | [[ string label = "Tiles in V", 100 | float min=0.000001, float max=1000000.0 ]], 101 | float TilingOffset = 0.5 102 | [[ string label = "Tiling Offset", 103 | float min=0.0, float max=1.0, 104 | string help = "An adjustable parameter which changes " 105 | "the appearance of the tiling. Does different things " 106 | "for different Tiling Modes" ]], 107 | float GapWidth = 0.1 108 | [[ string label = "Gap Width", 109 | string help = "The width of the gap between tiles", 110 | float min=0.0, float max=10.0 ]], 111 | float Radius = 0.2 112 | [[ string label = "Corner Roundness", 113 | string help = "Adds fillet radius to the corner of the tiles", 114 | float min=0.0, float max=10.0 ]], 115 | float Edge = 0.1 116 | [[ string label = "Edge Width (for Bump)", 117 | string help = "The width of a (slightly beveled) fake 'Edge' " 118 | "to give the tile a more realistic appearance", 119 | float min=0.0, float max=10.0 ]], 120 | float EdgeBump = 1.0 121 | [[ float min=-10.0, float max=10.0, 122 | string help = "The amount of Edge bump effect" ]], 123 | float ColorBump = 0.0 124 | [[ float min=-10.0, float max=10.0, 125 | string help = "Adds some contribution of the color " 126 | "settings to the Bump output" ]], 127 | color GapColor = 0.2 128 | [[ string label = "Gap Color", 129 | string help = "The color of the gap between tiles" ]], 130 | color TileColor1 = 0.4 131 | [[ string label = "Tile Color 1", 132 | string help = "First Tile Color" 133 | ]], 134 | color TileColor2 = 0.5 135 | [[ string label = "Tile Color 2", 136 | string help = "Second Tile Color" 137 | ]], 138 | color TileColor3 = 0.6 139 | [[ string label = "Tile Color 3", 140 | string help = "Third Tile Color. Not all Tiling Modes use this." 141 | ]], 142 | 143 | // Outputs 144 | output color Col = 0.0, 145 | output float Bump = 0.0, 146 | output int Tile = 0, 147 | output int TileIdx = 0, 148 | output int Index = 0 149 | ) 150 | { 151 | int Overlap = 1; 152 | vector Tiling = vector(U_Count, V_Count, 0.0); 153 | Col = GapColor; 154 | point uvw = UVW * Tiling / Scale; 155 | float to = TilingOffset; 156 | float to2 = to*0.5; 157 | 158 | float Roundness = Radius / 10.0; 159 | 160 | // Floor of UVW 161 | point fluvw = floor(uvw); 162 | // Fractional UVW 163 | point fruvw = uvw - fluvw; 164 | 165 | // Loop over neighbours 166 | for (int xx = -Overlap; xx <= 0; xx++) 167 | { 168 | point lookup = uvw - fluvw - point(xx,0,0); 169 | int HitIdx = 0; 170 | // Running Bond 171 | if (TileMode == 0) 172 | { 173 | if (Tile == 0) 174 | Tile = doRect(0.0 ,1.0, 0.0, 0.5, 1, 1, Roundness, PARAM); 175 | if (Tile == 0) 176 | Tile = doRect(to, to+1.0, 0.5, 1.0, 2, 2, Roundness, PARAM); 177 | } 178 | // Stack Bond 179 | if (TileMode == 1) 180 | { 181 | if (Tile == 0) 182 | Tile = doRect(0.0 ,0.5, 0.0, 0.5, 1, 1, Roundness, PARAM); 183 | if (Tile == 0) 184 | Tile = doRect(0.0, 0.5, 0.5, 1.0, 2, 2, Roundness, PARAM); 185 | if (Tile == 0) 186 | Tile = doRect(0.5 ,1.0, 0.0, 0.5, 2, 3, Roundness, PARAM); 187 | if (Tile == 0) 188 | Tile = doRect(0.5, 1.0, 0.5, 1.0, 1, 4, Roundness, PARAM); 189 | } 190 | // English Bond 191 | if (TileMode == 2) 192 | { 193 | if (Tile == 0) 194 | Tile = doRect(0.0 ,1.0, 0.0, 0.5, 1, 1, Roundness, PARAM); 195 | if (Tile == 0) 196 | Tile = doRect(0.0+to2, 0.5+to2, 0.5, 1.0, 2, 2, Roundness, PARAM); 197 | if (Tile == 0) 198 | Tile = doRect(0.5+to2, 1.0+to2, 0.5, 1.0, 2, 3, Roundness, PARAM); 199 | } 200 | // Fine Running Bond 201 | if (TileMode == 3) 202 | { 203 | if (Tile == 0) 204 | Tile = doRect(0.0 ,1.0, 0.0, 0.5, 1, 1, Roundness, PARAM); 205 | if (Tile == 0) 206 | Tile = doRect(0.0+to, 0.5+to, 0.5, 0.75, 2, 2, Roundness, PARAM); 207 | if (Tile == 0) 208 | Tile = doRect(0.5+to, 1.0+to, 0.5, 0.75, 2, 3, Roundness, PARAM); 209 | if (Tile == 0) 210 | Tile = doRect(0.0+to2, 0.5+to2, 0.75, 1.0, 3, 4, Roundness, PARAM); 211 | if (Tile == 0) 212 | Tile = doRect(0.5+to2, 1.0+to2, 0.75, 1.0, 3, 5, Roundness, PARAM); 213 | } 214 | // Twist Box 215 | if (TileMode == 4) 216 | { 217 | if (Tile == 0) 218 | Tile = doRect(0.0, 1.0-to2, 0.0, to2, 1, 1, Roundness, PARAM); 219 | if (Tile == 0) 220 | Tile = doRect(to2, 1.0, 1.0-to2, 1.0, 1, 2, Roundness, PARAM); 221 | if (Tile == 0) 222 | Tile = doRect(0.0, to2, to2, 1.0, 2, 3, Roundness, PARAM); 223 | if (Tile == 0) 224 | Tile = doRect(1.0-to2, 1.0, 0.0, 1.0-to2, 2, 4, Roundness, PARAM); 225 | if (Tile == 0) 226 | Tile = doRect(to2, 1.0-to2, to2, 1.0-to2, 3, 5, Roundness, PARAM); 227 | } 228 | if (HitIdx > 0) 229 | { 230 | TileIdx = HitIdx; 231 | Index = HitIdx + int((float)cellnoise(fluvw+point(xx,0,0)) * 1024.0); 232 | } 233 | } 234 | 235 | if (Tile == 1) Col = TileColor1; 236 | if (Tile == 2) Col = TileColor2; 237 | if (Tile == 3) Col = TileColor3; 238 | 239 | Bump *= EdgeBump; 240 | Bump += dot(0.3333, Col) * ColorBump; 241 | } -------------------------------------------------------------------------------- /SlopeMask.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/SlopeMask.jpg -------------------------------------------------------------------------------- /SlopeMask.osl: -------------------------------------------------------------------------------- 1 | // Slope Mask Shader by Saul Espinosa for Redshift 2 | // This file is licensed under Apache 2.0 license 3 | 4 | shader SlopeMask 5 | [[ string help = "Generates a mask based on Slope and direction", 6 | string label = "Slope Mask" ]] 7 | ( 8 | float Power = 4.0 9 | [[ 10 | float min =0.03, 11 | float max = 100 12 | ]], 13 | float Slope = 0.5 14 | [[ 15 | float min = 0.0, 16 | float max = 0.9999999 17 | ]], 18 | int Direction = 1 19 | [[ 20 | string widget = "mapper", 21 | string options = "X:0|Y:1|Z:2", 22 | int min = 0, 23 | int max = 2 24 | ]], 25 | output color Out = 1.0 26 | ) 27 | { 28 | Out = pow((N[Direction] - Slope) / .5, 1.0 / Power); 29 | } 30 | -------------------------------------------------------------------------------- /SpaceTransform.osl: -------------------------------------------------------------------------------- 1 | // Created by Saul Espinosa for Redshift 3D 2 | // Modified 01.11.2022 3 | 4 | shader SpaceTransform 5 | [[ string label = "Space Transform"]] 6 | ( 7 | // Inputs 8 | vector Input = 0 9 | [[ string label = "Input", string page = "Input" ]], 10 | 11 | string Type = "point" 12 | [[ string label = "Input Type", 13 | string page = "Input", 14 | string widget = "popup", 15 | string options = "point|vector|normal"]], 16 | 17 | string From = "world" 18 | [[ string label = "Input Space", 19 | string page = "Transform", 20 | string widget = "popup", 21 | string options = "world|object|camera|screen"]], 22 | 23 | string To = "world" 24 | [[ string label = "Output Space", 25 | string page = "Transform", 26 | string widget = "popup", 27 | string options = "world|object|camera|screen"]], 28 | 29 | int Normalize = 0 30 | [[ string widget = "checkBox", 31 | string page = "Transform", 32 | string label = "Normalize", 33 | int connectable = 0 ]], 34 | 35 | // Output 36 | output vector Output = 0 37 | [[ string label = "Output", string page = "Output" ]], 38 | 39 | ) 40 | { 41 | 42 | if (Normalize == 0) 43 | // Transform Input to Output 44 | if (Type == "point") Output = transform(From, To, point(Input)); 45 | else if (Type == "normal") Output = transform(From, To, normal(Input)); 46 | else Output = transform(From, To, Input);else 47 | { 48 | // Transform Input to Normalized Output 49 | if (Type == "point") Output = normalize(transform(From, To, point(Input))); 50 | else if (Type == "normal") Output = normalize(transform(From, To, normal(Input))); 51 | else Output = normalize(transform(From, To, Input)); 52 | } 53 | 54 | } -------------------------------------------------------------------------------- /Starfield.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/Starfield.jpg -------------------------------------------------------------------------------- /Starfield.osl: -------------------------------------------------------------------------------- 1 | /* 2 | * StarField.osl by Thomas Dinges 3 | * from https://github.com/sambler/osl-shaders 4 | * 5 | * original script from - 6 | * http://www.renderman.org/RMR/RMRShaders.html 7 | * 8 | * Starfield.sl -- Surface shader for a star field. 9 | * 10 | * DESCRIPTION: 11 | * Makes a star field. Best when used as a surface shader for the inside 12 | * of a large sphere. 13 | * 14 | * PARAMETERS: 15 | * frequency frequency of the stars 16 | * intensity how bright are the stars? 17 | * Width how wide is the point spread function? i.e. larger 18 | * values make "wider" stars, but the look less round. 19 | * 20 | * AUTHOR: written by Larry Gritz, 1992 21 | * 22 | * HISTORY: 23 | * 28 Dec 1992 -- written by lg for the "Timbre Trees" video (saucer) 24 | * 12 Jan 1994 -- recoded by lg in correct shading language. 25 | * 26 | * modified 12 Jan 1994 by Larry Gritz 27 | * converted to OSL by Thomas Dinges Dec 2012 28 | * modified 1/4/2020 by Saul Espinosa for Redshift 29 | * This file is licensed under Apache 2.0 license 30 | */ 31 | 32 | shader StarField 33 | [[ string help = "Generates procedural stars", 34 | string label = "Starfield" ]] 35 | ( 36 | float Intensity = 0.5 37 | [[ 38 | float min = 0, 39 | float max = 100 40 | ]], 41 | float Frequency = 100.0 42 | [[ 43 | float min = 0, 44 | float max = 500 45 | ]], 46 | float Width = 0.2 47 | [[ 48 | float min = 0, 49 | float max = 1 50 | ]], 51 | 52 | output float Fac = 1.0 ) 53 | { 54 | point PP; 55 | float val; 56 | 57 | PP = Frequency * P; 58 | 59 | /* Use a noise value, but only keep the "tips" of the blotches */ 60 | val = smoothstep (1 - Width, 1, noise(PP)); 61 | 62 | /* scale it by the intensity and sharpen it by squaring */ 63 | Fac = Intensity * val*val; 64 | } 65 | -------------------------------------------------------------------------------- /SubstanceFlow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/SubstanceFlow.jpg -------------------------------------------------------------------------------- /SubstanceFlow.osl: -------------------------------------------------------------------------------- 1 | // OSL version Mads Drøschler 2 | // WebGL version by Witek https://www.shadertoy.com/view/ltKyRR) 3 | // License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License 4 | // Modified 03.22.2021 by Saul Espinosa for Redshift 3d 5 | 6 | #include 7 | #define vec2 vector2 8 | #define vec3 vector 9 | #include 10 | #define vec4 vector4 11 | float fract ( float x) 12 | { 13 | return x-floor(x); 14 | } 15 | 16 | vec3 random3(vec3 c) 17 | { 18 | float j = 4096.0*sin(dot(c, vec3(17.0, 59.4, 15.0))); 19 | vec3 r; 20 | r[2] = fract(512.0 * j); 21 | j *= 0.125; 22 | r[0] = fract(512.0 * j); 23 | j *= 0.125; 24 | r[1] = fract(512.0 * j); 25 | 26 | return r - 0.5; 27 | } 28 | 29 | float simplex3d(vec3 p) 30 | { 31 | float F3 = 0.3333333; 32 | float G3 = 0.1666667; 33 | vec3 s = floor(p + dot(p, vec3(F3))); 34 | vec3 x = p - s + dot(s, vec3(G3)); 35 | vec3 e = step(vec3(0.0), x - vec3(x[1],x[2],x[0])); 36 | vec3 i1 = e*(1.0 - vec3(e[2],e[0],e[1])); 37 | vec3 i2 = 1.0 - vec3(e[2],e[0],e[1])*(1.0 - e); 38 | vec3 x1 = x - i1 + G3; 39 | vec3 x2 = x - i2 + 2.0*G3; 40 | vec3 x3 = x - 1.0 + 3.0*G3; 41 | vec4 w, d; 42 | w.x = dot(x, x); 43 | w.y = dot(x1, x1); 44 | w.z = dot(x2, x2); 45 | w.w = dot(x3, x3); 46 | w = max(0.6 - w, 0.0); 47 | d.x = dot(random3(s), x); 48 | d.y = dot(random3(s + i1), x1); 49 | d.z = dot(random3(s + i2), x2); 50 | d.w = dot(random3(s + 1.0), x3); 51 | w *= w; 52 | w *= w; 53 | d *= w; 54 | return dot(d, vec4(52.0,52.0,52.0,52.0)); 55 | } 56 | 57 | float simplex3d_fractal(vec3 m, int steps) 58 | { 59 | float sum = 0.0; 60 | for (int i = 0; i < steps; ++i) 61 | { 62 | float scale = pow(2.0, float(i)); 63 | sum += simplex3d(scale * m) / scale; 64 | } 65 | return sum; 66 | } 67 | 68 | vec3 flow_texture( vec3 p, float Time, int steps) 69 | { 70 | // animate initial coordinates 71 | vec3 p1 = 0.1 * p + vec3(1.0 + Time * 0.0023, 2.0 - Time * 0.0017, 4.0 + Time * 0.0005); 72 | // distort noise sampling coordinates using the same noise function 73 | vec3 p2 = p + 8.1 * simplex3d_fractal(p1,steps) + 0.5; 74 | vec3 p3 = p2 + 4.13 * simplex3d_fractal(0.5 * p2 + vec3(5.0, 4.0, 8.0 + Time * 0.07),steps) + 0.5; 75 | 76 | vec3 ret; 77 | ret[0] = simplex3d_fractal(p3 + vec3(0.0, 0.0, 0.0 + Time * 0.3),steps); 78 | ret[1] = simplex3d_fractal(p3 + vec3(0.0, 0.0, 0.2 + Time * 0.3),steps); 79 | ret[2] = simplex3d_fractal(p3 + vec3(0.0, 0.0, 0.3 + Time * 0.3),steps); 80 | 81 | // scale output & map 82 | ret = 0.5 + 0.5 * ret; 83 | ret = smoothstep(vec3(0.15), vec3(0.85), ret); 84 | return ret; 85 | } 86 | 87 | shader SubstanceFlow 88 | [[ string help = "Substance Flow Noise", 89 | string label = "Substance Flow" ]] 90 | ( 91 | point Po = P 92 | [[ 93 | string label = "UVW" 94 | ]], 95 | float Time = 0 96 | [[ 97 | float slidermin = 0, 98 | float slidermax = 100 99 | ]], 100 | int steps = 12 101 | [[ 102 | int slidermin = 1, 103 | int slidermax = 25 104 | ]], 105 | float scale = 1 106 | [[ 107 | float slidermin = 0, 108 | float slidermax = 100 109 | ]], 110 | 111 | int aces = 0 112 | [[ string widget = "checkBox", 113 | string label = "ACES", 114 | int connectable = 0 ]], 115 | 116 | output color outColor = 0, 117 | 118 | ) 119 | { 120 | // ACES sRGB Transform 121 | matrix aces_tm = matrix( 122 | 0.6131, 0.0701, 0.0206, 0, 123 | 0.3395, 0.9164, 0.1096, 0, 124 | 0.0474, 0.0135, 0.8698, 0, 125 | 0, 0, 0, 1); 126 | 127 | float iResolution = scale; 128 | 129 | int numSamples = 1; 130 | vec3 result = vec3(0.0); 131 | vec2 fragCoord = vec2(Po[0],Po[1]); 132 | // cheap AA 133 | for (int x = 0; x < numSamples; ++x) 134 | { 135 | for (int y = 0; y < numSamples; ++y) 136 | { 137 | vec2 offset = vec2(float(x), float(y)) / float(numSamples); 138 | vec2 uv = (fragCoord + offset) / iResolution; 139 | vec3 p = vec3(uv.x,uv.y, Time*0.001); 140 | result += flow_texture(p * 6.0,Time,steps); 141 | 142 | } 143 | } 144 | 145 | result /= float(numSamples * numSamples); 146 | vector Out = vec3(sqrt(result)); 147 | Out = pow(Out,2.2); 148 | 149 | float r = Out[0], g = Out[1], b = Out[2]; 150 | 151 | // ACES Output 152 | if (aces == 0) 153 | outColor = Out; 154 | else 155 | { 156 | outColor = transform(aces_tm, vector(r,g,b)); 157 | } 158 | 159 | } 160 | -------------------------------------------------------------------------------- /TextureNoTile.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/TextureNoTile.jpg -------------------------------------------------------------------------------- /TextureNoTile.osl: -------------------------------------------------------------------------------- 1 | // Non-Tiling Texture Shader 2 | // TextureNoTile.osl, by Zap Andersson 3 | // Modified: 2020-03-28 4 | // Copyright 2020 Autodesk Inc, All rights reserved. This file is licensed under Apache 2.0 license 5 | // https://github.com/ADN-DevTech/3dsMax-OSL-Shaders/blob/master/LICENSE.txt 6 | // Modified by Saul Espinosa for Redshift OSL Support 2020-12-28 7 | 8 | float sum( color col ) { return col[0]+col[1]+col[2]; } 9 | 10 | 11 | color textureNoTile( string FileName, point UV, float GradientScale, float Offset, float Rescale, float Rotate, int LevelCount, int Debug, int Seed ) 12 | { 13 | float k = noise("uperlin", UV / GradientScale, Seed); 14 | float l = k*LevelCount + UV[1] / GradientScale; 15 | float i = floor( l ); 16 | float f = l - i; 17 | vector offa = cellnoise(i + 0.0, Seed) * vector(Offset, Offset, 1.0); 18 | vector offb = cellnoise(i + 1.0, Seed) * vector(Offset, Offset, 1.0); 19 | float sca = 1.0 / (1.0 + (offa[2] - 0.5) * Rescale); 20 | float scb = 1.0 / (1.0 + (offb[2] - 0.5) * Rescale); 21 | 22 | float rota = offa[2] * Rotate; 23 | float rotb = offb[2] * Rotate; 24 | 25 | point rotA = rotate(UV, rota, vector(0.5,0.5,0), vector(0.5,0.5,1.0)); 26 | point rotB = rotate(UV, rotb, vector(0.5,0.5,0), vector(0.5,0.5,1.0)); 27 | 28 | color cola = texture(FileName, rotA[0] * sca + offa[0], 1.0 - (rotA[1] * sca + offa[1]), "wrap", "periodic" ); 29 | color colb = texture(FileName, rotB[0] * scb + offb[0], 1.0 - (rotB[1] * scb + offb[1]), "wrap", "periodic" ); 30 | 31 | if (Debug) 32 | { 33 | cola = offa; 34 | colb = offb; 35 | } 36 | 37 | return mix( cola, colb, smoothstep(0.1,0.9,f-0.1*sum(cola-colb)) ); 38 | } 39 | 40 | shader NoTile 41 | [[ string help = "Non-Tiling Bitmap Lookup, based on an OpenGL Technique", 42 | string label = "Non-Tiling Bitmap Lookup", 43 | string URL = "http://www.iquilezles.org/www/articles/texturerepetition/texturerepetition.htm" ]] 44 | ( 45 | 46 | // Texture Input 47 | point uvw = point(u,v,0) 48 | [[ string label= "UV Coordinate", 49 | string help = "The 2D coordiante at which the texture is looked up." ]], 50 | string Filename = "" [[ string widget="filename", string page = "Image" ]], 51 | 52 | string fileColorSpace = "" [[string label = "ColorSpace", string widget = "colorspace", string page = "Image"]], 53 | 54 | float gainMul = 1 55 | [[ string label = "Gain", 56 | string page = "Image", 57 | float softmin = 0, 58 | float softmax = 10, 59 | float slidermin = 0, 60 | float slidermax = 10, 61 | float sensitivity = 0.001 ]], 62 | 63 | // Noise Options 64 | float GradientScale = 2.0 65 | [[ float min = 0, 66 | float max = 25, 67 | string page = "Noise" 68 | ]], 69 | float Offset = 1.0 70 | [[ float min = 0, 71 | float max = 25, 72 | string page = "Noise" 73 | ]], 74 | float Rescale = 0.0 75 | [[ float min = 0, 76 | float max = 25, 77 | string page = "Noise" 78 | ]], 79 | float Rotate = 0.0 80 | [[ float min = -180, 81 | float max = 180, 82 | string page = "Noise" 83 | ]], 84 | int LevelCount = 8 85 | [[ int min = 0, 86 | int max = 25, 87 | string page = "Noise" 88 | ]], 89 | int Seed = 0 90 | [[ int min = 0, 91 | int max = 100, 92 | string page = "Noise" 93 | ]], 94 | int Debug = 0 95 | [[ string widget = "checkBox", 96 | string help = "Shows the regions that are being mixed", string page = "Utility" ]], 97 | int Bypass = 0 98 | [[ string widget = "checkBox", 99 | string help = "Turns the effect off, to compare", string page = "Utility" ]], 100 | 101 | output color outColor = 0 102 | ) 103 | { 104 | int s = Seed; 105 | 106 | 107 | point Pos = select(vector(u,v,0), uvw, isconnected(uvw)); 108 | 109 | if (Bypass) 110 | color Col = texture(Filename, Pos[0], 1.0 - Pos[1], "wrap", "periodic"); 111 | else 112 | Col = textureNoTile( Filename, Pos, GradientScale, Offset, Rescale, Rotate, LevelCount, Debug, s ); 113 | color textureSampleRAW = transformc("ACEScg", "scene-linear Rec.709-sRGB", Col); 114 | outColor = transformc(fileColorSpace, "ACEScg", textureSampleRAW) * gainMul; 115 | } 116 | -------------------------------------------------------------------------------- /TextureNoTile_Example.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/TextureNoTile_Example.jpg -------------------------------------------------------------------------------- /TextureSampleScreenSpace.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/TextureSampleScreenSpace.jpg -------------------------------------------------------------------------------- /TextureSampleScreenSpace.osl: -------------------------------------------------------------------------------- 1 | /* 2 | Screen space texture sampling for Redshift. 3 | Handles colorspace correctly in Redshift. 4 | This file is licensed under Apache 2.0 license 5 | */ 6 | 7 | shader ScreenSpaceTex 8 | [[ string help = "Screen Space Texture Projection Mapping", 9 | string label = "Screen Space Texture Map" ]] 10 | ( 11 | string file = "" [[string widget = "filename", int connectable = 0]], 12 | string fileColorSpace = "" [[string label = "ColorSpace", string widget = "colorspace"]], 13 | point scale = point(1.0, 1.0, 1.0), 14 | output color outColor = 0 15 | ) 16 | { 17 | point screenCordinates = transform("world", "screen", P); 18 | //this is a weird way to do this so I have to rescale the coordinates. 19 | screenCordinates += -1; 20 | screenCordinates *= 0.5; 21 | 22 | //texture tiling 23 | screenCordinates *= scale; 24 | color textureSample = texture(file, screenCordinates.x, 1-screenCordinates.y); 25 | //reverse baked in colorspace 26 | color textureSampleRAW = transformc("ACEScg", "scene-linear Rec.709-sRGB", textureSample); 27 | outColor = transformc(fileColorSpace, "ACEScg", textureSampleRAW); 28 | } 29 | -------------------------------------------------------------------------------- /ThinFilmInterference.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/ThinFilmInterference.jpg -------------------------------------------------------------------------------- /ToonOutlines.osl: -------------------------------------------------------------------------------- 1 | // Simple stylised shading node by Benjamin Mikhaiel 2 | // This file is licensed under Apache 2.0 license 3 | 4 | shader ToonOutlines( 5 | float thickness = 0.5, //mindex's comma 6 | float tracedist = 50.0, 7 | float tracedistSteep = 100, 8 | float steepnessStrength = 1, 9 | float threshold = 0, 10 | float bias = -10, 11 | float Curvature = 0, 12 | float curvatureCrunch = 0, 13 | output color line = 1, 14 | output float dfDxOut = 0, 15 | output float dfDyOut = 0, 16 | output float fres = 0 17 | ) 18 | { 19 | point points[4] = {point(-1.0, 1.0, 0.0), 20 | point(1.0, 1.0, 0.0), 21 | point(-1.0, -1.0, 0.0), 22 | point(1.0, -1.0, 0)}; 23 | 24 | point finalPoints[8]; 25 | 26 | point mainP = transform("world", "camera", P); 27 | //x left is -30? right is +30? 28 | //y up is +20? bottom is -20 29 | //z distance from camera 0 at cam, + value further away from camera 30 | 31 | 32 | 33 | fres = pow(1-clamp(dot(N, -normalize(I)), 0, 1), steepnessStrength); 34 | 35 | float scaledTraceDepth = mix(tracedistSteep, tracedist, fres); 36 | 37 | for (int i = 0; i < 4; i++) 38 | { 39 | // points around the position we want to check for an edge 40 | point samplePosition = mainP + (points[i] * thickness); 41 | // we then want to move the position towards the camera, so we need to move the bias distance along the vector to the camera. 42 | //back to world space? 43 | samplePosition = transform("camera", "world", samplePosition); 44 | finalPoints[i] = samplePosition - (normalize(I) * bias); 45 | } 46 | 47 | for (int i = 4; i < 8; i++) 48 | { 49 | // points around the position we want to check for an edge 50 | point samplePosition = mainP + (points[i - 4] * -thickness); 51 | // we then want to move the position towards the camera, so we need to move the bias distance along the vector to the camera. 52 | //back to world space? 53 | samplePosition = transform("camera", "world", samplePosition); 54 | finalPoints[i] = samplePosition - (normalize(I) * bias); 55 | } 56 | 57 | vector rayDir = normalize(I) * vector(-1.0, -1.0, -1.0); 58 | 59 | float traceXA = trace(finalPoints[0], rayDir, "maxdist", scaledTraceDepth); 60 | float traceXB = trace(finalPoints[1], rayDir, "maxdist", scaledTraceDepth); 61 | float traceYA = trace(finalPoints[2], rayDir, "maxdist", scaledTraceDepth); 62 | float traceYB = trace(finalPoints[3], rayDir, "maxdist", scaledTraceDepth); 63 | float traceXC = trace(finalPoints[4], rayDir, "maxdist", scaledTraceDepth); 64 | float traceXD = trace(finalPoints[5], rayDir, "maxdist", scaledTraceDepth); 65 | float traceYE = trace(finalPoints[6], rayDir, "maxdist", scaledTraceDepth); 66 | float traceYF = trace(finalPoints[7], rayDir, "maxdist", scaledTraceDepth); 67 | 68 | float dfDx = abs(traceXA - traceXB); 69 | float dfDy = abs(traceYB - traceYB); 70 | float dfDxB = abs(traceXC - traceXD); 71 | float dfDyB = abs(traceYE - traceYF); 72 | if (dfDx + dfDy + (Curvature - curvatureCrunch) > threshold) 73 | { 74 | line = 1; 75 | } 76 | else 77 | { 78 | line = 0; 79 | } 80 | 81 | if ((dfDxB + dfDyB) > threshold) 82 | { 83 | line += 1; 84 | } 85 | else 86 | { 87 | line += 0; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /ToonStylizedPass.osl: -------------------------------------------------------------------------------- 1 | // Simple stylised shading node by Benjamin Mikhaiel 2 | // This file is licensed under Apache 2.0 license 3 | // added basic option for point light effect 11/06/2023 (at like 3am) 4 | 5 | float frac(float x) 6 | { 7 | return x - floor(x); 8 | } 9 | 10 | float traceShadow(vector lightDir, float shadowBias, float maxDistance) 11 | { 12 | //point traceStart = P + (normalize(lightDir) * shadowBias); 13 | float traceRay = trace(P, lightDir, "mindist", shadowBias, "maxdist", maxDistance); 14 | return traceRay; 15 | } 16 | 17 | float ShadowOutline(vector lightDir, float shadowBias, float maxDistance, float thickness) 18 | { 19 | vector surfaceOffset = N * (thickness * 1.1); 20 | float traceRayA = trace((P + vector(thickness, 0, 0)) + surfaceOffset, lightDir, "mindist", shadowBias, "maxdist", maxDistance); 21 | float traceRayB = trace((P + vector(-thickness, 0, 0)) + surfaceOffset, lightDir, "mindist", shadowBias, "maxdist", maxDistance); 22 | float traceRayC = trace((P + vector(0, thickness, 0)) + surfaceOffset, lightDir, "mindist", shadowBias, "maxdist", maxDistance); 23 | float traceRayD = trace((P + vector(0, -thickness, 0)) + surfaceOffset, lightDir, "mindist", shadowBias, "maxdist", maxDistance); 24 | return abs(traceRayA - traceRayB) + abs(traceRayC - traceRayD); 25 | } 26 | 27 | float lambertSimple(vector lightDir) 28 | { 29 | float lambert = dot(N, lightDir); 30 | return clamp(lambert, 0, 1); 31 | } 32 | 33 | float steppedRamp(float x, int steps) 34 | { 35 | float stepped = (round(x * steps)) / steps; 36 | return stepped; 37 | } 38 | 39 | shader traceRay( 40 | vector lightDirection = vector(0,0,0) [[string page = "Light Settings", string label = "Light Dir / Position"]], 41 | int UseAsPoint = 0 [[string widget = "checkBox", string page = "Light Settings", string label = "Use as Point Light"]], 42 | color lightColor = 1 [[string page = "Light Settings"]], 43 | float lightFalloff = 100.0 [[string page = "Light Settings"]], 44 | 45 | 46 | color baseColor = color(0.25, 0.25, 0.25) [[string page = "Shading Settings"]], 47 | color shadowColor = 0 [[string page = "Shading Settings"]], 48 | int stepped = 1 [[string widget = "checkBox", string page = "Shading Settings"]], 49 | int lightSteps = 4 [[string page = "Shading Settings"]], 50 | 51 | 52 | int shadows = 1 [[string widget = "checkBox", string page = "Shadow Settings"]], 53 | int softShadows = 0 [[string widget = "checkBox", string page = "Shadow Settings"]], 54 | float softness = 0.5 [[string page = "Shadow Settings"]], 55 | float shadowBias = 0 [[string page = "Shadow Settings"]], 56 | float thickness = 1 [[string page = "Shadow Settings", string label = "Outline Thickness"]], 57 | 58 | 59 | float distortionScale = 1.0 [[string page = "Distortion"]], 60 | float shadingDistortion = 0.4 [[string page = "Distortion"]], 61 | 62 | int Zup = 0 [[string widget = "checkBox", string page = "Cordinate Settings"]], 63 | vector TransformFlipper = vector(1.0,1.0,1.0) [[string page = "Cordinate Settings"]], 64 | 65 | output color cout = 0, 66 | output float shadowMask = 0, 67 | output color shadowOutline = 0 68 | ) 69 | { 70 | float shading = 0; 71 | 72 | float distortion = shadingDistortion - 0.5; 73 | distortion = distortionScale * distortion; 74 | 75 | vector lightDirectionInternal = normalize(lightDirection); 76 | point lightPosition = lightDirection; 77 | if(Zup) 78 | { 79 | lightPosition = lightPosition * vector(1.0,1.0,-1.0); 80 | } 81 | 82 | 83 | float maxRayDistance = 999999999; 84 | if(UseAsPoint) 85 | { 86 | maxRayDistance = distance(lightPosition, P); 87 | lightDirectionInternal = normalize(point(lightPosition) - P); 88 | } 89 | 90 | vector LightDirOffset = lightDirectionInternal + vector(distortion, distortion, distortion); 91 | 92 | 93 | float lambert = lambertSimple(LightDirOffset); 94 | 95 | if(shadows) 96 | { 97 | if(softShadows) 98 | { 99 | float f = frac(fmod(cellnoise(P*1234562.0), 1.0)); 100 | vector randomDirOffset = vector(f - 0.5, f - 0.5, f - 0.5); 101 | shading = traceShadow(LightDirOffset + (f * softness), shadowBias, maxRayDistance); 102 | } 103 | else 104 | { 105 | shading = traceShadow(LightDirOffset, shadowBias, maxRayDistance); 106 | shadowMask = shading - (1-lambert); 107 | shadowOutline = ShadowOutline(LightDirOffset, shadowBias, maxRayDistance, thickness); 108 | } 109 | } 110 | shading = lambert * (1-shading); 111 | 112 | if(UseAsPoint) 113 | { 114 | shading = shading * (1 - (distance(lightPosition, P) / lightFalloff)); 115 | } 116 | //lets put some space between here to see if that fixes it? 117 | shading = clamp(shading, 0, 1); 118 | 119 | if(stepped) 120 | { 121 | shading = steppedRamp(shading, lightSteps); 122 | } 123 | 124 | color ColorShading = mix(shadowColor, lightColor, shading); 125 | ColorShading = baseColor * ColorShading; 126 | cout = ColorShading; 127 | } 128 | -------------------------------------------------------------------------------- /TransformTangentNormal.osl: -------------------------------------------------------------------------------- 1 | // Transform Tangent Normal Shader - applies a matrix transform or a rotation to a tangent space normal map 2 | /* 3 | Copyright 2023 Edward Darby Edelen 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | shader TransformTangentNormal( 19 | color normal_input = color(0,0,1) 20 | [[string label = "Normal Texture"]], 21 | vector tangent_in = 0 22 | [[string label="Tangent Input"]], 23 | float tangent_rotation = 0 24 | [[string label = "Tangent Rotation", string page="Transform", float slidermin = -180, float slidermax = 180]], 25 | matrix tangent_space = matrix(1) 26 | [[string label = "Tangent Space", string page="Transform"]], 27 | output normal Transformed_Normal = normal(0,0,1) 28 | ) 29 | { 30 | vector T = select(normalize(dPdu), tangent_in, isconnected(tangent_in)); 31 | vector B = cross(T, Ng); 32 | 33 | matrix TBN = matrix( 34 | T.x, T.y, T.z, 0, 35 | B.x, B.y, B.z, 0, 36 | Ng.x, Ng.y, Ng.z, 0, 37 | 0, 0, 0, 1 38 | ); 39 | 40 | vector unbiased_normal = normalize(normal_input * vector(2) - vector(1)); 41 | 42 | vector result = rotate(unbiased_normal, radians(tangent_rotation), vector(0,0,-1)); 43 | 44 | result = isconnected(tangent_space) ? normalize(transform(tangent_space / TBN, result)) : result; 45 | 46 | Transformed_Normal = (result + vector(1)) * vector(0.5); 47 | } -------------------------------------------------------------------------------- /TriplanarCoordinates.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/TriplanarCoordinates.jpg -------------------------------------------------------------------------------- /TriplanarCoordinates.osl: -------------------------------------------------------------------------------- 1 | // Triplanar Coordinates Shader - Triplanar coordinates to connect with UV offsets to apply the projection 2 | /* 3 | Copyright (c) 2023 Edward Darby Edelen 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | struct triplanar_normals 19 | // These should be stored as normals 20 | // Storing as vectors until the transform() issue is resolved 21 | { 22 | vector x; 23 | vector y; 24 | vector z; 25 | }; 26 | 27 | struct triplanar_uvws 28 | { 29 | point x; 30 | point y; 31 | point z; 32 | }; 33 | 34 | struct triplanar_data 35 | { 36 | triplanar_uvws uvws; 37 | triplanar_normals tangents; 38 | }; 39 | 40 | float soft_threshold(float a, float threshold, float delta) 41 | { 42 | return clamp((a - threshold + delta) / (clamp(delta, 0.0001, 10000)), 0, 1); 43 | } 44 | 45 | float soft_twin_threshold(float a, float thresh_a, float thresh_b, float delta) 46 | { 47 | return min(soft_threshold(a, thresh_a, delta), soft_threshold(a, thresh_b, delta)); 48 | } 49 | 50 | vector triplanar_heightblend(vector heights, float delta) 51 | { 52 | float height_start = max(max(heights.x, heights.y), heights.z) - delta; 53 | vector new_heights = max(heights - vector(height_start), vector(0)); 54 | vector blend = vector( 55 | soft_twin_threshold(heights.x, heights.y, heights.z, delta), 56 | soft_twin_threshold(heights.y, heights.x, heights.z, delta), 57 | soft_twin_threshold(heights.z, heights.x, heights.y, delta) 58 | ); 59 | 60 | return blend; 61 | } 62 | 63 | vector triplanar_blend_weights(vector heights, float delta, vector norm) 64 | { 65 | vector n = abs(norm); 66 | 67 | vector blend = triplanar_heightblend((heights + vector(1)) * n, delta); 68 | return blend / dot(blend, vector(1)); 69 | } 70 | 71 | triplanar_data triplanar_coordinates(point translate, vector rotation, vector scale, vector norm, point position, int space) 72 | { 73 | matrix projection = space == 1 ? matrix(1) : matrix("world","object"); 74 | point translation = translate * scale; 75 | point uvw = position * scale; 76 | triplanar_uvws uvw_planes = triplanar_uvws( 77 | uvw, 78 | uvw, 79 | uvw 80 | ); 81 | 82 | triplanar_normals tangents = triplanar_normals(transform(projection, vector(0,0,1)), transform(projection, vector(1,0,0)), transform(projection, vector(1,0,0))); 83 | 84 | vector flips = sign(vector(dot(norm, vector(1,0,0)), dot(norm, vector(0,1,0)), dot(norm, vector(0,0,1)))); 85 | 86 | uvw_planes.x = point(uvw_planes.x.z, uvw_planes.x.y, 0); 87 | uvw_planes.y = point(uvw_planes.y.x, uvw_planes.y.z, 0); 88 | uvw_planes.z = point(uvw_planes.z.x, uvw_planes.z.y, 0); 89 | 90 | uvw_planes.x = rotate(uvw_planes.x, rotation.x, vector(0,0,1)) + point(translation.z, translation.y, 0); 91 | uvw_planes.y = rotate(uvw_planes.y, rotation.y, vector(0,0,1)) + point(translation.x, translation.z, 0); 92 | uvw_planes.z = rotate(uvw_planes.z, rotation.z, vector(0,0,1)) + point(translation.x, translation.y, 0); 93 | 94 | tangents.x = rotate(tangents.x, rotation.x, vector(1,0,0)); 95 | tangents.y = rotate(tangents.y, rotation.y, vector(0,1,0)); 96 | tangents.z = rotate(tangents.z, rotation.z, vector(0,0,-1)); 97 | 98 | uvw_planes.x *= vector(flips.x, 1, 1); 99 | uvw_planes.y *= vector(flips.y, 1, 1); 100 | uvw_planes.z *= vector(-flips.z, 1, 1); 101 | tangents.x *= flips.x; 102 | tangents.y *= flips.y; 103 | tangents.z *= -flips.z; 104 | 105 | triplanar_data triplanar_coords; 106 | 107 | triplanar_coords.uvws = uvw_planes; 108 | triplanar_coords.tangents = tangents; 109 | 110 | return triplanar_coords; 111 | } 112 | 113 | shader TriplanarCoordinates( 114 | float blend = 0.1 115 | [[string label="Blend Amount", string widget="number", string page="Blending", float min=0, float max=1]], 116 | float gamma = 2 117 | [[string label="Blend Curve", string widget="number", string page="Blending", float min=0.5, float max=50, float slidermin=0.5, float slidermax=10]], 118 | float height_weight = 1 119 | [[string label="Height Weight", string widget="number", string page="Height", float min=0, float max=2, float slidermin=0, float slidermax=1]], 120 | string height_texture = "" 121 | [[string label="Height Texture", string widget="filename", string page="Height"]], 122 | float noise_weight = 0 123 | [[string label="Noise Weight", string widget="number", string page="Noise", float min=0, float max=2, float slidermin=0, float slidermax=1]], 124 | float noise_uniform_scale = 1 125 | [[string label="Noise Uniform Scale", string widget="number", string page="Noise", float min=0.0001, float slidermin=0.1, float slidermax=10]], 126 | vector noise_scale = 1 127 | [[string label="Noise Scale", string page="Noise", float sensitivity=0.1]], 128 | vector noise_offset = 0 129 | [[string label="Noise Offset", string widget="number", string page="Noise"]], 130 | int noise_seed = 12345 131 | [[string label="Noise Random Seed", string widget="number", string page="Noise"]], 132 | int space = 0 133 | [[string label="Projection Space", string page="Projection", string widget="mapper", string options="Object Space:0|World Space:1|Rest Space:2"]], 134 | point translation = 0 135 | [[string label="Translate", string page="Projection", float sensitivity=0.1]], 136 | vector rotation = 0 137 | [[string label="Rotate", string page="Projection"]], 138 | float uniform_scaling = 0.5 139 | [[string label="Uniform Scale", string page="Projection", float sensitivity=0.1, float slidermin=0, float slidermax=10]], 140 | vector scaling = 1 141 | [[string label="Scale", string page="Projection", float sensitivity=0.1]], 142 | normal rest_norm = normal(0,1,0) 143 | [[string label="Rest Normal", string page="Projection"]], 144 | point rest_pos = 0 145 | [[string label="Rest Position", string page="Projection"]], 146 | output point UV_Offset=0, 147 | output point Triplanar_UV=0, 148 | output vector Tangent_Out=0, 149 | output vector Texture_Weight=0, 150 | output float Edge_Weight=0, 151 | output matrix Tangent_Space=0 152 | ) 153 | { 154 | matrix projection = space == 1 ? matrix(1) : matrix("world","object"); 155 | point position = space == 2 ? rest_pos : transform(projection, P); 156 | vector scale = 0.01 / (uniform_scaling * scaling); 157 | vector norm = space == 2 ? rest_norm : transform(projection, vector(Ng)); 158 | 159 | triplanar_data triplanar_coords = triplanar_coordinates(translation, radians(rotation), scale, norm, position, space); 160 | triplanar_uvws planes = triplanar_coords.uvws; 161 | triplanar_normals tangents = triplanar_coords.tangents; 162 | 163 | vector heights = height_weight * (vector( 164 | texture(height_texture, planes.x.x, 1 - planes.x.y, "missingcolor", color(0.5)), 165 | texture(height_texture, planes.y.x, 1 - planes.y.y, "missingcolor", color(0.5)), 166 | texture(height_texture, planes.z.x, 1 - planes.z.y, "missingcolor", color(0.5)) 167 | ) * 2 - 1) + mix(0, noise("perlin", transform(projection, position) / (noise_uniform_scale * noise_scale) + noise_offset, noise_seed), noise_weight); 168 | 169 | vector blend_weights = pow(triplanar_blend_weights(heights, blend * M_SQRT1_2, norm), gamma); 170 | blend_weights /= dot(blend_weights, vector(1)); 171 | 172 | vector rnd = noise("hash", position); 173 | 174 | point uv = select(planes.z, select(planes.y, planes.x, rnd.x < blend_weights.x), rnd.x < (blend_weights.x + blend_weights.y)); 175 | vector final_weights = select(vector(0,0,1), select(vector(0,1,0), vector(1,0,0), rnd.x < blend_weights.x), rnd.x < (blend_weights.x + blend_weights.y)); 176 | float edge_weights = 3 * ((blend_weights.y * blend_weights.z) + (blend_weights.x * blend_weights.y) + (blend_weights.x * blend_weights.z)); 177 | 178 | vector tT = select(tangents.z, select(tangents.y, tangents.x, rnd.x < blend_weights.x), rnd.x < (blend_weights.x + blend_weights.y)); 179 | vector tB = cross(tT, Ng); 180 | 181 | matrix tTBN = matrix( 182 | tT.x, tT.y, tT.z, 0, 183 | tB.x, tB.y, tB.z, 0, 184 | Ng.x, Ng.y, Ng.z, 0, 185 | 0, 0, 0, 1 186 | ); 187 | 188 | UV_Offset = uv - point(u, v, 0); 189 | Triplanar_UV = uv; 190 | Texture_Weight = final_weights; 191 | Edge_Weight = edge_weights; 192 | Tangent_Space = tTBN; 193 | Tangent_Out = tT; 194 | } -------------------------------------------------------------------------------- /TurbulentColor.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/TurbulentColor.jpg -------------------------------------------------------------------------------- /TurbulentColor.osl: -------------------------------------------------------------------------------- 1 | /* 2 | * TurbulentColor.osl by elbrujodelatribu (c)2013 3 | * from https://github.com/sambler/osl-shaders 4 | * Modified 04.02.2021 by Saul Espinosa for Redshift 3d 5 | * original script from - 6 | * http://elbrujodelatribu.blogspot.com.au/2013/05/blender-cycles-osl-color-turbulence.html 7 | * based on work from 8 | * http://glsl.heroku.com/e#8664.0 9 | * This file is licensed under Apache 2.0 license 10 | */ 11 | 12 | 13 | shader TurbulentColor 14 | [[ string help = "Turbulent Color Noise", 15 | string label = "Turbulent Color" ]] 16 | ( 17 | vector Vector = P, 18 | float Scale = 5 19 | [[ 20 | float min = 0, float max = 25 21 | ]], 22 | float Time = 1.0 23 | [[ 24 | float min = 0, float max = 100 25 | ]], 26 | int MaxIterations = 64 27 | [[ 28 | int min = 1, int max = 100 29 | ]], 30 | 31 | output color Color = 0.8) 32 | { 33 | vector p = Vector * Scale;//surfacePosition; 34 | 35 | for(int i=1; i < MaxIterations; i++) 36 | { 37 | vector newp = p; 38 | newp[0]+=0.6/float(i)*sin(float(i)*p[1]+Time/20.0+0.3*float(i))+20.0; 39 | newp[1]+=0.6/float(i)*sin(float(i)*p[0]+Time/20.0+0.3*float(i+10))-5.0; 40 | p=newp; 41 | } 42 | 43 | Color = color(sin(Time+p[1]+p[0]-M_PI*color(0,2,4)/(4.0+sin(Time)))*0.3+0.5); 44 | } 45 | -------------------------------------------------------------------------------- /UVWTransform.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/UVWTransform.jpg -------------------------------------------------------------------------------- /UVWTransform.osl: -------------------------------------------------------------------------------- 1 | // An UVW coordinate tranfrormation tool 2 | // UVWTransform.osl by Zap Andersson 3 | // Modified: 2019-11-27 4 | // Copyright 2019 Autodesk Inc, All rights reserved. This file is licensed under Apache 2.0 license 5 | // https://github.com/ADN-DevTech/3dsMax-OSL-Shaders/blob/master/LICENSE.txt 6 | // Modified by Saul Espinosa for Redshift Renderer 2021-01-21 Added Extra Page Metadata 7 | 8 | shader UVWTransform 9 | [[ 10 | string label = "UVW Transform", 11 | string category = "UVW Coordinates", 12 | string version = "2.1" 13 | ]] 14 | ( 15 | point uvwInput = point(u, v, 0) 16 | [[ 17 | string label = "Input UVW" 18 | ]], 19 | 20 | float Scale = 1.0 21 | [[ 22 | string page = "Adjustments" , 23 | float min = 0, float max = 25 24 | ]], 25 | 26 | vector Tiling = 1.0 27 | [[ 28 | string page = "Adjustments" 29 | ]], 30 | 31 | vector Offset = 0.0 32 | [[ 33 | string page = "Adjustments" 34 | ]], 35 | 36 | int Wrap = 0 37 | [[ 38 | string widget = "checkBox", 39 | string page = "Adjustments", 40 | int connectable = 0, 41 | ]], 42 | 43 | float Rotate = 0.0 44 | [[ 45 | string page = "Rotation", 46 | float min = -180, float max = 180 47 | ]], 48 | 49 | point RotCenter = point(0.5,0.5,0) 50 | [[ 51 | string label = "Rotation Center", 52 | string page = "Rotation" 53 | ]], 54 | 55 | vector RotAxis = vector(0.0,0.0,1.0) 56 | [[ 57 | string label = "Rotation Axis", 58 | string page = "Rotation" 59 | ]], 60 | 61 | // UVW Output 62 | output point UVW = 0 63 | ) 64 | { 65 | vector worldScale = 1.0; 66 | point Input = select(vector(u,v,0), uvwInput, isconnected(uvwInput)); 67 | 68 | UVW = rotate(Input - -Offset, radians(Rotate), RotCenter, RotCenter + RotAxis) * Tiling / worldScale / (1.0/Scale); 69 | 70 | if (Wrap) 71 | UVW -= floor(UVW); 72 | } 73 | -------------------------------------------------------------------------------- /UberColorCorrect.osl: -------------------------------------------------------------------------------- 1 | // Color Correction 2 | // ColorCorrect.osl, by Zap Andersson 3 | // Modified: 2021-12-20 by Saul Espinosa for Redshift 3D 4 | // Removed Max UI specific options and added Page grouping Metadata 5 | // Copyright 2020 Autodesk Inc, All rights reserved. This file is licensed under Apache 2.0 license 6 | // https://github.com/ADN-DevTech/3dsMax-OSL-Shaders/blob/master/LICENSE.txt 7 | 8 | float remap(color In, int mapping) 9 | { 10 | if (mapping < 3) 11 | return In[mapping]; 12 | if (mapping < 6) 13 | return 1.0 - In[mapping-3]; 14 | if (mapping == 6) return luminance(In); 15 | if (mapping == 7) return 1.0 - luminance(In); 16 | if (mapping == 8) return 0.0; 17 | return 1.0; 18 | } 19 | 20 | shader UberColorCorrect 21 | [[ string label = "Color Correction", 22 | // string category = "Color Correction", 23 | string version = "1.5" ]] 24 | ( 25 | color Input = 0.18 [[string page = "Input"]], 26 | 27 | int Bypass = 0 [[ string widget = "checkBox", string page = "Input" ]], 28 | float Overall = 1.0 [[ float min = 0.0, float max = 1.0, string page = "Input" ]], 29 | 30 | 31 | int HueRange = 0 [[ string widget = "checkBox", string page = "Hue Ranges" ]], 32 | 33 | color AffectHue = color(1.0, 0.4, 0.3) [[string page = "Hue Ranges"]], 34 | float HueRangeWidth = 10 [[ float min = 0.0, float max = 360, float step = 1.0, string page = "Hue Ranges" ]], 35 | float HueRangeSoftness = 10 [[ float min = 0.0, float max = 360, float step = 1.0, string page = "Hue Ranges" ]], 36 | 37 | int ChannelMapping = 0 [[ string widget = "checkBox", string page = "Channels" ]], 38 | 39 | int RedMapping = 0 40 | [[ 41 | int connectable = 0, 42 | string page = "Channels", 43 | string widget = "mapper", 44 | string options = 45 | "Red:0|Green:1|Blue:2|" 46 | "Red (Inverse):3|Green (Inverse):4|Blue (Inverse):5|" 47 | "Luminance:6|Luminance (Inverse):7|Zero:8|One:9" ]], 48 | int GreenMapping = 1 49 | [[ int connectable = 0, 50 | string page = "Channels", 51 | string widget = "mapper", 52 | string options = 53 | "Red:0|Green:1|Blue:2|" 54 | "Red (Inverse):3|Green (Inverse):4|Blue (Inverse):5|" 55 | "Luminance:6|Luminance (Inverse):7|Zero:8|One:9" ]], 56 | int BlueMapping = 2 57 | [[ int connectable = 0, 58 | string page = "Channels", 59 | string widget = "mapper", 60 | string options = 61 | "Red:0|Green:1|Blue:2|" 62 | "Red (Inverse):3|Green (Inverse):4|Blue (Inverse):5|" 63 | "Luminance:6|Luminance (Inverse):7|Zero:8|One:9" ]], 64 | 65 | int BrightnessAdjustment = 1 [[ string widget = "checkBox", string page = "Value Adjustments" ]], 66 | int Invert = 0 [[ string widget = "checkBox", int connectable=0, string page = "Value Adjustments" ]], 67 | float Brightness = 1.0 [[string page = "Value Adjustments"]], 68 | float Contrast = 1.0 [[string page = "Value Adjustments"]], 69 | float Lift = 0.0 [[string page = "Value Adjustments"]], 70 | float Pivot = 0.5 [[string page = "Value Adjustments"]], 71 | int InverseGamma = 0 [[ string widget = "checkBox", int connectable=0, string page = "Value Adjustments" ]], 72 | float Gamma = 1.0 [[string page = "Value Adjustments"]], 73 | 74 | int ColorAdjustment = 0 [[ string widget = "checkBox", int connectable=0, string page = "Color Adjustments" ]], 75 | float HueShift = 0.0 [[ float min = -1.0, float max = 1.0, string page = "Color Adjustments" ]], 76 | float Saturation = 1.0 [[ float min = 0.0, float max = 10.0, string page = "Color Adjustments" ]], 77 | color TintColor = 1.0 [[ string page = "Color Adjustments"]], 78 | float TintStrength = 0.0 [[ float min = 0.0, float max = 1.0, string page = "Color Adjustments" ]], 79 | 80 | 81 | int OutputTint = 0 [[ string widget = "checkBox", int connectable=0, string page = "Output Adjustments" ]], 82 | color Shadows = 0.0 [[ string page = "Output Adjustments"]], 83 | color Midtones = 0.2 [[ string page = "Output Adjustments"]], 84 | color Highlights = 1.0 [[ string page = "Output Adjustments"]], 85 | float MidtoneLum = 0.2 [[ float min = 0.0, float max = 1.0, string page = "Output Adjustments" ]], 86 | 87 | int Clamp = 1 [[ string widget = "checkBox", int connectable=0, string page = "Output Clamp" ]], 88 | float ClampLow = 0.0 [[string page = "Output Clamp"]], 89 | float ClampHi = 1.0 [[string page = "Output Clamp"]], 90 | 91 | // Outputs 92 | output color Out = 0.0, 93 | output float R = 0.0, 94 | output float G = 0.0, 95 | output float B = 0.0 96 | ) 97 | { 98 | float effect = Overall; 99 | 100 | Out = Input; 101 | 102 | if (!Bypass) 103 | { 104 | // Apply only to hue range 105 | if (HueRange) 106 | { 107 | // Tramsform to HSV space 108 | color hsv = transformc("rgb", "hsv", Input); 109 | // Tramsform to HSV space 110 | color hsv2 = transformc("rgb", "hsv", AffectHue); 111 | 112 | float huedifference = fabs(hsv[0] - hsv2[0]); 113 | // If distance in hue is larger than half 114 | // the color wheel, measure the other way around 115 | if (huedifference > 0.5) 116 | huedifference = 1.0 - huedifference; 117 | 118 | float HRW = HueRangeWidth / 360.0 / 2.0; 119 | float HRS = HueRangeSoftness / 360.0; 120 | 121 | // Are we outside the hue range? Then we need to modulate 122 | // the effect value to apply the effect less (or not at all) 123 | if (huedifference > HRW) 124 | { 125 | // Outside range - apply softness (if any) 126 | if (HRS > 0.0) 127 | effect *= smoothstep(0.0, 1.0, 1.0 - (huedifference - HRW) / HRS); 128 | else 129 | effect = 0.0; // No softness - just hard cut effect to zero 130 | } 131 | } 132 | 133 | // Apply the channel mapping 134 | if (ChannelMapping) 135 | { 136 | Out[0] = remap(Input, RedMapping); 137 | Out[1] = remap(Input, GreenMapping); 138 | Out[2] = remap(Input, BlueMapping); 139 | } 140 | 141 | // Brightness adjustment section 142 | if (BrightnessAdjustment) 143 | { 144 | // Invert, if requested 145 | if (Invert) Out = 1.0 - Out; 146 | // Multiply by Brightness 147 | Out = Out * Brightness; 148 | // Scale around Pivot by Contrast 149 | Out = ((Out - Pivot) * Contrast) + Pivot; 150 | // Add Lift 151 | Out = Out + Lift; 152 | // Apply Gamma 153 | if (Gamma != 1.0) 154 | Out = pow(max(0.0, Out), InverseGamma?1.0/Gamma:Gamma); 155 | } 156 | // Color adjustment section 157 | if (ColorAdjustment) 158 | { 159 | // Tramsform to HSV space 160 | color hsv = transformc("rgb", "hsv", Out); 161 | 162 | hsv[0] += HueShift; 163 | hsv[1] *= Saturation; 164 | 165 | // Convert back to RGB 166 | Out = transformc("hsv", "rgb", hsv); 167 | 168 | // Mix with tint color scaled by value 169 | Out = mix(Out, TintColor * hsv[2], TintStrength); 170 | } 171 | 172 | // Output Tint Section 173 | if (OutputTint) 174 | { 175 | color below = clamp((Out / MidtoneLum), 0.0, 1.0); 176 | color above = clamp((Out - MidtoneLum) / (1.0 - MidtoneLum), 0.0, 1.0); 177 | Out = mix(Shadows, mix(Midtones, Highlights, above), below); 178 | } 179 | 180 | if (Clamp) 181 | Out = clamp(Out, ClampLow, ClampHi); 182 | 183 | // Do the overall mix in of the effect 184 | Out = mix(Input, Out, effect); 185 | } 186 | 187 | // Output individual channels for convenience 188 | R = Out[0]; 189 | G = Out[1]; 190 | B = Out[2]; 191 | } -------------------------------------------------------------------------------- /UberColorCorrect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/UberColorCorrect.png -------------------------------------------------------------------------------- /UberConstant.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/UberConstant.jpg -------------------------------------------------------------------------------- /UberConstant.osl: -------------------------------------------------------------------------------- 1 | // Color Space Changes by Adrian Cruceru 2 | // Redshift Rendering Technologies 2021 3 | // Modified by Saul Espinosa 09-24-2021 to output multiple constants 4 | // This file is licensed under Apache 2.0 license 5 | 6 | shader changeSpace [[ string label = "Uber Constant", 7 | string category = "Color", string help = "Transforms from an OCIO color space to another and outputs constants" ]] 8 | ( // Input Color 9 | color inColor = 0.5 [[ string label = "Input Color", string page = "Input Color"]], 10 | // Color Spaces 11 | string toSpace = "" 12 | [[ string label = "Output Space", string widget = "colorspace", string page = "Color OCIO Colorspace"]], 13 | // Float Color 14 | float inFloat = 0 [[ string label = "Input Float", string page = "Float", float min = 0, float max = 100]], 15 | // Vector Color 16 | vector inVector = 0 [[ string label = "Input Vector", string page = "Vector"]], 17 | // Matrix Input 18 | matrix inMatrix = 1 [[ string label = "Input Matrix", string page = "Matrix"]], 19 | // Output 20 | output color outColor = 0 [[ string label = "Out Color", string page = "Output" ]], 21 | output float outFloat = 0 [[ string label = "Out Float", string page = "Output" ]], 22 | output vector outVector = 0 [[ string label = "Out Vector", string page = "Output" ]], 23 | output matrix outMatrix = 0 [[ string label = "Out Matrix", string page = "Output" ]] 24 | ) 25 | { 26 | outColor = transformc(toSpace, inColor); 27 | outFloat = inFloat; 28 | outVector = inVector; 29 | outMatrix = inMatrix; 30 | } 31 | -------------------------------------------------------------------------------- /UberScalarMath.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/UberScalarMath.jpg -------------------------------------------------------------------------------- /UberScalarMath.osl: -------------------------------------------------------------------------------- 1 | // This file is licensed under Apache 2.0 license 2 | // Created by Dominik Lingenover 3 | 4 | shader UberScalarMath ( 5 | int operation = 0 6 | [[ 7 | string label = "Operation", 8 | string widget = "popup", 9 | string options = "\ 10 | Add|Subtract|Multiply|Divide|Multiply Add|Power|Logarithm|Square Root|\ 11 | Inverse Square Root|Absolute|Exponent|Minimum|Maximum|Less Than|\ 12 | Greater Than|Sign|Compare|Round|Floor|\ 13 | Ceil|Truncate|Fraction|Modulo|Wrap|Snap|Ping-Pong|Sine|Cosine|Tangent|\ 14 | Arcsine|Arccosine|Arctangent|Arctan2|Hyperbolic Sine|Hyperbolic Cosine|\ 15 | Hyperbolic Tangent|To Radians|To Degrees" 16 | ]], 17 | float input1 = 0.0 18 | [[ 19 | float min = -1000.0, 20 | float max = 1000.0, 21 | float sensitivity = 0.1 22 | ]], 23 | float input2 = 0.0 24 | [[ 25 | float min = -1000.0, 26 | float max = 1000.0, 27 | float sensitivity = 0.1 28 | ]], 29 | float input3 = 0.0 30 | [[ 31 | float min = -1000.0, 32 | float max = 1000.0, 33 | float sensitivity = 0.1 34 | ]], 35 | output float Out = 0.0, 36 | ) { 37 | // Add 38 | // input1 = Value 1, input2 = Value 2 39 | if (operation == 0) { 40 | Out = input1 + input2; 41 | } 42 | //Subtract 43 | // input1 = Value 1, input2 = Value 2 44 | else if (operation == 1) { 45 | Out = input1 - input2; 46 | } 47 | // Multiply 48 | // input1 = Value 1, input2 = Value 2 49 | else if (operation == 2) { 50 | Out = input1 * input2; 51 | } 52 | // Divide 53 | // input1 = Value 1, input2 = Value 2 54 | else if (operation == 3) { 55 | Out = input1 / input2; 56 | } 57 | // Multiply Add 58 | // input1 = Value, input2 = Multiplier, input3 = Addend 59 | else if (operation == 4) { 60 | float temp = input1 * input2; 61 | Out = input3 + temp; 62 | } 63 | // Power 64 | // input1 = Base, input2 = Exponent 65 | else if (operation == 5) { 66 | Out = pow(input1, input2); 67 | } 68 | // Logarithm 69 | // input1 = Value, input2 = Base 70 | else if (operation == 6) { 71 | Out = log(input1, input2); 72 | } 73 | // Square Root 74 | // input1 = Value 75 | else if (operation == 7) { 76 | Out = sqrt(input1); 77 | } 78 | // Inverse Square Root 79 | // input1 = Value 80 | else if (operation == 8) { 81 | Out = inversesqrt(input1); 82 | } 83 | // Absolute 84 | // input1 = Value 85 | else if (operation == 9) { 86 | Out = abs(input1); 87 | } 88 | // Exponent 89 | // input1 = Value 90 | else if (operation == 10) { 91 | Out = exp(input1); 92 | } 93 | // Minimum 94 | // input1 = Value 1, input2 = Value 2 95 | else if (operation == 11) { 96 | Out = min(input1, input2); 97 | } 98 | // Maximum 99 | // input1 = Value 1, input2 = Value 2 100 | else if (operation == 12) { 101 | Out = max(input1, input2); 102 | } 103 | // Less Than 104 | // input1 = Value, input2 = Threshold 105 | else if (operation == 13) { 106 | Out = select(1.0, 0.0, input1 < input2); 107 | } 108 | // Greater Than 109 | // input1 = Value, input2 = Threshold 110 | else if (operation == 14) { 111 | Out = select(1.0, 0.0, input1 > input2); 112 | } 113 | // Sign 114 | // input1 = Value 115 | else if (operation == 15) { 116 | Out = sign(input1); 117 | } 118 | // Compare 119 | // input1 = Value 1, input2 = Value 2, input3 = Epsilon 120 | else if (operation == 16) { 121 | Out = select(1.0, 0.0, (input1 - input2) <= input3); 122 | } 123 | // Round 124 | // input1 = Value 125 | else if (operation == 17) { 126 | Out = round(input1); 127 | } 128 | // Floor 129 | // input1 = Value 130 | else if (operation == 18) { 131 | Out = floor(input1); 132 | } 133 | // Ceil 134 | // input1 = Value 135 | else if (operation == 19) { 136 | Out = ceil(input1); 137 | } 138 | // Truncate 139 | // input1 = Value 140 | else if (operation == 20) { 141 | Out = trunc(input1); 142 | } 143 | // Fraction 144 | // input1 = Value 145 | else if (operation == 21) { 146 | float temp = trunc(input1); 147 | Out = input1 - temp; 148 | } 149 | // Modulo 150 | // input1 = Value 1, input2 = Value 2 151 | else if (operation == 22) { 152 | Out = mod(input1, input2); 153 | } 154 | // Wrap 155 | // input1 = Value, input2 = Min, input3 = Max 156 | else if (operation == 23) { 157 | Out = fmod(((fmod((input1 - input2), (input3 - input2))) + (input3 - input2)), (input3 - input2)) + input2; 158 | } 159 | // Snap 160 | // input1 = Value, input2 = Increment 161 | else if (operation == 24) { 162 | Out = (input1 + (input2 / 2)) - fmod((input1 + (input2 / 2)), input2); 163 | } 164 | // Ping-Pong 165 | // input1 = Value, input2 = Scale 166 | else if (operation == 25) { 167 | Out = 0.0 + fabs(fmod((input1 + input2), (input2 * 2)) - input2); 168 | } 169 | // Sine 170 | // input1 = Value 171 | else if (operation == 26) { 172 | Out = sin(input1); 173 | } 174 | // Cosine 175 | // input1 = Value 176 | else if (operation == 27) { 177 | Out = cos(input1); 178 | } 179 | // Tangent 180 | // input1 = Value 181 | else if (operation == 28) { 182 | Out = tan(input1); 183 | } 184 | // Arcsine 185 | // input1 = Value 186 | else if (operation == 29) { 187 | Out = asin(input1); 188 | } 189 | // input1 = Value 190 | // Arccosine 191 | else if (operation == 30) { 192 | Out = acos(input1); 193 | } 194 | // Arctangent 195 | // input1 = Value 196 | else if (operation == 31) { 197 | Out = atan(input1); 198 | } 199 | // Arctan2 200 | // input1 = Value 1, input2 = Value 2 201 | else if (operation == 32) { 202 | Out = atan2(input1, input2); 203 | } 204 | // Hyperbolic Sine 205 | // input1 = Value 206 | else if (operation == 33) { 207 | Out = sinh(input1); 208 | } 209 | // Hyperbolic Cosine 210 | // input1 = Value 211 | else if (operation == 34) { 212 | Out = cosh(input1); 213 | } 214 | // Hyperbolic Tangent 215 | // input1 = Value 216 | else if (operation == 35) { 217 | Out = tanh(input1); 218 | } 219 | // To Radians 220 | // input1 = Value 221 | else if (operation == 36) { 222 | Out = radians(input1); 223 | } 224 | // To Degrees 225 | // input1 = Value 226 | else if (operation == 37) { 227 | Out = degrees(input1); 228 | } 229 | } 230 | -------------------------------------------------------------------------------- /UberTexture.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/UberTexture.jpg -------------------------------------------------------------------------------- /UberTexture.osl: -------------------------------------------------------------------------------- 1 | // Author: Adrian Cruceru 2 | // simple texture node with extra controls 3 | // © Adrian Cruceru 2021 4 | // This file is licensed under Apache 2.0 license 5 | 6 | shader oslTexture 7 | [[ string label = "Uber Texture" ]] 8 | ( 9 | string fileName = "" 10 | [[ string widget="filename", 11 | string page = "Image" ]], 12 | 13 | // Color Spaces 14 | // might not be needed as the filename widget has this internally 15 | string fileColorSpace = "" 16 | [[ string label = "Colorspace", string page = "Color Space Conversion", string widget = "colorspace"]], 17 | // UVs 18 | string uTiling = "default" 19 | [[ string widget = "popup", 20 | string label = "U Tiling", 21 | string page = "Scale", 22 | string options = "default|periodic|clamp|mirror|black" ]], 23 | string vTiling = "default" 24 | [[ string widget = "popup", 25 | string label = "V Tiling", 26 | string page = "Scale", 27 | string options = "default|periodic|clamp|mirror|black" ]], 28 | // Transforms 29 | float scale = 1 30 | [[ string label = "Scale", 31 | string page = "Scale", 32 | float softmin = 0, 33 | float softmax = 10, 34 | float slidermin = 0, 35 | float slidermax = 10, 36 | float sensitivity = 0.001 ]], 37 | float uRepeats = 1 38 | [[ string label = "U Repeats", 39 | string page = "Scale", 40 | float softmin = 0, 41 | float softmax = 10, 42 | float slidermin = 0, 43 | float slidermax = 10, 44 | float sensitivity = 0.001 ]], 45 | float vRepeats = 1 46 | [[ string label = "V Repeats", 47 | string page = "Scale", 48 | float softmin = 0, 49 | float softmax = 10, 50 | float slidermin = 0, 51 | float slidermax = 10, 52 | float sensitivity = 0.001 ]], 53 | float uOffset = 0 54 | [[ string label = "U Offset", 55 | string page = "Offset", 56 | float slidermin = -1, 57 | float slidermax = 1, 58 | float softmin = -1, 59 | float softmax = 1, 60 | float sensitivity = 0.001 ]], 61 | float vOffset = 0 62 | [[ string label = "V Offset", 63 | string page = "Offset", 64 | float slidermin = -1, 65 | float slidermax = 1, 66 | float softmin = -1, 67 | float softmax = 1, 68 | float sensitivity = 0.001 ]], 69 | float angle = 0 70 | [[ string label = "Angle", 71 | string page = "Rotate", 72 | float slidermin = -360, 73 | float slidermax = 360, 74 | float softmin = -360, 75 | float softmax = 360, 76 | float sensitivity = 0.001 ]], 77 | float uCenter = 0.5 78 | [[ string label = "Center U", 79 | string page = "Rotate", 80 | float slidermin = -1, 81 | float slidermax = 1, 82 | float softmin = -1, 83 | float softmax = 1, 84 | float sensitivity = 0.001 ]], 85 | float vCenter = 0.5 86 | [[ string label = "Center V", 87 | string page = "Rotate", 88 | float slidermin = -1, 89 | float slidermax = 1, 90 | float softmin = -1, 91 | float softmax = 1, 92 | float sensitivity = 0.001 ]], 93 | 94 | color colorGain = 1 95 | [[ string label = "Gain", 96 | string page = "Adjust"]], 97 | float gainMul = 1 98 | [[ string label = "Gain Intensity", 99 | string page = "Adjust", 100 | float softmin = 0, 101 | float softmax = 10, 102 | float slidermin = 0, 103 | float slidermax = 10, 104 | float sensitivity = 0.001 ]], 105 | color colorOffset = 0 106 | [[ string label = "Offset", 107 | string page = "Adjust"]], 108 | float offsetMul = 1 109 | [[ string label = "Offset Intensity", 110 | string page = "Adjust", 111 | float softmin = -10, 112 | float softmax = 10, 113 | float slidermin = -10, 114 | float slidermax = 10, 115 | float sensitivity = 0.001 ]], 116 | // exposure 117 | float exposure = 0 118 | [[ string label = "Exposure", 119 | string page = "Adjust", 120 | float softmin = -10, 121 | float softmax = 10, 122 | float slidermin = -10, 123 | float slidermax = 10, 124 | float sensitivity = 0.001 ]], 125 | // negative 126 | int invert = 0 127 | [[ string label = "Color Invert", 128 | string page = "Adjust", 129 | string widget = "checkBox"]], 130 | 131 | // outputs 132 | output color outColor=0 133 | [[ string label = "Out Color"]], 134 | output string tex0 = "" 135 | [[ string label = "Tex 0"]] 136 | ) 137 | { 138 | // uv coord 139 | point p = point("object", u, v, 0); 140 | 141 | // rotate about a center pivot 142 | point r = transform("object", rotate( p, radians(angle), 143 | point(uCenter, vCenter, 0), point(uCenter, vCenter, 1))); 144 | float rotU = r[0]; 145 | float rotV = r[1]; 146 | 147 | // offset 148 | float uTranslate = (rotU - -uOffset); 149 | float vTranslate = (rotV - -vOffset); 150 | 151 | // repeats and scale 152 | float uCoord = clamp(mod(uTranslate * uRepeats / (1.0/scale), 1), 0, 1); 153 | float vCoord = clamp(mod(vTranslate * vRepeats / (1.0/scale), 1), 0, 1); 154 | 155 | // texture 156 | color outTexture = texture( fileName, uCoord, -vCoord, "swrap", uTiling, "twrap", vTiling); 157 | // color space conversion 158 | 159 | // invert 160 | if (invert == 1) 161 | outTexture = 1 - outTexture; 162 | 163 | // gain and offset controls 164 | outTexture = (outTexture * colorGain *gainMul) + (colorOffset*offsetMul); 165 | 166 | // exposure 167 | outTexture *= pow(2,exposure); 168 | 169 | // color space change 170 | color textureSampleRAW = transformc("ACEScg", "scene-linear Rec.709-sRGB", outTexture); 171 | outColor = transformc(fileColorSpace, "ACEScg", textureSampleRAW); 172 | 173 | // string output 174 | tex0 = fileName; 175 | } 176 | -------------------------------------------------------------------------------- /UberVectorMath.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/UberVectorMath.jpg -------------------------------------------------------------------------------- /UberVectorMath.osl: -------------------------------------------------------------------------------- 1 | // This file is licensed under Apache 2.0 license 2 | // Created by Dominik Lingenover 3 | 4 | shader UberScalarMath ( 5 | int operation = 0 6 | [[ 7 | string label = "Operation", 8 | string widget = "popup", 9 | int connectable = 0, 10 | string options = "\ 11 | Add|Subtract|Multiply|Divide|Multiply Add|Cross Product|Project|\ 12 | Reflect|Refract|Faceforward|Dot Product|Distance|Length|Scale|\ 13 | Normalize|Wrap|Snap|Floor|Ceil|Modulo|Fraction|Absolute|Minimum|\ 14 | Maximum|Sine|Cosine|Tangent" 15 | ]], 16 | vector input1 = 0.0 17 | [[ 18 | vector min = -1000.0, 19 | vector max = 1000.0 20 | ]], 21 | vector input2 = 0.0 22 | [[ 23 | vector min = -1000.0, 24 | vector max = 1000.0 25 | ]], 26 | vector input3 = 0.0 27 | [[ 28 | vector min = -1000.0, 29 | vector max = 1000.0 30 | ]], 31 | output vector Out = color(0.0, 0.0, 0.0), 32 | ) { 33 | // Add 34 | // input1 = Value 1, input2 = Value 2 35 | if (operation == 0) { 36 | Out = input1 + input2; 37 | } 38 | //Subtract 39 | // input1 = Value 1, input2 = Value 2 40 | else if (operation == 1) { 41 | Out = input1 - input2; 42 | } 43 | // Multiply 44 | // input1 = Value 1, input2 = Value 2 45 | else if (operation == 2) { 46 | Out = input1 * input2; 47 | } 48 | // Divide 49 | // input1 = Value 1, input2 = Value 2 50 | else if (operation == 3) { 51 | Out = input1 / input2; 52 | } 53 | // Multiply Add 54 | // input1 = Value, input2 = Multiplier, input3 = Addend 55 | else if (operation == 4) { 56 | vector temp = input1 * input2; 57 | Out = input3 + temp; 58 | } 59 | // Cross Product 60 | // input1 = Value 1, input2 = Value 2 61 | else if (operation == 5) { 62 | Out = cross(input1, input2); 63 | } 64 | // Project 65 | // input1 = Vector to project, input2 = Vector to project on 66 | else if (operation == 6) { 67 | Out = (dot(input1, input2) / pow(length(input2), 2)) * input2; 68 | } 69 | // Reflect 70 | // input1 = Incident Vector, input2 = Surface Orientation (normalized) 71 | else if (operation == 7) { 72 | Out = reflect(input1, normalize(input2)); 73 | } 74 | // Refract 75 | // input1 = Incident Vector, input2 = Surface Orientation, input3 = IOR 76 | else if (operation == 8) { 77 | Out = refract(input1, input2, input3[0]); 78 | } 79 | // Faceforward 80 | // input1 = Value, input2 = Incident Vector, input3 = Reference Normal 81 | else if (operation == 9) { 82 | Out = faceforward(input1, input2, input3); 83 | } 84 | // Dot Product 85 | // input1 = Value 1, input2 = Value 2 86 | else if (operation == 10) { 87 | Out = dot(input1, input2); 88 | } 89 | // Distance 90 | // input1 = Value 1, input2 = Value 2 91 | else if (operation == 11) { 92 | Out = distance(input1, input2); 93 | } 94 | // Length 95 | // input1 = Value 1 96 | else if (operation == 12) { 97 | Out = length(input1); 98 | } 99 | // Scale 100 | // input1 = Value, input2 = Scale (Float) 101 | else if (operation == 13) { 102 | Out = input1 * input2; 103 | } 104 | // Normalize 105 | // input1 = Value 106 | else if (operation == 14) { 107 | Out = normalize(input1); 108 | } 109 | // Wrap 110 | // input1 = Value, input2 = Min, input3 = Max 111 | else if (operation == 15) { 112 | Out = fmod(((fmod((input1 - input2), (input3 - input2))) + (input3 - input2)), (input3 - input2)) + input2; 113 | } 114 | // Snap 115 | // input1 = Value, input2 = Increment 116 | else if (operation == 16) { 117 | Out = (input1 + (input2 / 2)) - fmod((input1 + (input2 / 2)), input2); 118 | } 119 | // Floor 120 | // input1 = Value 121 | else if (operation == 17) { 122 | Out = floor(input1); 123 | } 124 | // Ceil 125 | // input1 = Value 126 | else if (operation == 18) { 127 | Out = ceil(input1); 128 | } 129 | // Modulo 130 | // input1 = Value 1, input2 = Value 2 131 | else if (operation == 19) { 132 | Out = mod(input1, input2); 133 | } 134 | // Fraction 135 | // input1 = Value 136 | else if (operation == 20) { 137 | vector temp = trunc(input1); 138 | Out = input1 - temp; 139 | } 140 | // Absolute 141 | // input1 = Value 142 | else if (operation == 21) { 143 | Out = abs(input1); 144 | } 145 | // Minimum 146 | // input1 = Value 1, input2 = Value 2 147 | else if (operation == 22) { 148 | Out = min(input1, input2); 149 | } 150 | // Maximum 151 | // input1 = Value 1, input2 = Value 2 152 | else if (operation == 23) { 153 | Out = max(input1, input2); 154 | } 155 | // Sine 156 | // input1 = Value 157 | else if (operation == 24) { 158 | Out = sin(input1); 159 | } 160 | // Cosine 161 | // input1 = Value 162 | else if (operation == 25) { 163 | Out = cos(input1); 164 | } 165 | // Tangent 166 | // input1 = Value 167 | else if (operation == 26) { 168 | Out = tan(input1); 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /Wavelength.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/Wavelength.jpg -------------------------------------------------------------------------------- /Wavelength.osl: -------------------------------------------------------------------------------- 1 | // Wavelength Color Shader 2 | // WaveLength.osl, by Zap Andersson 3 | // Modified: 2019-11-26 4 | // Copyright 2019 Autodesk Inc, All rights reserved. This file is licensed under Apache 2.0 license 5 | // https://github.com/ADN-DevTech/3dsMax-OSL-Shaders/blob/master/LICENSE.txt 6 | 7 | shader WaveLength 8 | [[ string help = "Modulates a color between two wavelengths of light", 9 | string label = "Wavelength Color", 10 | string category = "Utility" 11 | ]] 12 | ( 13 | float Input = u, 14 | float Min = 400.0, 15 | float Max = 700.0, 16 | output color Col = 0.0, 17 | ) 18 | { 19 | Col = wavelength_color(mix(Min, Max, Input)); 20 | } 21 | -------------------------------------------------------------------------------- /Weave.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/Weave.jpg -------------------------------------------------------------------------------- /Weave.osl: -------------------------------------------------------------------------------- 1 | // Making a simple Weave, can be used for carbon fiber, cloth, or similar 2 | // Weave.osl, by Zap Andersson 3 | // Modified: 2018-12-06 4 | // Modified: 2021-02-22 by Saul Espinosa for Redshift 3D 5 | // Copyright 2018 Autodesk Inc, All rights reserved. This file is licensed under Apache 2.0 license 6 | // https://github.com/ADN-DevTech/3dsMax-OSL-Shaders/blob/master/LICENSE.txt 7 | 8 | shader Weave 9 | [[ string help="Weave
A simple threaded weave shader. Can be used for everything from cloth to carbon fiber.", 10 | string label = "Weave", 11 | string URL ="https://github.com/ADN-DevTech/3dsMax-OSL-Shaders" ]] 12 | ( 13 | point UVW = point(u,v,0), 14 | float Scale = 0.2, 15 | // Inputs 16 | color U_Color = 0.2 [[ string label = "U Color"]], 17 | color V_Color = 0.5 [[ string label = "V Color"]], 18 | 19 | float Width = 0.5 20 | [[ float min = 0.0, float max = 1.0 ]], 21 | float Roundness = 1.0 22 | [[ float min = 0.0, float max = 1.0 ]], 23 | float RoundnessBump = 1.0 24 | [[ float min = 0.0, float max = 2.0 ]], 25 | float RoundShadow = 0.5 26 | [[ float min = 0.0, float max = 1.0 ]], 27 | float WeaveBump = 0.5 28 | [[ float min = 0.0, float max = 2.0 ]], 29 | float WeaveShadow = 0.4 30 | [[ float min = 0.0, float max = 1.0 ]], 31 | float Frizz = 0.0 32 | [[ float min = 0.0, float max = 1.0 ]], 33 | float FrizzBump = 0.0 34 | [[ float min = 0.0, float max = 2.0 ]], 35 | float FrizzScale = 0.1 36 | [[ float min = 0.0, float max = 10.0 ]], 37 | float Bendyness = 0.2 38 | [[ float min = 0.0, float max = 1.0 ]], 39 | float BendynessScale = 3.0 40 | [[ float min = 0.0, float max = 10.0 ]], 41 | float OpacityFade = 0.0 42 | [[ float min = 0.0, float max = 1.0 ]], 43 | 44 | 45 | // Outputs 46 | output color Col = 0.0, 47 | output float Bump = 0.5, 48 | output float ThreadID = 0, 49 | output float Opacity = 0.0, 50 | ) 51 | { 52 | // Compute the scaled point 53 | point uvw = UVW / Scale; 54 | 55 | // Add frizz to the width 56 | float frizz = noise("perlin", uvw / FrizzScale) ; 57 | float w2 = Width + frizz * Frizz; 58 | float w = w2 * 0.5; 59 | 60 | int uf = int(floor(uvw[0])); 61 | int vf = int(floor(uvw[1])); 62 | 63 | // Compute an independent per-thread randomness for bending it 64 | float ubend = noise("perlin", uvw[1] / BendynessScale + uf) * Bendyness; 65 | float vbend = noise("perlin", uvw[0] / BendynessScale + vf) * Bendyness; 66 | 67 | // Compute the thread coordinates 68 | float sx = uvw[0] - uf + ubend; 69 | float sy = uvw[1] - vf + vbend; 70 | 71 | int onU = (sy > 0.5 - w && sy < 0.5 + w); 72 | int onV = (sx > 0.5 - w && sx < 0.5 + w); 73 | 74 | float uu = (sy - (0.5 - w)) / w2; 75 | float vv = (sx - (0.5 - w)) / w2; 76 | 77 | // Odd or even U / V ? 78 | int oddU = uf % 2; 79 | int oddV = vf % 2; 80 | 81 | // Are we on neither thread? Just return 82 | if (onU == 0 && onV == 0) return; 83 | 84 | int U_on_top = (oddU ^ oddV) == 0; 85 | 86 | // Both - disambiguate 87 | if (onU && onV) 88 | { 89 | onU = U_on_top; 90 | onV = onU == 0; 91 | } 92 | 93 | // Return a random ID for each thread 94 | ThreadID = 1 + float((cellnoise(uf) * onV + cellnoise(vf) * onU) * 1024.0) + onU; 95 | 96 | // Which color to return? 97 | if (onU) 98 | Col = U_Color; 99 | else 100 | Col = V_Color; 101 | 102 | // Compute the bump and fake "Shadowing" 103 | float r = Roundness; 104 | float weave = (onU) ? sin((uvw[0] + oddV) * M_PI) : sin((uvw[1] + oddU + 1.0) * M_PI); 105 | 106 | float ubulge = sin(uu * M_PI); 107 | float vbulge = sin(vv * M_PI); 108 | 109 | float bulge = pow((onU ? ubulge : vbulge), r); 110 | 111 | Opacity = max(pow(ubulge, OpacityFade), pow(vbulge, OpacityFade)); 112 | 113 | Bump = 0.2 + weave * WeaveBump + bulge * RoundnessBump + frizz * FrizzBump; 114 | Col *= mix(1.0, bulge, RoundShadow); 115 | Col *= mix(1.0, weave, WeaveShadow); 116 | } 117 | -------------------------------------------------------------------------------- /WoodGrain.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maxon-Computer/Redshift-OSL-Shaders/b9892125b630f4bfad633e347ce1998ae919b276/WoodGrain.jpg -------------------------------------------------------------------------------- /WoodGrain.osl: -------------------------------------------------------------------------------- 1 | /* 2 | * WoodGrain.osl by Michel J. Anders (c)2012 3 | * from https://github.com/sambler/osl-shaders 4 | * 5 | * license: cc-by-sa 6 | * 7 | * original script from - 8 | * http://blenderthings.blogspot.com.au/2013/01/an-osl-wood-shader-for-blender-cycles.html 9 | * Modified by Saul Espinosa for Redshift 3D 2020-1-11 10 | */ 11 | 12 | 13 | // for the original renderman shader, check http://www.larrygritz.com/arman/materials.html 14 | 15 | // adapted from larry gritz advanced renderman patterns.h 16 | float smoothpulse (float e0, float e1, float e2, float e3, float x) 17 | { 18 | return smoothstep(e0,e1,x) - smoothstep(e2,e3,x); 19 | } 20 | 21 | /* A pulse train of smoothsteps: a signal that repeats with a given 22 | * period, and is 0 when 0 <= mod(x/period,1) < edge, and 1 when 23 | * mod(x/period,1) > edge. 24 | */ 25 | float smoothpulsetrain (float e0, float e1, float e2, float e3, float period, float x) 26 | { 27 | return smoothpulse (e0, e1, e2, e3, mod(x,period)); 28 | } 29 | 30 | // adapted from larry gritz advanced renderman noises.h 31 | /* fractional Brownian motion 32 | * Inputs: 33 | * p position 34 | * octaves max # of octaves to calculate 35 | * lacunarity frequency spacing between successive octaves 36 | * gain scaling factor between successive octaves 37 | */ 38 | 39 | /* A vector-valued antialiased fBm. */ 40 | vector vfBm (point p, float octaves, float lacunarity, float gain) 41 | { 42 | float amp = 1; 43 | point pp = p; 44 | vector sum = 0; 45 | float i; 46 | 47 | for (i = 0; i < octaves; i += 1) { 48 | vector d = snoise(pp); 49 | sum += amp * d; 50 | amp *= gain; 51 | pp *= lacunarity; 52 | } 53 | return sum; 54 | } 55 | 56 | // adapted from larry gritz oak.sl and oak.h 57 | // original comments between /* ... */ 58 | // my comments start with // 59 | // note that I dropped the whole filterwidth stuff, partly 60 | // because I don't think it necessary in Blender Cycles, partly 61 | // because the derivatives and area() function doesn't seem to work (yet) 62 | // all specialized snoise defines are replaced by snoise() function calls 63 | float oaktexture (point Pshad, 64 | float dPshad, 65 | float ringfreq, 66 | float ringunevenness, 67 | float grainfreq, 68 | float ringnoise, 69 | float ringnoisefreq, 70 | float trunkwobble, 71 | float trunkwobblefreq, 72 | float angularwobble, 73 | float angularwobblefreq, 74 | float ringy, 75 | float grainy) 76 | { 77 | /* We shade based on Pshad, but we add several layers of warping: */ 78 | /* Some general warping of the domain */ 79 | vector offset = vfBm(Pshad*ringnoisefreq, 2, 4, 0.5); 80 | 81 | point Pring = Pshad + ringnoise*offset; 82 | /* The trunk isn't totally steady xy as you go up in z */ 83 | vector d = snoise(Pshad[2]*trunkwobblefreq) ; 84 | Pring += trunkwobble * d * vector(1,1,0); 85 | 86 | /* Calculate the radius from the center. */ 87 | float r = hypot(Pring[0], Pring[1]) * ringfreq; 88 | /* Add some noise around the trunk */ 89 | r += angularwobble * smoothstep(0,5,r) 90 | * snoise (angularwobblefreq*(Pring)*vector(1,1,0.1)); 91 | 92 | /* Now add some noise so all rings are not equal width */ 93 | r += ringunevenness*snoise(r); 94 | 95 | float inring = smoothpulsetrain (0.1, 0.55, 0.7, 0.95, 1, r); 96 | 97 | point Pgrain = Pshad*grainfreq*vector(1,1,0.05); 98 | float dPgrain = dPshad; //dropped filterwidthp(Pgrain); 99 | float grain = 0; 100 | float i, amp=1; 101 | for (i = 0; i < 2; i += 1) { 102 | float grain1valid = 1-smoothstep(0.2,0.6,dPgrain); 103 | if (grain1valid > 0) { 104 | float g = grain1valid * snoise (Pgrain); 105 | g *= (0.3 + 0.7*inring); 106 | g = pow(clamp(0.8 - (g),0,1),2); 107 | g = grainy * smoothstep (0.5, 1, g); 108 | if (i == 0) 109 | inring *= (1-0.4*grain1valid); 110 | grain = max (grain, g); 111 | } 112 | Pgrain *= 2; 113 | dPgrain *= 2; 114 | amp *= 0.5; 115 | } 116 | 117 | return mix (inring*ringy, 1, grain); 118 | } 119 | 120 | // larry gritz' original shader was a closure but this shader 121 | // provides different outputs that you can plug into your own 122 | // closures/shaders 123 | surface oak 124 | [[ string help = "Procedural Wood Grain Shader", 125 | string label = "Wood Grain" ]] 126 | ( 127 | point Vector = P, 128 | color LightWood = color(0.5, 0.2, 0.067), 129 | color DarkWood = color(0.15, 0.077, 0.028), 130 | float Sharpness = 0.01 131 | [[ 132 | float min = 0, float max = 1 133 | ]], 134 | float Ringy = 1.0 135 | [[ 136 | float min = 0, float max = 5 137 | ]], 138 | float RingFreq = 8.0 139 | [[ 140 | float min = 0, float max = 50 141 | ]], 142 | float RingUnevenness = 0.5 143 | [[ 144 | float min = 0, float max = 50 145 | ]], 146 | float RingNoise = 0.02 147 | [[ 148 | float min = 0, float max = 1 149 | ]], 150 | float RingNoiseFreq = 1.0 151 | [[ 152 | float min = 0, float max = 1 153 | ]], 154 | float Grainy = 0.5 155 | [[ 156 | float min = 0, float max = 1 157 | ]], 158 | float GrainFreq = 25.0 159 | [[ 160 | float min = 0, float max = 50 161 | ]], 162 | float TrunkWobble = 0.15 163 | [[ 164 | float min = 0, float max = 50 165 | ]], 166 | float TrunkWobbleFreq = 0.025 167 | [[ 168 | float min = 0, float max = 1 169 | ]], 170 | float AngularWobble = 1.0 171 | [[ 172 | float min = 0, float max = 1 173 | ]], 174 | float AngularWobbleFreq = 1.5 175 | [[ 176 | float min = 0, float max = 5 177 | ]], 178 | output color Color = 0, 179 | output float Specular = 0.1, 180 | output float Roughness = 0.1, 181 | output float Displacement = 0.0 ) 182 | { 183 | float wood = oaktexture (Vector, Sharpness, RingFreq, RingUnevenness, GrainFreq, 184 | RingNoise, RingNoiseFreq, TrunkWobble, TrunkWobbleFreq, 185 | AngularWobble, AngularWobbleFreq, Ringy, Grainy); 186 | 187 | Color = mix (LightWood, DarkWood, wood); 188 | Displacement = -wood; // lightwood = 0, darkwood is deeper/lower = -1 189 | Specular = 0.1*(1.0-0.5*wood); // darkwood is less specular 190 | Roughness = 0.1+0.1*wood; // and rougher 191 | } 192 | --------------------------------------------------------------------------------