diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2017-10-30 19:19:37 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2017-11-08 00:35:12 +0300 |
commit | d0af56fe3b6490445ba3e501b0fb98cfec622aa3 (patch) | |
tree | 09d8c1b4a25bc48561eb28df949bee486a6573ec /intern/cycles/render | |
parent | ff34e489117e0a9f64ca192438d05f28922af6cc (diff) |
Cycles: antialias normal baking if the mesh has a bump map.
Diffstat (limited to 'intern/cycles/render')
-rw-r--r-- | intern/cycles/render/bake.cpp | 34 | ||||
-rw-r--r-- | intern/cycles/render/bake.h | 2 |
2 files changed, 27 insertions, 9 deletions
diff --git a/intern/cycles/render/bake.cpp b/intern/cycles/render/bake.cpp index bae72e67410..aeb5d1c1316 100644 --- a/intern/cycles/render/bake.cpp +++ b/intern/cycles/render/bake.cpp @@ -15,8 +15,13 @@ */ #include "render/bake.h" +#include "render/mesh.h" +#include "render/object.h" +#include "render/shader.h" #include "render/integrator.h" +#include "util/util_foreach.h" + CCL_NAMESPACE_BEGIN BakeData::BakeData(const int object, const size_t tri_offset, const size_t num_pixels): @@ -135,7 +140,7 @@ bool BakeManager::bake(Device *device, DeviceScene *dscene, Scene *scene, Progre { size_t num_pixels = bake_data->size(); - int num_samples = is_aa_pass(shader_type)? scene->integrator->aa_samples : 1; + int num_samples = aa_samples(scene, bake_data, shader_type); /* calculate the total pixel samples for the progress bar */ total_pixel_samples = 0; @@ -239,14 +244,27 @@ void BakeManager::device_free(Device * /*device*/, DeviceScene * /*dscene*/) { } -bool BakeManager::is_aa_pass(ShaderEvalType type) +int BakeManager::aa_samples(Scene *scene, BakeData *bake_data, ShaderEvalType type) { - switch(type) { - case SHADER_EVAL_UV: - case SHADER_EVAL_NORMAL: - return false; - default: - return true; + if(type == SHADER_EVAL_UV) { + return 1; + } + else if(type == SHADER_EVAL_NORMAL) { + /* Only antialias normal if mesh has bump mapping. */ + Object *object = scene->objects[bake_data->object()]; + + if(object->mesh) { + foreach(Shader *shader, object->mesh->used_shaders) { + if(shader->has_bump) { + return scene->integrator->aa_samples; + } + } + } + + return 1; + } + else { + return scene->integrator->aa_samples; } } diff --git a/intern/cycles/render/bake.h b/intern/cycles/render/bake.h index ceb94cfb682..fbb8686b8f6 100644 --- a/intern/cycles/render/bake.h +++ b/intern/cycles/render/bake.h @@ -69,7 +69,7 @@ public: void device_free(Device *device, DeviceScene *dscene); static int shader_type_to_pass_filter(ShaderEvalType type, const int pass_filter); - static bool is_aa_pass(ShaderEvalType type); + static int aa_samples(Scene *scene, BakeData *bake_data, ShaderEvalType type); bool need_update; |