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
|
|
|
|
* limitations under the License
|
2011-04-27 11:58:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
/* Texture Coordinate Node */
|
|
|
|
|
2013-06-08 10:51:33 +00:00
|
|
|
__device void svm_node_tex_coord(KernelGlobals *kg, ShaderData *sd, int path_flag, float *stack, uint type, uint out_offset)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
float3 data;
|
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case NODE_TEXCO_OBJECT: {
|
|
|
|
if(sd->object != ~0) {
|
2012-04-30 12:49:26 +00:00
|
|
|
data = sd->P;
|
2012-05-08 23:39:31 +00:00
|
|
|
object_inverse_position_transform(kg, sd, &data);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
data = sd->P;
|
|
|
|
break;
|
|
|
|
}
|
Cycles: merging features from tomato branch.
=== BVH build time optimizations ===
* BVH building was multithreaded. Not all building is multithreaded, packing
and the initial bounding/splitting is still single threaded, but recursive
splitting is, which was the main bottleneck.
* Object splitting now uses binning rather than sorting of all elements, using
code from the Embree raytracer from Intel.
http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/
* Other small changes to avoid allocations, pack memory more tightly, avoid
some unnecessary operations, ...
These optimizations do not work yet when Spatial Splits are enabled, for that
more work is needed. There's also other optimizations still needed, in
particular for the case of many low poly objects, the packing step and node
memory allocation.
BVH raytracing time should remain about the same, but BVH build time should be
significantly reduced, test here show speedup of about 5x to 10x on a dual core
and 5x to 25x on an 8-core machine, depending on the scene.
=== Threads ===
Centralized task scheduler for multithreading, which is basically the
CPU device threading code wrapped into something reusable.
Basic idea is that there is a single TaskScheduler that keeps a pool of threads,
one for each core. Other places in the code can then create a TaskPool that they
can drop Tasks in to be executed by the scheduler, and wait for them to complete
or cancel them early.
=== Normal ====
Added a Normal output to the texture coordinate node. This currently
gives the object space normal, which is the same under object animation.
In the future this might become a "generated" normal so it's also stable for
deforming objects, but for now it's already useful for non-deforming objects.
=== Render Layers ===
Per render layer Samples control, leaving it to 0 will use the common scene
setting.
Environment pass will now render environment even if film is set to transparent.
Exclude Layers" added. Scene layers (all object that influence the render,
directly or indirectly) are shared between all render layers. However sometimes
it's useful to leave out some object influence for a particular render layer.
That's what this option allows you to do.
=== Filter Glossy ===
When using a value higher than 0.0, this will blur glossy reflections after
blurry bounces, to reduce noise at the cost of accuracy. 1.0 is a good
starting value to tweak.
Some light paths have a low probability of being found while contributing much
light to the pixel. As a result these light paths will be found in some pixels
and not in others, causing fireflies. An example of such a difficult path might
be a small light that is causing a small specular highlight on a sharp glossy
material, which we are seeing through a rough glossy material. With path tracing
it is difficult to find the specular highlight, but if we increase the roughness
on the material the highlight gets bigger and softer, and so easier to find.
Often this blurring will be hardly noticeable, because we are seeing it through
a blurry material anyway, but there are also cases where this will lead to a
loss of detail in lighting.
2012-04-28 08:53:59 +00:00
|
|
|
case NODE_TEXCO_NORMAL: {
|
|
|
|
if(sd->object != ~0) {
|
2012-04-30 12:49:26 +00:00
|
|
|
data = sd->N;
|
2012-05-02 09:33:45 +00:00
|
|
|
object_inverse_normal_transform(kg, sd, &data);
|
Cycles: merging features from tomato branch.
=== BVH build time optimizations ===
* BVH building was multithreaded. Not all building is multithreaded, packing
and the initial bounding/splitting is still single threaded, but recursive
splitting is, which was the main bottleneck.
* Object splitting now uses binning rather than sorting of all elements, using
code from the Embree raytracer from Intel.
http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/
* Other small changes to avoid allocations, pack memory more tightly, avoid
some unnecessary operations, ...
These optimizations do not work yet when Spatial Splits are enabled, for that
more work is needed. There's also other optimizations still needed, in
particular for the case of many low poly objects, the packing step and node
memory allocation.
BVH raytracing time should remain about the same, but BVH build time should be
significantly reduced, test here show speedup of about 5x to 10x on a dual core
and 5x to 25x on an 8-core machine, depending on the scene.
=== Threads ===
Centralized task scheduler for multithreading, which is basically the
CPU device threading code wrapped into something reusable.
Basic idea is that there is a single TaskScheduler that keeps a pool of threads,
one for each core. Other places in the code can then create a TaskPool that they
can drop Tasks in to be executed by the scheduler, and wait for them to complete
or cancel them early.
=== Normal ====
Added a Normal output to the texture coordinate node. This currently
gives the object space normal, which is the same under object animation.
In the future this might become a "generated" normal so it's also stable for
deforming objects, but for now it's already useful for non-deforming objects.
=== Render Layers ===
Per render layer Samples control, leaving it to 0 will use the common scene
setting.
Environment pass will now render environment even if film is set to transparent.
Exclude Layers" added. Scene layers (all object that influence the render,
directly or indirectly) are shared between all render layers. However sometimes
it's useful to leave out some object influence for a particular render layer.
That's what this option allows you to do.
=== Filter Glossy ===
When using a value higher than 0.0, this will blur glossy reflections after
blurry bounces, to reduce noise at the cost of accuracy. 1.0 is a good
starting value to tweak.
Some light paths have a low probability of being found while contributing much
light to the pixel. As a result these light paths will be found in some pixels
and not in others, causing fireflies. An example of such a difficult path might
be a small light that is causing a small specular highlight on a sharp glossy
material, which we are seeing through a rough glossy material. With path tracing
it is difficult to find the specular highlight, but if we increase the roughness
on the material the highlight gets bigger and softer, and so easier to find.
Often this blurring will be hardly noticeable, because we are seeing it through
a blurry material anyway, but there are also cases where this will lead to a
loss of detail in lighting.
2012-04-28 08:53:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
data = sd->N;
|
|
|
|
break;
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
case NODE_TEXCO_CAMERA: {
|
|
|
|
Transform tfm = kernel_data.cam.worldtocamera;
|
|
|
|
|
|
|
|
if(sd->object != ~0)
|
2012-04-16 08:35:21 +00:00
|
|
|
data = transform_point(&tfm, sd->P);
|
2011-04-27 11:58:34 +00:00
|
|
|
else
|
2013-06-08 10:51:33 +00:00
|
|
|
data = transform_point(&tfm, sd->P + camera_position(kg));
|
2011-04-27 11:58:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_WINDOW: {
|
2013-06-08 10:51:33 +00:00
|
|
|
if((path_flag & PATH_RAY_CAMERA) && sd->object == ~0 && kernel_data.cam.type == CAMERA_ORTHOGRAPHIC)
|
|
|
|
data = camera_world_to_ndc(kg, sd, sd->ray_P);
|
|
|
|
else
|
|
|
|
data = camera_world_to_ndc(kg, sd, sd->P);
|
2012-11-21 13:00:57 +00:00
|
|
|
data.z = 0.0f;
|
2011-04-27 11:58:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_REFLECTION: {
|
|
|
|
if(sd->object != ~0)
|
2012-05-18 12:49:22 +00:00
|
|
|
data = 2.0f*dot(sd->N, sd->I)*sd->N - sd->I;
|
2011-04-27 11:58:34 +00:00
|
|
|
else
|
|
|
|
data = sd->I;
|
|
|
|
break;
|
|
|
|
}
|
2012-10-04 21:40:39 +00:00
|
|
|
case NODE_TEXCO_DUPLI_GENERATED: {
|
|
|
|
data = object_dupli_generated(kg, sd->object);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_DUPLI_UV: {
|
|
|
|
data = object_dupli_uv(kg, sd->object);
|
|
|
|
break;
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stack_store_float3(stack, out_offset, data);
|
|
|
|
}
|
|
|
|
|
2013-06-08 10:51:33 +00:00
|
|
|
__device void svm_node_tex_coord_bump_dx(KernelGlobals *kg, ShaderData *sd, int path_flag, float *stack, uint type, uint out_offset)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
#ifdef __RAY_DIFFERENTIALS__
|
|
|
|
float3 data;
|
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case NODE_TEXCO_OBJECT: {
|
|
|
|
if(sd->object != ~0) {
|
2012-04-30 12:49:26 +00:00
|
|
|
data = sd->P + sd->dP.dx;
|
2012-05-08 23:39:31 +00:00
|
|
|
object_inverse_position_transform(kg, sd, &data);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
data = sd->P + sd->dP.dx;
|
|
|
|
break;
|
|
|
|
}
|
Cycles: merging features from tomato branch.
=== BVH build time optimizations ===
* BVH building was multithreaded. Not all building is multithreaded, packing
and the initial bounding/splitting is still single threaded, but recursive
splitting is, which was the main bottleneck.
* Object splitting now uses binning rather than sorting of all elements, using
code from the Embree raytracer from Intel.
http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/
* Other small changes to avoid allocations, pack memory more tightly, avoid
some unnecessary operations, ...
These optimizations do not work yet when Spatial Splits are enabled, for that
more work is needed. There's also other optimizations still needed, in
particular for the case of many low poly objects, the packing step and node
memory allocation.
BVH raytracing time should remain about the same, but BVH build time should be
significantly reduced, test here show speedup of about 5x to 10x on a dual core
and 5x to 25x on an 8-core machine, depending on the scene.
=== Threads ===
Centralized task scheduler for multithreading, which is basically the
CPU device threading code wrapped into something reusable.
Basic idea is that there is a single TaskScheduler that keeps a pool of threads,
one for each core. Other places in the code can then create a TaskPool that they
can drop Tasks in to be executed by the scheduler, and wait for them to complete
or cancel them early.
=== Normal ====
Added a Normal output to the texture coordinate node. This currently
gives the object space normal, which is the same under object animation.
In the future this might become a "generated" normal so it's also stable for
deforming objects, but for now it's already useful for non-deforming objects.
=== Render Layers ===
Per render layer Samples control, leaving it to 0 will use the common scene
setting.
Environment pass will now render environment even if film is set to transparent.
Exclude Layers" added. Scene layers (all object that influence the render,
directly or indirectly) are shared between all render layers. However sometimes
it's useful to leave out some object influence for a particular render layer.
That's what this option allows you to do.
=== Filter Glossy ===
When using a value higher than 0.0, this will blur glossy reflections after
blurry bounces, to reduce noise at the cost of accuracy. 1.0 is a good
starting value to tweak.
Some light paths have a low probability of being found while contributing much
light to the pixel. As a result these light paths will be found in some pixels
and not in others, causing fireflies. An example of such a difficult path might
be a small light that is causing a small specular highlight on a sharp glossy
material, which we are seeing through a rough glossy material. With path tracing
it is difficult to find the specular highlight, but if we increase the roughness
on the material the highlight gets bigger and softer, and so easier to find.
Often this blurring will be hardly noticeable, because we are seeing it through
a blurry material anyway, but there are also cases where this will lead to a
loss of detail in lighting.
2012-04-28 08:53:59 +00:00
|
|
|
case NODE_TEXCO_NORMAL: {
|
|
|
|
if(sd->object != ~0) {
|
2012-04-30 12:49:26 +00:00
|
|
|
data = sd->N;
|
2012-05-02 09:33:45 +00:00
|
|
|
object_inverse_normal_transform(kg, sd, &data);
|
Cycles: merging features from tomato branch.
=== BVH build time optimizations ===
* BVH building was multithreaded. Not all building is multithreaded, packing
and the initial bounding/splitting is still single threaded, but recursive
splitting is, which was the main bottleneck.
* Object splitting now uses binning rather than sorting of all elements, using
code from the Embree raytracer from Intel.
http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/
* Other small changes to avoid allocations, pack memory more tightly, avoid
some unnecessary operations, ...
These optimizations do not work yet when Spatial Splits are enabled, for that
more work is needed. There's also other optimizations still needed, in
particular for the case of many low poly objects, the packing step and node
memory allocation.
BVH raytracing time should remain about the same, but BVH build time should be
significantly reduced, test here show speedup of about 5x to 10x on a dual core
and 5x to 25x on an 8-core machine, depending on the scene.
=== Threads ===
Centralized task scheduler for multithreading, which is basically the
CPU device threading code wrapped into something reusable.
Basic idea is that there is a single TaskScheduler that keeps a pool of threads,
one for each core. Other places in the code can then create a TaskPool that they
can drop Tasks in to be executed by the scheduler, and wait for them to complete
or cancel them early.
=== Normal ====
Added a Normal output to the texture coordinate node. This currently
gives the object space normal, which is the same under object animation.
In the future this might become a "generated" normal so it's also stable for
deforming objects, but for now it's already useful for non-deforming objects.
=== Render Layers ===
Per render layer Samples control, leaving it to 0 will use the common scene
setting.
Environment pass will now render environment even if film is set to transparent.
Exclude Layers" added. Scene layers (all object that influence the render,
directly or indirectly) are shared between all render layers. However sometimes
it's useful to leave out some object influence for a particular render layer.
That's what this option allows you to do.
=== Filter Glossy ===
When using a value higher than 0.0, this will blur glossy reflections after
blurry bounces, to reduce noise at the cost of accuracy. 1.0 is a good
starting value to tweak.
Some light paths have a low probability of being found while contributing much
light to the pixel. As a result these light paths will be found in some pixels
and not in others, causing fireflies. An example of such a difficult path might
be a small light that is causing a small specular highlight on a sharp glossy
material, which we are seeing through a rough glossy material. With path tracing
it is difficult to find the specular highlight, but if we increase the roughness
on the material the highlight gets bigger and softer, and so easier to find.
Often this blurring will be hardly noticeable, because we are seeing it through
a blurry material anyway, but there are also cases where this will lead to a
loss of detail in lighting.
2012-04-28 08:53:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
data = sd->N;
|
|
|
|
break;
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
case NODE_TEXCO_CAMERA: {
|
|
|
|
Transform tfm = kernel_data.cam.worldtocamera;
|
|
|
|
|
|
|
|
if(sd->object != ~0)
|
2012-04-16 08:35:21 +00:00
|
|
|
data = transform_point(&tfm, sd->P + sd->dP.dx);
|
2011-04-27 11:58:34 +00:00
|
|
|
else
|
2013-06-08 10:51:33 +00:00
|
|
|
data = transform_point(&tfm, sd->P + sd->dP.dx + camera_position(kg));
|
2011-04-27 11:58:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_WINDOW: {
|
2013-06-08 10:51:33 +00:00
|
|
|
if((path_flag & PATH_RAY_CAMERA) && sd->object == ~0 && kernel_data.cam.type == CAMERA_ORTHOGRAPHIC)
|
|
|
|
data = camera_world_to_ndc(kg, sd, sd->ray_P + sd->ray_dP.dx);
|
|
|
|
else
|
|
|
|
data = camera_world_to_ndc(kg, sd, sd->P + sd->dP.dx);
|
2012-11-21 13:00:57 +00:00
|
|
|
data.z = 0.0f;
|
2011-04-27 11:58:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_REFLECTION: {
|
|
|
|
if(sd->object != ~0)
|
2012-05-18 12:49:22 +00:00
|
|
|
data = 2.0f*dot(sd->N, sd->I)*sd->N - sd->I;
|
2011-04-27 11:58:34 +00:00
|
|
|
else
|
|
|
|
data = sd->I;
|
|
|
|
break;
|
|
|
|
}
|
2012-10-04 21:40:39 +00:00
|
|
|
case NODE_TEXCO_DUPLI_GENERATED: {
|
|
|
|
data = object_dupli_generated(kg, sd->object);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_DUPLI_UV: {
|
|
|
|
data = object_dupli_uv(kg, sd->object);
|
|
|
|
break;
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stack_store_float3(stack, out_offset, data);
|
|
|
|
#else
|
|
|
|
svm_node_tex_coord(kg, sd, stack, type, out_offset);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-06-08 10:51:33 +00:00
|
|
|
__device void svm_node_tex_coord_bump_dy(KernelGlobals *kg, ShaderData *sd, int path_flag, float *stack, uint type, uint out_offset)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
#ifdef __RAY_DIFFERENTIALS__
|
|
|
|
float3 data;
|
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case NODE_TEXCO_OBJECT: {
|
|
|
|
if(sd->object != ~0) {
|
2012-04-30 12:49:26 +00:00
|
|
|
data = sd->P + sd->dP.dy;
|
2012-05-08 23:39:31 +00:00
|
|
|
object_inverse_position_transform(kg, sd, &data);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
data = sd->P + sd->dP.dy;
|
|
|
|
break;
|
|
|
|
}
|
Cycles: merging features from tomato branch.
=== BVH build time optimizations ===
* BVH building was multithreaded. Not all building is multithreaded, packing
and the initial bounding/splitting is still single threaded, but recursive
splitting is, which was the main bottleneck.
* Object splitting now uses binning rather than sorting of all elements, using
code from the Embree raytracer from Intel.
http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/
* Other small changes to avoid allocations, pack memory more tightly, avoid
some unnecessary operations, ...
These optimizations do not work yet when Spatial Splits are enabled, for that
more work is needed. There's also other optimizations still needed, in
particular for the case of many low poly objects, the packing step and node
memory allocation.
BVH raytracing time should remain about the same, but BVH build time should be
significantly reduced, test here show speedup of about 5x to 10x on a dual core
and 5x to 25x on an 8-core machine, depending on the scene.
=== Threads ===
Centralized task scheduler for multithreading, which is basically the
CPU device threading code wrapped into something reusable.
Basic idea is that there is a single TaskScheduler that keeps a pool of threads,
one for each core. Other places in the code can then create a TaskPool that they
can drop Tasks in to be executed by the scheduler, and wait for them to complete
or cancel them early.
=== Normal ====
Added a Normal output to the texture coordinate node. This currently
gives the object space normal, which is the same under object animation.
In the future this might become a "generated" normal so it's also stable for
deforming objects, but for now it's already useful for non-deforming objects.
=== Render Layers ===
Per render layer Samples control, leaving it to 0 will use the common scene
setting.
Environment pass will now render environment even if film is set to transparent.
Exclude Layers" added. Scene layers (all object that influence the render,
directly or indirectly) are shared between all render layers. However sometimes
it's useful to leave out some object influence for a particular render layer.
That's what this option allows you to do.
=== Filter Glossy ===
When using a value higher than 0.0, this will blur glossy reflections after
blurry bounces, to reduce noise at the cost of accuracy. 1.0 is a good
starting value to tweak.
Some light paths have a low probability of being found while contributing much
light to the pixel. As a result these light paths will be found in some pixels
and not in others, causing fireflies. An example of such a difficult path might
be a small light that is causing a small specular highlight on a sharp glossy
material, which we are seeing through a rough glossy material. With path tracing
it is difficult to find the specular highlight, but if we increase the roughness
on the material the highlight gets bigger and softer, and so easier to find.
Often this blurring will be hardly noticeable, because we are seeing it through
a blurry material anyway, but there are also cases where this will lead to a
loss of detail in lighting.
2012-04-28 08:53:59 +00:00
|
|
|
case NODE_TEXCO_NORMAL: {
|
|
|
|
if(sd->object != ~0) {
|
2012-04-30 12:49:26 +00:00
|
|
|
data = sd->N;
|
2012-05-02 09:33:45 +00:00
|
|
|
object_inverse_normal_transform(kg, sd, &data);
|
Cycles: merging features from tomato branch.
=== BVH build time optimizations ===
* BVH building was multithreaded. Not all building is multithreaded, packing
and the initial bounding/splitting is still single threaded, but recursive
splitting is, which was the main bottleneck.
* Object splitting now uses binning rather than sorting of all elements, using
code from the Embree raytracer from Intel.
http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/
* Other small changes to avoid allocations, pack memory more tightly, avoid
some unnecessary operations, ...
These optimizations do not work yet when Spatial Splits are enabled, for that
more work is needed. There's also other optimizations still needed, in
particular for the case of many low poly objects, the packing step and node
memory allocation.
BVH raytracing time should remain about the same, but BVH build time should be
significantly reduced, test here show speedup of about 5x to 10x on a dual core
and 5x to 25x on an 8-core machine, depending on the scene.
=== Threads ===
Centralized task scheduler for multithreading, which is basically the
CPU device threading code wrapped into something reusable.
Basic idea is that there is a single TaskScheduler that keeps a pool of threads,
one for each core. Other places in the code can then create a TaskPool that they
can drop Tasks in to be executed by the scheduler, and wait for them to complete
or cancel them early.
=== Normal ====
Added a Normal output to the texture coordinate node. This currently
gives the object space normal, which is the same under object animation.
In the future this might become a "generated" normal so it's also stable for
deforming objects, but for now it's already useful for non-deforming objects.
=== Render Layers ===
Per render layer Samples control, leaving it to 0 will use the common scene
setting.
Environment pass will now render environment even if film is set to transparent.
Exclude Layers" added. Scene layers (all object that influence the render,
directly or indirectly) are shared between all render layers. However sometimes
it's useful to leave out some object influence for a particular render layer.
That's what this option allows you to do.
=== Filter Glossy ===
When using a value higher than 0.0, this will blur glossy reflections after
blurry bounces, to reduce noise at the cost of accuracy. 1.0 is a good
starting value to tweak.
Some light paths have a low probability of being found while contributing much
light to the pixel. As a result these light paths will be found in some pixels
and not in others, causing fireflies. An example of such a difficult path might
be a small light that is causing a small specular highlight on a sharp glossy
material, which we are seeing through a rough glossy material. With path tracing
it is difficult to find the specular highlight, but if we increase the roughness
on the material the highlight gets bigger and softer, and so easier to find.
Often this blurring will be hardly noticeable, because we are seeing it through
a blurry material anyway, but there are also cases where this will lead to a
loss of detail in lighting.
2012-04-28 08:53:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
data = sd->N;
|
|
|
|
break;
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
case NODE_TEXCO_CAMERA: {
|
|
|
|
Transform tfm = kernel_data.cam.worldtocamera;
|
|
|
|
|
|
|
|
if(sd->object != ~0)
|
2012-04-16 08:35:21 +00:00
|
|
|
data = transform_point(&tfm, sd->P + sd->dP.dy);
|
2011-04-27 11:58:34 +00:00
|
|
|
else
|
2013-06-08 10:51:33 +00:00
|
|
|
data = transform_point(&tfm, sd->P + sd->dP.dy + camera_position(kg));
|
2011-04-27 11:58:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_WINDOW: {
|
2013-06-08 10:51:33 +00:00
|
|
|
if((path_flag & PATH_RAY_CAMERA) && sd->object == ~0 && kernel_data.cam.type == CAMERA_ORTHOGRAPHIC)
|
|
|
|
data = camera_world_to_ndc(kg, sd, sd->ray_P + sd->ray_dP.dy);
|
|
|
|
else
|
|
|
|
data = camera_world_to_ndc(kg, sd, sd->P + sd->dP.dy);
|
2012-11-21 13:00:57 +00:00
|
|
|
data.z = 0.0f;
|
2011-04-27 11:58:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_REFLECTION: {
|
|
|
|
if(sd->object != ~0)
|
2012-05-18 12:49:22 +00:00
|
|
|
data = 2.0f*dot(sd->N, sd->I)*sd->N - sd->I;
|
2011-04-27 11:58:34 +00:00
|
|
|
else
|
|
|
|
data = sd->I;
|
|
|
|
break;
|
|
|
|
}
|
2012-10-04 21:40:39 +00:00
|
|
|
case NODE_TEXCO_DUPLI_GENERATED: {
|
|
|
|
data = object_dupli_generated(kg, sd->object);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_DUPLI_UV: {
|
|
|
|
data = object_dupli_uv(kg, sd->object);
|
|
|
|
break;
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stack_store_float3(stack, out_offset, data);
|
|
|
|
#else
|
|
|
|
svm_node_tex_coord(kg, sd, stack, type, out_offset);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-11-06 19:59:02 +00:00
|
|
|
__device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
|
|
|
|
{
|
2012-11-08 16:35:20 +00:00
|
|
|
uint color_offset, strength_offset, normal_offset, space;
|
|
|
|
decode_node_uchar4(node.y, &color_offset, &strength_offset, &normal_offset, &space);
|
2012-11-06 19:59:02 +00:00
|
|
|
|
|
|
|
float3 color = stack_load_float3(stack, color_offset);
|
|
|
|
color = 2.0f*make_float3(color.x - 0.5f, color.y - 0.5f, color.z - 0.5f);
|
|
|
|
|
2012-11-08 16:35:20 +00:00
|
|
|
float3 N;
|
|
|
|
|
2012-11-06 19:59:02 +00:00
|
|
|
if(space == NODE_NORMAL_MAP_TANGENT) {
|
|
|
|
/* tangent space */
|
2013-01-03 12:08:54 +00:00
|
|
|
if(sd->object == ~0) {
|
2012-11-06 19:59:02 +00:00
|
|
|
stack_store_float3(stack, normal_offset, make_float3(0.0f, 0.0f, 0.0f));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* first try to get tangent attribute */
|
2013-01-15 16:35:05 +00:00
|
|
|
AttributeElement attr_elem, attr_sign_elem, attr_normal_elem;
|
2013-01-03 12:08:54 +00:00
|
|
|
int attr_offset = find_attribute(kg, sd, node.z, &attr_elem);
|
|
|
|
int attr_sign_offset = find_attribute(kg, sd, node.w, &attr_sign_elem);
|
2013-01-15 16:35:05 +00:00
|
|
|
int attr_normal_offset = find_attribute(kg, sd, ATTR_STD_VERTEX_NORMAL, &attr_normal_elem);
|
2012-11-06 19:59:02 +00:00
|
|
|
|
2013-01-15 16:35:05 +00:00
|
|
|
if(attr_offset == ATTR_STD_NOT_FOUND || attr_sign_offset == ATTR_STD_NOT_FOUND || attr_normal_offset == ATTR_STD_NOT_FOUND) {
|
2012-11-06 19:59:02 +00:00
|
|
|
stack_store_float3(stack, normal_offset, make_float3(0.0f, 0.0f, 0.0f));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-01-15 16:35:05 +00:00
|
|
|
/* get _unnormalized_ interpolated normal and tangent */
|
2013-01-03 12:08:54 +00:00
|
|
|
float3 tangent = primitive_attribute_float3(kg, sd, attr_elem, attr_offset, NULL, NULL);
|
|
|
|
float sign = primitive_attribute_float(kg, sd, attr_sign_elem, attr_sign_offset, NULL, NULL);
|
2013-05-11 09:31:58 +00:00
|
|
|
float3 normal;
|
|
|
|
|
2013-06-13 13:55:05 +00:00
|
|
|
if(sd->shader & SHADER_SMOOTH_NORMAL) {
|
2013-05-11 09:31:58 +00:00
|
|
|
normal = primitive_attribute_float3(kg, sd, attr_normal_elem, attr_normal_offset, NULL, NULL);
|
2013-06-13 13:55:05 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
normal = sd->Ng;
|
|
|
|
object_inverse_normal_transform(kg, sd, &normal);
|
|
|
|
}
|
2012-11-06 19:59:02 +00:00
|
|
|
|
2013-01-15 16:35:05 +00:00
|
|
|
/* apply normal map */
|
|
|
|
float3 B = sign * cross(normal, tangent);
|
|
|
|
N = normalize(color.x * tangent + color.y * B + color.z * normal);
|
2012-11-06 19:59:02 +00:00
|
|
|
|
2013-01-15 16:35:05 +00:00
|
|
|
/* transform to world space */
|
|
|
|
object_normal_transform(kg, sd, &N);
|
2012-11-06 19:59:02 +00:00
|
|
|
}
|
|
|
|
else {
|
2013-05-27 17:48:02 +00:00
|
|
|
/* strange blender convention */
|
2013-05-28 14:24:03 +00:00
|
|
|
if(space == NODE_NORMAL_MAP_BLENDER_OBJECT || space == NODE_NORMAL_MAP_BLENDER_WORLD) {
|
|
|
|
color.y = -color.y;
|
|
|
|
color.z = -color.z;
|
|
|
|
}
|
2013-05-27 17:48:02 +00:00
|
|
|
|
2012-11-06 19:59:02 +00:00
|
|
|
/* object, world space */
|
2012-11-08 16:35:20 +00:00
|
|
|
N = color;
|
2012-11-06 19:59:02 +00:00
|
|
|
|
2013-05-28 14:24:03 +00:00
|
|
|
if(space == NODE_NORMAL_MAP_OBJECT || space == NODE_NORMAL_MAP_BLENDER_OBJECT)
|
2012-11-06 19:59:02 +00:00
|
|
|
object_normal_transform(kg, sd, &N);
|
2013-05-27 17:48:02 +00:00
|
|
|
else
|
|
|
|
N = normalize(N);
|
2012-11-08 16:35:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
float strength = stack_load_float(stack, strength_offset);
|
|
|
|
|
|
|
|
if(strength != 1.0f) {
|
|
|
|
strength = max(strength, 0.0f);
|
|
|
|
N = normalize(sd->N + (N - sd->N)*strength);
|
2012-11-06 19:59:02 +00:00
|
|
|
}
|
2012-11-08 16:35:20 +00:00
|
|
|
|
2012-11-22 16:08:18 +00:00
|
|
|
stack_store_float3(stack, normal_offset, N);
|
2012-11-06 19:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
__device void svm_node_tangent(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
|
|
|
|
{
|
|
|
|
uint tangent_offset, direction_type, axis;
|
|
|
|
decode_node_uchar4(node.y, &tangent_offset, &direction_type, &axis, NULL);
|
|
|
|
|
|
|
|
float3 tangent;
|
|
|
|
|
|
|
|
if(direction_type == NODE_TANGENT_UVMAP) {
|
|
|
|
/* UV map */
|
2013-01-03 12:08:54 +00:00
|
|
|
AttributeElement attr_elem;
|
|
|
|
int attr_offset = find_attribute(kg, sd, node.z, &attr_elem);
|
2012-11-06 19:59:02 +00:00
|
|
|
|
|
|
|
if(attr_offset == ATTR_STD_NOT_FOUND)
|
|
|
|
tangent = make_float3(0.0f, 0.0f, 0.0f);
|
|
|
|
else
|
2013-01-03 12:08:54 +00:00
|
|
|
tangent = primitive_attribute_float3(kg, sd, attr_elem, attr_offset, NULL, NULL);
|
2012-11-06 19:59:02 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* radial */
|
2013-01-03 12:08:54 +00:00
|
|
|
AttributeElement attr_elem;
|
|
|
|
int attr_offset = find_attribute(kg, sd, node.z, &attr_elem);
|
2012-11-06 19:59:02 +00:00
|
|
|
float3 generated;
|
|
|
|
|
|
|
|
if(attr_offset == ATTR_STD_NOT_FOUND)
|
|
|
|
generated = sd->P;
|
|
|
|
else
|
2013-01-03 12:08:54 +00:00
|
|
|
generated = primitive_attribute_float3(kg, sd, attr_elem, attr_offset, NULL, NULL);
|
2012-11-06 19:59:02 +00:00
|
|
|
|
|
|
|
if(axis == NODE_TANGENT_AXIS_X)
|
|
|
|
tangent = make_float3(0.0f, -(generated.z - 0.5f), (generated.y - 0.5f));
|
|
|
|
else if(axis == NODE_TANGENT_AXIS_Y)
|
|
|
|
tangent = make_float3(-(generated.z - 0.5f), 0.0f, (generated.x - 0.5f));
|
|
|
|
else
|
|
|
|
tangent = make_float3(-(generated.y - 0.5f), (generated.x - 0.5f), 0.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
object_normal_transform(kg, sd, &tangent);
|
|
|
|
tangent = cross(sd->N, normalize(cross(tangent, sd->N)));
|
|
|
|
stack_store_float3(stack, tangent_offset, tangent);
|
|
|
|
}
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|