Skip to content

Commit

Permalink
Started synching with cleanup codebase.
Browse files Browse the repository at this point in the history
  • Loading branch information
xelatihy committed Jan 11, 2024
1 parent facb3bd commit 595554a
Show file tree
Hide file tree
Showing 13 changed files with 1,128 additions and 312 deletions.
44 changes: 22 additions & 22 deletions libs/yocto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ add_library(yocto STATIC
yocto_parallel.h yocto_cli.h
)

set_target_properties(yocto PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED YES)
set_target_properties(yocto PROPERTIES CXX_STANDARD 20 CXX_STANDARD_REQUIRED YES)
target_include_directories(yocto PRIVATE ext/)
target_include_directories(yocto PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")

Expand Down Expand Up @@ -46,42 +46,42 @@ if(YOCTO_DENOISE)
endif(YOCTO_DENOISE)

if(YOCTO_CUDA)
enable_language(CUDA)
set_target_properties(yocto PROPERTIES CUDA_STANDARD 17 CUDA_STANDARD_REQUIRED YES)

enable_language(CUDA)
set_target_properties(yocto PROPERTIES CUDA_STANDARD 17 CUDA_STANDARD_REQUIRED YES)
# Optix
if(DEFINED ENV{OptiX_INSTALL_DIR})
find_path(OptiX_ROOT_DIR NAMES include/optix.h PATHS $ENV{OptiX_INSTALL_DIR})
else()
find_path(OptiX_ROOT_DIR NAMES include/optix.h)
endif()

# Optix
if (DEFINED ENV{OptiX_INSTALL_DIR})
find_path(OptiX_ROOT_DIR NAMES include/optix.h PATHS $ENV{OptiX_INSTALL_DIR})
else()
find_path(OptiX_ROOT_DIR NAMES include/optix.h)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OptiX FOUND_VAR OptiX_FOUND REQUIRED_VARS OptiX_ROOT_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OptiX FOUND_VAR OptiX_FOUND REQUIRED_VARS OptiX_ROOT_DIR)

add_library(OptiX::OptiX INTERFACE IMPORTED)
target_include_directories(OptiX::OptiX INTERFACE ${OptiX_ROOT_DIR}/include)
add_library(OptiX::OptiX INTERFACE IMPORTED)
target_include_directories(OptiX::OptiX INTERFACE ${OptiX_ROOT_DIR}/include)

embed_ptx(
OUTPUT_TARGET
embed_ptx(
OUTPUT_TARGET
yocto_cutrace_device
PTX_LINK_LIBRARIES
PTX_LINK_LIBRARIES
OptiX::OptiX
SOURCES
SOURCES
yocto_cutrace.cu
)

target_compile_definitions(yocto PUBLIC -DYOCTO_CUDA)
)

find_package(CUDAToolkit REQUIRED)
target_link_libraries(yocto PUBLIC OptiX::OptiX yocto_cutrace_device CUDA::cuda_driver CUDA::cudart_static)
target_compile_definitions(yocto PUBLIC -DYOCTO_CUDA)

find_package(CUDAToolkit REQUIRED)
target_link_libraries(yocto PUBLIC OptiX::OptiX yocto_cutrace_device CUDA::cuda_driver CUDA::cudart_static)
endif(YOCTO_CUDA)

# warning flags
if(APPLE)
target_compile_options(yocto PUBLIC -Wall -Wconversion -Wno-sign-conversion -Wno-implicit-float-conversion -Wno-unused-variable)
endif(APPLE)

