Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/bvh/bvh_special.h
- This file was added.
| /* | |||||
| * Copyright 2011-2016, Blender Foundation. | |||||
| * | |||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| * you may not use this file except in compliance with the License. | |||||
| * You may obtain a copy of the License at | |||||
| * | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| */ | |||||
| ccl_device_inline bool bvh_intersect_shadow_early_termination( | |||||
| KernelGlobals *kg, | |||||
| int isect_prim, | |||||
| uint num_hits, | |||||
| uint max_hits) { | |||||
| /* Detect if this surface has a shader with transparent shadows. */ | |||||
| /* TODO: optimize so primitive visibility flag indicates if | |||||
| * the primitive has a transparent shadow shader? | |||||
| */ | |||||
| int prim = kernel_tex_fetch(__prim_index, isect_prim); | |||||
| int shader = 0; | |||||
| #ifdef __HAIR__ | |||||
| if(kernel_tex_fetch(__prim_type, isect_prim) & PRIMITIVE_ALL_TRIANGLE) | |||||
| #endif | |||||
| { | |||||
| shader = kernel_tex_fetch(__tri_shader, prim); | |||||
| } | |||||
| #ifdef __HAIR__ | |||||
| else { | |||||
| float4 str = kernel_tex_fetch(__curves, prim); | |||||
| shader = __float_as_int(str.z); | |||||
| } | |||||
| #endif | |||||
| int flag = kernel_tex_fetch(__shader_flag, (shader & SHADER_MASK)*SHADER_SIZE); | |||||
| /* If no transparent shadows, all light is blocked. */ | |||||
| if(!(flag & SD_HAS_TRANSPARENT_SHADOW)) { | |||||
| return true; | |||||
| } | |||||
| /* if maximum number of hits reached, block all light */ | |||||
| else if(num_hits == max_hits) { | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| } | |||||
| ccl_device_inline bool bvh_intersect_volume_skip_primitive(KernelGlobals *kg, | |||||
| int prim_addr, | |||||
| int object) | |||||
| { | |||||
| /* Only primitives from volume object. */ | |||||
| uint tri_object = (object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, prim_addr): object; | |||||
| int object_flag = kernel_tex_fetch(__object_flag, tri_object); | |||||
| if((object_flag & SD_OBJECT_HAS_VOLUME) == 0) { | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| } | |||||