diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-02-21 19:55:24 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-04-06 17:22:17 +0300 |
commit | b5f58c1ad9b19f3fe7ee06a4ab5ec5498dfc0652 (patch) | |
tree | 54db8c7e24bdfa585e849ede412be4ac86c5702b /intern/cycles/render/shader.cpp | |
parent | 36f352a4e45202a6a45aa608ee083f30a4db2c81 (diff) |
Cycles: Experiment with making previews more interactive
There were two major problems with the interactivity of material previews:
- Beckmann tables were re-generated on every material tweak.
This is because preview scene is not set to be persistent, so re-triggering
the render leads to the full scene re-sync.
- Images could take rather noticeable time to load with OIIO from the disk
on every tweak.
This patch addressed this two issues in the following way:
- Beckmann tables are now static on CPU memory.
They're couple of hundred kilobytes only, so wouldn't expect this to be
an issue. And they're needed for almost every render anyway.
This actually also makes blackbody table to be static, but it's even smaller
than beckmann table.
Not totally happy with this approach, but others seems to complicate things
quite a bit with all this render engine life time and so..
- For preview rendering all images are considered to be built-in. This means
instead of OIIO which re-loads images on every re-render they're coming
from ImBuf cache which is fully manageable from blender side and unused
images gets freed later.
This would make it impossible to have mipmapping with OSL for now, but we'll
be working on that later anyway and don't think mipmaps are really so crucial
for the material preview.
This seems to be a better alternative to making preview scene persistent,
because of much optimal memory control from blender side.
Reviewers: brecht, juicyfruit, campbellbarton, dingto
Subscribers: eyecandy, venomgfx
Differential Revision: https://developer.blender.org/D1132
Diffstat (limited to 'intern/cycles/render/shader.cpp')
-rw-r--r-- | intern/cycles/render/shader.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp index 3ae1e80c2af..fba908ee447 100644 --- a/intern/cycles/render/shader.cpp +++ b/intern/cycles/render/shader.cpp @@ -32,6 +32,9 @@ CCL_NAMESPACE_BEGIN +vector<float> ShaderManager::blackbody_table; +vector<float> ShaderManager::beckmann_table; + /* Beckmann sampling precomputed table, see bsdf_microfacet.h */ /* 2D slope distribution (alpha = 1.0) */ @@ -394,7 +397,10 @@ void ShaderManager::device_update_common(Device *device, if(has_converter_blackbody && blackbody_table_offset == TABLE_OFFSET_INVALID) { if(blackbody_table.size() == 0) { - blackbody_table = blackbody_table_build(); + thread_scoped_lock lock(lookup_table_mutex); + if(blackbody_table.size() == 0) { + blackbody_table = blackbody_table_build(); + } } blackbody_table_offset = scene->lookup_tables->add_table(dscene, blackbody_table); @@ -408,7 +414,10 @@ void ShaderManager::device_update_common(Device *device, /* beckmann lookup table */ if(beckmann_table_offset == TABLE_OFFSET_INVALID) { if(beckmann_table.size() == 0) { - beckmann_table_build(beckmann_table); + thread_scoped_lock lock(lookup_table_mutex); + if(beckmann_table.size() == 0) { + beckmann_table_build(beckmann_table); + } } beckmann_table_offset = scene->lookup_tables->add_table(dscene, beckmann_table); ktables->beckmann_offset = (int)beckmann_table_offset; |