Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/closure/bsdf_oren_nayar.h
| /* | /* | ||||
| * Copyright 2011-2013 Blender Foundation | * Copyright 2011-2013 Blender Foundation | ||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| * You may obtain a copy of the License at | * You may obtain a copy of the License at | ||||
| * | * | ||||
| * http://www.apache.org/licenses/LICENSE-2.0 | * http://www.apache.org/licenses/LICENSE-2.0 | ||||
| * | * | ||||
| * Unless required by applicable law or agreed to in writing, software | * Unless required by applicable law or agreed to in writing, software | ||||
| * distributed under the License is distributed on an "AS IS" BASIS, | * distributed under the License is distributed on an "AS IS" BASIS, | ||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
| * See the License for the specific language governing permissions and | * See the License for the specific language governing permissions and | ||||
| * limitations under the License. | * limitations under the License. | ||||
| */ | */ | ||||
| #ifndef __BSDF_OREN_NAYAR_H__ | #pragma once | ||||
| #define __BSDF_OREN_NAYAR_H__ | |||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| typedef ccl_addr_space struct OrenNayarBsdf { | typedef ccl_addr_space struct OrenNayarBsdf { | ||||
| SHADER_CLOSURE_BASE; | SHADER_CLOSURE_BASE; | ||||
| float roughness; | float roughness; | ||||
| float a; | float a; | ||||
| Show All 29 Lines | ccl_device int bsdf_oren_nayar_setup(OrenNayarBsdf *bsdf) | ||||
| float div = 1.0f / (M_PI_F + ((3.0f * M_PI_F - 4.0f) / 6.0f) * sigma); | float div = 1.0f / (M_PI_F + ((3.0f * M_PI_F - 4.0f) / 6.0f) * sigma); | ||||
| bsdf->a = 1.0f * div; | bsdf->a = 1.0f * div; | ||||
| bsdf->b = sigma * div; | bsdf->b = sigma * div; | ||||
| return SD_BSDF | SD_BSDF_HAS_EVAL; | return SD_BSDF | SD_BSDF_HAS_EVAL; | ||||
| } | } | ||||
| ccl_device bool bsdf_oren_nayar_merge(const ShaderClosure *a, const ShaderClosure *b) | |||||
| { | |||||
| const OrenNayarBsdf *bsdf_a = (const OrenNayarBsdf *)a; | |||||
| const OrenNayarBsdf *bsdf_b = (const OrenNayarBsdf *)b; | |||||
| return (isequal_float3(bsdf_a->N, bsdf_b->N)) && (bsdf_a->roughness == bsdf_b->roughness); | |||||
| } | |||||
| ccl_device float3 bsdf_oren_nayar_eval_reflect(const ShaderClosure *sc, | ccl_device float3 bsdf_oren_nayar_eval_reflect(const ShaderClosure *sc, | ||||
| const float3 I, | const float3 I, | ||||
| const float3 omega_in, | const float3 omega_in, | ||||
| float *pdf) | float *pdf) | ||||
| { | { | ||||
| const OrenNayarBsdf *bsdf = (const OrenNayarBsdf *)sc; | const OrenNayarBsdf *bsdf = (const OrenNayarBsdf *)sc; | ||||
| if (dot(bsdf->N, omega_in) > 0.0f) { | if (dot(bsdf->N, omega_in) > 0.0f) { | ||||
| *pdf = 0.5f * M_1_PI_F; | *pdf = 0.5f * M_1_PI_F; | ||||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | else { | ||||
| *pdf = 0.0f; | *pdf = 0.0f; | ||||
| *eval = make_float3(0.0f, 0.0f, 0.0f); | *eval = make_float3(0.0f, 0.0f, 0.0f); | ||||
| } | } | ||||
| return LABEL_REFLECT | LABEL_DIFFUSE; | return LABEL_REFLECT | LABEL_DIFFUSE; | ||||
| } | } | ||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||
| #endif /* __BSDF_OREN_NAYAR_H__ */ | |||||