diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2014-05-27 17:03:15 +0400 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2014-05-27 17:43:26 +0400 |
commit | 12abe94de827d9ae9c0dd6cc49bc6c3e377842ad (patch) | |
tree | 16d9b98cadde994dc9812e1d02090dc37289fc34 /intern/cycles/kernel/kernel_bake.h | |
parent | 55e4454db8edac58c3d64271d84263e5bb5e9c29 (diff) |
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
Diffstat (limited to 'intern/cycles/kernel/kernel_bake.h')
-rw-r--r-- | intern/cycles/kernel/kernel_bake.h | 11 |
1 files changed, 10 insertions, 1 deletions
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; |