Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/svm/svm_closure.h
| Show First 20 Lines • Show All 738 Lines • ▼ Show 20 Lines | case CLOSURE_BSDF_HAIR_PRINCIPLED_ID: { | ||||
| decode_node_uchar4(data_node2.x, &coat_ofs, &melanin_ofs, &melanin_redness_ofs, &absorption_coefficient_ofs); | decode_node_uchar4(data_node2.x, &coat_ofs, &melanin_ofs, &melanin_redness_ofs, &absorption_coefficient_ofs); | ||||
| uint tint_ofs, random_ofs, random_color_ofs, random_roughness_ofs; | uint tint_ofs, random_ofs, random_color_ofs, random_roughness_ofs; | ||||
| decode_node_uchar4(data_node3.x, &tint_ofs, &random_ofs, &random_color_ofs, &random_roughness_ofs); | decode_node_uchar4(data_node3.x, &tint_ofs, &random_ofs, &random_color_ofs, &random_roughness_ofs); | ||||
| const AttributeDescriptor attr_descr_random = find_attribute(kg, sd, data_node4.y); | const AttributeDescriptor attr_descr_random = find_attribute(kg, sd, data_node4.y); | ||||
| float random = 0.0f; | float random = 0.0f; | ||||
| if(attr_descr_random.offset != ATTR_STD_NOT_FOUND) { | if(attr_descr_random.offset != ATTR_STD_NOT_FOUND) { | ||||
| random = primitive_attribute_float(kg, sd, attr_descr_random, NULL, NULL); | random = primitive_surface_attribute_float(kg, sd, attr_descr_random, NULL, NULL); | ||||
| } | } | ||||
| else { | else { | ||||
| random = stack_load_float_default(stack, random_ofs, data_node3.y); | random = stack_load_float_default(stack, random_ofs, data_node3.y); | ||||
| } | } | ||||
| PrincipledHairBSDF *bsdf = (PrincipledHairBSDF*)bsdf_alloc(sd, sizeof(PrincipledHairBSDF), weight); | PrincipledHairBSDF *bsdf = (PrincipledHairBSDF*)bsdf_alloc(sd, sizeof(PrincipledHairBSDF), weight); | ||||
| if(bsdf) { | if(bsdf) { | ||||
| ▲ Show 20 Lines • Show All 213 Lines • ▼ Show 20 Lines | #ifdef __VOLUME__ | ||||
| float primitive_density = 1.0f; | float primitive_density = 1.0f; | ||||
| float density = (stack_valid(density_offset))? stack_load_float(stack, density_offset): __uint_as_float(value_node.x); | float density = (stack_valid(density_offset))? stack_load_float(stack, density_offset): __uint_as_float(value_node.x); | ||||
| density = mix_weight * fmaxf(density, 0.0f); | density = mix_weight * fmaxf(density, 0.0f); | ||||
| if(density > CLOSURE_WEIGHT_CUTOFF) { | if(density > CLOSURE_WEIGHT_CUTOFF) { | ||||
| /* Density and color attribute lookup if available. */ | /* Density and color attribute lookup if available. */ | ||||
| const AttributeDescriptor attr_density = find_attribute(kg, sd, attr_node.x); | const AttributeDescriptor attr_density = find_attribute(kg, sd, attr_node.x); | ||||
| if(attr_density.offset != ATTR_STD_NOT_FOUND) { | if(attr_density.offset != ATTR_STD_NOT_FOUND) { | ||||
| primitive_density = primitive_attribute_float(kg, sd, attr_density, NULL, NULL); | primitive_density = primitive_volume_attribute_float(kg, sd, attr_density); | ||||
| density = fmaxf(density * primitive_density, 0.0f); | density = fmaxf(density * primitive_density, 0.0f); | ||||
| } | } | ||||
| } | } | ||||
| if(density > CLOSURE_WEIGHT_CUTOFF) { | if(density > CLOSURE_WEIGHT_CUTOFF) { | ||||
| /* Compute scattering color. */ | /* Compute scattering color. */ | ||||
| float3 color = sd->svm_closure_weight; | float3 color = sd->svm_closure_weight; | ||||
| const AttributeDescriptor attr_color = find_attribute(kg, sd, attr_node.y); | const AttributeDescriptor attr_color = find_attribute(kg, sd, attr_node.y); | ||||
| if(attr_color.offset != ATTR_STD_NOT_FOUND) { | if(attr_color.offset != ATTR_STD_NOT_FOUND) { | ||||
| color *= primitive_attribute_float3(kg, sd, attr_color, NULL, NULL); | color *= primitive_volume_attribute_float3(kg, sd, attr_color); | ||||
| } | } | ||||
| /* Add closure for volume scattering. */ | /* Add closure for volume scattering. */ | ||||
| HenyeyGreensteinVolume *volume = (HenyeyGreensteinVolume*)bsdf_alloc(sd, sizeof(HenyeyGreensteinVolume), color * density); | HenyeyGreensteinVolume *volume = (HenyeyGreensteinVolume*)bsdf_alloc(sd, sizeof(HenyeyGreensteinVolume), color * density); | ||||
| if(volume) { | if(volume) { | ||||
| float anisotropy = (stack_valid(anisotropy_offset))? stack_load_float(stack, anisotropy_offset): __uint_as_float(value_node.y); | float anisotropy = (stack_valid(anisotropy_offset))? stack_load_float(stack, anisotropy_offset): __uint_as_float(value_node.y); | ||||
| volume->g = anisotropy; | volume->g = anisotropy; | ||||
| sd->flag |= volume_henyey_greenstein_setup(volume); | sd->flag |= volume_henyey_greenstein_setup(volume); | ||||
| Show All 24 Lines | #ifdef __VOLUME__ | ||||
| } | } | ||||
| if(blackbody > CLOSURE_WEIGHT_CUTOFF) { | if(blackbody > CLOSURE_WEIGHT_CUTOFF) { | ||||
| float T = stack_load_float(stack, temperature_offset); | float T = stack_load_float(stack, temperature_offset); | ||||
| /* Add flame temperature from attribute if available. */ | /* Add flame temperature from attribute if available. */ | ||||
| const AttributeDescriptor attr_temperature = find_attribute(kg, sd, attr_node.z); | const AttributeDescriptor attr_temperature = find_attribute(kg, sd, attr_node.z); | ||||
| if(attr_temperature.offset != ATTR_STD_NOT_FOUND) { | if(attr_temperature.offset != ATTR_STD_NOT_FOUND) { | ||||
| float temperature = primitive_attribute_float(kg, sd, attr_temperature, NULL, NULL); | float temperature = primitive_volume_attribute_float(kg, sd, attr_temperature); | ||||
| T *= fmaxf(temperature, 0.0f); | T *= fmaxf(temperature, 0.0f); | ||||
| } | } | ||||
| T = fmaxf(T, 0.0f); | T = fmaxf(T, 0.0f); | ||||
| /* Stefan-Boltzmann law. */ | /* Stefan-Boltzmann law. */ | ||||
| float T4 = sqr(sqr(T)); | float T4 = sqr(sqr(T)); | ||||
| float sigma = 5.670373e-8f * 1e-6f / M_PI_F; | float sigma = 5.670373e-8f * 1e-6f / M_PI_F; | ||||
| ▲ Show 20 Lines • Show All 122 Lines • Show Last 20 Lines | |||||