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(); check_updates();
} }
else { else {
use_scene_lights_ = V3D_USES_SCENE_LIGHTS(view3d); if (view3d) {
shading_flag_ = view3d->shading.flag; use_scene_lights_ = V3D_USES_SCENE_LIGHTS(view3d);
lookdev_light_ = view3d->shading.lookdev_light; shading_flag_ = view3d->shading.flag;
lookdev_light_ = view3d->shading.lookdev_light;
}
add_new_objects(); add_new_objects();
update_world(); update_world();
} }
@ -341,7 +343,7 @@ void BlenderSceneDelegate::update_objects(Object *object)
if (!ObjectData::is_supported(object)) { if (!ObjectData::is_supported(object)) {
return; return;
} }
if (!V3D_USES_SCENE_LIGHTS(view3d) && object->type == OB_LAMP) { if (view3d && !V3D_USES_SCENE_LIGHTS(view3d) && object->type == OB_LAMP) {
return; return;
} }
pxr::SdfPath id = object_prim_id(object); pxr::SdfPath id = object_prim_id(object);
@ -444,7 +446,7 @@ void BlenderSceneDelegate::check_updates()
add_new_objects(true); add_new_objects(true);
} }
else { else {
remove_unused_objects(); do_update_collection = true;
} }
} }
if (LOOK_DEV_STUDIO_LIGHT_ENABLED(view3d) && 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); scene_delegate_->depsgraph, scene_delegate_->scene, (Object *)id);
LISTBASE_FOREACH (DupliObject *, dupli, lb) { LISTBASE_FOREACH (DupliObject *, dupli, lb) {
Object *ob = dupli->ob; 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) {
BogdanNagirniak marked this conversation as resolved Outdated

if (ob->type == OB_LAMP && !scene_delegate_->shading_settings.use_scene_lights)

`if (ob->type == OB_LAMP && !scene_delegate_->shading_settings.use_scene_lights)`
return; return;
} }
if (!is_supported(ob) || !is_instance_visible(ob)) { if (!is_supported(ob) || !is_instance_visible(ob)) {

View File

@ -13,6 +13,7 @@
#include "BKE_context.h" #include "BKE_context.h"
#include "DNA_node_types.h" #include "DNA_node_types.h"
BogdanNagirniak marked this conversation as resolved Outdated

shouldn't be needed

shouldn't be needed
#include "DEG_depsgraph_query.h"
#include "BKE_node.h" #include "BKE_node.h"
#include "BKE_node_runtime.hh" #include "BKE_node_runtime.hh"
@ -43,16 +44,19 @@ void WorldData::init()
{ {
ID_LOG(1, ""); ID_LOG(1, "");
rotation = scene_delegate_->view3d->shading.studiolight_rot_z; if (scene_delegate_->view3d) {
intensity = scene_delegate_->view3d->shading.studiolight_intensity; rotation = scene_delegate_->view3d->shading.studiolight_rot_z;
intensity = scene_delegate_->view3d->shading.studiolight_intensity;
}
write_transform(); write_transform();
World *world = (World *)id; World *world = (World *)id;
BogdanNagirniak marked this conversation as resolved Outdated
if (scene_delegate_.shading_settings.use_scene_world) {
   <previous code>
}
else {
  <new code>
}
``` if (scene_delegate_.shading_settings.use_scene_world) { <previous code> } else { <new code> } ```
data_.clear(); data_.clear();
data_[pxr::UsdLuxTokens->orientToStageUpAxis] = true; data_[pxr::UsdLuxTokens->orientToStageUpAxis] = true;
eEvaluationMode deg_mode = DEG_get_mode(scene_delegate_->depsgraph);
if (world->use_nodes && V3D_USES_SCENE_WORLD(scene_delegate_->view3d)) { 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 */ /* TODO: Create nodes parsing system */
bNode *output_node = ntreeShaderOutputNode(world->nodetree, SHD_OUTPUT_ALL); bNode *output_node = ntreeShaderOutputNode(world->nodetree, SHD_OUTPUT_ALL);