Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
#include "mx_roughness_anisotropy.glsl"
#include "mx_rotate_vector3.glsl"
#include "mx_oren_nayar_diffuse_bsdf.glsl"
#include "mx_translucent_bsdf.glsl"
#include "mx_subsurface_bsdf.glsl"
#include "mx_sheen_bsdf.glsl"
#include "mx_dielectric_bsdf.glsl"
#include "mx_conductor_bsdf.glsl"
#include "mx_artistic_ior.glsl"
// Rodrigues' rotation formula.
//
// Private copy of the stdlib rotate3d helper. Avoids
// duplicate-definition errors when the material's own nodegraph
// also uses rotate3d nodes, which would cause the generator to
// emit mx_rotate_vector3 a second time
// (see https://github.com/metashade/metashade/issues/230).
//
void _mx_metashade_rotate_vector3(vec3 in_, float amount, vec3 axis, out vec3 result)
{
vec3 axis_n = normalize(axis);
float rad = radians(amount);
float s = sin(rad);
float c = cos(rad);
result = ((in_ * c) + (cross(in_, axis_n) * s)) + ((axis_n * dot(axis_n, in_)) * (1 - c));
}

void mx_metashade_standard_surface_bsdf(ClosureData closureData, float base, vec3 base_color, float diffuse_roughness, float metalness, float specular, vec3 specular_color, float specular_roughness, float specular_IOR, float specular_anisotropy, float specular_rotation, float transmission, vec3 transmission_color, float transmission_extra_roughness, float subsurface, vec3 subsurface_color, vec3 subsurface_radius, float subsurface_scale, float subsurface_anisotropy, float sheen, vec3 sheen_color, float sheen_roughness, float coat, vec3 coat_color, float coat_roughness, float coat_anisotropy, float coat_rotation, float coat_IOR, vec3 coat_normal, float coat_affect_color, float coat_affect_roughness, float thin_film_thickness, float thin_film_IOR, bool thin_walled, vec3 normal, vec3 tangent, inout BSDF bsdf)
{
//
Expand All @@ -24,7 +40,7 @@ void mx_metashade_standard_surface_bsdf(ClosureData closureData, float base, vec
{
float tangent_rotate_degree = specular_rotation * 360.0;
vec3 tangent_rotated;
mx_rotate_vector3(tangent, tangent_rotate_degree, normal, tangent_rotated);
_mx_metashade_rotate_vector3(tangent, tangent_rotate_degree, normal, tangent_rotated);
main_tangent = normalize(tangent_rotated);
}
//
Expand All @@ -34,7 +50,7 @@ void mx_metashade_standard_surface_bsdf(ClosureData closureData, float base, vec
{
float coat_tangent_rotate_degree = coat_rotation * 360.0;
vec3 coat_tangent_rotated;
mx_rotate_vector3(tangent, coat_tangent_rotate_degree, coat_normal, coat_tangent_rotated);
_mx_metashade_rotate_vector3(tangent, coat_tangent_rotate_degree, coat_normal, coat_tangent_rotated);
coat_tangent = normalize(coat_tangent_rotated);
}
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -867,19 +867,6 @@ void mx_roughness_anisotropy(float roughness, float anisotropy, out vec2 result)
result.y = roughness_sqr;
}
}
void mx_rotate_vector3(vec3 _in, float amount, vec3 axis, out vec3 result)
{
// Based on https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula, where the
// Wikipedia formula follows v' = M * v and MaterialX follows v' = v * M, thus the
// order of parameters to cross are reversed.

axis = normalize(axis);
float rotationRadians = mx_radians(amount);
float s = mx_sin(rotationRadians);
float c = mx_cos(rotationRadians);
float oc = 1.0 - c;
result = _in * c + cross(_in, axis) * s + axis * dot(axis, _in) * oc;
}
// These are defined based on the HwShaderGenerator::ClosureContextType enum
// if that changes - these need to be updated accordingly.

Expand Down Expand Up @@ -1581,6 +1568,23 @@ void mx_artistic_ior(vec3 reflectivity, vec3 edge_color, out vec3 ior, out vec3
k2 = max(k2, 0.0);
extinction = sqrt(k2);
}
// Rodrigues' rotation formula.
//
// Private copy of the stdlib rotate3d helper. Avoids
// duplicate-definition errors when the material's own nodegraph
// also uses rotate3d nodes, which would cause the generator to
// emit mx_rotate_vector3 a second time
// (see https://github.com/metashade/metashade/issues/230).
//
void _mx_metashade_rotate_vector3(vec3 in_, float amount, vec3 axis, out vec3 result)
{
vec3 axis_n = normalize(axis);
float rad = radians(amount);
float s = sin(rad);
float c = cos(rad);
result = ((in_ * c) + (cross(in_, axis_n) * s)) + ((axis_n * dot(axis_n, in_)) * (1 - c));
}

void mx_metashade_standard_surface_bsdf(ClosureData closureData, float base, vec3 base_color, float diffuse_roughness, float metalness, float specular, vec3 specular_color, float specular_roughness, float specular_IOR, float specular_anisotropy, float specular_rotation, float transmission, vec3 transmission_color, float transmission_extra_roughness, float subsurface, vec3 subsurface_color, vec3 subsurface_radius, float subsurface_scale, float subsurface_anisotropy, float sheen, vec3 sheen_color, float sheen_roughness, float coat, vec3 coat_color, float coat_roughness, float coat_anisotropy, float coat_rotation, float coat_IOR, vec3 coat_normal, float coat_affect_color, float coat_affect_roughness, float thin_film_thickness, float thin_film_IOR, bool thin_walled, vec3 normal, vec3 tangent, inout BSDF bsdf)
{
//
Expand All @@ -1598,7 +1602,7 @@ void mx_metashade_standard_surface_bsdf(ClosureData closureData, float base, vec
{
float tangent_rotate_degree = specular_rotation * 360.0;
vec3 tangent_rotated;
mx_rotate_vector3(tangent, tangent_rotate_degree, normal, tangent_rotated);
_mx_metashade_rotate_vector3(tangent, tangent_rotate_degree, normal, tangent_rotated);
main_tangent = normalize(tangent_rotated);
}
//
Expand All @@ -1608,7 +1612,7 @@ void mx_metashade_standard_surface_bsdf(ClosureData closureData, float base, vec
{
float coat_tangent_rotate_degree = coat_rotation * 360.0;
vec3 coat_tangent_rotated;
mx_rotate_vector3(tangent, coat_tangent_rotate_degree, coat_normal, coat_tangent_rotated);
_mx_metashade_rotate_vector3(tangent, coat_tangent_rotate_degree, coat_normal, coat_tangent_rotated);
coat_tangent = normalize(coat_tangent_rotated);
}
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1025,19 +1025,6 @@ void mx_roughness_anisotropy(float roughness, float anisotropy, out vec2 result)
result.y = roughness_sqr;
}
}
void mx_rotate_vector3(vec3 _in, float amount, vec3 axis, out vec3 result)
{
// Based on https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula, where the
// Wikipedia formula follows v' = M * v and MaterialX follows v' = v * M, thus the
// order of parameters to cross are reversed.

axis = normalize(axis);
float rotationRadians = mx_radians(amount);
float s = mx_sin(rotationRadians);
float c = mx_cos(rotationRadians);
float oc = 1.0 - c;
result = _in * c + cross(_in, axis) * s + axis * dot(axis, _in) * oc;
}
// These are defined based on the HwShaderGenerator::ClosureContextType enum
// if that changes - these need to be updated accordingly.

Expand Down Expand Up @@ -1739,6 +1726,23 @@ void mx_artistic_ior(vec3 reflectivity, vec3 edge_color, out vec3 ior, out vec3
k2 = max(k2, 0.0);
extinction = sqrt(k2);
}
// Rodrigues' rotation formula.
//
// Private copy of the stdlib rotate3d helper. Avoids
// duplicate-definition errors when the material's own nodegraph
// also uses rotate3d nodes, which would cause the generator to
// emit mx_rotate_vector3 a second time
// (see https://github.com/metashade/metashade/issues/230).
//
void _mx_metashade_rotate_vector3(vec3 in_, float amount, vec3 axis, out vec3 result)
{
vec3 axis_n = normalize(axis);
float rad = radians(amount);
float s = sin(rad);
float c = cos(rad);
result = ((in_ * c) + (cross(in_, axis_n) * s)) + ((axis_n * dot(axis_n, in_)) * (1 - c));
}

void mx_metashade_standard_surface_bsdf(ClosureData closureData, float base, vec3 base_color, float diffuse_roughness, float metalness, float specular, vec3 specular_color, float specular_roughness, float specular_IOR, float specular_anisotropy, float specular_rotation, float transmission, vec3 transmission_color, float transmission_extra_roughness, float subsurface, vec3 subsurface_color, vec3 subsurface_radius, float subsurface_scale, float subsurface_anisotropy, float sheen, vec3 sheen_color, float sheen_roughness, float coat, vec3 coat_color, float coat_roughness, float coat_anisotropy, float coat_rotation, float coat_IOR, vec3 coat_normal, float coat_affect_color, float coat_affect_roughness, float thin_film_thickness, float thin_film_IOR, bool thin_walled, vec3 normal, vec3 tangent, inout BSDF bsdf)
{
//
Expand All @@ -1756,7 +1760,7 @@ void mx_metashade_standard_surface_bsdf(ClosureData closureData, float base, vec
{
float tangent_rotate_degree = specular_rotation * 360.0;
vec3 tangent_rotated;
mx_rotate_vector3(tangent, tangent_rotate_degree, normal, tangent_rotated);
_mx_metashade_rotate_vector3(tangent, tangent_rotate_degree, normal, tangent_rotated);
main_tangent = normalize(tangent_rotated);
}
//
Expand All @@ -1766,7 +1770,7 @@ void mx_metashade_standard_surface_bsdf(ClosureData closureData, float base, vec
{
float coat_tangent_rotate_degree = coat_rotation * 360.0;
vec3 coat_tangent_rotated;
mx_rotate_vector3(tangent, coat_tangent_rotate_degree, coat_normal, coat_tangent_rotated);
_mx_metashade_rotate_vector3(tangent, coat_tangent_rotate_degree, coat_normal, coat_tangent_rotated);
coat_tangent = normalize(coat_tangent_rotated);
}
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1065,19 +1065,6 @@ void mx_roughness_anisotropy(float roughness, float anisotropy, out vec2 result)
result.y = roughness_sqr;
}
}
void mx_rotate_vector3(vec3 _in, float amount, vec3 axis, out vec3 result)
{
// Based on https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula, where the
// Wikipedia formula follows v' = M * v and MaterialX follows v' = v * M, thus the
// order of parameters to cross are reversed.

axis = normalize(axis);
float rotationRadians = mx_radians(amount);
float s = mx_sin(rotationRadians);
float c = mx_cos(rotationRadians);
float oc = 1.0 - c;
result = _in * c + cross(_in, axis) * s + axis * dot(axis, _in) * oc;
}
// These are defined based on the HwShaderGenerator::ClosureContextType enum
// if that changes - these need to be updated accordingly.

Expand Down Expand Up @@ -1779,6 +1766,23 @@ void mx_artistic_ior(vec3 reflectivity, vec3 edge_color, out vec3 ior, out vec3
k2 = max(k2, 0.0);
extinction = sqrt(k2);
}
// Rodrigues' rotation formula.
//
// Private copy of the stdlib rotate3d helper. Avoids
// duplicate-definition errors when the material's own nodegraph
// also uses rotate3d nodes, which would cause the generator to
// emit mx_rotate_vector3 a second time
// (see https://github.com/metashade/metashade/issues/230).
//
void _mx_metashade_rotate_vector3(vec3 in_, float amount, vec3 axis, out vec3 result)
{
vec3 axis_n = normalize(axis);
float rad = radians(amount);
float s = sin(rad);
float c = cos(rad);
result = ((in_ * c) + (cross(in_, axis_n) * s)) + ((axis_n * dot(axis_n, in_)) * (1 - c));
}

void mx_metashade_standard_surface_bsdf(ClosureData closureData, float base, vec3 base_color, float diffuse_roughness, float metalness, float specular, vec3 specular_color, float specular_roughness, float specular_IOR, float specular_anisotropy, float specular_rotation, float transmission, vec3 transmission_color, float transmission_extra_roughness, float subsurface, vec3 subsurface_color, vec3 subsurface_radius, float subsurface_scale, float subsurface_anisotropy, float sheen, vec3 sheen_color, float sheen_roughness, float coat, vec3 coat_color, float coat_roughness, float coat_anisotropy, float coat_rotation, float coat_IOR, vec3 coat_normal, float coat_affect_color, float coat_affect_roughness, float thin_film_thickness, float thin_film_IOR, bool thin_walled, vec3 normal, vec3 tangent, inout BSDF bsdf)
{
//
Expand All @@ -1796,7 +1800,7 @@ void mx_metashade_standard_surface_bsdf(ClosureData closureData, float base, vec
{
float tangent_rotate_degree = specular_rotation * 360.0;
vec3 tangent_rotated;
mx_rotate_vector3(tangent, tangent_rotate_degree, normal, tangent_rotated);
_mx_metashade_rotate_vector3(tangent, tangent_rotate_degree, normal, tangent_rotated);
main_tangent = normalize(tangent_rotated);
}
//
Expand All @@ -1806,7 +1810,7 @@ void mx_metashade_standard_surface_bsdf(ClosureData closureData, float base, vec
{
float coat_tangent_rotate_degree = coat_rotation * 360.0;
vec3 coat_tangent_rotated;
mx_rotate_vector3(tangent, coat_tangent_rotate_degree, coat_normal, coat_tangent_rotated);
_mx_metashade_rotate_vector3(tangent, coat_tangent_rotate_degree, coat_normal, coat_tangent_rotated);
coat_tangent = normalize(coat_tangent_rotated);
}
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -864,19 +864,6 @@ void mx_roughness_anisotropy(float roughness, float anisotropy, out vec2 result)
result.y = roughness_sqr;
}
}
void mx_rotate_vector3(vec3 _in, float amount, vec3 axis, out vec3 result)
{
// Based on https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula, where the
// Wikipedia formula follows v' = M * v and MaterialX follows v' = v * M, thus the
// order of parameters to cross are reversed.

axis = normalize(axis);
float rotationRadians = mx_radians(amount);
float s = mx_sin(rotationRadians);
float c = mx_cos(rotationRadians);
float oc = 1.0 - c;
result = _in * c + cross(_in, axis) * s + axis * dot(axis, _in) * oc;
}
// These are defined based on the HwShaderGenerator::ClosureContextType enum
// if that changes - these need to be updated accordingly.

Expand Down Expand Up @@ -1578,6 +1565,23 @@ void mx_artistic_ior(vec3 reflectivity, vec3 edge_color, out vec3 ior, out vec3
k2 = max(k2, 0.0);
extinction = sqrt(k2);
}
// Rodrigues' rotation formula.
//
// Private copy of the stdlib rotate3d helper. Avoids
// duplicate-definition errors when the material's own nodegraph
// also uses rotate3d nodes, which would cause the generator to
// emit mx_rotate_vector3 a second time
// (see https://github.com/metashade/metashade/issues/230).
//
void _mx_metashade_rotate_vector3(vec3 in_, float amount, vec3 axis, out vec3 result)
{
vec3 axis_n = normalize(axis);
float rad = radians(amount);
float s = sin(rad);
float c = cos(rad);
result = ((in_ * c) + (cross(in_, axis_n) * s)) + ((axis_n * dot(axis_n, in_)) * (1 - c));
}

void mx_metashade_standard_surface_bsdf(ClosureData closureData, float base, vec3 base_color, float diffuse_roughness, float metalness, float specular, vec3 specular_color, float specular_roughness, float specular_IOR, float specular_anisotropy, float specular_rotation, float transmission, vec3 transmission_color, float transmission_extra_roughness, float subsurface, vec3 subsurface_color, vec3 subsurface_radius, float subsurface_scale, float subsurface_anisotropy, float sheen, vec3 sheen_color, float sheen_roughness, float coat, vec3 coat_color, float coat_roughness, float coat_anisotropy, float coat_rotation, float coat_IOR, vec3 coat_normal, float coat_affect_color, float coat_affect_roughness, float thin_film_thickness, float thin_film_IOR, bool thin_walled, vec3 normal, vec3 tangent, inout BSDF bsdf)
{
//
Expand All @@ -1595,7 +1599,7 @@ void mx_metashade_standard_surface_bsdf(ClosureData closureData, float base, vec
{
float tangent_rotate_degree = specular_rotation * 360.0;
vec3 tangent_rotated;
mx_rotate_vector3(tangent, tangent_rotate_degree, normal, tangent_rotated);
_mx_metashade_rotate_vector3(tangent, tangent_rotate_degree, normal, tangent_rotated);
main_tangent = normalize(tangent_rotated);
}
//
Expand All @@ -1605,7 +1609,7 @@ void mx_metashade_standard_surface_bsdf(ClosureData closureData, float base, vec
{
float coat_tangent_rotate_degree = coat_rotation * 360.0;
vec3 coat_tangent_rotated;
mx_rotate_vector3(tangent, coat_tangent_rotate_degree, coat_normal, coat_tangent_rotated);
_mx_metashade_rotate_vector3(tangent, coat_tangent_rotate_degree, coat_normal, coat_tangent_rotated);
coat_tangent = normalize(coat_tangent_rotated);
}
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -864,19 +864,6 @@ void mx_roughness_anisotropy(float roughness, float anisotropy, out vec2 result)
result.y = roughness_sqr;
}
}
void mx_rotate_vector3(vec3 _in, float amount, vec3 axis, out vec3 result)
{
// Based on https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula, where the
// Wikipedia formula follows v' = M * v and MaterialX follows v' = v * M, thus the
// order of parameters to cross are reversed.

axis = normalize(axis);
float rotationRadians = mx_radians(amount);
float s = mx_sin(rotationRadians);
float c = mx_cos(rotationRadians);
float oc = 1.0 - c;
result = _in * c + cross(_in, axis) * s + axis * dot(axis, _in) * oc;
}
// These are defined based on the HwShaderGenerator::ClosureContextType enum
// if that changes - these need to be updated accordingly.

Expand Down Expand Up @@ -1578,6 +1565,23 @@ void mx_artistic_ior(vec3 reflectivity, vec3 edge_color, out vec3 ior, out vec3
k2 = max(k2, 0.0);
extinction = sqrt(k2);
}
// Rodrigues' rotation formula.
//
// Private copy of the stdlib rotate3d helper. Avoids
// duplicate-definition errors when the material's own nodegraph
// also uses rotate3d nodes, which would cause the generator to
// emit mx_rotate_vector3 a second time
// (see https://github.com/metashade/metashade/issues/230).
//
void _mx_metashade_rotate_vector3(vec3 in_, float amount, vec3 axis, out vec3 result)
{
vec3 axis_n = normalize(axis);
float rad = radians(amount);
float s = sin(rad);
float c = cos(rad);
result = ((in_ * c) + (cross(in_, axis_n) * s)) + ((axis_n * dot(axis_n, in_)) * (1 - c));
}

void mx_metashade_standard_surface_bsdf(ClosureData closureData, float base, vec3 base_color, float diffuse_roughness, float metalness, float specular, vec3 specular_color, float specular_roughness, float specular_IOR, float specular_anisotropy, float specular_rotation, float transmission, vec3 transmission_color, float transmission_extra_roughness, float subsurface, vec3 subsurface_color, vec3 subsurface_radius, float subsurface_scale, float subsurface_anisotropy, float sheen, vec3 sheen_color, float sheen_roughness, float coat, vec3 coat_color, float coat_roughness, float coat_anisotropy, float coat_rotation, float coat_IOR, vec3 coat_normal, float coat_affect_color, float coat_affect_roughness, float thin_film_thickness, float thin_film_IOR, bool thin_walled, vec3 normal, vec3 tangent, inout BSDF bsdf)
{
//
Expand All @@ -1595,7 +1599,7 @@ void mx_metashade_standard_surface_bsdf(ClosureData closureData, float base, vec
{
float tangent_rotate_degree = specular_rotation * 360.0;
vec3 tangent_rotated;
mx_rotate_vector3(tangent, tangent_rotate_degree, normal, tangent_rotated);
_mx_metashade_rotate_vector3(tangent, tangent_rotate_degree, normal, tangent_rotated);
main_tangent = normalize(tangent_rotated);
}
//
Expand All @@ -1605,7 +1609,7 @@ void mx_metashade_standard_surface_bsdf(ClosureData closureData, float base, vec
{
float coat_tangent_rotate_degree = coat_rotation * 360.0;
vec3 coat_tangent_rotated;
mx_rotate_vector3(tangent, coat_tangent_rotate_degree, coat_normal, coat_tangent_rotated);
_mx_metashade_rotate_vector3(tangent, coat_tangent_rotate_degree, coat_normal, coat_tangent_rotated);
coat_tangent = normalize(coat_tangent_rotated);
}
//
Expand Down
Loading
Loading