2011-04-27 11:58:34 +00:00
|
|
|
/*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Copyright 2011-2013 Blender Foundation
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
2014-12-25 01:50:24 +00:00
|
|
|
* limitations under the License.
|
2011-04-27 11:58:34 +00:00
|
|
|
*/
|
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 18:39:14 +00:00
|
|
|
#include "device/device.h"
|
2011-04-27 11:58:34 +00: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 15:59:20 +00:00
|
|
|
#include "integrator/shader_eval.h"
|
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 18:39:14 +00:00
|
|
|
#include "render/mesh.h"
|
|
|
|
#include "render/object.h"
|
|
|
|
#include "render/scene.h"
|
|
|
|
#include "render/shader.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 18:39:14 +00:00
|
|
|
#include "util/util_foreach.h"
|
2019-08-14 05:53:09 +00:00
|
|
|
#include "util/util_map.h"
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 18:39:14 +00:00
|
|
|
#include "util/util_progress.h"
|
2019-08-14 05:53:09 +00:00
|
|
|
#include "util/util_set.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
2016-08-02 09:13:58 +00:00
|
|
|
static float3 compute_face_normal(const Mesh::Triangle &t, float3 *verts)
|
|
|
|
{
|
|
|
|
float3 v0 = verts[t.v[0]];
|
|
|
|
float3 v1 = verts[t.v[1]];
|
|
|
|
float3 v2 = verts[t.v[2]];
|
|
|
|
|
|
|
|
float3 norm = cross(v1 - v0, v2 - v0);
|
|
|
|
float normlen = len(norm);
|
|
|
|
|
|
|
|
if (normlen == 0.0f)
|
|
|
|
return make_float3(1.0f, 0.0f, 0.0f);
|
|
|
|
|
|
|
|
return norm / normlen;
|
|
|
|
}
|
|
|
|
|
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 15:59:20 +00:00
|
|
|
/* Fill in coordinates for mesh displacement shader evaluation on device. */
|
|
|
|
static int fill_shader_input(const Scene *scene,
|
|
|
|
const Mesh *mesh,
|
|
|
|
const int object_index,
|
|
|
|
device_vector<KernelShaderEvalInput> &d_input)
|
2011-04-27 11:58:34 +00: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 15:59:20 +00:00
|
|
|
int d_input_size = 0;
|
|
|
|
KernelShaderEvalInput *d_input_data = d_input.data();
|
2019-04-17 04:17:24 +00: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 15:59:20 +00:00
|
|
|
const array<int> &mesh_shaders = mesh->get_shader();
|
|
|
|
const array<Node *> &mesh_used_shaders = mesh->get_used_shaders();
|
|
|
|
const array<float3> &mesh_verts = mesh->get_verts();
|
2019-04-17 04:17:24 +00: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 15:59:20 +00:00
|
|
|
const int num_verts = mesh_verts.size();
|
2016-01-16 10:36:42 +00:00
|
|
|
vector<bool> done(num_verts, false);
|
2019-04-17 04:17:24 +00: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 15:59:20 +00:00
|
|
|
int num_triangles = mesh->num_triangles();
|
|
|
|
for (int i = 0; i < num_triangles; i++) {
|
2016-05-07 22:09:08 +00:00
|
|
|
Mesh::Triangle t = mesh->get_triangle(i);
|
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 15:59:20 +00:00
|
|
|
int shader_index = mesh_shaders[i];
|
|
|
|
Shader *shader = (shader_index < mesh_used_shaders.size()) ?
|
|
|
|
static_cast<Shader *>(mesh_used_shaders[shader_index]) :
|
2016-05-17 23:50:35 +00:00
|
|
|
scene->default_surface;
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2020-11-04 10:17:38 +00:00
|
|
|
if (!shader->has_displacement || shader->get_displacement_method() == DISPLACE_BUMP) {
|
2011-04-27 11:58:34 +00:00
|
|
|
continue;
|
2016-08-02 09:13:58 +00:00
|
|
|
}
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
for (int j = 0; j < 3; j++) {
|
|
|
|
if (done[t.v[j]])
|
|
|
|
continue;
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
done[t.v[j]] = true;
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* set up object, primitive and barycentric coordinates */
|
2016-09-03 01:37:17 +00:00
|
|
|
int object = object_index;
|
2020-02-02 11:04:19 +00:00
|
|
|
int prim = mesh->prim_offset + i;
|
2011-04-27 11:58:34 +00:00
|
|
|
float u, v;
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2015-10-08 14:08:28 +00:00
|
|
|
switch (j) {
|
2013-05-09 15:20:00 +00:00
|
|
|
case 0:
|
|
|
|
u = 1.0f;
|
|
|
|
v = 0.0f;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
u = 0.0f;
|
|
|
|
v = 1.0f;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
u = 0.0f;
|
|
|
|
v = 0.0f;
|
|
|
|
break;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* back */
|
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 15:59:20 +00:00
|
|
|
KernelShaderEvalInput in;
|
|
|
|
in.object = object;
|
|
|
|
in.prim = prim;
|
|
|
|
in.u = u;
|
|
|
|
in.v = v;
|
2012-12-26 20:59:35 +00:00
|
|
|
d_input_data[d_input_size++] = in;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-17 04:17:24 +00: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 15:59:20 +00:00
|
|
|
return d_input_size;
|
|
|
|
}
|
2019-04-17 04:17:24 +00: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 15:59:20 +00:00
|
|
|
/* Read back mesh displacement shader output. */
|
|
|
|
static void read_shader_output(const Scene *scene,
|
|
|
|
Mesh *mesh,
|
|
|
|
const device_vector<float4> &d_output)
|
|
|
|
{
|
|
|
|
const array<int> &mesh_shaders = mesh->get_shader();
|
|
|
|
const array<Node *> &mesh_used_shaders = mesh->get_used_shaders();
|
|
|
|
array<float3> &mesh_verts = mesh->get_verts();
|
2019-04-17 04:17:24 +00: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 15:59:20 +00:00
|
|
|
const int num_verts = mesh_verts.size();
|
|
|
|
const int num_motion_steps = mesh->get_motion_steps();
|
|
|
|
vector<bool> done(num_verts, false);
|
2019-04-17 04:17:24 +00: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 15:59:20 +00:00
|
|
|
const float4 *d_output_data = d_output.data();
|
|
|
|
int d_output_index = 0;
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2016-01-16 10:36:42 +00:00
|
|
|
Attribute *attr_mP = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
|
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 15:59:20 +00:00
|
|
|
int num_triangles = mesh->num_triangles();
|
|
|
|
for (int i = 0; i < num_triangles; i++) {
|
2016-05-07 22:09:08 +00:00
|
|
|
Mesh::Triangle t = mesh->get_triangle(i);
|
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 15:59:20 +00:00
|
|
|
int shader_index = mesh_shaders[i];
|
|
|
|
Shader *shader = (shader_index < mesh_used_shaders.size()) ?
|
|
|
|
static_cast<Shader *>(mesh_used_shaders[shader_index]) :
|
2016-05-17 23:50:35 +00:00
|
|
|
scene->default_surface;
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2020-11-04 10:17:38 +00:00
|
|
|
if (!shader->has_displacement || shader->get_displacement_method() == DISPLACE_BUMP) {
|
2011-04-27 11:58:34 +00:00
|
|
|
continue;
|
2016-08-02 09:13:58 +00:00
|
|
|
}
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
for (int j = 0; j < 3; j++) {
|
|
|
|
if (!done[t.v[j]]) {
|
|
|
|
done[t.v[j]] = true;
|
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 15:59:20 +00:00
|
|
|
float3 off = float4_to_float3(d_output_data[d_output_index++]);
|
2017-05-15 13:44:09 +00:00
|
|
|
/* Avoid illegal vertex coordinates. */
|
|
|
|
off = ensure_finite3(off);
|
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 15:59:20 +00:00
|
|
|
mesh_verts[t.v[j]] += off;
|
2016-01-16 10:36:42 +00:00
|
|
|
if (attr_mP != NULL) {
|
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 15:59:20 +00:00
|
|
|
for (int step = 0; step < num_motion_steps - 1; step++) {
|
2016-01-16 10:36:42 +00:00
|
|
|
float3 *mP = attr_mP->data_float3() + step * num_verts;
|
|
|
|
mP[t.v[j]] += off;
|
|
|
|
}
|
|
|
|
}
|
2011-04-27 11:58:34 +00: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 15:59:20 +00:00
|
|
|
}
|
2019-04-17 04:17:24 +00: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 15:59:20 +00:00
|
|
|
bool GeometryManager::displace(
|
|
|
|
Device *device, DeviceScene *dscene, Scene *scene, Mesh *mesh, Progress &progress)
|
|
|
|
{
|
|
|
|
/* verify if we have a displacement shader */
|
|
|
|
if (!mesh->has_true_displacement()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const size_t num_verts = mesh->verts.size();
|
|
|
|
const size_t num_triangles = mesh->num_triangles();
|
|
|
|
|
|
|
|
if (num_triangles == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
string msg = string_printf("Computing Displacement %s", mesh->name.c_str());
|
|
|
|
progress.set_status("Updating Mesh", msg);
|
|
|
|
|
|
|
|
/* find object index. todo: is arbitrary */
|
|
|
|
size_t object_index = OBJECT_NONE;
|
|
|
|
|
|
|
|
for (size_t i = 0; i < scene->objects.size(); i++) {
|
|
|
|
if (scene->objects[i]->get_geometry() == mesh) {
|
|
|
|
object_index = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Needs to be up to data for attribute access. */
|
|
|
|
device->const_copy_to("__data", &dscene->data, sizeof(dscene->data));
|
|
|
|
|
|
|
|
/* Evaluate shader on device. */
|
|
|
|
ShaderEval shader_eval(device, progress);
|
|
|
|
if (!shader_eval.eval(SHADER_EVAL_DISPLACE,
|
|
|
|
num_verts,
|
|
|
|
function_bind(&fill_shader_input, scene, mesh, object_index, _1),
|
|
|
|
function_bind(&read_shader_output, scene, mesh, _1))) {
|
|
|
|
return false;
|
|
|
|
}
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2019-08-14 05:53:09 +00:00
|
|
|
/* stitch */
|
|
|
|
unordered_set<int> stitch_keys;
|
|
|
|
for (pair<int, int> i : mesh->vert_to_stitching_key_map) {
|
|
|
|
stitch_keys.insert(i.second); /* stitching index */
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef unordered_multimap<int, int>::iterator map_it_t;
|
|
|
|
|
|
|
|
for (int key : stitch_keys) {
|
|
|
|
pair<map_it_t, map_it_t> verts = mesh->vert_stitching_map.equal_range(key);
|
|
|
|
|
2021-02-17 00:47:18 +00:00
|
|
|
float3 pos = zero_float3();
|
2019-08-14 05:53:09 +00:00
|
|
|
int num = 0;
|
|
|
|
|
|
|
|
for (map_it_t v = verts.first; v != verts.second; ++v) {
|
|
|
|
int vert = v->second;
|
|
|
|
|
|
|
|
pos += mesh->verts[vert];
|
|
|
|
num++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (num <= 1) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos *= 1.0f / num;
|
|
|
|
|
|
|
|
for (map_it_t v = verts.first; v != verts.second; ++v) {
|
|
|
|
mesh->verts[v->second] = pos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* for displacement method both, we only need to recompute the face
|
|
|
|
* normals, as bump mapping in the shader will already alter the
|
|
|
|
* vertex normal, so we start from the non-displaced vertex normals
|
|
|
|
* to avoid applying the perturbation twice. */
|
2012-04-30 12:49:26 +00:00
|
|
|
mesh->attributes.remove(ATTR_STD_FACE_NORMAL);
|
2011-04-27 11:58:34 +00:00
|
|
|
mesh->add_face_normals();
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2016-08-02 09:13:58 +00:00
|
|
|
bool need_recompute_vertex_normals = false;
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2020-11-04 10:17:38 +00:00
|
|
|
foreach (Node *node, mesh->get_used_shaders()) {
|
|
|
|
Shader *shader = static_cast<Shader *>(node);
|
|
|
|
if (shader->has_displacement && shader->get_displacement_method() == DISPLACE_TRUE) {
|
2016-08-02 09:13:58 +00:00
|
|
|
need_recompute_vertex_normals = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2016-08-02 09:13:58 +00:00
|
|
|
if (need_recompute_vertex_normals) {
|
|
|
|
bool flip = mesh->transform_negative_scaled;
|
|
|
|
vector<bool> tri_has_true_disp(num_triangles, false);
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2016-08-02 09:13:58 +00:00
|
|
|
for (size_t i = 0; i < num_triangles; i++) {
|
|
|
|
int shader_index = mesh->shader[i];
|
|
|
|
Shader *shader = (shader_index < mesh->used_shaders.size()) ?
|
2020-11-04 10:17:38 +00:00
|
|
|
static_cast<Shader *>(mesh->used_shaders[shader_index]) :
|
2016-08-02 09:13:58 +00:00
|
|
|
scene->default_surface;
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2016-08-02 09:13:58 +00:00
|
|
|
tri_has_true_disp[i] = shader->has_displacement &&
|
2020-11-04 10:17:38 +00:00
|
|
|
shader->get_displacement_method() == DISPLACE_TRUE;
|
2016-08-02 09:13:58 +00:00
|
|
|
}
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2016-08-02 09:13:58 +00:00
|
|
|
/* static vertex normals */
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2016-08-02 09:13:58 +00:00
|
|
|
/* get attributes */
|
|
|
|
Attribute *attr_fN = mesh->attributes.find(ATTR_STD_FACE_NORMAL);
|
|
|
|
Attribute *attr_vN = mesh->attributes.find(ATTR_STD_VERTEX_NORMAL);
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2016-08-02 09:13:58 +00:00
|
|
|
float3 *fN = attr_fN->data_float3();
|
|
|
|
float3 *vN = attr_vN->data_float3();
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2016-08-02 09:13:58 +00:00
|
|
|
/* compute vertex normals */
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2016-08-02 09:13:58 +00:00
|
|
|
/* zero vertex normals on triangles with true displacement */
|
|
|
|
for (size_t i = 0; i < num_triangles; i++) {
|
|
|
|
if (tri_has_true_disp[i]) {
|
|
|
|
for (size_t j = 0; j < 3; j++) {
|
2021-02-17 00:47:18 +00:00
|
|
|
vN[mesh->get_triangle(i).v[j]] = zero_float3();
|
2016-08-02 09:13:58 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-17 04:17:24 +00:00
|
|
|
}
|
|
|
|
|
2016-08-02 09:13:58 +00:00
|
|
|
/* add face normals to vertex normals */
|
|
|
|
for (size_t i = 0; i < num_triangles; i++) {
|
|
|
|
if (tri_has_true_disp[i]) {
|
|
|
|
for (size_t j = 0; j < 3; j++) {
|
2019-08-14 05:53:09 +00:00
|
|
|
int vert = mesh->get_triangle(i).v[j];
|
|
|
|
vN[vert] += fN[i];
|
|
|
|
|
|
|
|
/* add face normals to stitched vertices */
|
|
|
|
if (stitch_keys.size()) {
|
|
|
|
map_it_t key = mesh->vert_to_stitching_key_map.find(vert);
|
|
|
|
|
|
|
|
if (key != mesh->vert_to_stitching_key_map.end()) {
|
|
|
|
pair<map_it_t, map_it_t> verts = mesh->vert_stitching_map.equal_range(key->second);
|
|
|
|
|
|
|
|
for (map_it_t v = verts.first; v != verts.second; ++v) {
|
|
|
|
if (v->second == vert) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
vN[v->second] += fN[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-08-02 09:13:58 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-17 04:17:24 +00:00
|
|
|
}
|
|
|
|
|
2016-08-02 09:13:58 +00:00
|
|
|
/* normalize vertex normals */
|
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 15:59:20 +00:00
|
|
|
vector<bool> done(num_verts, false);
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2016-08-02 09:13:58 +00:00
|
|
|
for (size_t i = 0; i < num_triangles; i++) {
|
|
|
|
if (tri_has_true_disp[i]) {
|
|
|
|
for (size_t j = 0; j < 3; j++) {
|
|
|
|
int vert = mesh->get_triangle(i).v[j];
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2016-08-02 09:13:58 +00:00
|
|
|
if (done[vert]) {
|
|
|
|
continue;
|
|
|
|
}
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2016-08-02 09:13:58 +00:00
|
|
|
vN[vert] = normalize(vN[vert]);
|
|
|
|
if (flip)
|
|
|
|
vN[vert] = -vN[vert];
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2016-08-02 09:13:58 +00:00
|
|
|
done[vert] = true;
|
|
|
|
}
|
|
|
|
}
|
2019-04-17 04:17:24 +00:00
|
|
|
}
|
|
|
|
|
2016-08-02 09:13:58 +00:00
|
|
|
/* motion vertex normals */
|
|
|
|
Attribute *attr_mP = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
|
|
|
|
Attribute *attr_mN = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_NORMAL);
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2016-08-02 09:13:58 +00:00
|
|
|
if (mesh->has_motion_blur() && attr_mP && attr_mN) {
|
|
|
|
for (int step = 0; step < mesh->motion_steps - 1; step++) {
|
|
|
|
float3 *mP = attr_mP->data_float3() + step * mesh->verts.size();
|
|
|
|
float3 *mN = attr_mN->data_float3() + step * mesh->verts.size();
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2016-08-02 09:13:58 +00:00
|
|
|
/* compute */
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2016-08-02 09:13:58 +00:00
|
|
|
/* zero vertex normals on triangles with true displacement */
|
|
|
|
for (size_t i = 0; i < num_triangles; i++) {
|
|
|
|
if (tri_has_true_disp[i]) {
|
|
|
|
for (size_t j = 0; j < 3; j++) {
|
2021-02-17 00:47:18 +00:00
|
|
|
mN[mesh->get_triangle(i).v[j]] = zero_float3();
|
2016-08-02 09:13:58 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-17 04:17:24 +00:00
|
|
|
}
|
|
|
|
|
2016-08-02 09:13:58 +00:00
|
|
|
/* add face normals to vertex normals */
|
|
|
|
for (size_t i = 0; i < num_triangles; i++) {
|
|
|
|
if (tri_has_true_disp[i]) {
|
|
|
|
for (size_t j = 0; j < 3; j++) {
|
2019-08-14 05:53:09 +00:00
|
|
|
int vert = mesh->get_triangle(i).v[j];
|
2016-08-02 09:13:58 +00:00
|
|
|
float3 fN = compute_face_normal(mesh->get_triangle(i), mP);
|
2019-08-14 05:53:09 +00:00
|
|
|
mN[vert] += fN;
|
|
|
|
|
|
|
|
/* add face normals to stitched vertices */
|
|
|
|
if (stitch_keys.size()) {
|
|
|
|
map_it_t key = mesh->vert_to_stitching_key_map.find(vert);
|
|
|
|
|
|
|
|
if (key != mesh->vert_to_stitching_key_map.end()) {
|
|
|
|
pair<map_it_t, map_it_t> verts = mesh->vert_stitching_map.equal_range(
|
|
|
|
key->second);
|
|
|
|
|
|
|
|
for (map_it_t v = verts.first; v != verts.second; ++v) {
|
|
|
|
if (v->second == vert) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
mN[v->second] += fN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-08-02 09:13:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2016-08-02 09:13:58 +00:00
|
|
|
/* normalize vertex normals */
|
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 15:59:20 +00:00
|
|
|
vector<bool> done(num_verts, false);
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2016-08-02 09:13:58 +00:00
|
|
|
for (size_t i = 0; i < num_triangles; i++) {
|
|
|
|
if (tri_has_true_disp[i]) {
|
|
|
|
for (size_t j = 0; j < 3; j++) {
|
|
|
|
int vert = mesh->get_triangle(i).v[j];
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2016-08-02 09:13:58 +00:00
|
|
|
if (done[vert]) {
|
|
|
|
continue;
|
|
|
|
}
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2016-08-02 09:13:58 +00:00
|
|
|
mN[vert] = normalize(mN[vert]);
|
|
|
|
if (flip)
|
|
|
|
mN[vert] = -mN[vert];
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2016-08-02 09:13:58 +00:00
|
|
|
done[vert] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|