Commit 3b7ec7ad authored by Milan Jaros's avatar Milan Jaros
Browse files

add new version, add libug, add new mercedes scene

parent fc83326e
......@@ -279,7 +279,7 @@ endif()
if (WITH_CLIENT_CUDA)
find_package(CUDA REQUIRED)
set(CUDA_BINARIES_ARCH sm_30 sm_35 sm_37 sm_50 sm_52 sm_60 sm_61 sm_70 sm_75 CACHE STRING "CUDA architectures to build binaries for")
set(CUDA_CUSTOM_LIBRARIES "" CACHE FILEPATH "")
#set(CUDA_CUSTOM_LIBRARIES "" CACHE FILEPATH "")
endif()
if(WITH_CUDA_GL_INTEROP)
......@@ -299,7 +299,7 @@ endif()
# Subdirectories
if (WITH_CLIENT_CUDA)
add_subdirectory(cycles_cuda)
#add_subdirectory(cycles_cuda)
endif()
if (WITH_CLIENT_RENDERENGINE)
......
......@@ -2119,9 +2119,9 @@ void file_path_trace_socket(client_kernel_struct &data)
# ifdef WITH_CLIENT_ULTRAGRID
// YUV I420
{
# ifdef _WIN32
// usleep(2000000);
# endif
//# ifdef _WIN32
// // usleep(2000000);
//# endif
int tile_w = data.client_path_trace_data.tile_w;
int tile_h = data.client_path_trace_data.tile_h;
......@@ -2130,7 +2130,7 @@ void file_path_trace_socket(client_kernel_struct &data)
tile_w *= 2;
# endif
# ifdef WITH_RGBA_FORMAT
# if defined(WITH_RGBA_FORMAT) || defined(WITH_CLIENT_ULTRAGRID_LIB)
// rendering buffer - results in RGBA format
int buf_type = cesnet_set_render_buffer_rgba(
(unsigned char *)pixels, tile_w, tile_h);
......
......@@ -3750,7 +3750,7 @@ void cuda_path_trace_internal(int numDevice,
void *args[] = {&scope.get().d_work_tiles,
&total_work_size,
&wtile.y,
&wtile.h,
&h, //&wtile.h,
&dev_buffer,
&dev_pixels_node,
&start_sample,
......
......@@ -359,6 +359,18 @@ endif()
)
endif()
if(WITH_CLIENT_ULTRAGRID_LIB)
list(APPEND cuda_flags
-DWITH_CLIENT_ULTRAGRID_LIB
)
endif()
if(WITH_RGBA_FORMAT)
list(APPEND cuda_flags
-DWITH_RGBA_FORMAT
)
endif()
if(WITH_SIZE_UCHAR3)
list(APPEND cuda_flags
-DWITH_SIZE_UCHAR3
......
......@@ -21,6 +21,11 @@
#include "vrgstream.h"
#endif
#include <omp.h>
#ifndef _WIN32
#include <unistd.h>
#endif
constexpr const int BUFFERS = 2;
#define KEY "UltraGrid-SHM"
#define MAX_BUF_LEN (7680 * 2160 * 4)
......@@ -167,6 +172,10 @@ bool g_cdata_init = false;
bool g_is_required_exit = false;
int g_sensor_width = 36;
double g_max_fps = 90.0;
double g_last_time = 0.0;
double g_last_time_counter = 0.0;
struct shm_frame {
atomic_bool buffer_free;
int width, height;
......@@ -288,9 +297,8 @@ void cesnet_set_camera_data(cyclesphi::cyclesphi_data *cdata)
g_cdata.width = 7680 / 2 ;
g_cdata.height = 2160 ;
// g_cdata.width = 5120 / 2;
// g_cdata.height = 1440; //2116x1203
//g_cdata.width = 1440;
//g_cdata.height = 1600;
const char* env_res_w = getenv("DEBUG_RES_W");
const char* env_res_h = getenv("DEBUG_RES_H");
if (env_res_w != NULL && env_res_h != NULL) {
......@@ -373,7 +381,7 @@ void cesnet_set_camera_data(cyclesphi::cyclesphi_data *cdata)
if(env_p_port_cam)
g_init_params.rx_port = atoi(env_p_port_cam);
g_init_params.compression = UG_UNCOMPRESSED; //UG_JPEG
g_init_params.compression = UG_JPEG; //UG_JPEG; //UG_UNCOMPRESSED; //UG_JPEG;//
const char* env_libug_comp = getenv("LIBUG_COMPRESSION");
if (env_libug_comp != NULL) {
if (!strcmp(env_libug_comp, "UG_UNCOMPRESSED")) {
......@@ -383,20 +391,34 @@ void cesnet_set_camera_data(cyclesphi::cyclesphi_data *cdata)
g_init_params.compression = UG_JPEG;
}
}
g_init_params.rprc = render_packet_received_callback;
g_init_params.rprc_udata = NULL; // not used by render_packet_received_callback()
//g_init_params.mtu = 8900;
g_init_params.mtu = 9000;
g_ug_sender = ug_sender_init(&g_init_params);
printf("ug_sender_init: %s, %lld\n", g_init_params.receiver, g_ug_sender);
#endif
g_cdata_init = true;
const char *env_p_max_fps = std::getenv("UG_MAX_FPS");
if(env_p_max_fps)
g_max_fps = atof(env_p_max_fps);
g_cdata_init = true;
}
memcpy(cdata, &g_cdata, sizeof(cyclesphi::cyclesphi_data));
if(omp_get_wtime() - g_last_time < 1.0 / g_max_fps /*&& g_last_time_counter > g_max_fps*/) {
#ifndef _WIN32
usleep(1000.0 * 1000.0 * (1.0 / g_max_fps - omp_get_wtime() + g_last_time));
#endif
//g_cdata.step_samples++;
//g_last_time_counter = 0;
}
g_last_time = omp_get_wtime();
//g_last_time_counter = g_last_time_counter + 1.0;
}
#define READY_TO_CONSUME_FRAME 0
......@@ -489,7 +511,7 @@ static bool post_should_exit = false;
static platform_ipc_shm_t shm_id = PLATFORM_IPC_ERR;
static platform_ipc_sem_t sem[3] = {PLATFORM_IPC_ERR, PLATFORM_IPC_ERR, PLATFORM_IPC_ERR};
#ifdef WITH_RGBA_FORMAT
# if defined(WITH_RGBA_FORMAT) || defined(WITH_CLIENT_ULTRAGRID_LIB)
static void shm_cleanup() {
#ifdef DEBUG
fprintf(stderr, "shm_cleanup() called\n");
......@@ -542,8 +564,12 @@ int cesnet_set_render_buffer_rgba(unsigned char* rgba, int width, int height)
}
#ifdef WITH_CLIENT_ULTRAGRID_LIB
//printf("ug_send_frame: %d x %d\n", width, height);
#ifdef WITH_RGBA_FORMAT
ug_send_frame(g_ug_sender, (char*)rgba, UG_RGBA, width, height);
#else
//printf("ug_send_frame: %d x %d\n", width, height);
ug_send_frame(g_ug_sender, (char*)rgba, UG_I420, width, height);
#endif
return 0;
#endif
......
......@@ -8,7 +8,7 @@ bool cesnet_is_required_exit();
void cesnet_set_camera_data(cyclesphi::cyclesphi_data *cdata);
//void cesnet_set_inverse_matrix(float* transform_inverse_view_matrix, float* position, float* orientation);
#ifdef WITH_RGBA_FORMAT
# if defined(WITH_RGBA_FORMAT) || defined(WITH_CLIENT_ULTRAGRID_LIB)
int cesnet_set_render_buffer_rgba(unsigned char *rgba, int width, int height);
int cesnet_get_buffers(char** buf1, char** buf2);
#else
......
......@@ -6,11 +6,13 @@
#define DLLIMPORT
#endif
#ifndef VRG_STREAM_API
#ifdef __cplusplus
#define VRG_STREAM_API extern "C" DLLIMPORT
#else
#define VRG_STREAM_API
#endif
#endif
struct ProjectionFovTan {
float left;
......
set(INC
.
${GLFW_INCLUDE_DIR}
${OPENVR_INCLUDE_DIR}
${OPENVR_INCLUDE_DIR}
../glad/include
../renderengine/src
......@@ -16,6 +16,7 @@ set(INC
${CUDA_INCLUDE_DIRS}
${NVPIPE_INCLUDE_DIR}
${ULTRAGRID_INCLUDE_DIR}
)
set(SRC
......@@ -27,6 +28,10 @@ set(SRC
../api/client_api.h
)
set(SRC_LIBUG
vrclient_libug.cpp
)
if(WITH_OPENMP)
add_definitions(-DWITH_OPENMP)
endif()
......@@ -87,7 +92,7 @@ add_definitions(
include_directories(${INC})
if(WITH_VRCLIENT_VRGSTREAM)
add_library(vrgstream STATIC ${SRC})
add_library(vrgstream SHARED ${SRC})
target_link_libraries(vrgstream glad ${GLFW_LIBRARIES})
if(WITH_CUDA_GL_INTEROP)
......@@ -100,6 +105,11 @@ if(WITH_VRCLIENT_VRGSTREAM)
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include
)
add_executable(vrclient ${SRC_LIBUG})
target_link_libraries(vrclient vrgstream ${ULTRAGRID_LIBRARIES})
install (TARGETS vrclient DESTINATION bin)
else()
add_executable(vrclient ${SRC})
target_link_libraries(vrclient glad ${GLFW_LIBRARIES})
......
This diff is collapsed.
//#include <unistd.h>
#if _WIN32
#include <windows.h>
#endif
#include <assert.h>
//#include <pthread.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libug.h>
//static bool exit_requested = false;
//static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
//static pthread_cond_t cv = PTHREAD_COND_INITIALIZER;
//
//static void signal_handler(int signal) {
// char msg[] = "Signal XXX caught... Exiting\n";
// char *signum = strstr(msg, "XXX"); // allowed in POSIX.1-2016
// signum[0] = '0' + ((signal / 100) % 10);
// signum[1] = '0' + ((signal / 10) % 10);
// signum[2] = '0' + (signal % 10);
// write(2, msg, sizeof msg - 1);
// pthread_mutex_lock(&lock);
// exit_requested = true;
// pthread_mutex_unlock(&lock);
// pthread_cond_signal(&cv);
//}
//
//static void usage(const char *progname) {
// printf("%s [options] [sender[:port]]\n", progname);
// printf("options:\n");
// printf("\t-h - show this help\n");
// printf("\t-d - display (default vrg)\n");
// printf("\t-c I420|RGBA - force decompress to codec\n");
//}
int main(int argc, char *argv[]) {
ug_receiver_parameters init_params;
memset(&init_params, 0, sizeof(ug_receiver_parameters));
init_params.decompress_to = UG_RGBA;// : UG_I420;
init_params.display = "vrg";//"gl";// "vrg";
init_params.sender = "195.113.250.203";// "localhost";
//init_params.rx_port = 5004;
//init_params.tx_port = 5006;
ug_receiver* s = ug_receiver_start(&init_params);
if (s == NULL) {
return 2;
}
while (true) {
#ifdef _WIN32
Sleep(1);
#else
usleep(1000000L);
#endif
}
ug_receiver_done(s);
return 0;
}
......@@ -89,26 +89,38 @@ ccl_device uchar4 film_float_to_byte(float4 color)
// i420
ccl_device void kernel_rgb_to_yuv_i420(
ccl_global uchar *destination, uchar r, uchar g, uchar b, int x, int y, int tile_h, int tile_w)
ccl_global uchar *destination,
uchar r, uchar g, uchar b,
int x,
int y,
int offset,
int stride,
//int tile_x,
//int tile_y,
int tile_h,
int tile_w)
{
size_t image_size = tile_w * tile_h;
size_t image_size = stride * tile_h;
uchar *dst_y = destination;
uchar *dst_u = destination + image_size;
uchar *dst_v = destination + image_size + image_size / 4;
// Y
int index_y = x + y * tile_w;
int index_y = offset + x + y * stride;
//int index_y = offset + (x + tile_x) + (y + tile_y) * stride;
dst_y[index_y] = ((66 * r + 129 * g + 25 * b) >> 8) + 16;
// U
if (x % 2 == 0 && y % 2 == 0) {
int index_u = (x / 2) + (y / 2) * (tile_w / 2);
if ((x) % 2 == 0 && (y) % 2 == 0) {
int index_u = offset / 2 + (x / 2) + (y / 2) * (stride / 2);
//int index_u = offset / 2 + (x + tile_x) / 2 + (y + tile_y) / 2 * stride / 2;
dst_u[index_u] = ((-38 * r + -74 * g + 112 * b) >> 8) + 128;
}
// V
if (x % 2 == 0 && y % 2 == 0) {
int index_v = (x / 2) + (y / 2) * (tile_w / 2);
if ((x) % 2 == 0 && (y) % 2 == 0) {
int index_v = offset / 2 + (x / 2) + (y / 2) * (stride / 2);
//int index_v = offset / 2 + (x + tile_x) / 2 + (y + tile_y) / 2 * stride / 2;
dst_v[index_v] = ((112 * r + -94 * g + -18 * b) >> 8) + 128;
}
}
......@@ -121,22 +133,32 @@ ccl_device void kernel_film_convert_to_byte_i420(KernelGlobals *kg,
int y,
int offset,
int stride,
int tile_x,
int tile_y,
//int tile_x,
//int tile_y,
int tile_h,
int tile_w)
{
/* buffer offset */
int index = offset + (x + tile_x) + (y + tile_y) * stride;
// /* buffer offset */
// int index = offset + (x + tile_x) + (y + tile_y) * stride;
//
// buffer += index * kernel_data.film.pass_stride;
//
// /* map colors */
// float4 irradiance = *((float4 *)buffer);
// float4 float_result = film_map(kg, irradiance, sample_scale);
// uchar4 byte_result = film_float_to_byte(float_result);
//
// kernel_rgb_to_yuv_i420(yuv, byte_result.x, byte_result.y, byte_result.z, x, y, tile_h, tile_w);
int index = offset + x + y * stride;
buffer += index * kernel_data.film.pass_stride;
//rgba += index;
buffer += index*kernel_data.film.pass_stride ;
/* map colors */
float4 irradiance = *((float4 *)buffer);
float4 float_result = film_map(kg, irradiance, sample_scale);
float4 rgba_in = *(ccl_global float4 *)buffer;
float4 float_result = film_map(kg, rgba_in * sample_scale, 1.0f);
uchar4 byte_result = film_float_to_byte(float_result);
kernel_rgb_to_yuv_i420(yuv, byte_result.x, byte_result.y, byte_result.z, x, y, tile_h, tile_w);
//*rgba = byte_result;
kernel_rgb_to_yuv_i420(yuv, byte_result.x, byte_result.y, byte_result.z, x, y, offset, stride, tile_h, tile_w);
}
ccl_device void kernel_film_convert_to_byte(KernelGlobals *kg,
......@@ -171,7 +193,7 @@ ccl_device void kernel_film_convert_to_byte(KernelGlobals *kg,
rgba += index;
*rgba = uchar_result;
#endif
#endif
}
ccl_device void kernel_film_convert_to_float(KernelGlobals *kg,
......
......@@ -110,17 +110,17 @@ CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS)
if(pixel != NULL) {
#if defined(WITH_CLIENT_YUV)
#if defined(WITH_CLIENT_YUV) || (!defined(WITH_RGBA_FORMAT) && defined(WITH_CLIENT_ULTRAGRID_LIB))
kernel_film_convert_to_byte_i420(NULL,
(uchar *)pixel,
(float *)buffer,
1.0f / end_sample,
x,
y,
x + tile->x,
y + tile_y,
tile->offset,
tile->stride,
tile->x,
tile_y,
//tile->x,
//tile_y,
tile_h,
tile->w);
#else
......
This diff is collapsed.
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
bl_info = {
"name": "Add Camera Rigs",
"author": "Wayne Dixon, Brian Raschko, Kris Wittig, Damien Picard, Flavio Perez",
"version": (1, 4, 4),
"blender": (2, 80, 0),
"location": "View3D > Add > Camera > Dolly or Crane Rig",
"description": "Adds a Camera Rig with UI",
"doc_url": "{BLENDER_MANUAL_URL}/addons/camera/camera_rigs.html",
"tracker_url": "https://github.com/waylow/add_camera_rigs/issues",
"category": "Camera",
}
import bpy
import os
from . import build_rigs
from . import operators
from . import ui_panels
from . import prefs
from . import composition_guides_menu
# =========================================================================
# Registration:
# =========================================================================
def register():
build_rigs.register()
operators.register()
ui_panels.register()
prefs.register()
composition_guides_menu.register()
def unregister():
build_rigs.unregister()
operators.unregister()
ui_panels.unregister()
prefs.unregister()
composition_guides_menu.unregister()
if __name__ == "__main__":
register()
This diff is collapsed.
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
import bpy
from bpy.types import Panel
from .operators import get_rig_and_cam
class ADD_CAMERA_RIGS_PT_composition_guides(Panel):
bl_label = "Composition Guides"
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
def draw(self, context):
layout = self.layout
rig, cam = get_rig_and_cam(context.active_object)
cam = cam.data
layout.prop(cam, "show_safe_areas")
layout.row().separator()
layout.prop(cam, "show_composition_center")
layout.prop(cam, "show_composition_center_diagonal")
layout.prop(cam, "show_composition_golden")
layout.prop(cam, "show_composition_golden_tria_a")
layout.prop(cam, "show_composition_golden_tria_b")
layout.prop(cam, "show_composition_harmony_tri_a")
layout.prop(cam, "show_composition_harmony_tri_b")
layout.prop(cam, "show_composition_thirds")
def register():
bpy.utils.register_class(ADD_CAMERA_RIGS_PT_composition_guides)
def unregister():
bpy.utils.unregister_class(ADD_CAMERA_RIGS_PT_composition_guides)
if __name__ == "__main__":
register()
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
import bpy
from mathutils import Vector
from math import cos, sin, pi
def create_widget(name):
"""Create an empty widget object and return the object"""
prefs = bpy.context.preferences.addons["add_camera_rigs"].preferences
widget_prefix = prefs.widget_prefix
obj_name = widget_prefix + name
scene = bpy.context.scene
obj = bpy.data.objects.get(obj_name)
if obj is None:
mesh = bpy.data.meshes.new(obj_name)
obj = bpy.data.objects.new(obj_name, mesh)
# Create a new collection for the widgets
collection_name = prefs.camera_widget_collection_name
coll = bpy.data.collections.get(collection_name)
if coll is None:
coll = bpy.data.collections.new(collection_name)
scene.collection.children.link(coll)
coll.hide_viewport = True
coll.hide_render = True