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
|
|
|
*/
|
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
/* Perspective Camera */
|
|
|
|
|
2013-11-15 23:17:10 +00:00
|
|
|
ccl_device float2 camera_sample_aperture(KernelGlobals *kg, float u, float v)
|
2011-09-16 13:14:02 +00:00
|
|
|
{
|
|
|
|
float blades = kernel_data.cam.blades;
|
2014-08-27 08:51:50 +00:00
|
|
|
float2 bokeh;
|
2011-09-16 13:14:02 +00:00
|
|
|
|
|
|
|
if(blades == 0.0f) {
|
|
|
|
/* sample disk */
|
2014-08-27 08:51:50 +00:00
|
|
|
bokeh = concentric_sample_disk(u, v);
|
2011-09-16 13:14:02 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* sample polygon */
|
|
|
|
float rotation = kernel_data.cam.bladesrotation;
|
2014-08-27 08:51:50 +00:00
|
|
|
bokeh = regular_polygon_sample(blades, rotation, u, v);
|
2011-09-16 13:14:02 +00:00
|
|
|
}
|
2014-08-27 08:51:50 +00:00
|
|
|
|
|
|
|
/* anamorphic lens bokeh */
|
|
|
|
bokeh.x *= kernel_data.cam.inv_aperture_ratio;
|
|
|
|
|
|
|
|
return bokeh;
|
2011-09-16 13:14:02 +00:00
|
|
|
}
|
|
|
|
|
Cycles: OpenCL kernel split
This commit contains all the work related on the AMD megakernel split work
which was mainly done by Varun Sundar, George Kyriazis and Lenny Wang, plus
some help from Sergey Sharybin, Martijn Berger, Thomas Dinges and likely
someone else which we're forgetting to mention.
Currently only AMD cards are enabled for the new split kernel, but it is
possible to force split opencl kernel to be used by setting the following
environment variable: CYCLES_OPENCL_SPLIT_KERNEL_TEST=1.
Not all the features are supported yet, and that being said no motion blur,
camera blur, SSS and volumetrics for now. Also transparent shadows are
disabled on AMD device because of some compiler bug.
This kernel is also only implements regular path tracing and supporting
branched one will take a bit. Branched path tracing is exposed to the
interface still, which is a bit misleading and will be hidden there soon.
More feature will be enabled once they're ported to the split kernel and
tested.
Neither regular CPU nor CUDA has any difference, they're generating the
same exact code, which means no regressions/improvements there.
Based on the research paper:
https://research.nvidia.com/sites/default/files/publications/laine2013hpg_paper.pdf
Here's the documentation:
https://docs.google.com/document/d/1LuXW-CV-sVJkQaEGZlMJ86jZ8FmoPfecaMdR-oiWbUY/edit
Design discussion of the patch:
https://developer.blender.org/T44197
Differential Revision: https://developer.blender.org/D1200
2015-05-09 14:34:30 +00:00
|
|
|
ccl_device void camera_sample_perspective(KernelGlobals *kg, float raster_x, float raster_y, float lens_u, float lens_v, ccl_addr_space Ray *ray)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
/* create ray form raster position */
|
|
|
|
Transform rastertocamera = kernel_data.cam.rastertocamera;
|
2012-04-16 08:35:21 +00:00
|
|
|
float3 Pcamera = transform_perspective(&rastertocamera, make_float3(raster_x, raster_y, 0.0f));
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
ray->P = make_float3(0.0f, 0.0f, 0.0f);
|
|
|
|
ray->D = Pcamera;
|
|
|
|
|
|
|
|
/* modify ray for depth of field */
|
2011-09-16 13:14:02 +00:00
|
|
|
float aperturesize = kernel_data.cam.aperturesize;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-09-16 13:14:02 +00:00
|
|
|
if(aperturesize > 0.0f) {
|
|
|
|
/* sample point on aperture */
|
|
|
|
float2 lensuv = camera_sample_aperture(kg, lens_u, lens_v)*aperturesize;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
/* compute point on plane of focus */
|
|
|
|
float ft = kernel_data.cam.focaldistance/ray->D.z;
|
2013-04-03 17:32:30 +00:00
|
|
|
float3 Pfocus = ray->D*ft;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
/* update ray for effect of lens */
|
|
|
|
ray->P = make_float3(lensuv.x, lensuv.y, 0.0f);
|
|
|
|
ray->D = normalize(Pfocus - ray->P);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* transform ray from camera to world */
|
|
|
|
Transform cameratoworld = kernel_data.cam.cameratoworld;
|
|
|
|
|
2012-10-09 18:37:14 +00:00
|
|
|
#ifdef __CAMERA_MOTION__
|
2015-02-21 07:33:21 +00:00
|
|
|
if(kernel_data.cam.have_motion) {
|
2015-05-09 13:57:51 +00:00
|
|
|
#ifdef __KERNEL_OPENCL__
|
|
|
|
const MotionTransform tfm = kernel_data.cam.motion;
|
2015-02-21 07:33:21 +00:00
|
|
|
transform_motion_interpolate(&cameratoworld,
|
2015-05-09 13:57:51 +00:00
|
|
|
((const DecompMotionTransform*)&tfm),
|
2015-02-21 07:33:21 +00:00
|
|
|
ray->time);
|
2015-05-09 13:57:51 +00:00
|
|
|
#else
|
|
|
|
transform_motion_interpolate(&cameratoworld,
|
|
|
|
((const DecompMotionTransform*)&kernel_data.cam.motion),
|
|
|
|
ray->time);
|
|
|
|
#endif
|
2015-02-21 07:33:21 +00:00
|
|
|
}
|
2012-04-30 12:49:26 +00:00
|
|
|
#endif
|
|
|
|
|
2012-04-16 08:35:21 +00:00
|
|
|
ray->P = transform_point(&cameratoworld, ray->P);
|
2011-04-27 11:58:34 +00:00
|
|
|
ray->D = transform_direction(&cameratoworld, ray->D);
|
|
|
|
ray->D = normalize(ray->D);
|
|
|
|
|
|
|
|
#ifdef __RAY_DIFFERENTIALS__
|
|
|
|
/* ray differential */
|
|
|
|
float3 Ddiff = transform_direction(&cameratoworld, Pcamera);
|
|
|
|
|
2013-05-03 21:34:51 +00:00
|
|
|
ray->dP = differential3_zero();
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-12-20 12:25:45 +00:00
|
|
|
ray->dD.dx = normalize(Ddiff + float4_to_float3(kernel_data.cam.dx)) - normalize(Ddiff);
|
|
|
|
ray->dD.dy = normalize(Ddiff + float4_to_float3(kernel_data.cam.dy)) - normalize(Ddiff);
|
2011-04-27 11:58:34 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __CAMERA_CLIPPING__
|
|
|
|
/* clipping */
|
2015-01-13 21:34:49 +00:00
|
|
|
float3 Pclip = normalize(Pcamera);
|
|
|
|
float z_inv = 1.0f / Pclip.z;
|
|
|
|
ray->P += kernel_data.cam.nearclip*ray->D * z_inv;
|
|
|
|
ray->t = kernel_data.cam.cliplength * z_inv;
|
2011-04-27 11:58:34 +00:00
|
|
|
#else
|
|
|
|
ray->t = FLT_MAX;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Orthographic Camera */
|
Cycles: OpenCL kernel split
This commit contains all the work related on the AMD megakernel split work
which was mainly done by Varun Sundar, George Kyriazis and Lenny Wang, plus
some help from Sergey Sharybin, Martijn Berger, Thomas Dinges and likely
someone else which we're forgetting to mention.
Currently only AMD cards are enabled for the new split kernel, but it is
possible to force split opencl kernel to be used by setting the following
environment variable: CYCLES_OPENCL_SPLIT_KERNEL_TEST=1.
Not all the features are supported yet, and that being said no motion blur,
camera blur, SSS and volumetrics for now. Also transparent shadows are
disabled on AMD device because of some compiler bug.
This kernel is also only implements regular path tracing and supporting
branched one will take a bit. Branched path tracing is exposed to the
interface still, which is a bit misleading and will be hidden there soon.
More feature will be enabled once they're ported to the split kernel and
tested.
Neither regular CPU nor CUDA has any difference, they're generating the
same exact code, which means no regressions/improvements there.
Based on the research paper:
https://research.nvidia.com/sites/default/files/publications/laine2013hpg_paper.pdf
Here's the documentation:
https://docs.google.com/document/d/1LuXW-CV-sVJkQaEGZlMJ86jZ8FmoPfecaMdR-oiWbUY/edit
Design discussion of the patch:
https://developer.blender.org/T44197
Differential Revision: https://developer.blender.org/D1200
2015-05-09 14:34:30 +00:00
|
|
|
ccl_device void camera_sample_orthographic(KernelGlobals *kg, float raster_x, float raster_y, float lens_u, float lens_v, ccl_addr_space Ray *ray)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
/* create ray form raster position */
|
|
|
|
Transform rastertocamera = kernel_data.cam.rastertocamera;
|
2012-04-16 08:35:21 +00:00
|
|
|
float3 Pcamera = transform_perspective(&rastertocamera, make_float3(raster_x, raster_y, 0.0f));
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
ray->D = make_float3(0.0f, 0.0f, 1.0f);
|
|
|
|
|
2013-03-21 02:38:11 +00:00
|
|
|
/* modify ray for depth of field */
|
|
|
|
float aperturesize = kernel_data.cam.aperturesize;
|
|
|
|
|
|
|
|
if(aperturesize > 0.0f) {
|
|
|
|
/* sample point on aperture */
|
|
|
|
float2 lensuv = camera_sample_aperture(kg, lens_u, lens_v)*aperturesize;
|
|
|
|
|
|
|
|
/* compute point on plane of focus */
|
2013-05-12 17:14:01 +00:00
|
|
|
float3 Pfocus = ray->D * kernel_data.cam.focaldistance;
|
2013-03-21 02:38:11 +00:00
|
|
|
|
|
|
|
/* update ray for effect of lens */
|
2013-04-04 23:52:33 +00:00
|
|
|
float3 lensuvw = make_float3(lensuv.x, lensuv.y, 0.0f);
|
2013-04-06 11:52:40 +00:00
|
|
|
ray->P = Pcamera + lensuvw;
|
2013-04-04 23:52:33 +00:00
|
|
|
ray->D = normalize(Pfocus - lensuvw);
|
2013-03-21 02:38:11 +00:00
|
|
|
}
|
2013-04-06 11:52:40 +00:00
|
|
|
else {
|
|
|
|
ray->P = Pcamera;
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
/* transform ray from camera to world */
|
|
|
|
Transform cameratoworld = kernel_data.cam.cameratoworld;
|
|
|
|
|
2012-10-09 18:37:14 +00:00
|
|
|
#ifdef __CAMERA_MOTION__
|
2015-02-21 07:33:21 +00:00
|
|
|
if(kernel_data.cam.have_motion) {
|
2015-05-09 13:57:51 +00:00
|
|
|
#ifdef __KERNEL_OPENCL__
|
|
|
|
const MotionTransform tfm = kernel_data.cam.motion;
|
2015-02-21 07:33:21 +00:00
|
|
|
transform_motion_interpolate(&cameratoworld,
|
2015-05-09 13:57:51 +00:00
|
|
|
(const DecompMotionTransform*)&tfm,
|
2015-02-21 07:33:21 +00:00
|
|
|
ray->time);
|
2015-05-09 13:57:51 +00:00
|
|
|
#else
|
|
|
|
transform_motion_interpolate(&cameratoworld,
|
|
|
|
(const DecompMotionTransform*)&kernel_data.cam.motion,
|
|
|
|
ray->time);
|
|
|
|
#endif
|
2015-02-21 07:33:21 +00:00
|
|
|
}
|
2012-04-30 12:49:26 +00:00
|
|
|
#endif
|
|
|
|
|
2012-04-16 08:35:21 +00:00
|
|
|
ray->P = transform_point(&cameratoworld, ray->P);
|
2011-04-27 11:58:34 +00:00
|
|
|
ray->D = transform_direction(&cameratoworld, ray->D);
|
|
|
|
ray->D = normalize(ray->D);
|
|
|
|
|
|
|
|
#ifdef __RAY_DIFFERENTIALS__
|
|
|
|
/* ray differential */
|
2011-12-20 12:25:45 +00:00
|
|
|
ray->dP.dx = float4_to_float3(kernel_data.cam.dx);
|
|
|
|
ray->dP.dy = float4_to_float3(kernel_data.cam.dy);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2013-05-03 21:34:51 +00:00
|
|
|
ray->dD = differential3_zero();
|
2011-04-27 11:58:34 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __CAMERA_CLIPPING__
|
|
|
|
/* clipping */
|
|
|
|
ray->t = kernel_data.cam.cliplength;
|
|
|
|
#else
|
|
|
|
ray->t = FLT_MAX;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-05-04 16:20:51 +00:00
|
|
|
/* Panorama Camera */
|
2012-02-28 16:44:54 +00:00
|
|
|
|
Cycles: OpenCL kernel split
This commit contains all the work related on the AMD megakernel split work
which was mainly done by Varun Sundar, George Kyriazis and Lenny Wang, plus
some help from Sergey Sharybin, Martijn Berger, Thomas Dinges and likely
someone else which we're forgetting to mention.
Currently only AMD cards are enabled for the new split kernel, but it is
possible to force split opencl kernel to be used by setting the following
environment variable: CYCLES_OPENCL_SPLIT_KERNEL_TEST=1.
Not all the features are supported yet, and that being said no motion blur,
camera blur, SSS and volumetrics for now. Also transparent shadows are
disabled on AMD device because of some compiler bug.
This kernel is also only implements regular path tracing and supporting
branched one will take a bit. Branched path tracing is exposed to the
interface still, which is a bit misleading and will be hidden there soon.
More feature will be enabled once they're ported to the split kernel and
tested.
Neither regular CPU nor CUDA has any difference, they're generating the
same exact code, which means no regressions/improvements there.
Based on the research paper:
https://research.nvidia.com/sites/default/files/publications/laine2013hpg_paper.pdf
Here's the documentation:
https://docs.google.com/document/d/1LuXW-CV-sVJkQaEGZlMJ86jZ8FmoPfecaMdR-oiWbUY/edit
Design discussion of the patch:
https://developer.blender.org/T44197
Differential Revision: https://developer.blender.org/D1200
2015-05-09 14:34:30 +00:00
|
|
|
ccl_device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float raster_y, float lens_u, float lens_v, ccl_addr_space Ray *ray)
|
2012-02-28 16:44:54 +00:00
|
|
|
{
|
|
|
|
Transform rastertocamera = kernel_data.cam.rastertocamera;
|
2012-04-16 08:35:21 +00:00
|
|
|
float3 Pcamera = transform_perspective(&rastertocamera, make_float3(raster_x, raster_y, 0.0f));
|
2012-02-28 16:44:54 +00:00
|
|
|
|
|
|
|
/* create ray form raster position */
|
2012-04-30 10:03:13 +00:00
|
|
|
ray->P = make_float3(0.0f, 0.0f, 0.0f);
|
2012-05-04 16:20:51 +00:00
|
|
|
|
|
|
|
#ifdef __CAMERA_CLIPPING__
|
|
|
|
/* clipping */
|
|
|
|
ray->t = kernel_data.cam.cliplength;
|
|
|
|
#else
|
|
|
|
ray->t = FLT_MAX;
|
|
|
|
#endif
|
|
|
|
|
2012-05-05 19:44:35 +00:00
|
|
|
ray->D = panorama_to_direction(kg, Pcamera.x, Pcamera.y);
|
|
|
|
|
2013-07-10 17:25:52 +00:00
|
|
|
/* indicates ray should not receive any light, outside of the lens */
|
|
|
|
if(is_zero(ray->D)) {
|
|
|
|
ray->t = 0.0f;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-09-17 11:25:29 +00:00
|
|
|
/* modify ray for depth of field */
|
|
|
|
float aperturesize = kernel_data.cam.aperturesize;
|
|
|
|
|
|
|
|
if(aperturesize > 0.0f) {
|
|
|
|
/* sample point on aperture */
|
|
|
|
float2 lensuv = camera_sample_aperture(kg, lens_u, lens_v)*aperturesize;
|
|
|
|
|
|
|
|
/* compute point on plane of focus */
|
|
|
|
float3 D = normalize(ray->D);
|
|
|
|
float3 Pfocus = D * kernel_data.cam.focaldistance;
|
|
|
|
|
|
|
|
/* calculate orthonormal coordinates perpendicular to D */
|
|
|
|
float3 U, V;
|
2014-08-27 08:51:50 +00:00
|
|
|
U = normalize(make_float3(1.0f, 0.0f, 0.0f) - D.x * D);
|
|
|
|
V = normalize(cross(D, U));
|
2012-09-17 11:25:29 +00:00
|
|
|
|
|
|
|
/* update ray for effect of lens */
|
|
|
|
ray->P = U * lensuv.x + V * lensuv.y;
|
|
|
|
ray->D = normalize(Pfocus - ray->P);
|
|
|
|
}
|
|
|
|
|
2012-02-28 16:44:54 +00:00
|
|
|
/* transform ray from camera to world */
|
|
|
|
Transform cameratoworld = kernel_data.cam.cameratoworld;
|
|
|
|
|
2012-10-09 18:37:14 +00:00
|
|
|
#ifdef __CAMERA_MOTION__
|
2015-05-09 13:57:51 +00:00
|
|
|
if(kernel_data.cam.have_motion) {
|
|
|
|
#ifdef __KERNEL_OPENCL__
|
|
|
|
const MotionTransform tfm = kernel_data.cam.motion;
|
|
|
|
transform_motion_interpolate(&cameratoworld,
|
|
|
|
(const DecompMotionTransform*)&tfm,
|
|
|
|
ray->time);
|
|
|
|
#else
|
2015-02-21 07:33:21 +00:00
|
|
|
transform_motion_interpolate(&cameratoworld,
|
2015-05-09 13:57:51 +00:00
|
|
|
(const DecompMotionTransform*)&kernel_data.cam.motion,
|
2015-02-21 07:33:21 +00:00
|
|
|
ray->time);
|
2012-04-30 12:49:26 +00:00
|
|
|
#endif
|
2015-05-09 13:57:51 +00:00
|
|
|
}
|
|
|
|
#endif
|
2012-04-30 12:49:26 +00:00
|
|
|
|
2012-04-16 08:35:21 +00:00
|
|
|
ray->P = transform_point(&cameratoworld, ray->P);
|
2012-02-28 16:44:54 +00:00
|
|
|
ray->D = transform_direction(&cameratoworld, ray->D);
|
|
|
|
ray->D = normalize(ray->D);
|
|
|
|
|
|
|
|
#ifdef __RAY_DIFFERENTIALS__
|
|
|
|
/* ray differential */
|
2013-05-03 21:34:51 +00:00
|
|
|
ray->dP = differential3_zero();
|
2012-02-28 16:44:54 +00:00
|
|
|
|
2012-04-16 08:35:21 +00:00
|
|
|
Pcamera = transform_perspective(&rastertocamera, make_float3(raster_x + 1.0f, raster_y, 0.0f));
|
2012-05-05 19:44:35 +00:00
|
|
|
ray->dD.dx = normalize(transform_direction(&cameratoworld, panorama_to_direction(kg, Pcamera.x, Pcamera.y))) - ray->D;
|
2012-02-28 16:44:54 +00:00
|
|
|
|
2012-04-16 08:35:21 +00:00
|
|
|
Pcamera = transform_perspective(&rastertocamera, make_float3(raster_x, raster_y + 1.0f, 0.0f));
|
2012-05-05 19:44:35 +00:00
|
|
|
ray->dD.dy = normalize(transform_direction(&cameratoworld, panorama_to_direction(kg, Pcamera.x, Pcamera.y))) - ray->D;
|
2012-02-28 16:44:54 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* Common */
|
|
|
|
|
2013-11-15 23:17:10 +00:00
|
|
|
ccl_device void camera_sample(KernelGlobals *kg, int x, int y, float filter_u, float filter_v,
|
Cycles: OpenCL kernel split
This commit contains all the work related on the AMD megakernel split work
which was mainly done by Varun Sundar, George Kyriazis and Lenny Wang, plus
some help from Sergey Sharybin, Martijn Berger, Thomas Dinges and likely
someone else which we're forgetting to mention.
Currently only AMD cards are enabled for the new split kernel, but it is
possible to force split opencl kernel to be used by setting the following
environment variable: CYCLES_OPENCL_SPLIT_KERNEL_TEST=1.
Not all the features are supported yet, and that being said no motion blur,
camera blur, SSS and volumetrics for now. Also transparent shadows are
disabled on AMD device because of some compiler bug.
This kernel is also only implements regular path tracing and supporting
branched one will take a bit. Branched path tracing is exposed to the
interface still, which is a bit misleading and will be hidden there soon.
More feature will be enabled once they're ported to the split kernel and
tested.
Neither regular CPU nor CUDA has any difference, they're generating the
same exact code, which means no regressions/improvements there.
Based on the research paper:
https://research.nvidia.com/sites/default/files/publications/laine2013hpg_paper.pdf
Here's the documentation:
https://docs.google.com/document/d/1LuXW-CV-sVJkQaEGZlMJ86jZ8FmoPfecaMdR-oiWbUY/edit
Design discussion of the patch:
https://developer.blender.org/T44197
Differential Revision: https://developer.blender.org/D1200
2015-05-09 14:34:30 +00:00
|
|
|
float lens_u, float lens_v, float time, ccl_addr_space Ray *ray)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
/* pixel filter */
|
2013-04-01 20:26:43 +00:00
|
|
|
int filter_table_offset = kernel_data.film.filter_table_offset;
|
2013-04-01 20:26:52 +00:00
|
|
|
float raster_x = x + lookup_table_read(kg, filter_u, filter_table_offset, FILTER_TABLE_SIZE);
|
|
|
|
float raster_y = y + lookup_table_read(kg, filter_v, filter_table_offset, FILTER_TABLE_SIZE);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2015-02-26 12:27:02 +00:00
|
|
|
#ifdef __CAMERA_MOTION__
|
|
|
|
/* motion blur */
|
|
|
|
if(kernel_data.cam.shuttertime == -1.0f)
|
|
|
|
ray->time = TIME_INVALID;
|
|
|
|
else
|
|
|
|
ray->time = time;
|
|
|
|
#endif
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* sample */
|
2012-02-28 16:44:54 +00:00
|
|
|
if(kernel_data.cam.type == CAMERA_PERSPECTIVE)
|
|
|
|
camera_sample_perspective(kg, raster_x, raster_y, lens_u, lens_v, ray);
|
|
|
|
else if(kernel_data.cam.type == CAMERA_ORTHOGRAPHIC)
|
2013-03-21 02:38:11 +00:00
|
|
|
camera_sample_orthographic(kg, raster_x, raster_y, lens_u, lens_v, ray);
|
2011-04-27 11:58:34 +00:00
|
|
|
else
|
2012-09-17 11:25:29 +00:00
|
|
|
camera_sample_panorama(kg, raster_x, raster_y, lens_u, lens_v, ray);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
2012-11-21 13:00:57 +00:00
|
|
|
/* Utilities */
|
|
|
|
|
2013-11-15 23:17:10 +00:00
|
|
|
ccl_device_inline float3 camera_position(KernelGlobals *kg)
|
2013-06-08 10:51:33 +00:00
|
|
|
{
|
|
|
|
Transform cameratoworld = kernel_data.cam.cameratoworld;
|
|
|
|
return make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w);
|
|
|
|
}
|
|
|
|
|
2013-11-15 23:17:10 +00:00
|
|
|
ccl_device_inline float camera_distance(KernelGlobals *kg, float3 P)
|
2012-11-21 13:00:57 +00:00
|
|
|
{
|
|
|
|
Transform cameratoworld = kernel_data.cam.cameratoworld;
|
|
|
|
float3 camP = make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w);
|
|
|
|
|
|
|
|
if(kernel_data.cam.type == CAMERA_ORTHOGRAPHIC) {
|
|
|
|
float3 camD = make_float3(cameratoworld.x.z, cameratoworld.y.z, cameratoworld.z.z);
|
|
|
|
return fabsf(dot((P - camP), camD));
|
|
|
|
}
|
|
|
|
else
|
2013-06-04 17:20:00 +00:00
|
|
|
return len(P - camP);
|
2012-11-21 13:00:57 +00:00
|
|
|
}
|
|
|
|
|
2014-05-27 13:56:59 +00:00
|
|
|
ccl_device_inline float3 camera_direction_from_point(KernelGlobals *kg, float3 P)
|
|
|
|
{
|
|
|
|
Transform cameratoworld = kernel_data.cam.cameratoworld;
|
|
|
|
|
|
|
|
if(kernel_data.cam.type == CAMERA_ORTHOGRAPHIC) {
|
|
|
|
float3 camD = make_float3(cameratoworld.x.z, cameratoworld.y.z, cameratoworld.z.z);
|
|
|
|
return -camD;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
float3 camP = make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w);
|
|
|
|
return normalize(camP - P);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-15 23:17:10 +00:00
|
|
|
ccl_device_inline float3 camera_world_to_ndc(KernelGlobals *kg, ShaderData *sd, float3 P)
|
2013-06-08 10:51:33 +00:00
|
|
|
{
|
|
|
|
if(kernel_data.cam.type != CAMERA_PANORAMA) {
|
|
|
|
/* perspective / ortho */
|
Cycles: OpenCL kernel split
This commit contains all the work related on the AMD megakernel split work
which was mainly done by Varun Sundar, George Kyriazis and Lenny Wang, plus
some help from Sergey Sharybin, Martijn Berger, Thomas Dinges and likely
someone else which we're forgetting to mention.
Currently only AMD cards are enabled for the new split kernel, but it is
possible to force split opencl kernel to be used by setting the following
environment variable: CYCLES_OPENCL_SPLIT_KERNEL_TEST=1.
Not all the features are supported yet, and that being said no motion blur,
camera blur, SSS and volumetrics for now. Also transparent shadows are
disabled on AMD device because of some compiler bug.
This kernel is also only implements regular path tracing and supporting
branched one will take a bit. Branched path tracing is exposed to the
interface still, which is a bit misleading and will be hidden there soon.
More feature will be enabled once they're ported to the split kernel and
tested.
Neither regular CPU nor CUDA has any difference, they're generating the
same exact code, which means no regressions/improvements there.
Based on the research paper:
https://research.nvidia.com/sites/default/files/publications/laine2013hpg_paper.pdf
Here's the documentation:
https://docs.google.com/document/d/1LuXW-CV-sVJkQaEGZlMJ86jZ8FmoPfecaMdR-oiWbUY/edit
Design discussion of the patch:
https://developer.blender.org/T44197
Differential Revision: https://developer.blender.org/D1200
2015-05-09 14:34:30 +00:00
|
|
|
if(ccl_fetch(sd, object) == PRIM_NONE && kernel_data.cam.type == CAMERA_PERSPECTIVE)
|
2013-06-08 10:51:33 +00:00
|
|
|
P += camera_position(kg);
|
|
|
|
|
|
|
|
Transform tfm = kernel_data.cam.worldtondc;
|
|
|
|
return transform_perspective(&tfm, P);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* panorama */
|
|
|
|
Transform tfm = kernel_data.cam.worldtocamera;
|
|
|
|
|
Cycles: OpenCL kernel split
This commit contains all the work related on the AMD megakernel split work
which was mainly done by Varun Sundar, George Kyriazis and Lenny Wang, plus
some help from Sergey Sharybin, Martijn Berger, Thomas Dinges and likely
someone else which we're forgetting to mention.
Currently only AMD cards are enabled for the new split kernel, but it is
possible to force split opencl kernel to be used by setting the following
environment variable: CYCLES_OPENCL_SPLIT_KERNEL_TEST=1.
Not all the features are supported yet, and that being said no motion blur,
camera blur, SSS and volumetrics for now. Also transparent shadows are
disabled on AMD device because of some compiler bug.
This kernel is also only implements regular path tracing and supporting
branched one will take a bit. Branched path tracing is exposed to the
interface still, which is a bit misleading and will be hidden there soon.
More feature will be enabled once they're ported to the split kernel and
tested.
Neither regular CPU nor CUDA has any difference, they're generating the
same exact code, which means no regressions/improvements there.
Based on the research paper:
https://research.nvidia.com/sites/default/files/publications/laine2013hpg_paper.pdf
Here's the documentation:
https://docs.google.com/document/d/1LuXW-CV-sVJkQaEGZlMJ86jZ8FmoPfecaMdR-oiWbUY/edit
Design discussion of the patch:
https://developer.blender.org/T44197
Differential Revision: https://developer.blender.org/D1200
2015-05-09 14:34:30 +00:00
|
|
|
if(ccl_fetch(sd, object) != OBJECT_NONE)
|
2013-06-08 10:51:33 +00:00
|
|
|
P = normalize(transform_point(&tfm, P));
|
|
|
|
else
|
|
|
|
P = normalize(transform_direction(&tfm, P));
|
|
|
|
|
|
|
|
float2 uv = direction_to_panorama(kg, P);
|
|
|
|
|
|
|
|
return make_float3(uv.x, uv.y, 0.0f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
CCL_NAMESPACE_END
|