Blender V2.61 - r43446

svm_geometry.h

Go to the documentation of this file.
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 /* Geometry Node */
00022 
00023 __device void svm_node_geometry(ShaderData *sd, float *stack, uint type, uint out_offset)
00024 {
00025     float3 data;
00026 
00027     switch(type) {
00028         case NODE_GEOM_P: data = sd->P; break;
00029         case NODE_GEOM_N: data = sd->N; break;
00030 #ifdef __DPDU__
00031         case NODE_GEOM_T: data = normalize(sd->dPdu); break;
00032 #endif
00033         case NODE_GEOM_I: data = sd->I; break;
00034         case NODE_GEOM_Ng: data = sd->Ng; break;
00035 #ifdef __UV__
00036         case NODE_GEOM_uv: data = make_float3(sd->u, sd->v, 0.0f); break;
00037 #endif
00038     }
00039 
00040     stack_store_float3(stack, out_offset, data);
00041 }
00042 
00043 __device void svm_node_geometry_bump_dx(ShaderData *sd, float *stack, uint type, uint out_offset)
00044 {
00045 #ifdef __RAY_DIFFERENTIALS__
00046     float3 data;
00047 
00048     switch(type) {
00049         case NODE_GEOM_P: data = sd->P + sd->dP.dx; break;
00050         case NODE_GEOM_uv: data = make_float3(sd->u + sd->du.dx, sd->v + sd->dv.dx, 0.0f); break;
00051         default: svm_node_geometry(sd, stack, type, out_offset); return;
00052     }
00053 
00054     stack_store_float3(stack, out_offset, data);
00055 #else
00056     svm_node_geometry(sd, stack, type, out_offset);
00057 #endif
00058 }
00059 
00060 __device void svm_node_geometry_bump_dy(ShaderData *sd, float *stack, uint type, uint out_offset)
00061 {
00062 #ifdef __RAY_DIFFERENTIALS__
00063     float3 data;
00064 
00065     switch(type) {
00066         case NODE_GEOM_P: data = sd->P + sd->dP.dy; break;
00067         case NODE_GEOM_uv: data = make_float3(sd->u + sd->du.dy, sd->v + sd->dv.dy, 0.0f); break;
00068         default: svm_node_geometry(sd, stack, type, out_offset); return;
00069     }
00070 
00071     stack_store_float3(stack, out_offset, data);
00072 #else
00073     svm_node_geometry(sd, stack, type, out_offset);
00074 #endif
00075 }
00076 
00077 CCL_NAMESPACE_END
00078