Cycles: try to avoid NaN pixels with oren nayar. Also small cmake code cleanup.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 18 Nov 2011 15:39:40 +0000 (15:39 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 18 Nov 2011 15:39:40 +0000 (15:39 +0000)
intern/cycles/CMakeLists.txt
intern/cycles/cmake/external_libs.cmake
intern/cycles/kernel/svm/bsdf_oren_nayar.h

index cfff7485e611de12762f211f91b84955e108af92..2a7a6f4ca653b2cfd9e0595e362038b8a0e64c12 100644 (file)
@@ -62,6 +62,7 @@ include_directories(
 
 if(WITH_CYCLES_BLENDER)
        add_subdirectory(blender)
+       add_definitions(-DBLENDER_PLUGIN)
 endif(WITH_CYCLES_BLENDER)
 
 add_subdirectory(app)
index 9037362f1ab9eef6738a03bdc1280fb38e4e21aa..7d12e2610684ad1522826f371862ca4623e84357 100644 (file)
@@ -70,21 +70,6 @@ if(WITH_CYCLES_PARTIO)
 
 endif()
 
-###########################################################################
-# Blender
-
-if(WITH_CYCLES_BLENDER)
-
-       set(BLENDER_INCLUDE_DIRS
-               ${CMAKE_SOURCE_DIR}/intern/guardedalloc
-               ${CMAKE_SOURCE_DIR}/source/blender/makesdna
-               ${CMAKE_SOURCE_DIR}/source/blender/makesrna
-               ${CMAKE_SOURCE_DIR}/source/blender/blenloader
-               ${CMAKE_BINARY_DIR}/source/blender/makesrna/intern)
-
-       add_definitions(-DBLENDER_PLUGIN)
-endif()
-
 ###########################################################################
 # CUDA
 
index 11dc07e485c77e7b7d555deda43621496e8cf2b8..0ad7cad06bbc0139d54cf22bc00977bfbb9ccc59 100644 (file)
@@ -70,8 +70,8 @@ __device float3 bsdf_oren_nayar_get_intensity(const ShaderClosure *sc, float3 n,
                cos_b = nl;
        }
 
-       float sin_a = sqrtf(1.0f - cos_a * cos_a);
-       float tan_b = sqrtf(1.0f - cos_b * cos_b) / (cos_b + FLT_MIN);
+       float sin_a = sqrtf(max(1.0f - cos_a * cos_a, 0.0f));
+       float tan_b = sqrtf(max(1.0f - cos_b * cos_b, 0.0f)) / max(cos_b, 1e-8f);
 
        float is = nl * (sc->data0 + sc->data1 * t * sin_a * tan_b);
        return make_float3(is, is, is);
@@ -84,8 +84,10 @@ __device void bsdf_oren_nayar_setup(ShaderData *sd, ShaderClosure *sc, float sig
 
        sigma = clamp(sigma, 0.0f, 1.0f);
 
-       sc->data0 =  1.0f / ((1.0f + 0.5f * sigma) * M_PI_F);
-       sc->data1 = sigma / ((1.0f + 0.5f * sigma) * M_PI_F);
+       float div = 1.0f / ((1.0f + 0.5f * sigma) * M_PI_F);
+
+       sc->data0 =  1.0f * div;
+       sc->data1 = sigma * div;
 }
 
 __device void bsdf_oren_nayar_blur(ShaderClosure *sc, float roughness)