forked from bartvdbraak/blender
Cycles: antialias normal baking if the mesh has a bump map.
This commit is contained in:
parent
ff34e48911
commit
d0af56fe3b
@ -172,17 +172,6 @@ ccl_device_inline void compute_light_pass(KernelGlobals *kg,
|
|||||||
path_radiance_accum_sample(L, &L_sample);
|
path_radiance_accum_sample(L, &L_sample);
|
||||||
}
|
}
|
||||||
|
|
||||||
ccl_device bool is_aa_pass(ShaderEvalType type)
|
|
||||||
{
|
|
||||||
switch(type) {
|
|
||||||
case SHADER_EVAL_UV:
|
|
||||||
case SHADER_EVAL_NORMAL:
|
|
||||||
return false;
|
|
||||||
default:
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* this helps with AA but it's not the real solution as it does not AA the geometry
|
/* this helps with AA but it's not the real solution as it does not AA the geometry
|
||||||
* but it's better than nothing, thus committed */
|
* but it's better than nothing, thus committed */
|
||||||
ccl_device_inline float bake_clamp_mirror_repeat(float u, float max)
|
ccl_device_inline float bake_clamp_mirror_repeat(float u, float max)
|
||||||
@ -485,10 +474,10 @@ ccl_device void kernel_bake_evaluate(KernelGlobals *kg, ccl_global uint4 *input,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* write output */
|
/* write output */
|
||||||
const float output_fac = is_aa_pass(type)? 1.0f/num_samples: 1.0f;
|
const float output_fac = 1.0f/num_samples;
|
||||||
const float4 scaled_result = make_float4(out.x, out.y, out.z, 1.0f) * output_fac;
|
const float4 scaled_result = make_float4(out.x, out.y, out.z, 1.0f) * output_fac;
|
||||||
|
|
||||||
output[i] = (sample == 0)? scaled_result: output[i] + scaled_result;
|
output[i] = (sample == 0)? scaled_result: output[i] + scaled_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __BAKING__ */
|
#endif /* __BAKING__ */
|
||||||
|
@ -15,8 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "render/bake.h"
|
#include "render/bake.h"
|
||||||
|
#include "render/mesh.h"
|
||||||
|
#include "render/object.h"
|
||||||
|
#include "render/shader.h"
|
||||||
#include "render/integrator.h"
|
#include "render/integrator.h"
|
||||||
|
|
||||||
|
#include "util/util_foreach.h"
|
||||||
|
|
||||||
CCL_NAMESPACE_BEGIN
|
CCL_NAMESPACE_BEGIN
|
||||||
|
|
||||||
BakeData::BakeData(const int object, const size_t tri_offset, const size_t num_pixels):
|
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();
|
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 */
|
/* calculate the total pixel samples for the progress bar */
|
||||||
total_pixel_samples = 0;
|
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) {
|
if(type == SHADER_EVAL_UV) {
|
||||||
case SHADER_EVAL_UV:
|
return 1;
|
||||||
case SHADER_EVAL_NORMAL:
|
}
|
||||||
return false;
|
else if(type == SHADER_EVAL_NORMAL) {
|
||||||
default:
|
/* Only antialias normal if mesh has bump mapping. */
|
||||||
return true;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ public:
|
|||||||
void device_free(Device *device, DeviceScene *dscene);
|
void device_free(Device *device, DeviceScene *dscene);
|
||||||
|
|
||||||
static int shader_type_to_pass_filter(ShaderEvalType type, const int pass_filter);
|
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;
|
bool need_update;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user