forked from blender/blender
Implement Viewport render with material preview #56
@ -422,6 +422,18 @@ void BlenderSceneDelegate::check_updates()
|
|||||||
bool do_update_visibility = false;
|
bool do_update_visibility = false;
|
||||||
bool do_update_world = false;
|
bool do_update_world = false;
|
||||||
|
|
||||||
|
if (shading_flag_ != view3d->shading.flag) {
|
||||||
|
shading_flag_ = view3d->shading.flag;
|
||||||
|
do_update_world = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LOOK_DEV_STUDIO_LIGHT_ENABLED(view3d) &&
|
||||||
|
(world_data_->rotation != view3d->shading.studiolight_rot_z ||
|
||||||
|
world_data_->intensity != view3d->shading.studiolight_intensity))
|
||||||
|
{
|
||||||
|
do_update_world = true;
|
||||||
|
}
|
||||||
|
|
||||||
DEGIDIterData data = {0};
|
DEGIDIterData data = {0};
|
||||||
data.graph = depsgraph;
|
data.graph = depsgraph;
|
||||||
data.only_updated = true;
|
data.only_updated = true;
|
||||||
|
@ -98,6 +98,14 @@ class BlenderSceneDelegate : public pxr::HdSceneDelegate {
|
|||||||
MaterialDataMap materials_;
|
MaterialDataMap materials_;
|
||||||
InstancerDataMap instancers_;
|
InstancerDataMap instancers_;
|
||||||
std::unique_ptr<WorldData> world_data_;
|
std::unique_ptr<WorldData> world_data_;
|
||||||
|
|
||||||
|
short shading_flag_;
|
||||||
BogdanNagirniak marked this conversation as resolved
Outdated
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
#define LOOK_DEV_STUDIO_LIGHT_ENABLED(v3d) \
|
||||||
|
((v3d) && (((v3d->shading.type == OB_MATERIAL) && \
|
||||||
BogdanNagirniak marked this conversation as resolved
Outdated
Bogdan Nagirniak
commented
remove parameter remove parameter `view3d`
|
|||||||
|
((v3d->shading.flag & V3D_SHADING_SCENE_WORLD) == 0)) || \
|
||||||
|
((v3d->shading.type == OB_RENDER) && \
|
||||||
|
((v3d->shading.flag & V3D_SHADING_SCENE_WORLD_RENDER) == 0))))
|
||||||
|
|
||||||
} // namespace blender::render::hydra
|
} // namespace blender::render::hydra
|
||||||
|
@ -15,7 +15,9 @@
|
|||||||
#include "DNA_node_types.h"
|
#include "DNA_node_types.h"
|
||||||
BogdanNagirniak marked this conversation as resolved
Outdated
Bogdan Nagirniak
commented
shouldn't be needed shouldn't be needed
|
|||||||
|
|
||||||
#include "BKE_node.h"
|
#include "BKE_node.h"
|
||||||
|
#include "BKE_studiolight.h"
|
||||||
#include "BKE_node_runtime.hh"
|
#include "BKE_node_runtime.hh"
|
||||||
|
#include "BLI_math_rotation.h"
|
||||||
#include "BLI_path_util.h"
|
#include "BLI_path_util.h"
|
||||||
#include "NOD_shader.h"
|
#include "NOD_shader.h"
|
||||||
|
|
||||||
@ -26,6 +28,8 @@
|
|||||||
|
|
||||||
/* TODO : add custom tftoken "transparency"? */
|
/* TODO : add custom tftoken "transparency"? */
|
||||||
|
|
||||||
|
/* NOTE: opacity and blur aren't supported by USD */
|
||||||
|
|
||||||
namespace blender::render::hydra {
|
namespace blender::render::hydra {
|
||||||
|
|
||||||
WorldData::WorldData(BlenderSceneDelegate *scene_delegate,
|
WorldData::WorldData(BlenderSceneDelegate *scene_delegate,
|
||||||
@ -39,6 +43,8 @@ void WorldData::init()
|
|||||||
{
|
{
|
||||||
ID_LOG(1, "");
|
ID_LOG(1, "");
|
||||||
|
|
||||||
|
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;
|
||||||
@ -46,7 +52,7 @@ void WorldData::init()
|
|||||||
|
|
||||||
data_[pxr::UsdLuxTokens->orientToStageUpAxis] = true;
|
data_[pxr::UsdLuxTokens->orientToStageUpAxis] = true;
|
||||||
BogdanNagirniak marked this conversation as resolved
Outdated
Bogdan Nagirniak
commented
```
if (scene_delegate_.shading_settings.use_scene_world) {
<previous code>
}
else {
<new code>
}
```
|
|||||||
|
|
||||||
if (world->use_nodes) {
|
if (world->use_nodes && V3D_USES_SCENE_WORLD(scene_delegate_->view3d)) {
|
||||||
/* 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);
|
||||||
@ -95,6 +101,20 @@ void WorldData::init()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (LOOK_DEV_STUDIO_LIGHT_ENABLED(scene_delegate_->view3d)) {
|
||||||
|
StudioLight *sl = BKE_studiolight_find(scene_delegate_->view3d->shading.lookdev_light,
|
||||||
|
STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE);
|
||||||
|
if (sl == NULL || (sl->flag & STUDIOLIGHT_TYPE_WORLD) == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data_[pxr::HdLightTokens->textureFile] = pxr::SdfAssetPath(sl->filepath, sl->filepath);
|
||||||
|
data_[pxr::HdLightTokens->intensity] = scene_delegate_->view3d->shading.studiolight_intensity / 2;
|
||||||
|
|
||||||
|
transform *= pxr::GfMatrix4d(
|
||||||
|
pxr::GfRotation(pxr::GfVec3d(0.0, 0.0, -1.0),
|
||||||
|
RAD2DEGF(scene_delegate_->view3d->shading.studiolight_rot_z)),
|
||||||
|
pxr::GfVec3d());
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
data_[pxr::HdLightTokens->intensity] = 1.0f;
|
data_[pxr::HdLightTokens->intensity] = 1.0f;
|
||||||
data_[pxr::HdLightTokens->exposure] = world->exposure;
|
data_[pxr::HdLightTokens->exposure] = world->exposure;
|
||||||
BogdanNagirniak marked this conversation as resolved
Outdated
Bogdan Nagirniak
commented
thif thif `if` can be removed
|
|||||||
|
@ -31,6 +31,8 @@ class WorldData : public IdData {
|
|||||||
pxr::VtValue get_data(pxr::TfToken const &key) const override;
|
pxr::VtValue get_data(pxr::TfToken const &key) const override;
|
||||||
|
|
||||||
pxr::GfMatrix4d transform;
|
pxr::GfMatrix4d transform;
|
||||||
|
float rotation;
|
||||||
|
float intensity;
|
||||||
BogdanNagirniak marked this conversation as resolved
Outdated
Bogdan Nagirniak
commented
move this to move this to `BlenderSceneDelegate::ShadingSettings`
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void write_transform();
|
void write_transform();
|
||||||
|
Loading…
Reference in New Issue
Block a user
Move this new settings to internal
struct ShadingSettings