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 <brechtvanlommel@pandora.be>2013-06-08 14:51:33 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-06-08 14:51:33 +0400
commitc53b20b683cbc6c198f2ec1e78e1b8a16e83d2b3 (patch)
tree2e3ba6f31128fe5f33917a81e7e7cce08dcc9fe3 /intern/cycles/kernel/kernel_camera.h
parentc423e3ed8f2b92eddd37709648e185bce67f32c7 (diff)
Cycles: window texture coordinates now work with orthographic cameras, this
was an old issue since the first version.
Diffstat (limited to 'intern/cycles/kernel/kernel_camera.h')
-rw-r--r--intern/cycles/kernel/kernel_camera.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/intern/cycles/kernel/kernel_camera.h b/intern/cycles/kernel/kernel_camera.h
index a23586a53a4..4b9ef8893f7 100644
--- a/intern/cycles/kernel/kernel_camera.h
+++ b/intern/cycles/kernel/kernel_camera.h
@@ -245,6 +245,12 @@ __device void camera_sample(KernelGlobals *kg, int x, int y, float filter_u, flo
/* Utilities */
+__device_inline float3 camera_position(KernelGlobals *kg)
+{
+ Transform cameratoworld = kernel_data.cam.cameratoworld;
+ return make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w);
+}
+
__device_inline float camera_distance(KernelGlobals *kg, float3 P)
{
Transform cameratoworld = kernel_data.cam.cameratoworld;
@@ -258,5 +264,30 @@ __device_inline float camera_distance(KernelGlobals *kg, float3 P)
return len(P - camP);
}
+__device_inline float3 camera_world_to_ndc(KernelGlobals *kg, ShaderData *sd, float3 P)
+{
+ if(kernel_data.cam.type != CAMERA_PANORAMA) {
+ /* perspective / ortho */
+ if(sd->object == ~0 && kernel_data.cam.type == CAMERA_PERSPECTIVE)
+ P += camera_position(kg);
+
+ Transform tfm = kernel_data.cam.worldtondc;
+ return transform_perspective(&tfm, P);
+ }
+ else {
+ /* panorama */
+ Transform tfm = kernel_data.cam.worldtocamera;
+
+ if(sd->object != ~0)
+ 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);
+ }
+}
+
CCL_NAMESPACE_END