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
This commit is contained in:
Dalai Felinto 2014-05-27 10:03:15 -03:00
parent 55e4454db8
commit 12abe94de8
Notes: blender-bot 2023-02-14 10:35:24 +01:00
Referenced by commit 3a3edc6c2d, Revert "fix T40375 Glossy shader bakes different than render"
Referenced by issue #40375, Glossy shader bakes different than render
1 changed files with 10 additions and 1 deletions

View File

@ -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;