forked from blender/blender
Collection of bugfixes #76
@ -2,6 +2,7 @@
|
||||
* Copyright 2011-2022 Blender Foundation */
|
||||
|
||||
#include "DNA_camera_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_view3d_types.h"
|
||||
|
||||
@ -10,11 +11,9 @@
|
||||
|
||||
namespace blender::render::hydra {
|
||||
|
||||
CameraData::CameraData(bContext *context)
|
||||
CameraData::CameraData(View3D *v3d, ARegion *region)
|
||||
{
|
||||
View3D *view3d = CTX_wm_view3d(context);
|
||||
RegionView3D *region_data = (RegionView3D *)CTX_wm_region_data(context);
|
||||
ARegion *region = CTX_wm_region(context);
|
||||
RegionView3D *region_data = (RegionView3D *)region->regiondata;
|
||||
|
||||
/* This constant was found experimentally, didn't find such option in
|
||||
* context.view3d or context.region_data. */
|
||||
@ -27,9 +26,9 @@ CameraData::CameraData(bContext *context)
|
||||
switch (region_data->persp) {
|
||||
case RV3D_PERSP: {
|
||||
mode_ = CAM_PERSP;
|
||||
clip_range_ = pxr::GfRange1f(view3d->clip_start, view3d->clip_end);
|
||||
clip_range_ = pxr::GfRange1f(v3d->clip_start, v3d->clip_end);
|
||||
lens_shift_ = pxr::GfVec2f(0.0, 0.0);
|
||||
focal_length_ = view3d->lens;
|
||||
focal_length_ = v3d->lens;
|
||||
|
||||
if (ratio > 1.0) {
|
||||
sensor_size_ = pxr::GfVec2f(VIEWPORT_SENSOR_SIZE, VIEWPORT_SENSOR_SIZE / ratio);
|
||||
@ -44,8 +43,8 @@ CameraData::CameraData(bContext *context)
|
||||
mode_ = CAM_ORTHO;
|
||||
lens_shift_ = pxr::GfVec2f(0.0f, 0.0f);
|
||||
|
||||
float o_size = region_data->dist * VIEWPORT_SENSOR_SIZE / view3d->lens;
|
||||
float o_depth = view3d->clip_end;
|
||||
float o_size = region_data->dist * VIEWPORT_SENSOR_SIZE / v3d->lens;
|
||||
float o_depth = v3d->clip_end;
|
||||
|
||||
clip_range_ = pxr::GfRange1f(-o_depth * 0.5, o_depth * 0.5);
|
||||
|
||||
@ -60,7 +59,7 @@ CameraData::CameraData(bContext *context)
|
||||
|
||||
case RV3D_CAMOB: {
|
||||
pxr::GfMatrix4d mat = transform_;
|
||||
*this = CameraData(view3d->camera, res, pxr::GfVec4f(0, 0, 1, 1));
|
||||
*this = CameraData(v3d->camera, res, pxr::GfVec4f(0, 0, 1, 1));
|
||||
transform_ = mat;
|
||||
|
||||
/* This formula was taken from previous plugin with corresponded comment.
|
||||
@ -141,7 +140,7 @@ CameraData::CameraData(Object *camera_obj, pxr::GfVec2i res, pxr::GfVec4f tile)
|
||||
lens_shift_[1] / t_size[1] + (t_pos[1] + t_size[1] * 0.5 - 0.5) / t_size[1]);
|
||||
|
||||
switch (camera->type) {
|
||||
case CAM_PERSP:
|
||||
case CAM_PERSP: {
|
||||
focal_length_ = camera->lens;
|
||||
|
||||
switch (camera->sensor_fit) {
|
||||
@ -165,8 +164,9 @@ CameraData::CameraData(Object *camera_obj, pxr::GfVec2i res, pxr::GfVec4f tile)
|
||||
}
|
||||
sensor_size_ = pxr::GfVec2f(sensor_size_[0] * t_size[0], sensor_size_[1] * t_size[1]);
|
||||
break;
|
||||
}
|
||||
|
||||
case CAM_ORTHO:
|
||||
case CAM_ORTHO: {
|
||||
focal_length_ = 0.0f;
|
||||
switch (camera->sensor_fit) {
|
||||
case CAMERA_SENSOR_FIT_VERT:
|
||||
@ -189,8 +189,9 @@ CameraData::CameraData(Object *camera_obj, pxr::GfVec2i res, pxr::GfVec4f tile)
|
||||
}
|
||||
ortho_size_ = pxr::GfVec2f(ortho_size_[0] * t_size[0], ortho_size_[1] * t_size[1]);
|
||||
break;
|
||||
}
|
||||
|
||||
case CAM_PANO:
|
||||
case CAM_PANO: {
|
||||
/* TODO: Recheck parameters for PANO camera */
|
||||
focal_length_ = camera->lens;
|
||||
|
||||
@ -214,10 +215,14 @@ CameraData::CameraData(Object *camera_obj, pxr::GfVec2i res, pxr::GfVec4f tile)
|
||||
break;
|
||||
}
|
||||
sensor_size_ = pxr::GfVec2f(sensor_size_[0] * t_size[0], sensor_size_[1] * t_size[1]);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
default: {
|
||||
focal_length_ = camera->lens;
|
||||
sensor_size_ = pxr::GfVec2f(camera->sensor_y * ratio, camera->sensor_y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,15 +8,15 @@
|
||||
#include <pxr/base/gf/camera.h>
|
||||
#include <pxr/base/gf/vec2f.h>
|
||||
|
||||
#include "BKE_context.h"
|
||||
|
||||
#include "DNA_object_types.h"
|
||||
struct ARegion;
|
||||
struct Object;
|
||||
struct View3D;
|
||||
|
||||
namespace blender::render::hydra {
|
||||
|
||||
class CameraData {
|
||||
public:
|
||||
CameraData(bContext *context);
|
||||
CameraData(View3D *v3d, ARegion *region);
|
||||
CameraData(Object *camera_obj, pxr::GfVec2i res, pxr::GfVec4f tile);
|
||||
|
||||
pxr::GfCamera gf_camera();
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
#include "BLI_path_util.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
|
||||
#include "GPU_context.h"
|
||||
|
||||
#include "DEG_depsgraph_query.h"
|
||||
@ -83,7 +85,7 @@ void Engine::sync(Depsgraph *depsgraph, bContext *context)
|
||||
hydra_scene_delegate_ = std::make_unique<BlenderSceneDelegate>(
|
||||
render_index_.get(), scene_path, scene_delegate_settings_);
|
||||
}
|
||||
hydra_scene_delegate_->populate(depsgraph, context);
|
||||
hydra_scene_delegate_->populate(depsgraph, CTX_wm_view3d(context));
|
||||
}
|
||||
else {
|
||||
/* Slow USD export for reference. */
|
||||
@ -98,7 +100,7 @@ void Engine::sync(Depsgraph *depsgraph, bContext *context)
|
||||
usd_scene_delegate_ = std::make_unique<USDSceneDelegate>(
|
||||
render_index_.get(), scene_path, scene_delegate_settings_);
|
||||
}
|
||||
usd_scene_delegate_->populate(depsgraph, context);
|
||||
usd_scene_delegate_->populate(depsgraph);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,8 @@ void FinalEngine::render(Depsgraph *depsgraph)
|
||||
const Scene *scene = DEG_get_evaluated_scene(depsgraph);
|
||||
const ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
|
||||
|
||||
char scene_name[MAX_NAME];
|
||||
BKE_id_full_name_get(scene_name, (ID *)scene, 0);
|
||||
char scene_name[MAX_ID_FULL_NAME];
|
||||
BKE_id_full_name_get(scene_name, &scene->id, 0);
|
||||
scene_name_ = scene_name;
|
||||
layer_name_ = view_layer->name;
|
||||
|
||||
@ -98,23 +98,26 @@ void FinalEngine::notify_status(float progress, const std::string &title, const
|
||||
|
||||
void FinalEngine::update_render_result()
|
||||
{
|
||||
RenderResult *result = RE_engine_begin_result(
|
||||
RenderResult *rr = RE_engine_begin_result(
|
||||
bl_engine_, 0, 0, resolution_[0], resolution_[1], layer_name_.c_str(), nullptr);
|
||||
|
||||
/* TODO: only for the first render layer */
|
||||
RenderLayer *layer = (RenderLayer *)result->layers.first;
|
||||
for (RenderPass *pass = (RenderPass *)layer->passes.first; pass != nullptr; pass = pass->next) {
|
||||
RenderLayer *rlayer = static_cast<RenderLayer *>(
|
||||
BLI_findstring(&rr->layers, layer_name_.c_str(), offsetof(RenderLayer, name)));
|
||||
|
||||
if (rlayer) {
|
||||
LISTBASE_FOREACH (RenderPass *, rpass, &rlayer->passes) {
|
||||
pxr::TfToken aov_key;
|
||||
if (STREQ(pass->name, "Combined")) {
|
||||
if (STREQ(rpass->name, "Combined")) {
|
||||
aov_key = pxr::HdAovTokens->color;
|
||||
}
|
||||
else if (STREQ(pass->name, "Depth")) {
|
||||
else if (STREQ(rpass->name, "Depth")) {
|
||||
aov_key = pxr::HdAovTokens->depth;
|
||||
}
|
||||
render_task_delegate_->read_aov(aov_key, pass->ibuf->float_buffer.data);
|
||||
render_task_delegate_->read_aov(aov_key, rpass->ibuf->float_buffer.data);
|
||||
}
|
||||
}
|
||||
|
||||
RE_engine_end_result(bl_engine_, result, false, false, false);
|
||||
RE_engine_end_result(bl_engine_, rr, false, false, false);
|
||||
}
|
||||
|
||||
} // namespace blender::render::hydra
|
||||
|
@ -5,9 +5,9 @@
|
||||
|
||||
namespace blender::render::hydra {
|
||||
|
||||
void PreviewEngine::notify_status(float progress,
|
||||
const std::string &title,
|
||||
const std::string &info)
|
||||
void PreviewEngine::notify_status(float /* progress */,
|
||||
const std::string & /* title */,
|
||||
const std::string & /* info */)
|
||||
{
|
||||
/* Empty fucntion */
|
||||
}
|
||||
|
@ -11,6 +11,8 @@
|
||||
#include <pxr/usdImaging/usdImagingGL/engine.h>
|
||||
|
||||
#include "BKE_appdir.h"
|
||||
#include "BKE_context.h"
|
||||
|
||||
#include "BLI_fileops.h"
|
||||
#include "BLI_path_util.h"
|
||||
|
||||
@ -220,7 +222,8 @@ static PyObject *cache_or_get_image_file_func(PyObject * /*self*/, PyObject *arg
|
||||
bContext *context = (bContext *)PyLong_AsVoidPtr(pycontext);
|
||||
Image *image = (Image *)PyLong_AsVoidPtr(pyimage);
|
||||
|
||||
std::string image_path = cache_or_get_image_file(image, context, nullptr);
|
||||
std::string image_path = cache_or_get_image_file(
|
||||
CTX_data_main(context), CTX_data_scene(context), image, nullptr);
|
||||
return PyUnicode_FromString(image_path.c_str());
|
||||
}
|
||||
|
||||
@ -258,6 +261,8 @@ static struct PyModuleDef module = {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyObject *BPyInit_hydra(void);
|
||||
|
||||
PyObject *BPyInit_hydra(void)
|
||||
{
|
||||
PyObject *mod = PyModule_Create(&blender::render::hydra::module);
|
||||
|
@ -198,14 +198,14 @@ pxr::HdVolumeFieldDescriptorVector BlenderSceneDelegate::GetVolumeFieldDescripto
|
||||
return v_data->field_descriptors();
|
||||
}
|
||||
|
||||
void BlenderSceneDelegate::populate(Depsgraph *deps, bContext *cont)
|
||||
void BlenderSceneDelegate::populate(Depsgraph *deps, View3D *v3d)
|
||||
{
|
||||
bool is_populated = depsgraph != nullptr;
|
||||
|
||||
depsgraph = deps;
|
||||
context = cont;
|
||||
bmain = DEG_get_bmain(deps);
|
||||
scene = DEG_get_input_scene(depsgraph);
|
||||
view3d = CTX_wm_view3d(context);
|
||||
view3d = v3d;
|
||||
|
||||
if (is_populated) {
|
||||
check_updates();
|
||||
@ -231,7 +231,7 @@ void BlenderSceneDelegate::clear()
|
||||
materials_.clear();
|
||||
|
||||
depsgraph = nullptr;
|
||||
context = nullptr;
|
||||
bmain = nullptr;
|
||||
scene = nullptr;
|
||||
view3d = nullptr;
|
||||
}
|
||||
|
@ -6,8 +6,8 @@
|
||||
#include <pxr/base/gf/vec2f.h>
|
||||
#include <pxr/imaging/hd/sceneDelegate.h>
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BLI_map.hh"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
|
||||
#include "CLG_log.h"
|
||||
@ -22,6 +22,11 @@
|
||||
#include "volume_modifier.h"
|
||||
#include "world.h"
|
||||
|
||||
struct Depsgraph;
|
||||
struct Main;
|
||||
struct Scene;
|
||||
struct View3D;
|
||||
|
||||
namespace blender::render::hydra {
|
||||
|
||||
extern struct CLG_LogRef *LOG_RENDER_HYDRA_SCENE;
|
||||
@ -69,12 +74,12 @@ class BlenderSceneDelegate : public pxr::HdSceneDelegate {
|
||||
pxr::HdVolumeFieldDescriptorVector GetVolumeFieldDescriptors(
|
||||
pxr::SdfPath const &volume_id) override;
|
||||
|
||||
void populate(Depsgraph *depsgraph, bContext *context);
|
||||
void populate(Depsgraph *depsgraph, View3D *v3d);
|
||||
void clear();
|
||||
|
||||
Depsgraph *depsgraph = nullptr;
|
||||
bContext *context = nullptr;
|
||||
View3D *view3d = nullptr;
|
||||
Main *bmain = nullptr;
|
||||
Scene *scene = nullptr;
|
||||
const SceneDelegateSettings &settings;
|
||||
ShadingSettings shading_settings;
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <pxr/imaging/hio/imageRegistry.h>
|
||||
|
||||
#include "BKE_appdir.h"
|
||||
#include "BKE_image.h"
|
||||
#include "BKE_image_format.h"
|
||||
#include "BKE_image_save.h"
|
||||
#include "BLI_fileops.h"
|
||||
@ -29,16 +30,12 @@ static std::string get_cache_file(const std::string &file_name, bool mkdir = tru
|
||||
return file_path;
|
||||
}
|
||||
|
||||
static std::string cache_image_file(Image *image,
|
||||
bContext *context,
|
||||
ImageUser *iuser,
|
||||
bool check_exist)
|
||||
static std::string cache_image_file(
|
||||
Main *bmain, Scene *scene, Image *image, ImageUser *iuser, bool check_exist)
|
||||
{
|
||||
std::string file_path;
|
||||
Main *main = CTX_data_main(context);
|
||||
Scene *scene = CTX_data_scene(context);
|
||||
ImageSaveOptions opts;
|
||||
if (BKE_image_save_options_init(&opts, main, scene, image, iuser, false, false)) {
|
||||
if (BKE_image_save_options_init(&opts, bmain, scene, image, iuser, false, false)) {
|
||||
char file_name[32];
|
||||
const char *r_ext = BLI_path_extension_or_end(image->id.name);
|
||||
if (!pxr::HioImageRegistry::GetInstance().IsSupportedImageFile(image->id.name)) {
|
||||
@ -55,7 +52,7 @@ static std::string cache_image_file(Image *image,
|
||||
|
||||
opts.save_copy = true;
|
||||
STRNCPY(opts.filepath, file_path.c_str());
|
||||
if (BKE_image_save(nullptr, main, image, iuser, &opts)) {
|
||||
if (BKE_image_save(nullptr, bmain, image, iuser, &opts)) {
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 1, "%s -> %s", image->id.name, file_path.c_str());
|
||||
}
|
||||
else {
|
||||
@ -67,23 +64,22 @@ static std::string cache_image_file(Image *image,
|
||||
return file_path;
|
||||
}
|
||||
|
||||
std::string cache_or_get_image_file(Image *image, bContext *context, ImageUser *iuser)
|
||||
std::string cache_or_get_image_file(Main *bmain, Scene *scene, Image *image, ImageUser *iuser)
|
||||
{
|
||||
std::string file_path;
|
||||
if (image->source == IMA_SRC_GENERATED) {
|
||||
file_path = cache_image_file(image, context, iuser, false);
|
||||
file_path = cache_image_file(bmain, scene, image, iuser, false);
|
||||
}
|
||||
else if (BKE_image_has_packedfile(image)) {
|
||||
file_path = cache_image_file(image, context, iuser, true);
|
||||
file_path = cache_image_file(bmain, scene, image, iuser, true);
|
||||
}
|
||||
else {
|
||||
Main *main = CTX_data_main(context);
|
||||
char str[FILE_MAX];
|
||||
BKE_image_user_file_path_ex(main, iuser, image, str, false, true);
|
||||
BKE_image_user_file_path_ex(bmain, iuser, image, str, false, true);
|
||||
file_path = str;
|
||||
|
||||
if (!pxr::HioImageRegistry::GetInstance().IsSupportedImageFile(file_path)) {
|
||||
file_path = cache_image_file(image, context, iuser, true);
|
||||
file_path = cache_image_file(bmain, scene, image, iuser, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,7 +92,7 @@ std::string cache_image_color(float color[4])
|
||||
char name[128];
|
||||
snprintf(name,
|
||||
sizeof(name),
|
||||
"color_%02x%02x%02x.hdr",
|
||||
"color_%02d%02d%02d.hdr",
|
||||
int(color[0] * 255),
|
||||
int(color[1] * 255),
|
||||
int(color[2] * 255));
|
||||
|
@ -3,12 +3,16 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_image.h"
|
||||
#include <string>
|
||||
|
||||
struct Main;
|
||||
struct Scene;
|
||||
struct Image;
|
||||
struct ImageUser;
|
||||
|
||||
namespace blender::render::hydra {
|
||||
|
||||
std::string cache_or_get_image_file(Image *image, bContext *context, ImageUser *iuser);
|
||||
std::string cache_or_get_image_file(Main *bmain, Scene *Scene, Image *image, ImageUser *iuser);
|
||||
std::string cache_image_color(float color[4]);
|
||||
|
||||
} // namespace blender::render::hydra
|
||||
|
@ -128,7 +128,7 @@ void InstancerData::pre_update()
|
||||
}
|
||||
}
|
||||
|
||||
void InstancerData::update_instance(Object *parent_ob, DupliObject *dupli)
|
||||
void InstancerData::update_instance(Object * /* parent_ob */, DupliObject *dupli)
|
||||
{
|
||||
Object *object = dupli->ob;
|
||||
pxr::SdfPath p_id = object_prim_id(object);
|
||||
@ -207,14 +207,14 @@ pxr::SdfPath InstancerData::object_prim_id(Object *object) const
|
||||
pxr::SdfPath InstancerData::nonmesh_prim_id(pxr::SdfPath const &prim_id, int index) const
|
||||
{
|
||||
char name[16];
|
||||
snprintf(name, sizeof(name), "NM_%08x", index);
|
||||
snprintf(name, sizeof(name), "NM_%08d", index);
|
||||
return prim_id.AppendElementString(name);
|
||||
}
|
||||
|
||||
int InstancerData::nonmesh_prim_id_index(pxr::SdfPath const &id) const
|
||||
{
|
||||
int index;
|
||||
sscanf(id.GetName().c_str(), "NM_%x", &index);
|
||||
sscanf(id.GetName().c_str(), "NM_%d", &index);
|
||||
return index;
|
||||
}
|
||||
|
||||
|
@ -202,14 +202,14 @@ void MeshData::write_materials()
|
||||
pxr::SdfPath MeshData::submesh_prim_id(int index) const
|
||||
{
|
||||
char name[16];
|
||||
snprintf(name, sizeof(name), "SM_%04x", index);
|
||||
snprintf(name, sizeof(name), "SM_%04d", index);
|
||||
return prim_id.AppendElementString(name);
|
||||
}
|
||||
|
||||
const MeshData::SubMesh &MeshData::submesh(pxr::SdfPath const &id) const
|
||||
{
|
||||
int index;
|
||||
sscanf(id.GetName().c_str(), "SM_%x", &index);
|
||||
sscanf(id.GetName().c_str(), "SM_%d", &index);
|
||||
return submeshes_[index];
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ bool ObjectData::is_visible(BlenderSceneDelegate *scene_delegate, Object *object
|
||||
return ret;
|
||||
}
|
||||
|
||||
pxr::VtValue ObjectData::get_data(pxr::SdfPath const &id, pxr::TfToken const &key) const
|
||||
pxr::VtValue ObjectData::get_data(pxr::SdfPath const & /* id */, pxr::TfToken const &key) const
|
||||
{
|
||||
return get_data(key);
|
||||
}
|
||||
@ -111,12 +111,12 @@ pxr::SdfPath ObjectData::material_id() const
|
||||
return pxr::SdfPath();
|
||||
}
|
||||
|
||||
pxr::SdfPath ObjectData::material_id(pxr::SdfPath const &id) const
|
||||
pxr::SdfPath ObjectData::material_id(pxr::SdfPath const & /* id */) const
|
||||
{
|
||||
return material_id();
|
||||
}
|
||||
|
||||
void ObjectData::available_materials(Set<pxr::SdfPath> &paths) const {}
|
||||
void ObjectData::available_materials(Set<pxr::SdfPath> & /* paths */) const {}
|
||||
|
||||
void ObjectData::write_transform()
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ USDSceneDelegate::~USDSceneDelegate()
|
||||
BLI_delete(temp_dir_.c_str(), true, true);
|
||||
}
|
||||
|
||||
void USDSceneDelegate::populate(Depsgraph *depsgraph, bContext * /*context*/)
|
||||
void USDSceneDelegate::populate(Depsgraph *depsgraph)
|
||||
{
|
||||
/* TODO: implement MaterialX support in USD exporter. */
|
||||
const bool use_materialx = !settings_.mx_filename_key.IsEmpty();
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "settings.h"
|
||||
|
||||
struct Depsgraph;
|
||||
struct bContext;
|
||||
|
||||
namespace blender::render::hydra {
|
||||
|
||||
@ -32,7 +31,7 @@ class USDSceneDelegate {
|
||||
const SceneDelegateSettings &settings_);
|
||||
~USDSceneDelegate();
|
||||
|
||||
void populate(Depsgraph *depsgraph, bContext *context);
|
||||
void populate(Depsgraph *depsgraph);
|
||||
};
|
||||
|
||||
} // namespace blender::render::hydra
|
||||
|
@ -30,8 +30,7 @@ void VolumeData::init()
|
||||
field_descriptors_.clear();
|
||||
|
||||
Volume *volume = (Volume *)((Object *)this->id)->data;
|
||||
Main *main = CTX_data_main(scene_delegate_->context);
|
||||
if (!BKE_volume_load(volume, main)) {
|
||||
if (!BKE_volume_load(volume, scene_delegate_->bmain)) {
|
||||
return;
|
||||
}
|
||||
filepath_ = BKE_volume_grids_frame_filepath(volume);
|
||||
|
@ -11,14 +11,16 @@
|
||||
#include <pxr/imaging/hd/tokens.h>
|
||||
#include <pxr/usd/usdLux/tokens.h>
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "DNA_node_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
#include "BLI_math_rotation.h"
|
||||
#include "BLI_path_util.h"
|
||||
|
||||
#include "BKE_node.h"
|
||||
#include "BKE_node_runtime.hh"
|
||||
#include "BKE_studiolight.h"
|
||||
#include "BLI_math_rotation.h"
|
||||
#include "BLI_path_util.h"
|
||||
|
||||
#include "NOD_shader.h"
|
||||
|
||||
#include "../engine.h"
|
||||
@ -94,7 +96,7 @@ void WorldData::init()
|
||||
Image *image = (Image *)color_input_node->id;
|
||||
if (image) {
|
||||
std::string image_path = cache_or_get_image_file(
|
||||
image, scene_delegate_->context, &tex->iuser);
|
||||
scene_delegate_->bmain, scene_delegate_->scene, image, &tex->iuser);
|
||||
if (!image_path.empty()) {
|
||||
texture_file = pxr::SdfAssetPath(image_path, image_path);
|
||||
}
|
||||
|
@ -6,13 +6,19 @@
|
||||
#include <pxr/usd/usdGeom/camera.h>
|
||||
|
||||
#include "DNA_vec_types.h" /* this include must be before BKE_camera.h due to "rctf" type */
|
||||
#include "DNA_view3d_types.h"
|
||||
|
||||
#include "BKE_camera.h"
|
||||
#include "BKE_context.h"
|
||||
|
||||
#include "BLI_math_matrix.h"
|
||||
#include "BLI_timecode.h"
|
||||
#include "DEG_depsgraph_query.h"
|
||||
#include "DNA_camera_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "GPU_context.h"
|
||||
#include "GPU_matrix.h"
|
||||
#include "PIL_time.h"
|
||||
|
||||
@ -36,7 +42,8 @@ struct ViewSettings {
|
||||
pxr::GfVec4i border;
|
||||
};
|
||||
|
||||
ViewSettings::ViewSettings(bContext *context) : camera_data(context)
|
||||
ViewSettings::ViewSettings(bContext *context)
|
||||
: camera_data(CTX_wm_view3d(context), CTX_wm_region(context))
|
||||
{
|
||||
View3D *view3d = CTX_wm_view3d(context);
|
||||
RegionView3D *region_data = (RegionView3D *)CTX_wm_region_data(context);
|
||||
@ -175,8 +182,6 @@ void DrawTexture::write_data(int width, int height, const void *data)
|
||||
GPU_RGBA16F,
|
||||
GPU_TEXTURE_USAGE_GENERAL,
|
||||
(float *)data);
|
||||
GPU_texture_filter_mode(texture_, true);
|
||||
GPU_texture_mipmap_mode(texture_, true, true);
|
||||
}
|
||||
|
||||
void DrawTexture::draw(GPUShader *shader, const pxr::GfVec4d &viewport)
|
||||
@ -232,6 +237,14 @@ void ViewportEngine::render(Depsgraph *depsgraph, bContext *context)
|
||||
render_task_delegate_->add_aov(pxr::HdAovTokens->color);
|
||||
}
|
||||
|
||||
/* Workaround missing/buggy VAOs in hgiGL and hdSt. For OpenGL compatibility
|
||||
* profile this is not a problem, but for core profile it is. */
|
||||
GLuint VAO;
|
||||
if (GPU_backend_get_type() == GPU_BACKEND_OPENGL) {
|
||||
glGenVertexArrays(1, &VAO);
|
||||
glBindVertexArray(VAO);
|
||||
}
|
||||
|
||||
GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_IMAGE);
|
||||
GPU_shader_bind(shader);
|
||||
|
||||
@ -253,6 +266,10 @@ void ViewportEngine::render(Depsgraph *depsgraph, bContext *context)
|
||||
|
||||
GPU_shader_unbind();
|
||||
|
||||
if (GPU_backend_get_type() == GPU_BACKEND_OPENGL) {
|
||||
glDeleteVertexArrays(1, &VAO);
|
||||
}
|
||||
|
||||
if (renderer_percent_done() == 0.0f) {
|
||||
time_begin_ = PIL_check_seconds_timer();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user