Implement Viewport render with material preview #56

Merged
Bogdan Nagirniak merged 22 commits from BLEN-421 into hydra-render 2023-06-30 09:03:28 +02:00
3 changed files with 17 additions and 10 deletions
Showing only changes of commit 8e875becac - Show all commits

View File

@ -205,9 +205,11 @@ void BlenderSceneDelegate::populate(Depsgraph *deps, bContext *cont)
check_updates();
}
else {
use_scene_lights_ = V3D_USES_SCENE_LIGHTS(view3d);
shading_flag_ = view3d->shading.flag;
lookdev_light_ = view3d->shading.lookdev_light;
if (view3d) {
use_scene_lights_ = V3D_USES_SCENE_LIGHTS(view3d);
shading_flag_ = view3d->shading.flag;
lookdev_light_ = view3d->shading.lookdev_light;
}
add_new_objects();
update_world();
}
@ -341,7 +343,7 @@ void BlenderSceneDelegate::update_objects(Object *object)
if (!ObjectData::is_supported(object)) {
return;
}
if (!V3D_USES_SCENE_LIGHTS(view3d) && object->type == OB_LAMP) {
if (view3d && !V3D_USES_SCENE_LIGHTS(view3d) && object->type == OB_LAMP) {
return;
}
pxr::SdfPath id = object_prim_id(object);
@ -444,7 +446,7 @@ void BlenderSceneDelegate::check_updates()
add_new_objects(true);
}
else {
remove_unused_objects();
do_update_collection = true;
}
}
if (LOOK_DEV_STUDIO_LIGHT_ENABLED(view3d) &&

View File

@ -358,7 +358,8 @@ void InstancerData::write_instances()
scene_delegate_->depsgraph, scene_delegate_->scene, (Object *)id);
LISTBASE_FOREACH (DupliObject *, dupli, lb) {
Object *ob = dupli->ob;
if (!V3D_USES_SCENE_LIGHTS(scene_delegate_->view3d) && ob->type == OB_LAMP) {
if (scene_delegate_->view3d && !V3D_USES_SCENE_LIGHTS(scene_delegate_->view3d) &&
ob->type == OB_LAMP) {
return;
}
if (!is_supported(ob) || !is_instance_visible(ob)) {

View File

@ -13,6 +13,7 @@
#include "BKE_context.h"
#include "DNA_node_types.h"
#include "DEG_depsgraph_query.h"
#include "BKE_node.h"
#include "BKE_node_runtime.hh"
@ -43,16 +44,19 @@ void WorldData::init()
{
ID_LOG(1, "");
rotation = scene_delegate_->view3d->shading.studiolight_rot_z;
intensity = scene_delegate_->view3d->shading.studiolight_intensity;
if (scene_delegate_->view3d) {
rotation = scene_delegate_->view3d->shading.studiolight_rot_z;
intensity = scene_delegate_->view3d->shading.studiolight_intensity;
}
write_transform();
World *world = (World *)id;
data_.clear();
data_[pxr::UsdLuxTokens->orientToStageUpAxis] = true;
if (world->use_nodes && V3D_USES_SCENE_WORLD(scene_delegate_->view3d)) {
eEvaluationMode deg_mode = DEG_get_mode(scene_delegate_->depsgraph);
if (world->use_nodes && ((deg_mode == DAG_EVAL_VIEWPORT && scene_delegate_->view3d && V3D_USES_SCENE_WORLD(scene_delegate_->view3d)) || deg_mode == DAG_EVAL_RENDER))
{
/* TODO: Create nodes parsing system */
bNode *output_node = ntreeShaderOutputNode(world->nodetree, SHD_OUTPUT_ALL);