2022-02-11 13:53:21 +01:00
|
|
|
/* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
* Copyright 2019-2022 Blender Foundation */
|
2021-05-27 10:42:22 +02:00
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "blender/viewport.h"
|
|
|
|
|
#include "blender/util.h"
|
2019-08-27 15:47:30 +02:00
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "scene/pass.h"
|
2021-10-24 14:19:19 +02:00
|
|
|
|
|
|
|
|
#include "util/log.h"
|
2019-09-05 12:47:20 +02:00
|
|
|
|
2019-08-27 15:47:30 +02:00
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
|
|
BlenderViewportParameters::BlenderViewportParameters()
|
|
|
|
|
: use_scene_world(true),
|
|
|
|
|
use_scene_lights(true),
|
|
|
|
|
studiolight_rotate_z(0.0f),
|
2019-09-04 16:22:47 +02:00
|
|
|
studiolight_intensity(1.0f),
|
2021-05-27 11:31:03 +02:00
|
|
|
studiolight_background_alpha(1.0f),
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
display_pass(PASS_COMBINED),
|
|
|
|
|
show_active_pixels(false)
|
2019-08-27 15:47:30 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
BlenderViewportParameters::BlenderViewportParameters(BL::SpaceView3D &b_v3d, bool use_developer_ui)
|
2019-08-27 15:47:30 +02:00
|
|
|
: BlenderViewportParameters()
|
|
|
|
|
{
|
2021-05-26 11:07:05 +02:00
|
|
|
if (!b_v3d) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BL::View3DShading shading = b_v3d.shading();
|
2021-05-27 11:31:03 +02:00
|
|
|
PointerRNA cshading = RNA_pointer_get(&shading.ptr, "cycles");
|
2021-05-26 11:07:05 +02:00
|
|
|
|
2021-07-07 12:55:19 +10:00
|
|
|
/* We only copy the shading parameters if we are in look-dev mode.
|
|
|
|
|
* Otherwise defaults are being used. These defaults mimic normal render settings. */
|
2021-05-27 11:31:03 +02:00
|
|
|
if (shading.type() == BL::View3DShading::type_RENDERED) {
|
|
|
|
|
use_scene_world = shading.use_scene_world_render();
|
|
|
|
|
use_scene_lights = shading.use_scene_lights_render();
|
|
|
|
|
|
|
|
|
|
if (!use_scene_world) {
|
|
|
|
|
studiolight_rotate_z = shading.studiolight_rotate_z();
|
|
|
|
|
studiolight_intensity = shading.studiolight_intensity();
|
|
|
|
|
studiolight_background_alpha = shading.studiolight_background_alpha();
|
|
|
|
|
studiolight_path = shading.selected_studio_light().path();
|
|
|
|
|
}
|
2021-05-26 11:07:05 +02:00
|
|
|
}
|
|
|
|
|
|
2021-05-27 11:31:03 +02:00
|
|
|
/* Film. */
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
|
|
|
|
/* Lookup display pass based on the enum identifier.
|
|
|
|
|
* This is because integer values of python enum are not aligned with the passes definition in
|
|
|
|
|
* the kernel. */
|
|
|
|
|
|
|
|
|
|
display_pass = PASS_COMBINED;
|
|
|
|
|
|
|
|
|
|
const string display_pass_identifier = get_enum_identifier(cshading, "render_pass");
|
|
|
|
|
if (!display_pass_identifier.empty()) {
|
|
|
|
|
const ustring pass_type_identifier(string_to_lower(display_pass_identifier));
|
|
|
|
|
const NodeEnum *pass_type_enum = Pass::get_type_enum();
|
|
|
|
|
if (pass_type_enum->exists(pass_type_identifier)) {
|
|
|
|
|
display_pass = static_cast<PassType>((*pass_type_enum)[pass_type_identifier]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (use_developer_ui) {
|
|
|
|
|
show_active_pixels = get_boolean(cshading, "show_active_pixels");
|
|
|
|
|
}
|
2019-08-27 15:47:30 +02:00
|
|
|
}
|
|
|
|
|
|
2021-05-27 11:16:40 +02:00
|
|
|
bool BlenderViewportParameters::shader_modified(const BlenderViewportParameters &other) const
|
2019-08-27 15:47:30 +02:00
|
|
|
{
|
|
|
|
|
return use_scene_world != other.use_scene_world || use_scene_lights != other.use_scene_lights ||
|
|
|
|
|
studiolight_rotate_z != other.studiolight_rotate_z ||
|
2019-09-04 16:22:47 +02:00
|
|
|
studiolight_intensity != other.studiolight_intensity ||
|
2019-08-27 15:47:30 +02:00
|
|
|
studiolight_background_alpha != other.studiolight_background_alpha ||
|
|
|
|
|
studiolight_path != other.studiolight_path;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-27 11:31:03 +02:00
|
|
|
bool BlenderViewportParameters::film_modified(const BlenderViewportParameters &other) const
|
2019-08-27 15:47:30 +02:00
|
|
|
{
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
return display_pass != other.display_pass || show_active_pixels != other.show_active_pixels;
|
2019-08-27 15:47:30 +02:00
|
|
|
}
|
|
|
|
|
|
2021-05-27 11:31:03 +02:00
|
|
|
bool BlenderViewportParameters::modified(const BlenderViewportParameters &other) const
|
2019-09-05 12:47:20 +02:00
|
|
|
{
|
2021-05-27 11:31:03 +02:00
|
|
|
return shader_modified(other) || film_modified(other);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BlenderViewportParameters::use_custom_shader() const
|
|
|
|
|
{
|
|
|
|
|
return !(use_scene_world && use_scene_lights);
|
2019-09-05 12:47:20 +02:00
|
|
|
}
|
|
|
|
|
|
2019-08-27 15:47:30 +02:00
|
|
|
CCL_NAMESPACE_END
|