diff --git a/log/xray/GetGitRevisionDescription.cmake b/log/xray/GetGitRevisionDescription.cmake new file mode 100644 index 0000000..8ab03bc --- /dev/null +++ b/log/xray/GetGitRevisionDescription.cmake @@ -0,0 +1,168 @@ +# - Returns a version string from Git +# +# These functions force a re-configure on each git commit so that you can +# trust the values of the variables in your build system. +# +# get_git_head_revision( [ ...]) +# +# Returns the refspec and sha hash of the current head revision +# +# git_describe( [ ...]) +# +# Returns the results of git describe on the source tree, and adjusting +# the output so that it tests false if an error occurs. +# +# git_get_exact_tag( [ ...]) +# +# Returns the results of git describe --exact-match on the source tree, +# and adjusting the output so that it tests false if there was no exact +# matching tag. +# +# git_local_changes() +# +# Returns either "CLEAN" or "DIRTY" with respect to uncommitted changes. +# Uses the return code of "git diff-index --quiet HEAD --". +# Does not regard untracked files. +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +if(__get_git_revision_description) + return() +endif() +set(__get_git_revision_description YES) + +# We must run the following at "include" time, not at function call time, +# to find the path to this module rather than the path to a calling list file +get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) + +function(get_git_head_revision _refspecvar _hashvar) + set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories + set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}") + get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH) + if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT) + # We have reached the root directory, we are not in git + set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + return() + endif() + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + endwhile() + # check if this is a submodule + if(NOT IS_DIRECTORY ${GIT_DIR}) + file(READ ${GIT_DIR} submodule) + string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule}) + get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) + get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE) + endif() + set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") + if(NOT EXISTS "${GIT_DATA}") + file(MAKE_DIRECTORY "${GIT_DATA}") + endif() + + if(NOT EXISTS "${GIT_DIR}/HEAD") + return() + endif() + set(HEAD_FILE "${GIT_DATA}/HEAD") + configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY) + + configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" + "${GIT_DATA}/grabRef.cmake" + @ONLY) + include("${GIT_DATA}/grabRef.cmake") + + set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE) + set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE) +endfunction() + +function(git_describe _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + get_git_head_revision(refspec hash) + if(NOT GIT_FOUND) + set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) + return() + endif() + if(NOT hash) + set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) + return() + endif() + + # TODO sanitize + #if((${ARGN}" MATCHES "&&") OR + # (ARGN MATCHES "||") OR + # (ARGN MATCHES "\\;")) + # message("Please report the following error to the project!") + # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") + #endif() + + #message(STATUS "Arguments to execute_process: ${ARGN}") + + execute_process(COMMAND + "${GIT_EXECUTABLE}" + describe + ${hash} + ${ARGN} + WORKING_DIRECTORY + "${CMAKE_CURRENT_SOURCE_DIR}" + RESULT_VARIABLE + res + OUTPUT_VARIABLE + out + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT res EQUAL 0) + set(out "${out}-${res}-NOTFOUND") + endif() + + set(${_var} "${out}" PARENT_SCOPE) +endfunction() + +function(git_get_exact_tag _var) + git_describe(out --exact-match ${ARGN}) + set(${_var} "${out}" PARENT_SCOPE) +endfunction() + +function(git_local_changes _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + get_git_head_revision(refspec hash) + if(NOT GIT_FOUND) + set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) + return() + endif() + if(NOT hash) + set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) + return() + endif() + + execute_process(COMMAND + "${GIT_EXECUTABLE}" + diff-index --quiet HEAD -- + WORKING_DIRECTORY + "${CMAKE_CURRENT_SOURCE_DIR}" + RESULT_VARIABLE + res + OUTPUT_VARIABLE + out + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(res EQUAL 0) + set(${_var} "CLEAN" PARENT_SCOPE) + else() + set(${_var} "DIRTY" PARENT_SCOPE) + endif() +endfunction() diff --git a/log/xray/GetGitRevisionDescription.cmake.in b/log/xray/GetGitRevisionDescription.cmake.in new file mode 100644 index 0000000..6d8b708 --- /dev/null +++ b/log/xray/GetGitRevisionDescription.cmake.in @@ -0,0 +1,41 @@ +# +# Internal file for GetGitRevisionDescription.cmake +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +set(HEAD_HASH) + +file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) + +string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) +if(HEAD_CONTENTS MATCHES "ref") + # named branch + string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") + if(EXISTS "@GIT_DIR@/${HEAD_REF}") + configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) + else() + configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY) + file(READ "@GIT_DATA@/packed-refs" PACKED_REFS) + if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}") + set(HEAD_HASH "${CMAKE_MATCH_1}") + endif() + endif() +else() + # detached HEAD + configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) +endif() + +if(NOT HEAD_HASH) + file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) + string(STRIP "${HEAD_HASH}" HEAD_HASH) +endif() diff --git a/log/xray/c-ray.h b/log/xray/c-ray.h new file mode 100644 index 0000000..a01368d --- /dev/null +++ b/log/xray/c-ray.h @@ -0,0 +1,274 @@ +// +// c-ray.h +// libc-ray +// +// Created by Valtteri on 5.1.2020. +// Copyright © 2020-2023 Valtteri Koskivuori. All rights reserved. +// + +#ifndef C_RAY_H +#define C_RAY_H + +#ifdef __cplusplus +extern "C" { +#endif + +// c-ray public-facing API + +#include +#include +#include + +#ifdef CR_BUILDING_LIB + #if defined(_WIN32) || defined(__CYGWIN__) + #define CR_EXPORT __declspec(dllexport) + #elif defined(__GNUC__) + #define CR_EXPORT __attribute__((visibility("default"))) + #else + #define CR_EXPORT + #endif +#else + #define CR_EXPORT +#endif + +#define C_RAY_PROTO_DEFAULT_PORT 2222 +#define MAX_CRAY_VERTEX_COUNT 3 + +// -- Library info -- +CR_EXPORT char *cr_get_version(void); //The current semantic version +CR_EXPORT char *cr_get_git_hash(void); //The current git hash of the build + +// -- Renderer -- +struct cr_renderer; +CR_EXPORT struct cr_renderer *cr_new_renderer(void); +CR_EXPORT void cr_destroy_renderer(struct cr_renderer *r); + +enum cr_renderer_param { + // Num + cr_renderer_threads = 0, + cr_renderer_samples, + cr_renderer_bounces, + cr_renderer_tile_width, + cr_renderer_tile_height, + cr_renderer_tile_order, + cr_renderer_output_num, + cr_renderer_override_width, + cr_renderer_override_height, + cr_renderer_override_cam, + cr_renderer_is_iterative, + // String + cr_renderer_output_path, + cr_renderer_asset_path, + cr_renderer_output_name, + cr_renderer_output_filetype, + cr_renderer_node_list, + cr_renderer_blender_mode, +}; + +enum cr_tile_state { + cr_tile_ready_to_render = 0, + cr_tile_rendering, + cr_tile_finished +}; + +struct cr_tile { + int w; + int h; + int start_x; + int start_y; + int end_x; + int end_y; + enum cr_tile_state state; + bool network_renderer; + int index; + size_t total_samples; + size_t completed_samples; +}; + +struct cr_renderer_cb_info { + const struct cr_bitmap **fb; + const struct cr_tile *tiles; + size_t tiles_count; + + size_t active_threads; + double avg_per_ray_us; + int64_t samples_per_sec; + int64_t eta_ms; + size_t finished_passes; + double completion; + bool paused; +}; + +enum cr_renderer_callback { + cr_cb_on_start = 0, + cr_cb_on_stop, + cr_cb_status_update, + cr_cb_on_state_changed, + cr_cb_on_interactive_pass_finished, +}; + +CR_EXPORT bool cr_renderer_set_callback(struct cr_renderer *ext, + enum cr_renderer_callback t, + void (*callback_fn)(struct cr_renderer_cb_info *, void *), + void *user_data); + +CR_EXPORT bool cr_renderer_set_num_pref(struct cr_renderer *ext, enum cr_renderer_param p, uint64_t num); +CR_EXPORT bool cr_renderer_set_str_pref(struct cr_renderer *ext, enum cr_renderer_param p, const char *str); +CR_EXPORT void cr_renderer_stop(struct cr_renderer *ext); +CR_EXPORT void cr_renderer_restart_interactive(struct cr_renderer *ext); +CR_EXPORT void cr_renderer_toggle_pause(struct cr_renderer *ext); +CR_EXPORT const char *cr_renderer_get_str_pref(struct cr_renderer *ext, enum cr_renderer_param p); +CR_EXPORT uint64_t cr_renderer_get_num_pref(struct cr_renderer *ext, enum cr_renderer_param p); + +struct cr_bitmap { + enum cr_bm_colorspace { + cr_bm_linear = 0, + cr_bm_sRGB + } colorspace; + enum cr_bm_channel_precision { + cr_bm_char, + cr_bm_float + } precision; + union { + unsigned char *byte_ptr; + float *float_ptr; + } data; + size_t stride; + size_t width; + size_t height; +}; + +CR_EXPORT void cr_renderer_render(struct cr_renderer *r); +CR_EXPORT void cr_renderer_start_interactive(struct cr_renderer *ext); +CR_EXPORT struct cr_bitmap *cr_renderer_get_result(struct cr_renderer *r); + +// -- Scene -- + +struct cr_vector { + float x, y, z; +}; + +struct cr_coord { + float u, v; +}; + +struct cr_scene; +CR_EXPORT struct cr_scene *cr_renderer_scene_get(struct cr_renderer *r); + +struct cr_scene_totals { + size_t meshes; + size_t spheres; + size_t instances; + size_t cameras; +}; +CR_EXPORT struct cr_scene_totals cr_scene_totals(struct cr_scene *s_ext); + +struct cr_color { + float r; + float g; + float b; + float a; +}; + +typedef int64_t cr_object; + +typedef cr_object cr_sphere; +CR_EXPORT cr_sphere cr_scene_add_sphere(struct cr_scene *s_ext, float radius); +typedef cr_object cr_mesh; + +struct cr_vertex_buf_param { + struct cr_vector *vertices; + size_t vertex_count; + struct cr_vector *normals; + size_t normal_count; + struct cr_coord *tex_coords; + size_t tex_coord_count; +}; + +typedef cr_object cr_vertex_buf; +CR_EXPORT cr_vertex_buf cr_scene_vertex_buf_new(struct cr_scene *s_ext, struct cr_vertex_buf_param in); +CR_EXPORT void cr_mesh_bind_vertex_buf(struct cr_scene *s_ext, cr_mesh mesh, cr_vertex_buf buf); + +struct cr_face { + int vertex_idx[MAX_CRAY_VERTEX_COUNT]; + int normal_idx[MAX_CRAY_VERTEX_COUNT]; + int texture_idx[MAX_CRAY_VERTEX_COUNT]; + unsigned int mat_idx: 16; + bool has_normals; +}; + +CR_EXPORT void cr_mesh_bind_faces(struct cr_scene *s_ext, cr_mesh mesh, struct cr_face *faces, size_t face_count); + +CR_EXPORT cr_mesh cr_scene_mesh_new(struct cr_scene *s_ext, const char *name); +CR_EXPORT cr_mesh cr_scene_get_mesh(struct cr_scene *s_ext, const char *name); + +// -- Camera -- +// FIXME: Use cr_vector +// TODO: Support quaternions, or maybe just a mtx4x4? +enum cr_camera_param { + cr_camera_fov, + cr_camera_focus_distance, + cr_camera_fstops, + + cr_camera_pose_x, + cr_camera_pose_y, + cr_camera_pose_z, + cr_camera_pose_roll, + cr_camera_pose_pitch, + cr_camera_pose_yaw, + + cr_camera_time, + + cr_camera_res_x, + cr_camera_res_y, + cr_camera_blender_coord, +}; + +typedef cr_object cr_camera; +CR_EXPORT cr_camera cr_camera_new(struct cr_scene *ext); +CR_EXPORT bool cr_camera_set_num_pref(struct cr_scene *ext, cr_camera c, enum cr_camera_param p, double num); +CR_EXPORT double cr_camera_get_num_pref(struct cr_scene *ext, cr_camera c, enum cr_camera_param p); +CR_EXPORT bool cr_camera_update(struct cr_scene *ext, cr_camera c); + +// -- Materials -- +#include "node.h" + +typedef cr_object cr_material_set; +CR_EXPORT cr_material_set cr_scene_new_material_set(struct cr_scene *s_ext); +CR_EXPORT void cr_material_set_add(struct cr_scene *s_ext, cr_material_set set, struct cr_shader_node *desc); + +// -- Instancing -- + +typedef int64_t cr_instance; +enum cr_object_type { + cr_object_mesh = 0, + cr_object_sphere +}; + +CR_EXPORT cr_instance cr_instance_new(struct cr_scene *s_ext, cr_object object, enum cr_object_type type); +CR_EXPORT void cr_instance_set_transform(struct cr_scene *s_ext, cr_instance instance, float row_major[4][4]); +CR_EXPORT void cr_instance_transform(struct cr_scene *s_ext, cr_instance instance, float row_major[4][4]); +CR_EXPORT bool cr_instance_bind_material_set(struct cr_scene *s_ext, cr_instance instance, cr_material_set set); + +// -- Misc. -- +CR_EXPORT bool cr_scene_set_background(struct cr_scene *s_ext, struct cr_shader_node *desc); +CR_EXPORT void cr_start_render_worker(int port, size_t thread_limit); +CR_EXPORT void cr_send_shutdown_to_workers(const char *node_list); +CR_EXPORT bool cr_load_json(struct cr_renderer *r_ext, const char *file_path); + +enum cr_log_level { + Silent = 0, + Info, + Debug, + Spam, +}; + +CR_EXPORT void cr_log_level_set(enum cr_log_level); +CR_EXPORT enum cr_log_level cr_log_level_get(void); + +CR_EXPORT void cr_debug_dump_state(struct cr_renderer *r_ext); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/log/xray/gitsha1.c b/log/xray/gitsha1.c new file mode 100644 index 0000000..7add984 --- /dev/null +++ b/log/xray/gitsha1.c @@ -0,0 +1,15 @@ +// +// gitsha1.c +// C-ray +// +// Created by Valtteri Koskivuori on 7.4.2019. +// Copyright © 2019-2020 Valtteri Koskivuori. All rights reserved. +// + +// Autogenerated - Do not edit + +#define GIT_SHA1 "NoHash" + +char *gitHash(void) { + return GIT_SHA1; +} diff --git a/log/xray/node.h b/log/xray/node.h new file mode 100644 index 0000000..5a26acd --- /dev/null +++ b/log/xray/node.h @@ -0,0 +1,367 @@ +// +// node.h +// c-ray +// +// Created by Valtteri Koskivuori on 19/11/2023. +// Copyright © 2023 Valtteri Koskivuori. All rights reserved. +// + +#pragma once + +// These are ripped off here: +// https://docs.blender.org/manual/en/latest/render/shader_nodes/converter/math.html +// TODO: Commented ones need to be implemented to reach parity with Cycles. Feel free to do so! :^) +enum cr_math_op { + Add, + Subtract, + Multiply, + Divide, + //MultiplyAdd, + Power, + Log, + SquareRoot, + InvSquareRoot, + Absolute, + //Exponent, + Min, + Max, + LessThan, + GreaterThan, + Sign, + Compare, + //SmoothMin, + //SmoothMax, + Round, + Floor, + Ceil, + Truncate, + Fraction, + Modulo, + //Wrap, + //Snap, + //PingPong, + Sine, + Cosine, + Tangent, + //ArcSine, + //ArcCosine, + //ArcTangent, + //ArcTan2, + //HyperbolicSine, + //HyperbolicCosine, + //HyperbolicTangent, + ToRadians, + ToDegrees, +}; + +struct cr_value_node { + enum cr_value_node_type { + cr_vn_unknown = 0, + cr_vn_constant, + cr_vn_fresnel, + cr_vn_map_range, + cr_vn_light_path, + cr_vn_alpha, + cr_vn_vec_to_value, + cr_vn_math, + cr_vn_grayscale, + } type; + + union { + double constant; + + struct cr_fresnel_params { + struct cr_value_node *IOR; + struct cr_vector_node *normal; + } fresnel; + + struct cr_map_range_params { + struct cr_value_node *input_value; + struct cr_value_node *from_min; + struct cr_value_node *from_max; + struct cr_value_node *to_min; + struct cr_value_node *to_max; + } map_range; + + struct cr_light_path_params { + enum cr_light_path_info { + cr_is_camera_ray = 0, + cr_is_shadow_ray, + cr_is_diffuse_ray, + cr_is_glossy_ray, + cr_is_singular_ray, + cr_is_reflection_ray, + cr_is_transmission_ray, + cr_ray_length, + } query; + } light_path; + + struct cr_alpha_params { + struct cr_color_node *color; + } alpha; + + struct cr_vec_to_value_params { + enum cr_vec_to_value_component { + X = 0, Y, Z, U, V, F + } comp; + struct cr_vector_node *vec; + } vec_to_value; + + struct cr_math_params { + struct cr_value_node *A; + struct cr_value_node *B; + enum cr_math_op op; + } math; + + struct cr_grayscale_params { + struct cr_color_node *color; + } grayscale; + + } arg; +}; + +// ------ + +struct cr_color_node { + enum color_node_type { + cr_cn_unknown = 0, + cr_cn_constant, + cr_cn_image, + cr_cn_checkerboard, + cr_cn_blackbody, + cr_cn_split, + cr_cn_rgb, + cr_cn_hsl, + cr_cn_hsv, + cr_cn_hsv_tform, + cr_cn_vec_to_color, + cr_cn_gradient, + cr_cn_color_mix, + cr_cn_color_ramp, + } type; + + union { + struct cr_color constant; + + struct cr_image_texture_params { + char *full_path; + uint8_t options; + } image; + + struct cr_checkerboard_params { + struct cr_color_node *a; + struct cr_color_node *b; + struct cr_value_node *scale; + } checkerboard; + + struct cr_blackbody_params { + struct cr_value_node *degrees; + } blackbody; + + struct cr_split_params { + struct cr_value_node *node; + } split; + + struct cr_rgb_params { + struct cr_value_node *red; + struct cr_value_node *green; + struct cr_value_node *blue; + // Alpha? + } rgb; + + struct cr_hsl_params { + struct cr_value_node *H; + struct cr_value_node *S; + struct cr_value_node *L; + } hsl; + + struct cr_hsv_params { + struct cr_value_node *H; + struct cr_value_node *S; + struct cr_value_node *V; + } hsv; + + struct cr_hsv_tform_params { + struct cr_color_node *tex; + struct cr_value_node *H; + struct cr_value_node *S; + struct cr_value_node *V; + struct cr_value_node *f; + } hsv_tform; + + struct cr_vec_to_color_params { + struct cr_vector_node *vec; + } vec_to_color; + + struct cr_gradient_params { + struct cr_color_node *a; + struct cr_color_node *b; + } gradient; + + struct cr_color_mix_params { + struct cr_color_node *a; + struct cr_color_node *b; + struct cr_value_node *factor; + } color_mix; + + struct cr_color_ramp_params { + struct cr_value_node *factor; + enum cr_color_mode { + cr_mode_rgb, + cr_mode_hsv, + cr_mode_hsl, + } color_mode; + + enum cr_interpolation { + cr_ease, // TODO + cr_cardinal, // TODO + cr_linear, + cr_b_spline, // TODO + cr_constant, + } interpolation; + + struct ramp_element { + struct cr_color color; + float position; // [0.0,1.0] + } *elements; + + int element_count; + } color_ramp; + } arg; +}; + +// ----- + +// These are ripped off here: +// https://docs.blender.org/manual/en/latest/render/shader_nodes/converter/vector_math.html +// TODO: Commented ones need to be implemented to reach parity with Cycles. Feel free to do so! :^) +enum cr_vec_op { + VecAdd, + VecSubtract, + VecMultiply, + VecDivide, + //VecMultiplyAdd, + VecCross, + //VecProject, + VecReflect, + VecRefract, + //VecFaceforward, + VecDot, + VecDistance, + VecLength, + VecScale, + VecNormalize, + VecWrap, + //VecSnap, + VecFloor, + VecCeil, + VecModulo, + //VecFraction, + VecAbs, + VecMin, + VecMax, + VecSin, + VecCos, + VecTan, +}; + +struct cr_vector_node { + enum cr_vector_node_type { + cr_vec_unknown = 0, + cr_vec_constant, + cr_vec_normal, + cr_vec_uv, + cr_vec_vecmath, + cr_vec_mix, + } type; + + // TODO: Maybe express vectorValue vec/coord/float union a bit better here? + union { + struct cr_vector constant; + + struct cr_vecmath_params { + struct cr_vector_node *A; + struct cr_vector_node *B; + struct cr_vector_node *C; + struct cr_value_node *f; + enum cr_vec_op op; + } vecmath; + + struct cr_vec_mix_params { + struct cr_vector_node *A; + struct cr_vector_node *B; + struct cr_value_node *factor; + } vec_mix; + + } arg; +}; + +struct cr_shader_node { + enum cr_shader_node_type { + cr_bsdf_unknown = 0, + cr_bsdf_diffuse, + cr_bsdf_metal, + cr_bsdf_glass, + cr_bsdf_plastic, + cr_bsdf_mix, + cr_bsdf_add, + cr_bsdf_transparent, + cr_bsdf_emissive, + cr_bsdf_translucent, + cr_bsdf_background, + } type; + + union { + struct cr_diffuse_args { + struct cr_color_node *color; + } diffuse; + + struct cr_metal_args { + struct cr_color_node *color; + struct cr_value_node *roughness; + } metal; + + struct cr_glass_args { + struct cr_color_node *color; + struct cr_value_node *roughness; + struct cr_value_node *IOR; + } glass; + + struct cr_plastic_args { + struct cr_color_node *color; + struct cr_value_node *roughness; + struct cr_value_node *IOR; + } plastic; + + struct cr_mix_args { + struct cr_shader_node *A; + struct cr_shader_node *B; + struct cr_value_node *factor; + } mix; + + struct cr_add_args { + struct cr_shader_node *A; + struct cr_shader_node *B; + } add; + + struct cr_transparent_args { + struct cr_color_node *color; + } transparent; + + struct cr_emissive_args { + struct cr_color_node *color; + struct cr_value_node *strength; + } emissive; + + struct cr_translucent_args { + struct cr_color_node *color; + } translucent; + + struct cr_background_args { + struct cr_color_node *color; + struct cr_vector_node *pose; + struct cr_value_node *strength; + } background; + + } arg; +}; diff --git a/log/xray/set_up_ccache.cmake b/log/xray/set_up_ccache.cmake new file mode 100644 index 0000000..6c31bba --- /dev/null +++ b/log/xray/set_up_ccache.cmake @@ -0,0 +1,9 @@ +find_program(CCACHE_PROGRAM ccache) +if (CCACHE_PROGRAM) + get_filename_component(compiler_path "${CMAKE_C_COMPILER}" REALPATH) + get_filename_component(compiler_name "${compiler_path}" NAME) + if (NOT ${compiler_name} MATCHES "ccache") + message(STATUS "Enabling ccache") + set("CMAKE_C_COMPILER_LAUNCHER" "${CCACHE_PROGRAM}" CACHE FILEPATH "Path to a compiler launcher, usually ccache") + endif() +endif()