Osl шейдеры 3ds max
Перейти к содержимому

Osl шейдеры 3ds max

  • автор:

VRayOSLMtl

The VRayOSLMtl material can be used to load OSL shader code files (.osl) or OSL object code files (.oso) and render them directly with V-Ray.

The VRayOSLMtl plug-in can be used with shaders that use closure color output parameters. See the OSL Support page for more detailed descriptions and examples for writing an OSL shader in V-Ray.

Use the Quick Shader area to manually edit the shader’s code.

Coordinates and Noise

The Coordinates and Noise rollouts are standard 3ds Max texture rollouts.

General

The General rollout holds parameters that control common shader characteristics.

Shader file – Specifies the .osl or .oso file which contains the shader (object) code. This button control also supports a context menu with the following options:

Clear – Unloads the current shader and restores the plug-in as if no shaders have been loaded.
Reset – Reloads the shader and resets its parameters to the default values.
Reload – Reloads the shader but keeps the current parameter values.
Open Containing Folder – Reveals the shader location in Explorer.
Open in External Editor – Opens the shader in an appropriate text editor.
Open in Quick Shader – Opens the loaded file’s code in the text editor of the Quick Shader.
Copy File Path – Puts the full path of the currently loaded file in the clipboard.
Copy Folder Path – Copies the parent directory of the currently loaded file into the clipboard.
Recent Files – Holds a list of the recently loaded shaders and an option to clear the list.

Click here to see the shortcut keys for the context menu options

Shortcut Key Command
C Clear
R Reset
E Reload
O Open Containing Folder
X Open in External Editor
Q Open in Quick Shader
F Copy File Path
P Copy Folder Path
T Recent Files
1-0 The first 10 items of the Recent Files submenu have assigned shortcuts from 1 to 0

If you edit your OSL shader, the new version would be loaded only after a Clear, Reset, or a Reload option has been selected.

Closure output – Specifies the closure color source for the materials’s output. The built-in output closure color parameter Ci is selected by default.

Max ray depth – Specifies the maximum reflection/refraction depth for the shader.

Show preview – Determines whether to render a shader preview in the 3ds Max Material Editor.

Clamp shader result – Determines whether to force the result into the [0, clamping limit] range.

Clamping limit – Specifies the upper clamp limit if clamp shader result is enabled.

Viewport color – Specifies the diffuse component of the material used in viewport shading.

Wrap texture coordinates – Automatically wraps the texture coordinates for the OSL shader, passing only values in the [0.0, 1.0] range.

Flip textures – Flips all attached textures vertically for compatibility with 3ds Max OSL Map.

Use uvgen – Uses the information from the UV Generator of the VRayOSLMtl. When disabled, uses information from the UV Generator of textures used or the OSL node.

Export shader name to OSO – Saves the shader as *.oso file.

– Help button which opens a URL provided by the shader.

Saved searches

Use saved searches to filter your results more quickly

Cancel Create saved search

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

shared OSL shaders for 3ds Max

License

ADN-DevTech/3dsMax-OSL-Shaders

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Go to file

Folders and files

Last commit message
Last commit date

Latest commit

History

View all files

Repository files navigation

3dsMax-OSL-Shaders

This is the repo to hold shared OSL shaders for 3ds Max 2019 and beyond. Note that 3ds Max 2019 is the first version to support this standard.

All shaders in this repository are under the Apache 2.0 License — see LICENSE.txt. This is an extremely permissive Open Source License, where you can share, modify, use (even commercially), abuse, modify, tweak, break, mangle, or do whatever you want with any of the shaders. This is true also for the shaders that ship with 3ds Max itself. We believe in being Radically Open with this project. ENJOY!

For developer documentation, read The OSL Map and You.pdf, and for more user-facing information — as well as documentation for the 101 shaders shipping with 3ds Max — read OSL shaders in 3ds Max 2019.pdf.

Layout of the repository

3ds Max Shipping

The shaders shipping with the current version of max, and updates to them. The intent of this folder is that it should be safe to replace your 3dsmax\OSL folder with the content from here. It should only contain safe (compatible) updates to the shaders shipping together with max.

