[Bf-blender-cvs] [12abe94] master: fix T40375 Glossy shader bakes different than render

Dalai Felinto noreply at git.blender.org
Tue May 27 15:43:45 CEST 2014


Commit: 12abe94de827d9ae9c0dd6cc49bc6c3e377842ad
Author: Dalai Felinto
Date:   Tue May 27 10:03:15 2014 -0300
https://developer.blender.org/rB12abe94de827d9ae9c0dd6cc49bc6c3e377842ad

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

===================================================================

M	intern/cycles/kernel/kernel_bake.h

===================================================================

diff --git a/intern/cycles/kernel/kernel_bake.h b/intern/cycles/kernel/kernel_bake.h
index c3ae2b6..4aae0aa 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;




More information about the Bf-blender-cvs mailing list