Cycles: try to avoid NaN pixels with oren nayar. Also small cmake code cleanup.

This commit is contained in:
Brecht Van Lommel
2011-11-18 15:39:40 +00:00
parent b4097ad11d
commit 02ce6fd59c
3 changed files with 7 additions and 19 deletions

View 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)

View 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

View 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)