Non-shipping shaders

Non-shipping are under the OSL directory, with a few sub-folders. They are all under a main «OSL» folder. This allows you to add the folder checked out from GitHub as a plugin folder.

Go to Customize -> Configure System Paths -> 3rd Party Plug-Ins and add the checked out folder as a plugin path. 3ds Max will find the «OSL» subdirectory and automatically load everything in it at startup, and populate the material browser.

OSL\ADN-Experimental

Contains shaders in flux and in development that may change completely tomorrow. Use these with caution, and its probably safest to use them in unlinked mode, because if you download a new version in the future, the behavior may have changed enough such that your old scenes no longer work.

OSL\ADN-Stable

These are shaders that are mature enough and stable enough that the intent is that the shaders interface and behaviour won’t substantially change in the future. It may gain parameters, but defaults should be compatible with the previous version. These shaders are candidates to be included in the shipping set in the next version.

OSL\ADN-User Submitted

These are shaders submitted by users.

If you want to contribute, read the how to submit documentation for details.

Saved searches

Use saved searches to filter your results more quickly

Cancel Create saved search

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

3ds Max OSL shaders

License

p-groarke/fea_osl

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Go to file

Folders and files

Last commit message
Last commit date

Latest commit

History

View all files

Repository files navigation

fea_osl

3ds Max OSL shaders

Shader Installation

  • Download the latest release and unzip.
  • In 3dsMax, add a user plugin folder (Customize > Configure User and System Paths > 3rd Party Plug-Ins).
  • Add an OSL folder in that plugin folder.
  • Copy the FeaOSL-vVER folder to your new OSL directory.
  • You should see the shaders in your material editor drop-down on next 3dsMax launch.

Backward Compatibility

To prevent breaking pre-existing scenes that use the shader pack, or changing their looks, the shader folder now comes versioned by default. It is recommended to keep the version in the folder name. This will allow you to upgrade without breaking any old scenes.

Color Lab

An Oklab / Okhcl color gradient and color scheme playground.

Color Scheme

A utility helper which applies various color schemes to gradient maps. Includes a flatten and contour option.

Color Threshold

A utility helper to mask colors above or below an intensity threshold, or mask a picked color or intensity.

Component Min/Max/Average

Per component helper nodes.

Curvalicious

Curvalicious is a fast (no raytracing) screen-space curvature shader. It outputs various maps related to curvature, edge detection and concave / convex faces.

Shader Example

Distance To Node

Utility helper that outputs distance to picked node’s center.

Organic Noise

Organic looking noise generator. Caustics, fleshy bubbles and other abstract noises.

Shader Example

Simple Ocean

SimpleOcean is a Gerstner Wave implementation to simulate ocean vector displacement. It isn’t highly complex, but should do the job when you need a quick & dirty ocean. The shader outputs a main vector displacement map and multiple utility maps, like foam maps, above sea map, etc.

Shader Example

Tiling Simplex

A spacially and temporally tiling simplex noise.

Build Instructions

  • Install haskell.
  • Install 7-zip.
  • Run the build script, this will create a build folder and output the finalized shaders inside of it.
cd fea_osl runhaskell build.hs

OSL Support

This page provides detailed information on OSL support with V-Ray.

Overview

OSL shaders describe the appearance of a surface using symbolic representations called closures instead of explicitly computing color values. V-Ray supports some of the closures introduced by the OSL specification. Additionally V-Ray customizes the usage of OSL closure functions by defining keyword arguments. These arguments reveal additional parameters to better configure V-Ray BRDFs working behind the scenes of the OSL closures. Currently there are several guidelines and limitations to writing an OSL shader in V-Ray. Please read the Guidelines section for specifics before writing OSL shaders in V-Ray. See the Examples section for some samples.

Guidelines

There are several guidelines and limitations to writing an OSL shader in V-Ray.

General Setup

There are two types of OSL shaders supported: surface and shader.

The VRayOSLMtl takes into account only closure color output parameters. All other types of output parameters are ignored.

VRayOSLTex on the other hand ignores closure color output parameters. Writing to the built-in Ci for example is redundant. Use only simple color or float output parameters for texture shaders. All output parameters are considered as optional texture rgb output while all output float and int parameters are considered as optional texture alpha output.

