Blender V2.61 - r43446
|
00001 /* 00002 * Copyright 2011, Blender Foundation. 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 */ 00018 00019 CCL_NAMESPACE_BEGIN 00020 00021 __device void kernel_shader_evaluate(KernelGlobals *kg, uint4 *input, float3 *output, ShaderEvalType type, int i) 00022 { 00023 ShaderData sd; 00024 uint4 in = input[i]; 00025 float3 out; 00026 00027 if(type == SHADER_EVAL_DISPLACE) { 00028 /* setup shader data */ 00029 int object = in.x; 00030 int prim = in.y; 00031 float u = __int_as_float(in.z); 00032 float v = __int_as_float(in.w); 00033 00034 shader_setup_from_displace(kg, &sd, object, prim, u, v); 00035 00036 /* evaluate */ 00037 float3 P = sd.P; 00038 shader_eval_displacement(kg, &sd); 00039 out = sd.P - P; 00040 } 00041 else { // SHADER_EVAL_BACKGROUND 00042 /* setup ray */ 00043 Ray ray; 00044 00045 ray.P = make_float3(0.0f, 0.0f, 0.0f); 00046 ray.D = make_float3(__int_as_float(in.x), __int_as_float(in.y), __int_as_float(in.z)); 00047 ray.t = 0.0f; 00048 00049 #ifdef __RAY_DIFFERENTIALS__ 00050 ray.dD.dx = make_float3(0.0f, 0.0f, 0.0f); 00051 ray.dD.dy = make_float3(0.0f, 0.0f, 0.0f); 00052 ray.dP.dx = make_float3(0.0f, 0.0f, 0.0f); 00053 ray.dP.dy = make_float3(0.0f, 0.0f, 0.0f); 00054 #endif 00055 00056 /* setup shader data */ 00057 shader_setup_from_background(kg, &sd, &ray); 00058 00059 /* evaluate */ 00060 int flag = 0; /* we can't know which type of BSDF this is for */ 00061 out = shader_eval_background(kg, &sd, flag); 00062 } 00063 00064 /* write output */ 00065 output[i] = out; 00066 } 00067 00068 CCL_NAMESPACE_END 00069