if(MSVC)
target_compile_options(yocto PUBLIC /D_CRT_SECURE_NO_WARNINGS)
target_compile_options(yocto PUBLIC /EHsc)
Expand Down
4 changes: 0 additions & 4 deletions libs/yocto/yocto_bvh.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,6 @@ scene_intersection intersect_instance_ebvh(const scene_ebvh& bvh,
// -----------------------------------------------------------------------------
namespace yocto {

// backward compatibility
using bvh_shape [[deprecated]] = shape_bvh;
using bvh_scene [[deprecated]] = scene_bvh;

// backward compatibility
[[deprecated]] inline shape_bvh make_bvh(
const shape_data& shape, bool embree = false, bool highquality = false) {
Expand Down
22 changes: 22 additions & 0 deletions libs/yocto/yocto_color.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,18 @@ inline vec3f rgba_to_rgb(const vec4f& rgba);

// Apply contrast. Grey should be 0.18 for linear and 0.5 for gamma.
inline vec3f lincontrast(const vec3f& rgb, float contrast, float grey);
inline vec4f lincontrast(const vec4f& rgb, float contrast, float grey);
// Apply contrast in log2. Grey should be 0.18 for linear and 0.5 for gamma.
inline vec3f logcontrast(const vec3f& rgb, float logcontrast, float grey);
inline vec4f logcontrast(const vec4f& rgb, float logcontrast, float grey);
// Apply an s-shaped contrast.
inline vec3f contrast(const vec3f& rgb, float contrast);
inline vec4f contrast(const vec4f& rgb, float contrast);
// Apply saturation.
inline vec3f saturate(const vec3f& rgb, float saturation,
const vec3f& weights = vec3f{0.333333f, 0.333333f, 0.333333f});
inline vec4f saturate(const vec4f& rgb, float saturation,
const vec3f& weights = vec3f{0.333333f, 0.333333f, 0.333333f});

// Apply tone mapping
inline vec3f tonemap(
Expand Down Expand Up @@ -262,6 +267,10 @@ inline vec3f rgba_to_rgb(const vec4f& rgba) { return xyz(rgba); }
inline vec3f lincontrast(const vec3f& rgb, float contrast, float grey) {
return max({0, 0, 0}, grey + (rgb - grey) * (contrast * 2));
}
inline vec4f lincontrast(const vec4f& rgb, float contrast, float grey) {
auto ret = lincontrast(xyz(rgb), contrast, grey);
return {ret.x, ret.y, ret.z, rgb.w};
}
// Apply contrast in log2. Grey should be 0.18 for linear and 0.5 for gamma.
inline vec3f logcontrast(const vec3f& rgb, float logcontrast, float grey) {
auto epsilon = (float)0.0001;
Expand All @@ -270,16 +279,29 @@ inline vec3f logcontrast(const vec3f& rgb, float logcontrast, float grey) {
auto adjusted = log_grey + (log_ldr - log_grey) * (logcontrast * 2);
return max({0, 0, 0}, exp2(adjusted) - epsilon);
}
inline vec4f logcontrast(const vec4f& rgb, float contrast, float grey) {
auto ret = logcontrast(xyz(rgb), contrast, grey);
return {ret.x, ret.y, ret.z, rgb.w};
}
// Apply an s-shaped contrast.
inline vec3f contrast(const vec3f& rgb, float contrast) {
return gain(rgb, 1 - contrast);
}
inline vec4f contrast(const vec4f& rgb, float contrast) {
auto ret = yocto::contrast(xyz(rgb), contrast);
return {ret.x, ret.y, ret.z, rgb.w};
}
// Apply saturation.
inline vec3f saturate(
const vec3f& rgb, float saturation, const vec3f& weights) {
auto grey = dot(weights, rgb);
return max({0, 0, 0}, grey + (rgb - grey) * (saturation * 2));
}
inline vec4f saturate(
const vec4f& rgb, float saturation, const vec3f& weights) {
auto ret = saturate(xyz(rgb), saturation, weights);
return {ret.x, ret.y, ret.z, rgb.w};
}

#ifndef __CUDACC__

Expand Down
2 changes: 1 addition & 1 deletion libs/yocto/yocto_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2557,7 +2557,7 @@ struct glwidgets_param {
glwidgets_param(
vec3f value, const vec2f& minmax = {0, 0}, bool readonly = false)
: type{glwidgets_param_type::value3f}
, valuef{value.x, value.y, value.z}
, valuef{value.x, value.y, value.z, 0}
, minmaxf{minmax}
, readonly{readonly} {}
glwidgets_param(
Expand Down
Loading

0 comments on commit 595554a

Please sign in to comment.