diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2017-11-08 02:20:59 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2017-11-08 02:20:59 +0300 |
commit | 7b1d7074817dac9d0f088e8e7e5b336bae662c36 (patch) | |
tree | 4ebd67459d2fc160d3a6c76a2509cefc68f4e89c /intern/cycles/render | |
parent | 1b18e158025a488e1ba2446ad93c2eb563c11611 (diff) | |
parent | a0478ebe379c8384376586e2880ebc813a6afef7 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'intern/cycles/render')
-rw-r--r-- | intern/cycles/render/bake.cpp | 34 | ||||
-rw-r--r-- | intern/cycles/render/bake.h | 2 | ||||
-rw-r--r-- | intern/cycles/render/graph.h | 1 | ||||
-rw-r--r-- | intern/cycles/render/light.cpp | 4 | ||||
-rw-r--r-- | intern/cycles/render/nodes.cpp | 40 | ||||
-rw-r--r-- | intern/cycles/render/nodes.h | 12 | ||||
-rw-r--r-- | intern/cycles/render/shader.cpp | 3 |
7 files changed, 83 insertions, 13 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; diff --git a/intern/cycles/render/graph.h b/intern/cycles/render/graph.h index f0fd789c6bd..1d1701b30a2 100644 --- a/intern/cycles/render/graph.h +++ b/intern/cycles/render/graph.h @@ -157,6 +157,7 @@ public: virtual bool has_object_dependency() { return false; } virtual bool has_integrator_dependency() { return false; } virtual bool has_volume_support() { return false; } + virtual bool has_raytrace() { return false; } vector<ShaderInput*> inputs; vector<ShaderOutput*> outputs; diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp index d353709647d..b37a0768b53 100644 --- a/intern/cycles/render/light.cpp +++ b/intern/cycles/render/light.cpp @@ -414,7 +414,6 @@ void LightManager::device_update_distribution(Device *, DeviceScene *dscene, Sce /* precompute pdfs */ kintegrator->pdf_triangles = 0.0f; kintegrator->pdf_lights = 0.0f; - kintegrator->inv_pdf_lights = 0.0f; /* sample one, with 0.5 probability of light or triangle */ kintegrator->num_all_lights = num_lights; @@ -429,8 +428,6 @@ void LightManager::device_update_distribution(Device *, DeviceScene *dscene, Sce kintegrator->pdf_lights = 1.0f/num_lights; if(trianglearea > 0.0f) kintegrator->pdf_lights *= 0.5f; - - kintegrator->inv_pdf_lights = 1.0f/kintegrator->pdf_lights; } kintegrator->use_lamp_mis = use_lamp_mis; @@ -467,7 +464,6 @@ void LightManager::device_update_distribution(Device *, DeviceScene *dscene, Sce kintegrator->num_all_lights = 0; kintegrator->pdf_triangles = 0.0f; kintegrator->pdf_lights = 0.0f; - kintegrator->inv_pdf_lights = 0.0f; kintegrator->use_lamp_mis = false; kintegrator->num_portals = 0; kintegrator->portal_offset = 0; diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 2b682756c6a..4452fadaf02 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -5604,4 +5604,44 @@ void TangentNode::compile(OSLCompiler& compiler) compiler.add(this, "node_tangent"); } +/* Bevel */ + +NODE_DEFINE(BevelNode) +{ + NodeType* type = NodeType::add("bevel", create, NodeType::SHADER); + + SOCKET_INT(samples, "Samples", 4); + + SOCKET_IN_FLOAT(radius, "Radius", 0.05f); + SOCKET_IN_NORMAL(normal, "Normal", make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_NORMAL); + + SOCKET_OUT_NORMAL(bevel, "Normal"); + + return type; +} + +BevelNode::BevelNode() +: ShaderNode(node_type) +{ +} + +void BevelNode::compile(SVMCompiler& compiler) +{ + ShaderInput *radius_in = input("Radius"); + ShaderInput *normal_in = input("Normal"); + ShaderOutput *normal_out = output("Normal"); + + compiler.add_node(NODE_BEVEL, + compiler.encode_uchar4(samples, + compiler.stack_assign(radius_in), + compiler.stack_assign_if_linked(normal_in), + compiler.stack_assign(normal_out))); +} + +void BevelNode::compile(OSLCompiler& compiler) +{ + compiler.parameter(this, "samples"); + compiler.add(this, "node_bevel"); +} + CCL_NAMESPACE_END diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h index 3b8a8bcd4b5..64d7522a23a 100644 --- a/intern/cycles/render/nodes.h +++ b/intern/cycles/render/nodes.h @@ -1015,6 +1015,18 @@ public: float3 normal_osl; }; +class BevelNode : public ShaderNode { +public: + SHADER_NODE_CLASS(BevelNode) + bool has_spatial_varying() { return true; } + virtual int get_group() { return NODE_GROUP_LEVEL_3; } + virtual bool has_raytrace() { return true; } + + float radius; + float3 normal; + int samples; +}; + CCL_NAMESPACE_END #endif /* __NODES_H__ */ diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp index 70f6d5bab47..abb9e19a074 100644 --- a/intern/cycles/render/shader.cpp +++ b/intern/cycles/render/shader.cpp @@ -592,6 +592,9 @@ void ShaderManager::get_requested_graph_features(ShaderGraph *graph, if(node->has_surface_transparent()) { requested_features->use_transparent = true; } + if(node->has_raytrace()) { + requested_features->use_shader_raytrace = true; + } } } |