diff --git a/OSL/ADN-User Submitted/MadsD/Falloff.gif b/OSL/ADN-User Submitted/MadsD/Falloff.gif new file mode 100644 index 0000000..c0c0df7 Binary files /dev/null and b/OSL/ADN-User Submitted/MadsD/Falloff.gif differ diff --git a/OSL/ADN-User Submitted/MadsD/Falloff.osl b/OSL/ADN-User Submitted/MadsD/Falloff.osl new file mode 100644 index 0000000..34ce804 --- /dev/null +++ b/OSL/ADN-User Submitted/MadsD/Falloff.osl @@ -0,0 +1,52 @@ +// Updated by Mads Drøschler 5. November 2020 with a flip switch and some additional grading floats exposed fro flip state. + +// Falloff shader +// Falloff.osl, by Changsoo Eun, adapted by Zap Andersson +// Modified: 2019-11-26 +// Copyright 2019 Autodesk Inc, All rights reserved. This file is licensed under Apache 2.0 license +// https://github.com/ADN-DevTech/3dsMax-OSL-Shaders/blob/master/LICENSE.txt + +shader Falloff +[[ string help = "Falloff map, OSL version", + string category = "Utility", + string label = "Falloff"]] +( + color Face = 0.0, + color Away = 1.0, + string Coordspace = "camera" + [[ string widget="popup", + string help = "world, object, cmera, shader, screen, NDC, raster, or an explicitly named coordinate system", + string options="world|object|camera|shader|screen|NDC|raster", + int editable=1 ]], + vector FalloffDirection = vector (0.0, 0.0, 1.0) + [[ string label = "Falloff Direction", + string help = "Chooses the direction of falloff. Z-axis(0, 0, 1) is viewing direction for camera." ]], + int Type = 0 + [[ string widget = "mapper", + string help = "Perpendicular/Parallel : Sets the angular falloff ranges between face normals that are perpendicular to the falloff direction and normals that are parallel to the falloff direction. The falloff range is based on a 90-degree change in normal direction. (Default.) Towards/Away : Sets the angular falloff ranges between face normals that face toward (parallel to) the falloff direction and normals that face away from the falloff direction. The falloff range is based on a 180-degree change in normal direction." , + string options = "Perpendicular/Parallel:0|Towards/Away:1" ]], + float Power = 1.0 + [[ string help = "Adjusts the curve of how the falloff is applied. Higher gives thinner edges", + float min = 0.01, float max=100.0 ]], + int Flip = 0[[string widget = "checkBox"]], + float hardness = 0[[float min = 0, float max = 1]], + + float softness = 0.2, + output color Out = 0.0, + output float MixAmount = 0.0 +) +{ + vector normalDir = transform(Coordspace, N); + MixAmount = dot (normalDir, FalloffDirection); + if (Power != 1.0) + MixAmount = 1.0 - pow(1.0 - MixAmount, Power); + if (Type == 1) + MixAmount = (MixAmount + 1.0)/2.0; + + + Out = mix(Away, Face, MixAmount); + + Flip<1?Out = Out : Out = pow(mix(1-Out,hardness,softness),1/0.1); + + +} diff --git a/OSL/ADN-User Submitted/MadsD/FrontBack.osl b/OSL/ADN-User Submitted/MadsD/FrontBack.osl new file mode 100644 index 0000000..156eecb --- /dev/null +++ b/OSL/ADN-User Submitted/MadsD/FrontBack.osl @@ -0,0 +1,24 @@ +// Shader used to control 2 sided shader structures as control map. +// FrontBack.osl, by Zap Andersson. +// Udated with license, formatting, integration into Arnold Converter - by Mads Drøschler. +// Modified: 2019-11-23 +// +// Copyright 2018 Autodesk Inc, All rights reserved. This file is licensed under Apache 2.0 license +// https://github.com/ADN-DevTech/3dsMax-OSL-Shaders/blob/master/LICENSE.txt + +shader FrontBack + [[ + string category = "MDShaders" + ]] +( + color Front = color(1,0,0), + color Back = color(0,1,0), + + output color Out = 0 +) +{ + if (backfacing()) + Out = Back; + else + Out = Front; +} diff --git a/OSL/ADN-User Submitted/MadsD/NormalBlend.osl b/OSL/ADN-User Submitted/MadsD/NormalBlend.osl new file mode 100644 index 0000000..feeee66 --- /dev/null +++ b/OSL/ADN-User Submitted/MadsD/NormalBlend.osl @@ -0,0 +1,80 @@ +// NormalBlend.osl +// by Mads Drøschler +// Last update 10.12.2019 +// Based on an article by Colin Barré-Brisebois and Stephen Hill regarding different normal blend types. +// License MIT + +vector rnm(vector A, vector B) { + vector a = A * vector( 2, 2, 2) + vector(-1, -1, 0); + vector b = B * vector(-2, -2, 2) + vector( 1, 1, -1); + vector r = a * dot(a, b) / a[2] - b; + return r * 0.5 + 0.5; +} + +shader RNMNormalBlend + [[ + string help = "Use this map to blend normals, the blend method is reoriented and superior to many other blend types", + string category = "MDShaders", + ]] +( + color NormalA = color(0.5,0.5,1.0), + int Enable_NormalA = 1 + [[ + string widget = "checkBox", + ]], + float MixA = 1.0 + [[ + float min = 0, + float max = 1 + ]], + color NormalB = color(0.5,0.5,1.0), + int Enable_NormalB = 1 + [[ + string widget = "checkBox", + ]], + float MixB = 1.0 + [[ + float min = 0, + float max = 1 + ]], + int FlipOrder = 0 + [[ + string widget = "checkBox", + ]], + + output color Out = 0, +) +{ + color C = color(0.5,0.5,1.0); + color pipeA,pipeB = 0; + + if ( FlipOrder == 0 ) + { + pipeA = NormalA; + pipeB = NormalB; + } + else + { + pipeA = NormalB; + pipeB = NormalA; + } + + if ( Enable_NormalA == 1 ) + { + pipeA = mix(pipeA,C,1-MixA); + } + else + { + pipeA = C; + } + if( Enable_NormalB == 1 ) + { + pipeB = mix(pipeB,C,1-MixB); + } + else + { + pipeB = C; + } + + Out = rnm(pipeA,pipeB); +} \ No newline at end of file diff --git a/OSL/ADN-User Submitted/MadsD/VolumeDisplacement.osl b/OSL/ADN-User Submitted/MadsD/VolumeDisplacement.osl new file mode 100644 index 0000000..fdb54fd --- /dev/null +++ b/OSL/ADN-User Submitted/MadsD/VolumeDisplacement.osl @@ -0,0 +1,27 @@ +// VolumeDisplacement.osl +// Late October 2020 by Mads Drøschler +// +// The purspose of the shader is to lift OSL 3D noise into the right space, +// so propper volume displacement can be implemented. +// +// License: Public Domain + + + +shader VolumeDisplace +[[ string help = "Move the OSL 3D noise into Arnold displacement slot on the Volume material and scatter the edges
Useful for clouds etc.", + string label = "VolumeDisplacement" ]] +( + vector In = 0, + float scatter = 86[[int connectable = 0,]], + output vector scatter_color = 0, + output vector Displacement = 0, +) +{ + + scatter_color = -1+In*2; + Displacement = scatter*(-1+In*2); + + + +} \ No newline at end of file