Skip to content

Commit

Permalink
Merge remote-tracking branch 'b/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
youle31 committed Apr 26, 2024
2 parents 5472270 + d11c696 commit 0208b5b
Show file tree
Hide file tree
Showing 142 changed files with 2,524 additions and 1,532 deletions.
20 changes: 16 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,27 @@ enable_testing()
if(CMAKE_COMPILER_IS_GNUCC)
if("${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "11.0.0")
message(FATAL_ERROR "\
The minimum supported version of GCC is 11.0.0, found ${CMAKE_C_COMPILER_VERSION}"
The minimum supported version of GCC is 11.0.0, found C compiler: ${CMAKE_C_COMPILER_VERSION}"
)
endif()
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
if(CMAKE_COMPILER_IS_GNUCC AND ("${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "8.0"))
if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "11.0.0")
message(FATAL_ERROR "\
The minimum supported version of CLANG is 8.0, found ${CMAKE_C_COMPILER_VERSION}"
The minimum supported version of GCC is 11.0.0, found C++ compiler${CMAKE_CXX_COMPILER_VERSION}"
)
endif()
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
if(CMAKE_COMPILER_IS_GNUCC)
if("${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "8.0")
message(FATAL_ERROR "\
The minimum supported version of CLANG is 8.0, found C compiler ${CMAKE_C_COMPILER_VERSION}"
)
endif()
if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "8.0")
message(FATAL_ERROR "\
The minimum supported version of CLANG is 8.0, found C++ compiler ${CMAKE_CXX_COMPILER_VERSION}"
)
endif()
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
if(MSVC_VERSION VERSION_LESS "1928")
# MSVC_VERSION is an internal version number, it doesn't map to something
Expand Down
17 changes: 17 additions & 0 deletions build_files/build_environment/patches/openimageio.diff
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,20 @@ diff -Naur orig/src/cmake/compiler.cmake external_openimageio/src/cmake/compiler
endif (MSVC)

if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD"
diff --git a/src/libOpenImageIO/imageioplugin.cpp b/src/libOpenImageIO/imageioplugin.cpp
index 9ad45042e..d2a0210ff 100644
--- a/src/libOpenImageIO/imageioplugin.cpp
+++ b/src/libOpenImageIO/imageioplugin.cpp
@@ -469,12 +469,6 @@ pvt::catalog_all_plugins(std::string searchpath)

std::unique_lock<std::recursive_mutex> lock(imageio_mutex);
append_if_env_exists(searchpath, "OIIO_LIBRARY_PATH", true);
-#ifdef __APPLE__
- append_if_env_exists(searchpath, "DYLD_LIBRARY_PATH");
-#endif
-#if defined(__linux__) || defined(__FreeBSD__)
- append_if_env_exists(searchpath, "LD_LIBRARY_PATH");
-#endif

size_t patlen = pattern.length();
std::vector<std::string> dirs;
4 changes: 2 additions & 2 deletions extern/mantaflow/helper/util/simpleimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ bool SimpleImage::initFromPpm(std::string filename)
rowsize = windW * 3;
}

unsigned char *pic = new unsigned char[size]; // (GLubyte *)malloc (size);

// Read in maximum value (ignore) , could be scanned with sscanf as well, but this should be
// 255... 3rd line
if (fgets(line, MAXLINE, fp) == nullptr) {
Expand All @@ -162,6 +160,8 @@ bool SimpleImage::initFromPpm(std::string filename)
return 0;
}

unsigned char *pic = new unsigned char[size]; // (GLubyte *)malloc (size);

// Read in the pixel array row-by-row: 1st row = top scanline */
unsigned char *ptr = nullptr;
ptr = &pic[(windH - 1) * rowsize];
Expand Down
29 changes: 21 additions & 8 deletions intern/cycles/blender/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ BlenderAttributeType blender_attribute_name_split_type(ustring name, string *r_r
void python_thread_state_save(void **python_thread_state);
void python_thread_state_restore(void **python_thread_state);

static bool mesh_use_corner_normals(BL::Mesh &mesh, Mesh::SubdivisionType subdivision_type)
{
return mesh && (subdivision_type == Mesh::SUBDIVISION_NONE) &&
(static_cast<const ::Mesh *>(mesh.ptr.data)->normals_domain(true) ==
blender::bke::MeshNormalDomain::Corner);
}

static inline BL::Mesh object_to_mesh(BL::BlendData & /*data*/,
BObjectInfo &b_ob_info,
BL::Depsgraph & /*depsgraph*/,
Expand All @@ -88,27 +95,33 @@ static inline BL::Mesh object_to_mesh(BL::BlendData & /*data*/,

BL::Mesh mesh = (b_ob_info.object_data.is_a(&RNA_Mesh)) ? BL::Mesh(b_ob_info.object_data) :
BL::Mesh(PointerRNA_NULL);
const bool split_faces = (mesh) && (subdivision_type == Mesh::SUBDIVISION_NONE) &&
(static_cast<const ::Mesh *>(mesh.ptr.data)->normals_domain(true) ==
blender::bke::MeshNormalDomain::Corner);

bool use_corner_normals = false;

if (b_ob_info.is_real_object_data()) {
if (mesh) {
/* Make a copy to split faces if we use auto-smooth, otherwise not needed.
* Also in edit mode do we need to make a copy, to ensure data layers like
* UV are not empty. */
if (mesh.is_editmode() || split_faces) {
if (mesh.is_editmode()) {
/* Flush editmesh to mesh, including all data layers. */
BL::Depsgraph depsgraph(PointerRNA_NULL);
mesh = b_ob_info.real_object.to_mesh(false, depsgraph);
use_corner_normals = mesh_use_corner_normals(mesh, subdivision_type);
}
else if (mesh_use_corner_normals(mesh, subdivision_type)) {
/* Make a copy to split faces. */
BL::Depsgraph depsgraph(PointerRNA_NULL);
mesh = b_ob_info.real_object.to_mesh(false, depsgraph);
use_corner_normals = true;
}
}
else {
BL::Depsgraph depsgraph(PointerRNA_NULL);
mesh = b_ob_info.real_object.to_mesh(false, depsgraph);
use_corner_normals = mesh_use_corner_normals(mesh, subdivision_type);
}
}
else {
/* TODO: what to do about non-mesh geometry instances? */
use_corner_normals = mesh_use_corner_normals(mesh, subdivision_type);
}

#if 0
Expand All @@ -121,7 +134,7 @@ static inline BL::Mesh object_to_mesh(BL::BlendData & /*data*/,
#endif

if (mesh) {
if (split_faces) {
if (use_corner_normals) {
mesh.split_faces();
}

Expand Down
6 changes: 4 additions & 2 deletions intern/cycles/kernel/osl/shaders/node_glass_bsdf.osl
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ shader node_glass_bsdf(color Color = 0.8,
normal Normal = N,
output closure color BSDF = 0)
{
float r2 = Roughness * Roughness;
color base_color = max(Color, color(0.0));
float r2 = clamp(Roughness, 0.0, 1.0);
r2 = r2 * r2;
float eta = max(IOR, 1e-5);
eta = backfacing() ? 1.0 / eta : eta;
color F0 = F0_from_ior(eta);
color F90 = color(1.0);

BSDF = generalized_schlick_bsdf(
Normal, vector(0.0), Color, Color, r2, r2, F0, F90, -eta, distribution);
Normal, vector(0.0), base_color, base_color, r2, r2, F0, F90, -eta, distribution);
}
9 changes: 6 additions & 3 deletions intern/cycles/kernel/osl/shaders/node_glossy_bsdf.osl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ shader node_glossy_bsdf(color Color = 0.8,
output closure color BSDF = 0)
{
/* compute roughness */
float roughness = Roughness * Roughness;
color base_color = max(Color, color(0.0));
float roughness = clamp(Roughness, 0.0, 1.0);
roughness = roughness * roughness;
float roughness_u, roughness_v;
float aniso = clamp(Anisotropy, -0.99, 0.99);

Expand All @@ -41,7 +43,8 @@ shader node_glossy_bsdf(color Color = 0.8,
}

if (distribution == "Multiscatter GGX")
BSDF = Color * microfacet_multi_ggx_aniso(Normal, T, roughness_u, roughness_v, Color);
BSDF = base_color *
microfacet_multi_ggx_aniso(Normal, T, roughness_u, roughness_v, base_color);
else
BSDF = Color * microfacet(distribution, Normal, T, roughness_u, roughness_v, 0.0, 0);
BSDF = base_color * microfacet(distribution, Normal, T, roughness_u, roughness_v, 0.0, 0);
}
5 changes: 3 additions & 2 deletions intern/cycles/kernel/osl/shaders/node_sheen_bsdf.osl
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ shader node_sheen_bsdf(color Color = 0.8,
normal Normal = N,
output closure color BSDF = 0)
{
color base_color = max(Color, color(0.0));
float roughness = clamp(Roughness, 0.0, 1.0);

if (distribution == "ashikhmin")
BSDF = Color * ashikhmin_velvet(Normal, roughness);
BSDF = base_color * ashikhmin_velvet(Normal, roughness);
else if (distribution == "microfiber")
BSDF = Color * sheen(Normal, roughness);
BSDF = base_color * sheen(Normal, roughness);
}
21 changes: 11 additions & 10 deletions intern/cycles/kernel/osl/shaders/node_subsurface_scattering.osl
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ shader node_subsurface_scattering(color Color = 0.8,
normal Normal = N,
output closure color BSSRDF = 0)
{
BSSRDF = Color * bssrdf(method,
Normal,
Scale * Radius,
Color,
"ior",
IOR,
"anisotropy",
Anisotropy,
"roughness",
1.0);
color base_color = max(Color, color(0.0));
BSSRDF = base_color * bssrdf(method,
Normal,
Scale * Radius,
base_color,
"ior",
IOR,
"anisotropy",
Anisotropy,
"roughness",
1.0);
}
30 changes: 16 additions & 14 deletions intern/cycles/kernel/svm/closure.h
Original file line number Diff line number Diff line change
Expand Up @@ -470,24 +470,24 @@ ccl_device
break;
}

float roughness = sqr(param1);
float roughness = sqr(saturatef(param1));

bsdf->N = maybe_ensure_valid_specular_reflection(sd, N);
bsdf->ior = 1.0f;

/* compute roughness */
float anisotropy = clamp(param2, -0.99f, 0.99f);
if (data_node.y == SVM_STACK_INVALID || fabsf(anisotropy) <= 1e-4f) {
if (data_node.w == SVM_STACK_INVALID || fabsf(anisotropy) <= 1e-4f) {
/* Isotropic case. */
bsdf->T = zero_float3();
bsdf->alpha_x = roughness;
bsdf->alpha_y = roughness;
}
else {
bsdf->T = stack_load_float3(stack, data_node.y);
bsdf->T = stack_load_float3(stack, data_node.w);

/* rotate tangent */
float rotation = stack_load_float(stack, data_node.z);
float rotation = stack_load_float(stack, data_node.y);
if (rotation != 0.0f) {
bsdf->T = rotate_around_axis(bsdf->T, bsdf->N, rotation * M_2PI_F);
}
Expand All @@ -512,8 +512,9 @@ ccl_device
else {
sd->flag |= bsdf_microfacet_ggx_setup(bsdf);
if (type == CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID) {
kernel_assert(stack_valid(data_node.w));
const Spectrum color = rgb_to_spectrum(stack_load_float3(stack, data_node.w));
kernel_assert(stack_valid(data_node.z));
const Spectrum color = max(rgb_to_spectrum(stack_load_float3(stack, data_node.z)),
zero_spectrum());
bsdf_microfacet_setup_fresnel_constant(kg, bsdf, sd, color);
}
}
Expand Down Expand Up @@ -580,12 +581,12 @@ ccl_device

float ior = fmaxf(param2, 1e-5f);
bsdf->ior = (sd->flag & SD_BACKFACING) ? 1.0f / ior : ior;
bsdf->alpha_x = bsdf->alpha_y = sqr(param1);
bsdf->alpha_x = bsdf->alpha_y = sqr(saturatef(param1));

fresnel->f0 = make_float3(F0_from_ior(ior));
fresnel->f90 = one_spectrum();
fresnel->exponent = -ior;
const float3 color = stack_load_float3(stack, data_node.z);
const float3 color = max(stack_load_float3(stack, data_node.y), zero_float3());
fresnel->reflection_tint = reflective_caustics ? rgb_to_spectrum(color) : zero_spectrum();
fresnel->transmission_tint = refractive_caustics ? rgb_to_spectrum(color) :
zero_spectrum();
Expand Down Expand Up @@ -622,7 +623,7 @@ ccl_device

if (bsdf) {
bsdf->N = N;
bsdf->roughness = param1;
bsdf->roughness = saturatef(param1);

sd->flag |= bsdf_sheen_setup(kg, sd, bsdf);
}
Expand Down Expand Up @@ -834,10 +835,10 @@ ccl_device
bsdf->N = maybe_ensure_valid_specular_reflection(sd, N);
bsdf->roughness1 = param1;
bsdf->roughness2 = param2;
bsdf->offset = -stack_load_float(stack, data_node.z);
bsdf->offset = -stack_load_float(stack, data_node.y);

if (stack_valid(data_node.y)) {
bsdf->T = normalize(stack_load_float3(stack, data_node.y));
if (stack_valid(data_node.w)) {
bsdf->T = normalize(stack_load_float3(stack, data_node.w));
}
else if (!(sd->type & PRIMITIVE_CURVE)) {
bsdf->T = normalize(sd->dPdv);
Expand Down Expand Up @@ -866,12 +867,13 @@ ccl_device
ccl_private Bssrdf *bssrdf = bssrdf_alloc(sd, weight);

if (bssrdf) {
bssrdf->radius = rgb_to_spectrum(stack_load_float3(stack, data_node.z) * param1);
bssrdf->radius = max(rgb_to_spectrum(stack_load_float3(stack, data_node.y) * param1),
zero_spectrum());
bssrdf->albedo = closure_weight;
bssrdf->N = maybe_ensure_valid_specular_reflection(sd, N);
bssrdf->ior = param2;
bssrdf->alpha = 1.0f;
bssrdf->anisotropy = stack_load_float(stack, data_node.w);
bssrdf->anisotropy = stack_load_float(stack, data_node.z);

sd->flag |= bssrdf_setup(sd, bssrdf, path_flag, (ClosureType)type);
}
Expand Down
47 changes: 29 additions & 18 deletions intern/cycles/scene/shader_nodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2283,14 +2283,14 @@ bool BsdfBaseNode::has_bump()
BsdfNode::BsdfNode(const NodeType *node_type) : BsdfBaseNode(node_type) {}

void BsdfNode::compile(SVMCompiler &compiler,
ShaderInput *param1,
ShaderInput *param2,
ShaderInput *param3,
ShaderInput *param4)
ShaderInput *bsdf_y,
ShaderInput *bsdf_z,
ShaderInput *data_y,
ShaderInput *data_z,
ShaderInput *data_w)
{
ShaderInput *color_in = input("Color");
ShaderInput *normal_in = input("Normal");
ShaderInput *tangent_in = input("Tangent");

if (color_in->link) {
compiler.add_node(NODE_CLOSURE_WEIGHT, compiler.stack_assign(color_in));
Expand All @@ -2300,21 +2300,20 @@ void BsdfNode::compile(SVMCompiler &compiler,
}

int normal_offset = (normal_in) ? compiler.stack_assign_if_linked(normal_in) : SVM_STACK_INVALID;
int tangent_offset = (tangent_in) ? compiler.stack_assign_if_linked(tangent_in) :
SVM_STACK_INVALID;
int param3_offset = (param3) ? compiler.stack_assign(param3) : SVM_STACK_INVALID;
int param4_offset = (param4) ? compiler.stack_assign(param4) : SVM_STACK_INVALID;
int data_y_offset = (data_y) ? compiler.stack_assign(data_y) : SVM_STACK_INVALID;
int data_z_offset = (data_z) ? compiler.stack_assign(data_z) : SVM_STACK_INVALID;
int data_w_offset = (data_w) ? compiler.stack_assign(data_w) : SVM_STACK_INVALID;

compiler.add_node(
NODE_CLOSURE_BSDF,
compiler.encode_uchar4(closure,
(param1) ? compiler.stack_assign(param1) : SVM_STACK_INVALID,
(param2) ? compiler.stack_assign(param2) : SVM_STACK_INVALID,
(bsdf_y) ? compiler.stack_assign(bsdf_y) : SVM_STACK_INVALID,
(bsdf_z) ? compiler.stack_assign(bsdf_z) : SVM_STACK_INVALID,
compiler.closure_mix_weight_offset()),
__float_as_int((param1) ? get_float(param1->socket_type) : 0.0f),
__float_as_int((param2) ? get_float(param2->socket_type) : 0.0f));
__float_as_int((bsdf_y) ? get_float(bsdf_y->socket_type) : 0.0f),
__float_as_int((bsdf_z) ? get_float(bsdf_z->socket_type) : 0.0f));

compiler.add_node(normal_offset, tangent_offset, param3_offset, param4_offset);
compiler.add_node(normal_offset, data_y_offset, data_z_offset, data_w_offset);
}

void BsdfNode::compile(SVMCompiler &compiler)
Expand Down Expand Up @@ -2392,13 +2391,21 @@ void GlossyBsdfNode::compile(SVMCompiler &compiler)
{
closure = distribution;

ShaderInput *tangent = input("Tangent");
tangent = compiler.is_linked(tangent) ? tangent : nullptr;

/* TODO: Just use weight for legacy MultiGGX? Would also simplify OSL. */
if (closure == CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID) {
BsdfNode::compile(
compiler, input("Roughness"), input("Anisotropy"), input("Rotation"), input("Color"));
BsdfNode::compile(compiler,
input("Roughness"),
input("Anisotropy"),
input("Rotation"),
input("Color"),
tangent);
}
else {
BsdfNode::compile(compiler, input("Roughness"), input("Anisotropy"), input("Rotation"));
BsdfNode::compile(
compiler, input("Roughness"), input("Anisotropy"), input("Rotation"), nullptr, tangent);
}
}

Expand Down Expand Up @@ -3535,7 +3542,11 @@ void HairBsdfNode::compile(SVMCompiler &compiler)
{
closure = component;

BsdfNode::compile(compiler, input("RoughnessU"), input("RoughnessV"), input("Offset"));
ShaderInput *tangent = input("Tangent");
tangent = compiler.is_linked(tangent) ? tangent : nullptr;

BsdfNode::compile(
compiler, input("RoughnessU"), input("RoughnessV"), input("Offset"), nullptr, tangent);
}

void HairBsdfNode::compile(OSLCompiler &compiler)
Expand Down

0 comments on commit 0208b5b

Please sign in to comment.