Texture shader example:

shader simple_color_tex ( color tex_color = color(0.2, 0.45, 0.9), float tex_alpha = 1.0, output color result = color(0.0, 0.0, 0.0), output float alpha = 1.0 )

Material shader example:

surface diffuse_material ( color diffuse_color = color(0.2, 0.45, 0.9), color transparency_color = color(0.0, 0.0, 0.0) )

Implementation Specifics

Coordinate systems supported: «object», «world», «camera». The default coordinate system («common») is «world».

The default UI control type for string parameters in 3ds Max is a texture map button. If you need a text field instead use the «widget» parameter metadata.

string filter = "box" [[ string widget = "string" ]],

The default UI control type for integer parameters in 3ds Max is a spinner. If your integer parameter is intended to be a boolean switch use the «widget» parameter metadata.

int trace_reflection = 0 [[ string widget = "checkBox" ]],

Supported OSL Closures

Out of the many closure functions that OSL specifies VRay supports the following:

closure color diffuse (normal N);

closure color phong (normal N, float exponent);

closure color oren_nayar (normal N, float sigma);

closure color ward (normal N, vector T, float xrough, float yrough);

closure color reflection (normal N);

closure colorreflection (normal N, float eta);

closure color refraction (normal N, float eta);

closure color emission ();

closure color background ();

closure color microfacet(string distribution, normal N, float roughness, float eta);

Additionally we define:

closure color vray_blinn (normal N, float glossiness, float anisotropy, float anisoRotation);
Closure that can be used to create Blinn highlight/reflections for a surface.

closure color vray_cooktorrance (normal N, float glossiness);
Closure that can be used to create Cook-Torrance specular highlights for a surface.

closure color vray_light (int doubleSided, int emitOnBackSide);
Use the light closure function to convert simple color results to closure colors writable to Ci. This can be helpful when you are developing a simple material shader that has no closure output result but still it is necessary to use the material as an input to the VRayBlendMtl. It is equivalent to calling M_PI * emission().

closure color vray_hair(normal N, color diffuse_color, color transparency, color primary_specular_color, float primary_glossiness, float secondary_glossiness, color transmission_color, float transmission_glossiness_length, float transmission_glossiness_width);
Closure that is primarily designed for rendering hair and fur. See VRayHairMtl for in depth parameter explanation and examples. An OSL shader that simulates the VRayHairMtl is available in the Examples section. This shader also demonstrates how the VRayHairMtl’s parameters translate to the vray_hair closure ones.

Additional Closure Arguments

The OSL closure functions allow for additional customization via keyword arguments. Listed below are the V-Ray specific keyword arguments for some of the supported closures.

closure color diffuse (normal N);

Keyword usage example:

Ci = diffuse_color * diffuse(N, "roughness", 0.5);

closure color phong (normal N, float exponent);

float reflection_glossiness;
float soften_edge;
int subdivs;
int trace_reflections;

closure color ward (normal N, vector T, float ax, float ay);

float highlight_glossiness ;
float anisotropy;
float aniso_rotation;
float reflection_glossiness;
float soften_edge;
int subdivs;
int trace_reflections;

closure color refraction (normal N, float eta);

float glossiness;
int subdivs;
int auto;

closure color vray_blinn (normal N, float glossiness, float anisotropy, float anisoRotation);

float reflection_glossiness;
float soften_edge;
int subdivs;
int trace_reflections;

closure color vray_cooktorrance (normal N, float glossiness);

float anisotropy;
float aniso_rotation;
float reflection_glossiness;
float soften_edge;
int subdivs;
int trace_reflections;

closure color microfacet (string distribution, normal N, float roughness, float eta);

float highlight_glossiness;
float anisotropy;
float aniso_rotation;
float reflection_glossiness;
float soften_edge;
int subdivs;
int trace_reflections;
float gtr_gamma;

closure color vray_hair(normal N, color diffuse_color, color transparency, color primary_specular_color, float primary_glossiness, float secondary_glossiness, color transmission_color, float transmission_glossiness_length, float transmission_glossiness_width);

