From 12abe94de827d9ae9c0dd6cc49bc6c3e377842ad Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Tue, 27 May 2014 10:03:15 -0300 Subject: [PATCH] fix T40375 Glossy shader bakes different than render Comments from Brecht Van Lommel: """ Currently the viewing direction for each pixel is set to the normal, so at every pixel glossy is evaluated as if you're looking straight at it. Blender Internal works the same. """ This patch makes baking glossy as viewed from the camera. Reviewers: brecht CC: zanqdo Differential Revision: https://developer.blender.org/D555 --- intern/cycles/kernel/kernel_bake.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/intern/cycles/kernel/kernel_bake.h b/intern/cycles/kernel/kernel_bake.h index c3ae2b6a54e..4aae0aada0c 100644 --- a/intern/cycles/kernel/kernel_bake.h +++ b/intern/cycles/kernel/kernel_bake.h @@ -175,12 +175,21 @@ ccl_device void kernel_bake_evaluate(KernelGlobals *kg, ccl_global uint4 *input, float time = TIME_INVALID; int bounce = 0; int transparent_bounce = 0; + Transform cameratoworld = kernel_data.cam.cameratoworld; /* light passes */ PathRadiance L; shader_setup_from_sample(kg, &sd, P, Ng, I, shader, object, prim, u, v, t, time, bounce, transparent_bounce); - sd.I = sd.N; + + if(kernel_data.cam.type == CAMERA_ORTHOGRAPHIC) { + float3 camD = make_float3(cameratoworld.x.z, cameratoworld.y.z, cameratoworld.z.z); + sd.I = -camD; + } + else { + float3 camP = make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w); + sd.I = normalize(camP - sd.P); + } /* update differentials */ sd.dP.dx = sd.dPdu * dudx + sd.dPdv * dvdx;