Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
anderslanglands committed May 31, 2018
2 parents 50e8377 + acc057b commit 25066a2
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ project(alShaders2)

set(ALS_MAJOR_VERSION 2)
set(ALS_MINOR_VERSION 0)
set(ALS_PATCH_VERSION 0b3)
set(ALS_PATCH_VERSION 0b4)
set(ALS_VERSION "${ALS_MAJOR_VERSION}.${ALS_MINOR_VERSION}.${ALS_PATCH_VERSION}")

set(CMAKE_VERBOSE_MAKEFILE FALSE)
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

For Cryptomatte documentation, see this repo's wiki.

### Beta 4 release notes:

Bug fixes:
* Fixed crash with multiple Cryptomatte shaders in scene.
* Added error detection for issue where Cryptomatte filters do not get set up correctly, (reported by one user by not reproducible).

### Beta 3 release notes:

Features
Expand Down
2 changes: 2 additions & 0 deletions cryptomatte/cryptomatte.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "MurmurHash3.h"
#include <ai.h>

AtCritSec g_critsec;

// User data names
const AtString CRYPTO_ASSET_UDATA("crypto_asset");
const AtString CRYPTO_OBJECT_UDATA("crypto_object");
Expand Down
9 changes: 7 additions & 2 deletions cryptomatte/cryptomatte.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ extern const AtString CRYPTO_ASSET_OFFSET_UDATA;
extern const AtString CRYPTO_OBJECT_OFFSET_UDATA;
extern const AtString CRYPTO_MATERIAL_OFFSET_UDATA;

extern AtCritSec g_critsec;

// Some static AtStrings to cache
const AtString aStr_shader("shader");
const AtString aStr_list_aggregate("list_aggregate");
Expand Down Expand Up @@ -857,6 +859,7 @@ struct CryptomatteData {
set_option_channels(CRYPTO_DEPTH_DEFAULT, CRYPTO_PREVIEWINEXR_DEFAULT);
set_option_namespace_stripping(CRYPTO_NAME_ALL, CRYPTO_NAME_ALL);
set_option_ice_pcloud_verbosity(CRYPTO_ICEPCLOUDVERB_DEFAULT);
AiCritSecInit(&g_critsec);
}

void setup_all(const AtString aov_cryptoasset_, const AtString aov_cryptoobject_,
Expand All @@ -869,7 +872,10 @@ struct CryptomatteData {
destroy_arrays();

user_cryptomattes = UserCryptomattes(uc_aov_array, uc_src_array);

AiCritSecEnter(&g_critsec);
setup_cryptomatte_nodes();
AiCritSecLeave(&g_critsec);
}

void set_option_channels(int depth, bool exr_preview_channels) {
Expand Down Expand Up @@ -1079,10 +1085,9 @@ struct CryptomatteData {
}
}

if (new_outputs.size())
if (new_outputs.size()) {
this->do_preview_channels = this->option_exr_preview_channels;

if (new_outputs.size()) {
if (option_sidecar_manifests) {
AtString manifest_driver_name("cryptomatte_manifest_driver");
AtNode* manifest_driver = AiNodeLookUpByName(manifest_driver_name);
Expand Down
20 changes: 8 additions & 12 deletions cryptomatte/cryptomatte_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
//
///////////////////////////////////////////////

AI_FILTER_NODE_EXPORT_METHODS(cryptomatte_filterMtd)
AI_FILTER_NODE_EXPORT_METHODS(cryptomatte_filter_mtd)

static const AtString ats_opacity("opacity");

enum cryptomatte_filterParams {
p_width,
p_rank,
p_filter,
p_mode,
};

struct CryptomatteFilterData {
Expand All @@ -30,25 +29,18 @@ struct CryptomatteFilterData {
int filter;
};

enum modeEnum {
p_mode_double_rgba,
};

static const char* modeEnumNames[] = {"double_rgba", nullptr};

node_parameters {
AiMetaDataSetStr(nentry, nullptr, "maya.attr_prefix", "filter_");
AiMetaDataSetStr(nentry, nullptr, "maya.translator", "cryptomatteFilter");
AiMetaDataSetInt(nentry, nullptr, "maya.id", 0x00116420);

AiParameterFlt("width", 2.0);
AiParameterInt("rank", 0);
AiParameterInt("rank", -1);
AiParameterEnum("filter", p_filter_gaussian, filterEnumNames);
AiParameterEnum("mode", p_mode_double_rgba, modeEnumNames);
}

void registerCryptomatteFilter(AtNodeLib* node) {
node->methods = cryptomatte_filterMtd;
node->methods = cryptomatte_filter_mtd;
node->output_type = AI_TYPE_RGBA;
node->name = "cryptomatte_filter";
node->node_type = AI_NODE_FILTER;
Expand All @@ -70,9 +62,13 @@ node_finish {
}

node_update {
const int rank = AiNodeGetInt(node, "rank");
if (rank < 0)
AiMsgError("Cryptomatte not set up correctly, %s rank not set.", AiNodeGetName(node));

CryptomatteFilterData* data = (CryptomatteFilterData*)AiNodeGetLocalData(node);
data->width = AiNodeGetFlt(node, "width");
data->rank = AiNodeGetInt(node, "rank");
data->rank = rank;
data->filter = AiNodeGetInt(node, "filter");

switch (data->filter) {
Expand Down
1 change: 1 addition & 0 deletions cryptomatte/cryptomatte_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ shader_evaluate {
CryptomatteData* data = reinterpret_cast<CryptomatteData*>(AiNodeGetLocalData(node));
data->do_cryptomattes(sg);
}
sg->out.RGBA() = AI_RGBA_ZERO;
}

void registerCryptomatte(AtNodeLib* node) {
Expand Down
5 changes: 5 additions & 0 deletions tests/cryptomatte/000_mtoa_basic.ass
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ cryptomatte
run_unit_tests true
}

cryptomatte
{
name ADDITIONAL_CRYPTOMATTE_TO_TEST_PARALLEL_ISSUES
}

gaussian_filter
{
name defaultArnoldFilter@gaussian_filter
Expand Down
8 changes: 8 additions & 0 deletions tests/cryptomatte/002_multicam.ass
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ cryptomatte
user_crypto_src_0 "special_chars_udata"
}

cryptomatte
{
name ADDITIONAL_CRYPTOMATTE_TO_TEST_PARALLEL_ISSUES
user_crypto_aov_0 "other_aov"
user_crypto_src_0 "other_aov_udata"
}


gaussian_filter
{
name defaultArnoldFilter@gaussian_filter
Expand Down
2 changes: 2 additions & 0 deletions tests/cryptomatte_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ class Cryptomatte000(CryptomatteTestBase):
"""
ass = "cryptomatte/000_mtoa_basic.ass"
arnold_v = 6
arnold_t = 0

def test_compression_and_manifests(self):
self.assertAllManifestsValidAndMatch()
Expand Down Expand Up @@ -369,6 +370,7 @@ class Cryptomatte002(CryptomatteTestBase):
Multicamera renders with embedded manifests
"""
ass = "cryptomatte/002_multicam.ass"
arnold_t = 0

def test_compression_and_manifests(self):
self.assertAllManifestsValidAndMatch()
Expand Down

0 comments on commit 25066a2

Please sign in to comment.