color secondary_specular_color;
int opaque_for_shadows;
int opaque_for_gi;
int simplify_for_gi;
int use_cached_gi;
float light_multiplier;
vector hair_direction;

Additional argument information:

float roughness;
Controls surface roughness. Ranges from 0.0 to 1.0. Use 0.0 for regular diffuse surface. Increase the value to achieve flat or dusty effect. Default value is 0.0.

float highlight_glossiness;
Controls the shape of the highlight on the material. Ranges from 0.0 to 1.0. Larger values create more specular surface.

float reflection_glossiness;
Controls the sharpness of reflections. Ranges from 0.0 to 1.0. Use 1.0 for perfect mirror-like reflection. Default value is locked to highlight_glossiness.

float anisotropy;
Determines the shape of the highlight. Use this to simulate «brushed» surfaces. Ranges from -1.0 to 1.0 (exclusive). A value of 0.0 means isotropic highlights. Negative values stretch the highlight vertically while positive ones horizontally.

float aniso_rotation;
Determines the orientation of the anisotropic effect in degrees (rotation in degrees). Default value is 0.0.

float soften_edge;
Softens the transition from dark to bright areas in specular reflections. Ranges from -1.0 to 1.0. Default value is 0.001.

int subdivs;
Controls the noise quality of glossy surfaces. Larger number means less noise but longer render time. Default value is 8.

int trace_reflections;
Use 1 to enable reflections or 0 to disable them. Default value is 0.

int auto;
Use a value of 1 to allow V-Ray to take care of backface hits of refractive surfaces. Exit eta corrections and total internal reflections are done automatically. Default value is 0.

float gtr_gamma;
The gamma parameter of the Generalized-Trowbridge-Reitz (GTR) model. Default value is 2.0. At this value the GTR model behaves exactly as the GGX model.

color secondary_specular_color;
The color of the secondary specular component corresponding to light that is reflected off the back surface of the hair strand s. The default value is locked to the transmission_color parameter of the vary_hair closure. See VRayHairMtl for more information.

int opaque_for_shadows;
If set to 1 makes the hair closure opaque for shadow calculations. Default value is 0. See VRayHairMtl for more information.

int opaque_for_gi;
Use a value of 1 to make the hair material opaque for GI calculations. Default value is 0. See VRayHairMtl for more information.

int simplify_for_gi;
Use 1 to apply a simplified diffuse version of the closure for GI calculations. Default value is 0. See VRayHairMtl for more information.

int use_cached_gi;
If set to 1, an irradiance map will be used to approximate diffuse indirect illumination. Otherwise the hair closure will always be calculated with brute force GI. Default value is 1. See VRayHairMtl for more information.

float light_multiplier;
A multiplier for the effect of direct illumination on the current hair closure. Default value is 1.0. See VRayHairMtl for more information.

vector hair_direction;
If provided, overrides the internally derived hair strand direction. Default value is vector(0.0, 0.0, 1.0).

Unsupported OSL Features

Displacement and volume shaders are not supported.

Matrices, structures and closures are not allowed as input parameters for the 3ds Max plugin. The Standalone plugin does not accept only closure parameters.

Shader metadata items: page, digits, slider and units are currently ignored.

«NDC» coordinate space is not supported.

The displacement functions displace and bump have no effect.

Printing and file writing string functions such as: printf, error, warning, fprintf.

The texture functions texture3d, pointcloud_search, pointcloud_get, pointcloud_write are not implemented.

Volumetric and signaling closures are not available.

Some surface closures are not yet supported: microfacet_beckmann, microfacet_beckmann_refraction, microfacet_ggx_refraction, translucent.

Renderer state, message passing and dictionary lookups are currently not supported.

Shader Graphs

OSL shaders can be organized into networks of shaders (sometimes called a shader group, graph, or DAG), with named outputs of some nodes being connected to named inputs of other nodes within the network. Furthermore, the individual nodes are evaluated lazily, only their outputs are ”pulled” from the later nodes that depend on them.

Examples

Example: Mandelbrot Texture

This example generates a simple Mandelbrot set using texture coordinates.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *