Ajout du projet Depths sur Git
This commit is contained in:
+5
@@ -0,0 +1,5 @@
|
||||
void mx_anisotropic_vdf(vector absorption, vector scattering, float anisotropy, output VDF vdf)
|
||||
{
|
||||
// Not implemented in vanilla OSL
|
||||
vdf = 0; // volume_henyey_greenstein(color(absorption), color(scattering), color(0.0), anisotropy);
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
void mx_burley_diffuse_bsdf(float weight, color reflectance, float roughness, normal N, output BSDF bsdf)
|
||||
{
|
||||
// TODO: Implement properly.
|
||||
bsdf.response = reflectance * weight * oren_nayar(N, roughness);
|
||||
bsdf.throughput = color(0.0);
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
#include "../lib/mx_microfacet_specular.osl"
|
||||
|
||||
void mx_conductor_bsdf(float weight, color ior_n, color ior_k, vector2 roughness, normal N, vector U, string distribution, output BSDF bsdf)
|
||||
{
|
||||
bsdf.throughput = color(0.0);
|
||||
|
||||
if (weight < M_FLOAT_EPS)
|
||||
{
|
||||
bsdf.response = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate conductor fresnel
|
||||
//
|
||||
// Fresnel should be based on microfacet normal
|
||||
// but we have no access to that from here, so just use
|
||||
// view direction and surface normal instead
|
||||
//
|
||||
float NdotV = fabs(dot(N,-I));
|
||||
color F = mx_fresnel_conductor(NdotV, ior_n, ior_k);
|
||||
|
||||
// Calculate compensation for multiple scattering.
|
||||
// This should normally be done inside the closure
|
||||
// but since vanilla OSL doesen't support this we
|
||||
// add it here in shader code instead.
|
||||
vector2 safeAlpha = clamp(roughness, M_FLOAT_EPS, 1.0);
|
||||
float avgAlpha = mx_average_alpha(safeAlpha);
|
||||
color comp = mx_ggx_energy_compensation(NdotV, avgAlpha, F);
|
||||
|
||||
// Set ior to 0.0 to disable the internal dielectric fresnel
|
||||
bsdf.response = F * comp * weight * microfacet(distribution, N, U, safeAlpha.x, safeAlpha.y, 0.0, false);
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#include "../lib/mx_microfacet_specular.osl"
|
||||
|
||||
void mx_dielectric_bsdf(float weight, color tint, float ior, vector2 roughness, normal N, vector U, string distribution, string scatter_mode, output BSDF bsdf)
|
||||
{
|
||||
if (scatter_mode == "T")
|
||||
{
|
||||
bsdf.response = tint * weight * microfacet(distribution, N, U, roughness.x, roughness.y, ior, 1);
|
||||
bsdf.throughput = tint * weight;
|
||||
return;
|
||||
}
|
||||
|
||||
float NdotV = clamp(dot(N,-I), M_FLOAT_EPS, 1.0);
|
||||
float F0 = mx_ior_to_f0(ior);
|
||||
float F = mx_fresnel_schlick(NdotV, F0);
|
||||
|
||||
// Calculate compensation for multiple scattering.
|
||||
// This should normally be done inside the closure
|
||||
// but since vanilla OSL doesen't support this we
|
||||
// add it here in shader code instead.
|
||||
vector2 safeAlpha = clamp(roughness, M_FLOAT_EPS, 1.0);
|
||||
float avgAlpha = mx_average_alpha(safeAlpha);
|
||||
float comp = mx_ggx_energy_compensation(NdotV, avgAlpha, F);
|
||||
|
||||
// Calculate throughput from directional albedo.
|
||||
float dirAlbedo = mx_ggx_dir_albedo(NdotV, avgAlpha, ior) * comp;
|
||||
bsdf.throughput = 1.0 - dirAlbedo * weight;
|
||||
|
||||
if (scatter_mode == "R")
|
||||
{
|
||||
bsdf.response = tint * weight * comp * microfacet(distribution, N, U, safeAlpha.x, safeAlpha.y, ior, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
bsdf.response = tint * weight * comp * microfacet(distribution, N, U, safeAlpha.x, safeAlpha.y, ior, 2);
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
#include "../lib/mx_microfacet_specular.osl"
|
||||
|
||||
void mx_generalized_schlick_bsdf(float weight, color color0, color color90, float exponent, vector2 roughness, normal N, vector U, string distribution, string scatter_mode, output BSDF bsdf)
|
||||
{
|
||||
float avgF0 = dot(color0, color(1.0 / 3.0));
|
||||
float ior = mx_f0_to_ior(avgF0);
|
||||
|
||||
if (scatter_mode == "T")
|
||||
{
|
||||
bsdf.response = weight * microfacet(distribution, N, U, roughness.x, roughness.y, ior, 1);
|
||||
bsdf.throughput = weight;
|
||||
return;
|
||||
}
|
||||
|
||||
float NdotV = fabs(dot(N,-I));
|
||||
color F = mx_fresnel_schlick(NdotV, color0, color90, exponent);
|
||||
|
||||
// Calculate compensation for multiple scattering.
|
||||
// This should normally be done inside the closure
|
||||
// but since vanilla OSL doesen't support this we
|
||||
// add it here in shader code instead.
|
||||
vector2 safeAlpha = clamp(roughness, M_FLOAT_EPS, 1.0);
|
||||
float avgAlpha = mx_average_alpha(safeAlpha);
|
||||
color comp = mx_ggx_energy_compensation(NdotV, avgAlpha, F);
|
||||
|
||||
// Calculate throughput from directional albedo.
|
||||
color dirAlbedo = mx_ggx_dir_albedo(NdotV, avgAlpha, color0, color90) * comp;
|
||||
float avgDirAlbedo = dot(dirAlbedo, color(1.0 / 3.0));
|
||||
bsdf.throughput = 1.0 - avgDirAlbedo * weight;
|
||||
|
||||
// Calculate the reflection response, setting IOR to zero to disable internal Fresnel.
|
||||
bsdf.response = F * comp * weight * microfacet(distribution, N, U, safeAlpha.x, safeAlpha.y, 0.0, 0);
|
||||
|
||||
if (scatter_mode == "RT")
|
||||
{
|
||||
bsdf.response += bsdf.throughput * microfacet(distribution, N, U, safeAlpha.x, safeAlpha.y, ior, 1);
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
void mx_oren_nayar_diffuse_bsdf(float weight, color _color, float roughness, normal N, output BSDF bsdf)
|
||||
{
|
||||
bsdf.response = _color * weight * oren_nayar(N, roughness);
|
||||
bsdf.throughput = color(0.0);
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
#include "../lib/mx_microfacet_sheen.osl"
|
||||
|
||||
// TODO: Vanilla OSL doesn't have a proper sheen closure,
|
||||
// so use 'diffuse' scaled by sheen directional albedo for now.
|
||||
void mx_sheen_bsdf(float weight, color Ks, float roughness, vector N, output BSDF bsdf)
|
||||
{
|
||||
if (weight < M_FLOAT_EPS)
|
||||
{
|
||||
bsdf.response = 0;
|
||||
bsdf.throughput = color(1.0);
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Normalization should not be needed. My suspicion is that
|
||||
// BSDF sampling of new outgoing direction in 'testrender' needs
|
||||
// to be fixed.
|
||||
vector V = normalize(-I);
|
||||
|
||||
float NdotV = fabs(dot(N,V));
|
||||
float alpha = clamp(roughness, M_FLOAT_EPS, 1.0);
|
||||
float albedo = weight * mx_imageworks_sheen_dir_albedo(NdotV, alpha);
|
||||
bsdf.response = albedo * Ks * diffuse(N);
|
||||
bsdf.throughput = 1.0 - albedo;
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
void mx_subsurface_bsdf(float weight, color _color, vector radius, float anisotropy, normal N, output BSDF bsdf)
|
||||
{
|
||||
// TODO: Subsurface closure is not supported by vanilla OSL.
|
||||
bsdf.response = _color * weight * diffuse(N);
|
||||
bsdf.throughput = color(0.0);
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
void mx_surface(BSDF bsdf, EDF edf, float opacity, output surfaceshader result)
|
||||
{
|
||||
result.bsdf = bsdf.response;
|
||||
result.edf = edf;
|
||||
result.opacity = clamp(opacity, 0.0, 1.0);
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
void mx_translucent_bsdf(float weight, color _color, normal N, output BSDF bsdf)
|
||||
{
|
||||
bsdf.response = _color * weight * translucent(N);
|
||||
bsdf.throughput = color(0.0);
|
||||
}
|
||||
Vendored
+78
@@ -0,0 +1,78 @@
|
||||
float mx_square(float x)
|
||||
{
|
||||
return x*x;
|
||||
}
|
||||
|
||||
vector2 mx_square(vector2 x)
|
||||
{
|
||||
return x*x;
|
||||
}
|
||||
|
||||
vector mx_square(vector x)
|
||||
{
|
||||
return x*x;
|
||||
}
|
||||
|
||||
vector4 mx_square(vector4 x)
|
||||
{
|
||||
return x*x;
|
||||
}
|
||||
|
||||
float mx_pow5(float x)
|
||||
{
|
||||
return mx_square(mx_square(x)) * x;
|
||||
}
|
||||
|
||||
color mx_fresnel_conductor(float cosTheta, vector n, vector k)
|
||||
{
|
||||
float c2 = cosTheta*cosTheta;
|
||||
vector n2_k2 = n*n + k*k;
|
||||
vector nc2 = 2.0 * n * cosTheta;
|
||||
|
||||
vector rs_a = n2_k2 + c2;
|
||||
vector rp_a = n2_k2 * c2 + 1.0;
|
||||
vector rs = (rs_a - nc2) / (rs_a + nc2);
|
||||
vector rp = (rp_a - nc2) / (rp_a + nc2);
|
||||
|
||||
return 0.5 * (rs + rp);
|
||||
}
|
||||
|
||||
// Standard Schlick Fresnel
|
||||
float mx_fresnel_schlick(float cosTheta, float F0)
|
||||
{
|
||||
float x = clamp(1.0 - cosTheta, 0.0, 1.0);
|
||||
float x5 = mx_pow5(x);
|
||||
return F0 + (1.0 - F0) * x5;
|
||||
}
|
||||
color mx_fresnel_schlick(float cosTheta, color F0)
|
||||
{
|
||||
float x = clamp(1.0 - cosTheta, 0.0, 1.0);
|
||||
float x5 = mx_pow5(x);
|
||||
return F0 + (1.0 - F0) * x5;
|
||||
}
|
||||
|
||||
// Generalized Schlick Fresnel
|
||||
float mx_fresnel_schlick(float cosTheta, float F0, float F90)
|
||||
{
|
||||
float x = clamp(1.0 - cosTheta, 0.0, 1.0);
|
||||
float x5 = mx_pow5(x);
|
||||
return mix(F0, F90, x5);
|
||||
}
|
||||
color mx_fresnel_schlick(float cosTheta, color F0, color F90)
|
||||
{
|
||||
float x = clamp(1.0 - cosTheta, 0.0, 1.0);
|
||||
float x5 = mx_pow5(x);
|
||||
return mix(F0, F90, x5);
|
||||
}
|
||||
|
||||
// Generalized Schlick Fresnel with a variable exponent
|
||||
color mx_fresnel_schlick(float cosTheta, float f0, float f90, float exponent)
|
||||
{
|
||||
float x = clamp(1.0 - cosTheta, 0.0, 1.0);
|
||||
return mix(f0, f90, pow(x, exponent));
|
||||
}
|
||||
color mx_fresnel_schlick(float cosTheta, color f0, color f90, float exponent)
|
||||
{
|
||||
float x = clamp(1.0 - cosTheta, 0.0, 1.0);
|
||||
return mix(f0, f90, pow(x, exponent));
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
#include "mx_microfacet.osl"
|
||||
|
||||
// Rational curve fit approximation for the directional albedo of Imageworks sheen.
|
||||
float mx_imageworks_sheen_dir_albedo_analytic(float NdotV, float roughness)
|
||||
{
|
||||
float a = 5.25248 - 7.66024 * NdotV + 14.26377 * roughness;
|
||||
float b = 1.0 + 30.66449 * NdotV + 32.53420 * roughness;
|
||||
return a / b;
|
||||
}
|
||||
|
||||
float mx_imageworks_sheen_dir_albedo(float NdotV, float roughness)
|
||||
{
|
||||
float dirAlbedo = mx_imageworks_sheen_dir_albedo_analytic(NdotV, roughness);
|
||||
return clamp(dirAlbedo, 0.0, 1.0);
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
#include "mx_microfacet.osl"
|
||||
|
||||
// Compute the average of an anisotropic alpha pair.
|
||||
float mx_average_alpha(vector2 alpha)
|
||||
{
|
||||
return sqrt(alpha.x * alpha.y);
|
||||
}
|
||||
|
||||
// Convert a real-valued index of refraction to normal-incidence reflectivity.
|
||||
float mx_ior_to_f0(float ior)
|
||||
{
|
||||
return mx_square((ior - 1.0) / (ior + 1.0));
|
||||
}
|
||||
|
||||
// Convert normal-incidence reflectivity to real-valued index of refraction.
|
||||
float mx_f0_to_ior(float F0)
|
||||
{
|
||||
float sqrtF0 = sqrt(clamp(F0, 0.01, 0.99));
|
||||
return (1.0 + sqrtF0) / (1.0 - sqrtF0);
|
||||
}
|
||||
|
||||
// Rational quadratic fit to Monte Carlo data for GGX directional albedo.
|
||||
color mx_ggx_dir_albedo(float NdotV, float alpha, color F0, color F90)
|
||||
{
|
||||
float x = NdotV;
|
||||
float y = alpha;
|
||||
float x2 = mx_square(x);
|
||||
float y2 = mx_square(y);
|
||||
vector4 r = vector4(0.1003, 0.9345, 1.0, 1.0) +
|
||||
vector4(-0.6303, -2.323, -1.765, 0.2281) * x +
|
||||
vector4(9.748, 2.229, 8.263, 15.94) * y +
|
||||
vector4(-2.038, -3.748, 11.53, -55.83) * x * y +
|
||||
vector4(29.34, 1.424, 28.96, 13.08) * x2 +
|
||||
vector4(-8.245, -0.7684, -7.507, 41.26) * y2 +
|
||||
vector4(-26.44, 1.436, -36.11, 54.9) * x2 * y +
|
||||
vector4(19.99, 0.2913, 15.86, 300.2) * x * y2 +
|
||||
vector4(-5.448, 0.6286, 33.37, -285.1) * x2 * y2;
|
||||
vector2 AB = vector2(r.x, r.y) / vector2(r.z, r.w);
|
||||
AB.x = clamp(AB.x, 0.0, 1.0);
|
||||
AB.y = clamp(AB.y, 0.0, 1.0);
|
||||
return F0 * AB.x + F90 * AB.y;
|
||||
}
|
||||
|
||||
float mx_ggx_dir_albedo(float NdotV, float alpha, float F0, float F90)
|
||||
{
|
||||
color result = mx_ggx_dir_albedo(NdotV, alpha, color(F0), color(F90));
|
||||
return result[0];
|
||||
}
|
||||
|
||||
float mx_ggx_dir_albedo(float NdotV, float alpha, float ior)
|
||||
{
|
||||
color result = mx_ggx_dir_albedo(NdotV, alpha, color(mx_ior_to_f0(ior)), color(1.0));
|
||||
return result[0];
|
||||
}
|
||||
|
||||
// https://blog.selfshadow.com/publications/turquin/ms_comp_final.pdf
|
||||
// Equations 14 and 16
|
||||
color mx_ggx_energy_compensation(float NdotV, float alpha, color Fss)
|
||||
{
|
||||
float Ess = mx_ggx_dir_albedo(NdotV, alpha, 1.0, 1.0);
|
||||
return 1.0 + Fss * (1.0 - Ess) / Ess;
|
||||
}
|
||||
|
||||
float mx_ggx_energy_compensation(float NdotV, float alpha, float Fss)
|
||||
{
|
||||
color result = mx_ggx_energy_compensation(NdotV, alpha, color(Fss));
|
||||
return result[0];
|
||||
}
|
||||
Packaged/Windows/Engine/Binaries/ThirdParty/MaterialX/libraries/pbrlib/genosl/mx_anisotropic_vdf.osl
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
void mx_anisotropic_vdf(vector absorption, vector scattering, float anisotropy, output VDF vdf)
|
||||
{
|
||||
// TODO: Need to remap parameters to match the new closure,
|
||||
// or change the MaterialX spec to OSL parameterization.
|
||||
vdf = 0;
|
||||
}
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
void mx_artistic_ior(color reflectivity, color edge_color, output vector ior, output vector extinction)
|
||||
{
|
||||
// "Artist Friendly Metallic Fresnel", Ole Gulbrandsen, 2014
|
||||
// http://jcgt.org/published/0003/04/03/paper.pdf
|
||||
|
||||
color r = clamp(reflectivity, 0.0, 0.99);
|
||||
color r_sqrt = sqrt(r);
|
||||
color n_min = (1.0 - r) / (1.0 + r);
|
||||
color n_max = (1.0 + r_sqrt) / (1.0 - r_sqrt);
|
||||
ior = mix(n_max, n_min, edge_color);
|
||||
|
||||
color np1 = ior + 1.0;
|
||||
color nm1 = ior - 1.0;
|
||||
color k2 = (np1*np1 * r - nm1*nm1) / (1.0 - r);
|
||||
k2 = max(k2, 0.0);
|
||||
extinction = sqrt(k2);
|
||||
}
|
||||
Vendored
+49
@@ -0,0 +1,49 @@
|
||||
void mx_blackbody(float temp, output color color_value)
|
||||
{
|
||||
float xc, yc;
|
||||
float t, t2, t3, xc2, xc3;
|
||||
|
||||
// if value outside valid range of approximation clamp to accepted temperature range
|
||||
float temperature = clamp(temp, 1667.0, 25000.0);
|
||||
|
||||
t = 1000.0 / temperature;
|
||||
t2 = t * t;
|
||||
t3 = t * t * t;
|
||||
|
||||
// Cubic spline approximation for Kelvin temperature to sRGB conversion
|
||||
// (https://en.wikipedia.org/wiki/Planckian_locus#Approximation)
|
||||
if (temperature < 4000.0) { // 1667K <= temperature < 4000K
|
||||
xc = -0.2661239 * t3 - 0.2343580 * t2 + 0.8776956 * t + 0.179910;
|
||||
}
|
||||
else { // 4000K <= temperature <= 25000K
|
||||
xc = -3.0258469 * t3 + 2.1070379 * t2 + 0.2226347 * t + 0.240390;
|
||||
}
|
||||
xc2 = xc * xc;
|
||||
xc3 = xc * xc * xc;
|
||||
|
||||
if (temperature < 2222.0) { // 1667K <= temperature < 2222K
|
||||
yc = -1.1063814 * xc3 - 1.34811020 * xc2 + 2.18555832 * xc - 0.20219683;
|
||||
}
|
||||
else if (temperature < 4000.0) { // 2222K <= temperature < 4000K
|
||||
yc = -0.9549476 * xc3 - 1.37418593 * xc2 + 2.09137015 * xc - 0.16748867;
|
||||
}
|
||||
else { // 4000K <= temperature <= 25000K
|
||||
yc = 3.0817580 * xc3 - 5.87338670 * xc2 + 3.75112997 * xc - 0.37001483;
|
||||
}
|
||||
|
||||
if (yc <= 0.0) { // avoid division by zero
|
||||
color_value = color(1.0);
|
||||
return;
|
||||
}
|
||||
|
||||
vector XYZ = vector(xc / yc, 1.0, (1 - xc - yc) / yc);
|
||||
|
||||
/// XYZ to Rec.709 RGB colorspace conversion
|
||||
matrix XYZ_to_RGB = matrix( 3.2406, -0.9689, 0.0557, 0.0,
|
||||
-1.5372, 1.8758, -0.2040, 0.0,
|
||||
-0.4986, 0.0415, 1.0570, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
color_value = transform(XYZ_to_RGB, XYZ);
|
||||
color_value = max(color_value, vector(0.0));
|
||||
}
|
||||
Packaged/Windows/Engine/Binaries/ThirdParty/MaterialX/libraries/pbrlib/genosl/mx_dielectric_bsdf.osl
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
void mx_dielectric_bsdf(float weight, color tint, float ior, vector2 roughness, normal N, vector U, string distribution, string scatter_mode, output BSDF bsdf)
|
||||
{
|
||||
if (scatter_mode == "R")
|
||||
{
|
||||
bsdf = weight * dielectric_bsdf(N, U, tint, color(0.0), roughness.x, roughness.y, ior, distribution);
|
||||
}
|
||||
else if (scatter_mode == "T")
|
||||
{
|
||||
bsdf = weight * dielectric_bsdf(N, U, color(0.0), tint, roughness.x, roughness.y, ior, distribution);
|
||||
}
|
||||
else
|
||||
{
|
||||
bsdf = weight * dielectric_bsdf(N, U, tint, tint, roughness.x, roughness.y, ior, distribution);
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
void mx_displacement_float(float displacement, float scale, output displacementshader result)
|
||||
{
|
||||
result = vector(displacement * scale);
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
void mx_displacement_vector3(vector displacement, float scale, output displacementshader result)
|
||||
{
|
||||
result = displacement * scale;
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
void mx_generalized_schlick_bsdf(float weight, color color0, color color90, float exponent, vector2 roughness, normal N, vector U, string distribution, string scatter_mode, output BSDF bsdf)
|
||||
{
|
||||
if (scatter_mode == "R")
|
||||
{
|
||||
bsdf = weight * generalized_schlick_bsdf(N, U, color(1.0), color(0.0), roughness.x, roughness.y, color0, color90, exponent, distribution);
|
||||
}
|
||||
else if (scatter_mode == "T")
|
||||
{
|
||||
bsdf = weight * generalized_schlick_bsdf(N, U, color(0.0), color(1.0), roughness.x, roughness.y, color0, color90, exponent, distribution);
|
||||
}
|
||||
else
|
||||
{
|
||||
bsdf = weight * generalized_schlick_bsdf(N, U, color(1.0), color(1.0), roughness.x, roughness.y, color0, color90, exponent, distribution);
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
#include "lib/mx_microfacet.osl"
|
||||
|
||||
void mx_generalized_schlick_edf(color color0, color color90, float exponent, EDF base, output EDF result)
|
||||
{
|
||||
float NdotV = fabs(dot(N,-I));
|
||||
color f = mx_fresnel_schlick(NdotV, color0, color90, exponent);
|
||||
result = base * f;
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
void mx_roughness_anisotropy(float roughness, float anisotropy, output vector2 result)
|
||||
{
|
||||
float roughness_sqr = clamp(roughness*roughness, M_FLOAT_EPS, 1.0);
|
||||
if (anisotropy > 0.0)
|
||||
{
|
||||
float aspect = sqrt(1.0 - clamp(anisotropy, 0.0, 0.98));
|
||||
result.x = min(roughness_sqr / aspect, 1.0);
|
||||
result.y = roughness_sqr * aspect;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.x = roughness_sqr;
|
||||
result.y = roughness_sqr;
|
||||
}
|
||||
}
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
void mx_roughness_dual(vector2 roughness, output vector2 result)
|
||||
{
|
||||
result.x = clamp(roughness.x * roughness.x, M_FLOAT_EPS, 1.0);
|
||||
if (roughness.y < 0.0)
|
||||
{
|
||||
result.y = result.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.y = clamp(roughness.y * roughness.y, M_FLOAT_EPS, 1.0);
|
||||
}
|
||||
}
|
||||
Packaged/Windows/Engine/Binaries/ThirdParty/MaterialX/libraries/pbrlib/genosl/mx_subsurface_bsdf.osl
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
void mx_subsurface_bsdf(float weight, color _color, vector radius, float anisotropy, normal N, output BSDF bsdf)
|
||||
{
|
||||
// TODO: Subsurface closure is not supported by vanilla OSL.
|
||||
bsdf = _color * weight * diffuse(N);
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
void mx_surface(BSDF bsdf, EDF edf, float opacity, output surfaceshader result)
|
||||
{
|
||||
result.bsdf = bsdf;
|
||||
result.edf = edf;
|
||||
result.opacity = clamp(opacity, 0.0, 1.0);
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38">
|
||||
|
||||
<!-- <oren_nayar_diffuse_bsdf> -->
|
||||
<implementation name="IM_oren_nayar_diffuse_bsdf_genosl" nodedef="ND_oren_nayar_diffuse_bsdf" sourcecode="{{weight}} * oren_nayar_diffuse_bsdf({{normal}}, {{color}}, {{roughness}})" target="genosl" />
|
||||
|
||||
<!-- <burley_diffuse_bsdf> -->
|
||||
<implementation name="IM_burley_diffuse_bsdf_genosl" nodedef="ND_burley_diffuse_bsdf" sourcecode="{{weight}} * burley_diffuse_bsdf({{normal}}, {{color}}, {{roughness}})" target="genosl" />
|
||||
|
||||
<!-- <translucent_bsdf> -->
|
||||
<implementation name="IM_translucent_bsdf_genosl" nodedef="ND_translucent_bsdf" sourcecode="{{weight}} * translucent_bsdf({{normal}}, {{color}})" target="genosl" />
|
||||
|
||||
<!-- <dielectric_bsdf> -->
|
||||
<implementation name="IM_dielectric_bsdf_genosl" nodedef="ND_dielectric_bsdf" file="mx_dielectric_bsdf.osl" function="mx_dielectric_bsdf" target="genosl" />
|
||||
|
||||
<!-- <conductor_bsdf> -->
|
||||
<implementation name="IM_conductor_bsdf_genosl" nodedef="ND_conductor_bsdf" sourcecode="{{weight}} * conductor_bsdf({{normal}}, {{tangent}}, {{roughness}}.x, {{roughness}}.y, {{ior}}, {{extinction}}, {{distribution}})" target="genosl" />
|
||||
|
||||
<!-- <generalized_schlick_bsdf> -->
|
||||
<implementation name="IM_generalized_schlick_bsdf_genosl" nodedef="ND_generalized_schlick_bsdf" file="mx_generalized_schlick_bsdf.osl" function="mx_generalized_schlick_bsdf" target="genosl" />
|
||||
|
||||
<!-- <subsurface_bsdf> -->
|
||||
<implementation name="IM_subsurface_bsdf_genosl" nodedef="ND_subsurface_bsdf" file="mx_subsurface_bsdf.osl" function="mx_subsurface_bsdf" target="genosl" />
|
||||
|
||||
<!-- <sheen_bsdf> -->
|
||||
<implementation name="IM_sheen_bsdf_genosl" nodedef="ND_sheen_bsdf" sourcecode="{{weight}} * sheen_bsdf({{normal}}, {{color}}, {{roughness}})" target="genosl" />
|
||||
|
||||
<!-- <anisotropic_vdf> -->
|
||||
<implementation name="IM_anisotropic_vdf_genosl" nodedef="ND_anisotropic_vdf" file="mx_anisotropic_vdf.osl" function="mx_anisotropic_vdf" target="genosl" />
|
||||
|
||||
<!-- <thin_film_bsdf> -->
|
||||
<implementation name="IM_thin_film_bsdf_genosl" nodedef="ND_thin_film_bsdf" target="genosl" />
|
||||
|
||||
<!-- <uniform_edf> -->
|
||||
<implementation name="IM_uniform_edf_genosl" nodedef="ND_uniform_edf" sourcecode="uniform_edf({{color}})" target="genosl" />
|
||||
|
||||
<!-- <generalized_schlick_edf> -->
|
||||
<implementation name="IM_generalized_schlick_edf_genosl" nodedef="ND_generalized_schlick_edf" file="mx_generalized_schlick_edf.osl" function="mx_generalized_schlick_edf" target="genosl" />
|
||||
|
||||
<!-- <layer> -->
|
||||
<implementation name="IM_layer_bsdf_genosl" nodedef="ND_layer_bsdf" target="genosl" />
|
||||
<implementation name="IM_layer_vdf_genosl" nodedef="ND_layer_vdf" target="genosl" />
|
||||
|
||||
<!-- <mix> -->
|
||||
<implementation name="IM_mix_bsdf_genosl" nodedef="ND_mix_bsdf" sourcecode="mix({{bg}}, {{fg}}, {{mix}})" target="genosl" />
|
||||
<implementation name="IM_mix_edf_genosl" nodedef="ND_mix_edf" sourcecode="mix({{bg}}, {{fg}}, {{mix}})" target="genosl" />
|
||||
|
||||
<!-- <add> -->
|
||||
<implementation name="IM_add_bsdf_genosl" nodedef="ND_add_bsdf" sourcecode="({{in1}} + {{in2}})" target="genosl" />
|
||||
<implementation name="IM_add_edf_genosl" nodedef="ND_add_edf" sourcecode="({{in1}} + {{in2}})" target="genosl" />
|
||||
|
||||
<!-- <multiply> -->
|
||||
<implementation name="IM_multiply_bsdfC_genosl" nodedef="ND_multiply_bsdfC" sourcecode="({{in2}} * {{in1}})" target="genosl" />
|
||||
<implementation name="IM_multiply_bsdfF_genosl" nodedef="ND_multiply_bsdfF" sourcecode="({{in2}} * {{in1}})" target="genosl" />
|
||||
<implementation name="IM_multiply_edfC_genosl" nodedef="ND_multiply_edfC" sourcecode="({{in2}} * {{in1}})" target="genosl" />
|
||||
<implementation name="IM_multiply_edfF_genosl" nodedef="ND_multiply_edfF" sourcecode="({{in2}} * {{in1}})" target="genosl" />
|
||||
|
||||
<!-- <surface> -->
|
||||
<implementation name="IM_surface_genosl" nodedef="ND_surface" file="mx_surface.osl" function="mx_surface" target="genosl" />
|
||||
|
||||
<!-- <displacement> -->
|
||||
<implementation name="IM_displacement_float_genosl" nodedef="ND_displacement_float" file="mx_displacement_float.osl" function="mx_displacement_float" target="genosl" />
|
||||
<implementation name="IM_displacement_vector3_genosl" nodedef="ND_displacement_vector3" file="mx_displacement_vector3.osl" function="mx_displacement_vector3" target="genosl" />
|
||||
|
||||
<!-- <roughness_anisotropy> -->
|
||||
<implementation name="IM_roughness_anisotropy_genosl" nodedef="ND_roughness_anisotropy" file="mx_roughness_anisotropy.osl" function="mx_roughness_anisotropy" target="genosl" />
|
||||
|
||||
<!-- <roughness_dual> -->
|
||||
<implementation name="IM_roughness_dual_genosl" nodedef="ND_roughness_dual" file="mx_roughness_dual.osl" function="mx_roughness_dual" target="genosl" />
|
||||
|
||||
<!-- <artistic_ior> -->
|
||||
<implementation name="IM_artistic_ior_genosl" nodedef="ND_artistic_ior" file="mx_artistic_ior.osl" function="mx_artistic_ior" target="genosl" />
|
||||
|
||||
<!-- <blackbody> -->
|
||||
<implementation name="IM_blackbody_genosl" nodedef="ND_blackbody" file="mx_blackbody.osl" function="mx_blackbody" target="genosl" />
|
||||
|
||||
</materialx>
|
||||
Reference in New Issue
Block a user