[Bf-blender-cvs] [5c10bd4f199] gsoc-2018-many-light-sampling: Fix: Merge conflict with background resolution
Erik Englesson
noreply at git.blender.org
Fri Jun 29 16:27:18 CEST 2018
Commit: 5c10bd4f199377fc2d0aaeadfd99d7c5ab511d95
Author: Erik Englesson
Date: Fri Jun 29 16:25:28 2018 +0200
Branches: gsoc-2018-many-light-sampling
https://developer.blender.org/rB5c10bd4f199377fc2d0aaeadfd99d7c5ab511d95
Fix: Merge conflict with background resolution
===================================================================
M intern/cycles/render/light.cpp
M intern/cycles/render/light.h
===================================================================
diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp
index b5205a2f2fa..9cd5290e4c3 100644
--- a/intern/cycles/render/light.cpp
+++ b/intern/cycles/render/light.cpp
@@ -299,10 +299,9 @@ float LightManager::background_light_energy(Device *device,
const Light *lamp = scene->lights[prim.lamp_id];
if(lamp->type != LIGHT_BACKGROUND) continue;
- int res = lamp->map_resolution;
- assert(res > 0);
vector<float3> pixels;
- shade_background_pixels(device, dscene, res, pixels, progress);
+ int2 res = get_background_map_resolution(lamp, scene);
+ shade_background_pixels(device, dscene, res.x, res.y, pixels, progress);
num_pixels += pixels.size();
for(int i = 0; i < pixels.size(); ++i){
average_luminance += rgb_to_luminance(pixels[i]);
@@ -810,29 +809,8 @@ void LightManager::device_update_background(Device *device,
assert(kintegrator->use_direct_light);
/* get the resolution from the light's size (we stuff it in there) */
- int2 res = make_int2(background_light->map_resolution, background_light->map_resolution/2);
- /* If the resolution isn't set manually, try to find an environment texture. */
- if (res.x == 0) {
- Shader *shader = (scene->background->shader) ? scene->background->shader : scene->default_background;
- foreach(ShaderNode *node, shader->graph->nodes) {
- if(node->type == EnvironmentTextureNode::node_type) {
- EnvironmentTextureNode *env = (EnvironmentTextureNode*) node;
- ImageMetaData metadata;
- if(env->image_manager && env->image_manager->get_image_metadata(env->slot, metadata)) {
- res.x = max(res.x, metadata.width);
- res.y = max(res.y, metadata.height);
- }
- }
- }
- if (res.x > 0 && res.y > 0) {
- VLOG(2) << "Automatically set World MIS resolution to " << res.x << " by " << res.y << "\n";
- }
- }
- /* If it's still unknown, just use the default. */
- if (res.x == 0 || res.y == 0) {
- res = make_int2(1024, 512);
- VLOG(2) << "Setting World MIS resolution to default\n";
- }
+ int2 res = get_background_map_resolution(background_light, scene);
+
kintegrator->pdf_background_res_x = res.x;
kintegrator->pdf_background_res_y = res.y;
@@ -1297,5 +1275,35 @@ void LightManager::device_update_ies(DeviceScene *dscene)
}
}
+int2 LightManager::get_background_map_resolution(const Light *background_light,
+ const Scene *scene)
+{
+ int2 res = make_int2(background_light->map_resolution, background_light->map_resolution/2);
+ /* If the resolution isn't set manually, try to find an environment texture. */
+ if (res.x == 0) {
+ Shader *shader = (scene->background->shader) ? scene->background->shader : scene->default_background;
+ foreach(ShaderNode *node, shader->graph->nodes) {
+ if(node->type == EnvironmentTextureNode::node_type) {
+ EnvironmentTextureNode *env = (EnvironmentTextureNode*) node;
+ ImageMetaData metadata;
+ if(env->image_manager && env->image_manager->get_image_metadata(env->slot, metadata)) {
+ res.x = max(res.x, metadata.width);
+ res.y = max(res.y, metadata.height);
+ }
+ }
+ }
+ if (res.x > 0 && res.y > 0) {
+ VLOG(2) << "Automatically set World MIS resolution to " << res.x << " by " << res.y << "\n";
+ }
+ }
+ /* If it's still unknown, just use the default. */
+ if (res.x == 0 || res.y == 0) {
+ res = make_int2(1024, 512);
+ VLOG(2) << "Setting World MIS resolution to default\n";
+ }
+
+ return res;
+}
+
CCL_NAMESPACE_END
diff --git a/intern/cycles/render/light.h b/intern/cycles/render/light.h
index b12028aad4e..644efdee66c 100644
--- a/intern/cycles/render/light.h
+++ b/intern/cycles/render/light.h
@@ -139,6 +139,8 @@ protected:
float distant_lights_energy(const Scene *scene,
const vector<Primitive> &prims);
+ int2 get_background_map_resolution(const Light *background_light,
+ const Scene *scene);
struct IESSlot {
IESFile ies;
More information about the Bf-blender-cvs
mailing list