Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/svm/svm_closure.h
| Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | else { | ||||
| if (refract) | if (refract) | ||||
| sd->flag |= bsdf_microfacet_ggx_refraction_setup(bsdf); | sd->flag |= bsdf_microfacet_ggx_refraction_setup(bsdf); | ||||
| else | else | ||||
| sd->flag |= bsdf_microfacet_ggx_setup(bsdf); | sd->flag |= bsdf_microfacet_ggx_setup(bsdf); | ||||
| } | } | ||||
| } | } | ||||
| ccl_device_inline int svm_node_closure_bsdf_skip(KernelGlobals kg, int offset, uint type) | |||||
| { | |||||
| if (type == CLOSURE_BSDF_PRINCIPLED_ID) { | |||||
| /* Read all principled BSDF extra data to get the right offset. */ | |||||
| read_node(kg, &offset); | |||||
| read_node(kg, &offset); | |||||
| read_node(kg, &offset); | |||||
| read_node(kg, &offset); | |||||
| } | |||||
| return offset; | |||||
| } | |||||
| template<uint node_feature_mask, ShaderType shader_type> | template<uint node_feature_mask, ShaderType shader_type> | ||||
| ccl_device_noinline int svm_node_closure_bsdf(ccl_global const KernelGlobals *kg, | ccl_device_noinline int svm_node_closure_bsdf(KernelGlobals kg, | ||||
| ccl_private ShaderData *sd, | ccl_private ShaderData *sd, | ||||
| ccl_private float *stack, | ccl_private float *stack, | ||||
| uint4 node, | uint4 node, | ||||
| int path_flag, | int path_flag, | ||||
| int offset) | int offset) | ||||
| { | { | ||||
| uint type, param1_offset, param2_offset; | uint type, param1_offset, param2_offset; | ||||
| uint mix_weight_offset; | uint mix_weight_offset; | ||||
| svm_unpack_node_uchar4(node.y, &type, ¶m1_offset, ¶m2_offset, &mix_weight_offset); | svm_unpack_node_uchar4(node.y, &type, ¶m1_offset, ¶m2_offset, &mix_weight_offset); | ||||
| float mix_weight = (stack_valid(mix_weight_offset) ? stack_load_float(stack, mix_weight_offset) : | float mix_weight = (stack_valid(mix_weight_offset) ? stack_load_float(stack, mix_weight_offset) : | ||||
| 1.0f); | 1.0f); | ||||
| /* note we read this extra node before weight check, so offset is added */ | /* note we read this extra node before weight check, so offset is added */ | ||||
| uint4 data_node = read_node(kg, &offset); | uint4 data_node = read_node(kg, &offset); | ||||
| /* Only compute BSDF for surfaces, transparent variable is shared with volume extinction. */ | /* Only compute BSDF for surfaces, transparent variable is shared with volume extinction. */ | ||||
| if ((!KERNEL_NODES_FEATURE(BSDF) || shader_type != SHADER_TYPE_SURFACE) || mix_weight == 0.0f) { | IF_KERNEL_NODES_FEATURE(BSDF) | ||||
| if (type == CLOSURE_BSDF_PRINCIPLED_ID) { | { | ||||
| /* Read all principled BSDF extra data to get the right offset. */ | if ((shader_type != SHADER_TYPE_SURFACE) || mix_weight == 0.0f) { | ||||
| read_node(kg, &offset); | return svm_node_closure_bsdf_skip(kg, offset, type); | ||||
| read_node(kg, &offset); | |||||
| read_node(kg, &offset); | |||||
| read_node(kg, &offset); | |||||
| } | } | ||||
| } | |||||
| return offset; | else | ||||
| { | |||||
| return svm_node_closure_bsdf_skip(kg, offset, type); | |||||
| } | } | ||||
| float3 N = stack_valid(data_node.x) ? stack_load_float3(stack, data_node.x) : sd->N; | float3 N = stack_valid(data_node.x) ? stack_load_float3(stack, data_node.x) : sd->N; | ||||
| if (!(sd->type & PRIMITIVE_ALL_CURVE)) { | if (!(sd->type & PRIMITIVE_ALL_CURVE)) { | ||||
| N = ensure_valid_reflection(sd->Ng, sd->I, N); | N = ensure_valid_reflection(sd->Ng, sd->I, N); | ||||
| } | } | ||||
| float param1 = (stack_valid(param1_offset)) ? stack_load_float(stack, param1_offset) : | float param1 = (stack_valid(param1_offset)) ? stack_load_float(stack, param1_offset) : | ||||
| ▲ Show 20 Lines • Show All 838 Lines • ▼ Show 20 Lines | #endif | ||||
| default: | default: | ||||
| break; | break; | ||||
| } | } | ||||
| return offset; | return offset; | ||||
| } | } | ||||
| template<ShaderType shader_type> | template<ShaderType shader_type> | ||||
| ccl_device_noinline void svm_node_closure_volume(ccl_global const KernelGlobals *kg, | ccl_device_noinline void svm_node_closure_volume(KernelGlobals kg, | ||||
| ccl_private ShaderData *sd, | ccl_private ShaderData *sd, | ||||
| ccl_private float *stack, | ccl_private float *stack, | ||||
| uint4 node) | uint4 node) | ||||
| { | { | ||||
| #ifdef __VOLUME__ | #ifdef __VOLUME__ | ||||
| /* Only sum extinction for volumes, variable is shared with surface transparency. */ | /* Only sum extinction for volumes, variable is shared with surface transparency. */ | ||||
| if (shader_type != SHADER_TYPE_VOLUME) { | if (shader_type != SHADER_TYPE_VOLUME) { | ||||
| return; | return; | ||||
| Show All 38 Lines | #ifdef __VOLUME__ | ||||
| } | } | ||||
| /* Sum total extinction weight. */ | /* Sum total extinction weight. */ | ||||
| volume_extinction_setup(sd, weight); | volume_extinction_setup(sd, weight); | ||||
| #endif | #endif | ||||
| } | } | ||||
| template<ShaderType shader_type> | template<ShaderType shader_type> | ||||
| ccl_device_noinline int svm_node_principled_volume(ccl_global const KernelGlobals *kg, | ccl_device_noinline int svm_node_principled_volume(KernelGlobals kg, | ||||
| ccl_private ShaderData *sd, | ccl_private ShaderData *sd, | ||||
| ccl_private float *stack, | ccl_private float *stack, | ||||
| uint4 node, | uint4 node, | ||||
| int path_flag, | int path_flag, | ||||
| int offset) | int offset) | ||||
| { | { | ||||
| #ifdef __VOLUME__ | #ifdef __VOLUME__ | ||||
| uint4 value_node = read_node(kg, &offset); | uint4 value_node = read_node(kg, &offset); | ||||
| ▲ Show 20 Lines • Show All 178 Lines • ▼ Show 20 Lines | |||||
| ccl_device void svm_node_closure_weight(ccl_private ShaderData *sd, | ccl_device void svm_node_closure_weight(ccl_private ShaderData *sd, | ||||
| ccl_private float *stack, | ccl_private float *stack, | ||||
| uint weight_offset) | uint weight_offset) | ||||
| { | { | ||||
| float3 weight = stack_load_float3(stack, weight_offset); | float3 weight = stack_load_float3(stack, weight_offset); | ||||
| svm_node_closure_store_weight(sd, weight); | svm_node_closure_store_weight(sd, weight); | ||||
| } | } | ||||
| ccl_device_noinline void svm_node_emission_weight(ccl_global const KernelGlobals *kg, | ccl_device_noinline void svm_node_emission_weight(KernelGlobals kg, | ||||
| ccl_private ShaderData *sd, | ccl_private ShaderData *sd, | ||||
| ccl_private float *stack, | ccl_private float *stack, | ||||
| uint4 node) | uint4 node) | ||||
| { | { | ||||
| uint color_offset = node.y; | uint color_offset = node.y; | ||||
| uint strength_offset = node.z; | uint strength_offset = node.z; | ||||
| float strength = stack_load_float(stack, strength_offset); | float strength = stack_load_float(stack, strength_offset); | ||||
| Show All 21 Lines | ccl_device_noinline void svm_node_mix_closure(ccl_private ShaderData *sd, | ||||
| if (stack_valid(weight1_offset)) | if (stack_valid(weight1_offset)) | ||||
| stack_store_float(stack, weight1_offset, in_weight * (1.0f - weight)); | stack_store_float(stack, weight1_offset, in_weight * (1.0f - weight)); | ||||
| if (stack_valid(weight2_offset)) | if (stack_valid(weight2_offset)) | ||||
| stack_store_float(stack, weight2_offset, in_weight * weight); | stack_store_float(stack, weight2_offset, in_weight * weight); | ||||
| } | } | ||||
| /* (Bump) normal */ | /* (Bump) normal */ | ||||
| ccl_device void svm_node_set_normal(ccl_global const KernelGlobals *kg, | ccl_device void svm_node_set_normal(KernelGlobals kg, | ||||
| ccl_private ShaderData *sd, | ccl_private ShaderData *sd, | ||||
| ccl_private float *stack, | ccl_private float *stack, | ||||
| uint in_direction, | uint in_direction, | ||||
| uint out_normal) | uint out_normal) | ||||
| { | { | ||||
| float3 normal = stack_load_float3(stack, in_direction); | float3 normal = stack_load_float3(stack, in_direction); | ||||
| sd->N = normal; | sd->N = normal; | ||||
| stack_store_float3(stack, out_normal, normal); | stack_store_float3(stack, out_normal, normal); | ||||
| } | } | ||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||