Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2021-10-13 20:13:35 +0300
committerBrecht Van Lommel <brecht@blender.org>2021-10-15 16:42:44 +0300
commit2ba7c3aa650c3c795d903a24998204f67c75b017 (patch)
treeef80c7cadbe59d1062dd75818baad4d8ad594bcb /intern/cycles/render
parent70376154a0b09dc05fcc5bd79c33fdf7c6acbd9a (diff)
Cleanup: refactor to make number of channels for shader evaluation variable
Diffstat (limited to 'intern/cycles/render')
-rw-r--r--intern/cycles/render/light.cpp12
-rw-r--r--intern/cycles/render/mesh_displace.cpp11
2 files changed, 15 insertions, 8 deletions
diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp
index ae1150fc07b..400ed0802a6 100644
--- a/intern/cycles/render/light.cpp
+++ b/intern/cycles/render/light.cpp
@@ -50,6 +50,7 @@ static void shade_background_pixels(Device *device,
device->const_copy_to("__data", &dscene->data, sizeof(dscene->data));
const int size = width * height;
+ const int num_channels = 3;
pixels.resize(size);
/* Evaluate shader on device. */
@@ -57,6 +58,7 @@ static void shade_background_pixels(Device *device,
shader_eval.eval(
SHADER_EVAL_BACKGROUND,
size,
+ num_channels,
[&](device_vector<KernelShaderEvalInput> &d_input) {
/* Fill coordinates for shading. */
KernelShaderEvalInput *d_input_data = d_input.data();
@@ -77,15 +79,15 @@ static void shade_background_pixels(Device *device,
return size;
},
- [&](device_vector<float4> &d_output) {
+ [&](device_vector<float> &d_output) {
/* Copy output to pixel buffer. */
- float4 *d_output_data = d_output.data();
+ float *d_output_data = d_output.data();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
- pixels[y * width + x].x = d_output_data[y * width + x].x;
- pixels[y * width + x].y = d_output_data[y * width + x].y;
- pixels[y * width + x].z = d_output_data[y * width + x].z;
+ pixels[y * width + x].x = d_output_data[(y * width + x) * num_channels + 0];
+ pixels[y * width + x].y = d_output_data[(y * width + x) * num_channels + 1];
+ pixels[y * width + x].z = d_output_data[(y * width + x) * num_channels + 2];
}
}
});
diff --git a/intern/cycles/render/mesh_displace.cpp b/intern/cycles/render/mesh_displace.cpp
index c00c4c24211..bf8a4585907 100644
--- a/intern/cycles/render/mesh_displace.cpp
+++ b/intern/cycles/render/mesh_displace.cpp
@@ -115,7 +115,7 @@ static int fill_shader_input(const Scene *scene,
/* Read back mesh displacement shader output. */
static void read_shader_output(const Scene *scene,
Mesh *mesh,
- const device_vector<float4> &d_output)
+ const device_vector<float> &d_output)
{
const array<int> &mesh_shaders = mesh->get_shader();
const array<Node *> &mesh_used_shaders = mesh->get_used_shaders();
@@ -125,7 +125,7 @@ static void read_shader_output(const Scene *scene,
const int num_motion_steps = mesh->get_motion_steps();
vector<bool> done(num_verts, false);
- const float4 *d_output_data = d_output.data();
+ const float *d_output_data = d_output.data();
int d_output_index = 0;
Attribute *attr_mP = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
@@ -144,7 +144,11 @@ static void read_shader_output(const Scene *scene,
for (int j = 0; j < 3; j++) {
if (!done[t.v[j]]) {
done[t.v[j]] = true;
- float3 off = float4_to_float3(d_output_data[d_output_index++]);
+ float3 off = make_float3(d_output_data[d_output_index + 0],
+ d_output_data[d_output_index + 1],
+ d_output_data[d_output_index + 2]);
+ d_output_index += 3;
+
/* Avoid illegal vertex coordinates. */
off = ensure_finite3(off);
mesh_verts[t.v[j]] += off;
@@ -194,6 +198,7 @@ bool GeometryManager::displace(
ShaderEval shader_eval(device, progress);
if (!shader_eval.eval(SHADER_EVAL_DISPLACE,
num_verts,
+ 3,
function_bind(&fill_shader_input, scene, mesh, object_index, _1),
function_bind(&read_shader_output, scene, mesh, _1))) {
return false;