8#include <pxr/base/gf/camera.h>
9#include <pxr/imaging/glf/drawTarget.h>
10#include <pxr/usd/usdGeom/camera.h>
59 Object *camera_obj = scene->camera;
61 float camera_points[4][3];
64 float screen_points[4][2];
65 for (
int i = 0; i < 4; i++) {
66 float world_location[] = {
67 camera_points[i][0], camera_points[i][1], camera_points[i][2], 1.0f};
68 mul_m4_v4(camera_obj->object_to_world().ptr(), world_location);
71 if (world_location[3] > 0.0) {
73 screen_width * 0.5f * (world_location[0] / world_location[3]);
75 screen_height * 0.5f * (world_location[1] / world_location[3]);
80 float x1_f = std::min(
81 {screen_points[0][0], screen_points[1][0], screen_points[2][0], screen_points[3][0]});
82 float x2_f = std::max(
83 {screen_points[0][0], screen_points[1][0], screen_points[2][0], screen_points[3][0]});
84 float y1_f = std::min(
85 {screen_points[0][1], screen_points[1][1], screen_points[2][1], screen_points[3][1]});
86 float y2_f = std::max(
87 {screen_points[0][1], screen_points[1][1], screen_points[2][1], screen_points[3][1]});
90 float x = x1_f, y = y1_f;
91 float dx = x2_f - x1_f, dy = y2_f - y1_f;
93 x1 = x + scene->r.border.xmin * dx;
94 x2 = x + scene->r.border.xmax * dx;
95 y1 = y + scene->r.border.ymin * dy;
96 y2 = y + scene->r.border.ymax * dy;
114 border = pxr::GfVec4i(x1, y1, x2, y2);
137 float coords[8] = {0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0};
205 if (view_settings.
width() * view_settings.
height() == 0) {
211 pxr::GfVec4d viewport(0.0, 0.0, view_settings.
width(), view_settings.
height());
232 pxr::GfVec4d draw_viewport(view_settings.
border[0],
239 draw_texture_.
draw(shader, draw_viewport, gpu_task->
aov_texture(pxr::HdAovTokens->color));
244 draw_texture_.
draw(shader, draw_viewport);
253 char elapsed_time[32];
261 std ::string(
"Time: ") + elapsed_time +
262 " | Done: " + std::to_string(
int(percent_done)) +
"%",
267 notify_status(percent_done / 100.0, std::string(
"Time: ") + elapsed_time,
"Rendering Done");
278 const std::string &info,
279 const std::string &status)
Camera data-block and utility functions.
void BKE_camera_view_frame(const struct Scene *scene, const struct Camera *camera, float r_vec[4][3])
void * CTX_wm_region_data(const bContext *C)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
View3D * CTX_wm_view3d(const bContext *C)
void mul_m4_v4(const float mat[4][4], float r[4])
Platform independent time functions.
double BLI_time_now_seconds(void)
size_t BLI_timecode_string_from_time_simple(char *str, size_t maxncpy, double time_seconds) ATTR_NONNULL()
blender::gpu::Batch * GPU_batch_create_ex(GPUPrimType primitive_type, blender::gpu::VertBuf *vertex_buf, blender::gpu::IndexBuf *index_buf, eGPUBatchFlag owns_flag)
void GPU_batch_discard(blender::gpu::Batch *batch)
void GPU_batch_set_shader(blender::gpu::Batch *batch, GPUShader *shader)
void GPU_batch_draw(blender::gpu::Batch *batch)
GPUFrameBuffer * GPU_framebuffer_active_get()
void GPU_framebuffer_bind(GPUFrameBuffer *framebuffer)
void GPU_matrix_scale_2f(float x, float y)
void GPU_matrix_translate_2f(float x, float y)
int GPU_shader_get_sampler_binding(GPUShader *shader, const char *name)
void GPU_shader_uniform_1i(GPUShader *sh, const char *name, int value)
void GPU_shader_bind(GPUShader *shader)
GPUShader * GPU_shader_get_builtin_shader(eGPUBuiltinShader shader)
int GPU_texture_height(const GPUTexture *texture)
void GPU_texture_bind(GPUTexture *texture, int unit)
GPUTexture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, eGPUTextureFormat format, eGPUTextureUsage usage, const float *data)
void GPU_texture_free(GPUTexture *texture)
int GPU_texture_width(const GPUTexture *texture)
@ GPU_TEXTURE_USAGE_GENERAL
void GPU_texture_update(GPUTexture *texture, eGPUDataFormat data_format, const void *data)
#define GPU_vertbuf_create_with_format(format)
void GPU_vertbuf_attr_fill(blender::gpu::VertBuf *, uint a_idx, const void *data)
void GPU_vertbuf_data_alloc(blender::gpu::VertBuf &verts, uint v_len)
struct GPUShader GPUShader
GPUTexture * texture() const
void write_data(int width, int height, const void *data)
void draw(GPUShader *shader, const pxr::GfVec4d &viewport, GPUTexture *tex=nullptr)
RenderEngine * bl_engine_
float renderer_percent_done()
std::unique_ptr< pxr::HdxFreeCameraSceneDelegate > free_camera_delegate_
pxr::HdTaskSharedPtrVector tasks()
std::unique_ptr< RenderTaskDelegate > render_task_delegate_
std::unique_ptr< pxr::HdRenderIndex > render_index_
std::unique_ptr< LightTasksDelegate > light_tasks_delegate_
std::unique_ptr< pxr::HdEngine > engine_
GPUTexture * aov_texture(pxr::TfToken const &aov_key)
void notify_status(float progress, const std::string &title, const std::string &info) override
additional_info("compositor_sum_float_shared") .push_constant(Type additional_info("compositor_sum_float_shared") .push_constant(Type GPU_RGBA32F
void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char *info)
static pxr::GfCamera gf_camera(const CameraParams ¶ms, const pxr::GfVec2i &res, const pxr::GfVec4f &border)
ViewSettings(bContext *context)