Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

files #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added OSL/ADN-User Submitted/MadsD/Falloff.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions OSL/ADN-User Submitted/MadsD/Falloff.osl
Original file line number Diff line number Diff line change
@@ -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);


}
24 changes: 24 additions & 0 deletions OSL/ADN-User Submitted/MadsD/FrontBack.osl
Original file line number Diff line number Diff line change
@@ -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;
}
80 changes: 80 additions & 0 deletions OSL/ADN-User Submitted/MadsD/NormalBlend.osl
Original file line number Diff line number Diff line change
@@ -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);
}
27 changes: 27 additions & 0 deletions OSL/ADN-User Submitted/MadsD/VolumeDisplacement.osl
Original file line number Diff line number Diff line change
@@ -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<br/>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);



}