View Categories

VFB Katmanları API’si

4 dakika okuma

giriiş #


VFB, App SDK aracılığıyla birçok şekilde programatik olarak kontrol edilebilir. Bunlardan biri çeşitli ortam değişkenlerini kullanmaktır . Diğeri ise VFB katmanı JSON dizesini almak ve ayarlamaktır; bu da ayrıştırmayı içerir (Python ve JavaScript gibi dillerde daha kolaydır, ancak özel kütüphaneler olmadan C++ ve C#’da zordur). VFB katmanlarının daha kolay manipülasyonu için bir API sunuyoruz.

Her App SDK bağlamasında iki soyutlama oluşturulur: VFB Katman Yöneticisi soyutlaması ve gerçek bir VFB Katmanına erişim sağlayan VFB Katmanı soyutlaması (bir erişim sağladığı için, mevcut örneğin geçersiz hale gelebileceği ve yeni bir erişim almanız gerekebileceği durumlar olabilir).

VFB Katman Yöneticisi #


Katman Yöneticisi’ni kullanarak aşağıdaki işlemleri gerçekleştirebilirsiniz:

  • Katman Yöneticisi katmanlarını varsayılan ayarlarına sıfırlayın (bu işlemi gerçekleştirmeden önce yerine getirilmesi gereken belirli koşullar vardır ve bunlar dokümantasyonda açıklanmıştır);

  • VFB katmanlarını dosya olarak yükleyin ve kaydedin;

  • VFB katmanlarını JSON dizesi olarak al ve ayarla;

  • OCIO veya ICC yapılandırma dosyalarını yükleyin ve bunlarla ilgili olarak kullanıcı arayüzünde gösterilen bazı özellikleri alın/ayarlayın;

  • Kullanıcı tarafından oluşturulabilen katman sınıflarını alın;

  • Tüm katmanları bir LUT (.cube) dosyasına dönüştürün;

  • Katmanlar oluşturabilir veya silebilirsiniz. Belirtilen üst katmanla hangi katmanları oluşturabileceğiniz ve hangi katmanları silebileceğiniz konusunda bazı özellikler vardır (tüm katmanlar silinemez);

  • İstediğiniz zaman ortak katmanlara erişebilirsiniz: Kök katman, Görüntü Düzeltme katmanı, Damga katmanı, Kaynak katman, Gürültü Azaltıcı katman, Keskinleştirme/Bulanıklaştırma katmanı, Lens Efektleri katmanı ve Işık Karıştırma katmanı.

Bazı yardımcı işlevler, kullanıcı tarafından belirtilen bir özelliğe sahip katmanları bir araya getirebilir: örneğin, etkin olan tüm katmanları veya belirli bir sınıfa sahip tüm katmanları almak gibi. İş parçacığı güvenli işlemler ve toplu işlemler gerçekleştirmek istiyorsanız , Katman Yöneticisini kilitlemenin ve ardından kilidini açmanın yolları vardır.

VFB Katmanı #


VFB Katmanı tanıtıcısı edinmeyi seçerseniz, gerçekleştirebileceğiniz birçok yaygın işlem vardır:

  • Geçerli bir tanıtıcı olup olmadığını kontrol edin;

  • Kök katmandan geçerli katmana giden benzersiz yolu, üst katmanın alt katmanlarının indekslerini (üst katmanın alt katmanlarının listesindeki indeksler) kullanarak elde edin. Örneğin, ‘/0/1’ kök katmanı elde etmeye karşılık gelir, ardından kök katmanın alt katmanlarının listesindeki sıfır indeksli alt katmanı elde edin. Daha sonra, kök katmanın sıfırıncı alt katmanının listesindeki 1 indeksli alt katmanı elde edin;

  • Katmanın sınıfı, silinebilir olup olmadığı veya karıştırılabilir olup olmadığı gibi daha temel, salt okunur diğer özelliklere de erişebilirsiniz;

  • Katmanın adı, etkin olup olmadığı, opaklığı ve karıştırılabilir ise karıştırma modu gibi özellikleri alıp ayarlayabilirsiniz;

  • Bir katmanın üst öğesini, alt öğelerini veya belirli bir alt öğesini alın;

  • Değiştirilebilen katman özelliklerini alın (bazıları değiştirilemez, bazıları ise belirli koşullar mevcut olduğunda değiştirilemez);

  • Salt okunur olan katman özelliklerini alabilir veya belirli bir türdeki (tamsayı, ondalık sayı, numaralandırılabilir sayı, renk vb.) katman özelliklerini alabilirsiniz.

Kullanabileceğiniz bazı özel katman özelliği yöntemleri şunlardır:

  • Katmanın görünen adını alın;

  • Katman özelliğini varsayılan değerine sıfırla;

  • Salt okunur olup olmadığını kontrol edin;

  • türünü belirle;

  • bayraklarını al;

  • Bir özelliğin değerini türüne bağlı olarak al/ayarla.

Detaylar #


Şimdi daha önce bahsettiğimiz bazı özelliklerden bahsetmekte fayda var:

Birincisi, şu anda render işlemi yapmıyorken yüklenmiş bir vrscene’den VFB katman ayarlarıyla çalışmak istiyorsanız, bu ayarların “yüklenmesini” ve “boşaltılmasını” ( fillSettingsVFB ,  applySettingsVFB  ve Katman Yöneticisi yöntemi  reset kullanarak ) kendiniz yönetmeniz gerekir.

# Load scene from a file.
renderer.load(os.path.join(SCENE_PATH, 'intro.vrscene'))
# Fill the VFB layers settings from the SettingsVFB plugin to the VFB Layer Manager
renderer.vfb.applySettingsVFB()
# Now the VFB Layer Manager configuration is overwritten with the setting coming from SettingsVFB plugin

// Load scene from a file.
renderer.load("intro.vrscene");
// Fill the VFB layers settings from the SettingsVFB plugin to the VFB Layer Manager
renderer.vfb.applySettingsVFB();
// Now the VFB Layer Manager configuration is overwritten with the setting coming from SettingsVFB plugin

// Load scene from a file.
renderer.Load("intro.vrscene");
// Fill the VFB layers settings from the SettingsVFB plugin to the VFB Layer Manager
renderer.Vfb.ApplySettingsVFB();
// Now the VFB Layer Manager configuration is overwritten with the setting coming from SettingsVFB plugin

// Load scene from a file asynchronously.
renderer.load('intro.vrscene', function(err) {
if (err) {
// Scene was not loaded.
throw err;
}
// Fill the VFB layers settings from the SettingsVFB plugin to the VFB Layer Manager
renderer.vfb.applySettingsVFB();
// Now the VFB Layer Manager configuration is overwritten with the setting coming from SettingsVFB plugin
});

Render işlemine başlarken, varsayılan olarak SettingsVFB  eklentisinin  vfb2_layers  ve  cc_settings parametreleri    Katman Yöneticisi’nin içeriğini geçersiz kılmak için kullanılır. Bu istenmeyen bir etki ise,  sahnedeki SettingsVFB eklentisinin dont_affect_settings  parametresini   true olarak ayarlayabilirsiniz (varsayılan değer false’tur). Bu durumda Katman Yöneticisi’nin içeriği değişmeden kalacaktır. Bu parametreyi kullanmak istemiyorsanız,   katmanlardaki değişiklikleri  SettingsVFB eklentisine yazmak için fillSettingsVFB  ve  applySettingsVFB yöntemlerinin bir kombinasyonunu kullanabilirsiniz  ; bu değişiklikler daha sonra render işlemi başladığında okunacaktır.

SettingsVFB eklentisinde vfb2_layers  ve  cc_settings parametreleri ayarlanmamışsa  , varsayılan olarak Katman Yöneticisinin mevcut yapılandırması kullanılır.

`dont_affect_settings` parametresini kullanan örnek kod parçası .

Bu yöntem, VFB Katmanları ayarlarıyla ilgili vrscene parametrelerinin üzerine yazmaz .

 Get the SettingsVFB plugin instance if such a plugin exists in the vrscene
settingsVFBPlugins = renderer.classes.SettingsVFB.getInstances()
if len(settingsVFBPlugins) > 0:
    # Set the dont_affect_settings to true if you don't want the settings coming from
# the vrscene file to override the VFB Layer Manager current layers configuration
    settingsVFBPlugins[0]['dont_affect_settings'] = True
# Start rendering.
renderer.startSync()
# Wait for rendering to end.
renderer.waitForRenderEnd()
// Get the SettingsVFB plugin instance if such a plugin exists in the vrscene
Plugin settingsVFB = renderer.getInstanceOf("SettingsVFB");
if (settingsVFB.isValid()) {
// Set the dont_affect_settings to true if you don't want the settings coming from
// the vrscene file to override the VFB Layer Manager current layers configuration
settingsVFB.setValue("dont_affect_settings", true);
}
// Start rendering.
renderer.startSync();
// Wait for rendering to end.
renderer.waitForRenderEnd();
// Get the SettingsVFB plugin instance if such a plugin exists in the vrscene
SettingsVFB settingsVFB = (SettingsVFB)renderer.GetInstanceOf("SettingsVFB");
if (settingsVFB != null)
{
// Set the dont_affect_settings to true if you don't want the settings coming from
// the vrscene file to override the VFB Layer Manager current layers configuration
settingsVFB.DontAffectSettings = true;
}
// Start rendering.
renderer.StartSync();
// Wait for rendering to end.
renderer.WaitForRenderEnd();
// Get the SettingsVFB plugin instance if such a plugin exists in the vrscene
settingsVFBPlugins = renderer.classes.SettingsVFB.getInstances();
if (settingsVFBPlugins.length > 0) {
    // Set the dont_affect_settings to true if you don't want the settings coming from
// the vrscene file to override the VFB Layer Manager current layers configuration
    settingsVFBPlugins[0].dont_affect_settings = true;
}
// Start rendering.
renderer.start(function(err) {
    if (err) {
        // Couldn't start rendering.
        throw err;
    }
 
    // Wait for rendering to end.
    renderer.waitForRenderEnd(function() {
 
        // Closes the renderer.
        // The renderer object is unusable after closing since its resources
        // are freed. It should be released for garbage collection.
        renderer.close();
    });
});

Ve dont_affect_settings parametresini kullanmaktan kaçındığımız bir örnek .

Bu yöntem, VFB Katmanları ayarlarıyla ilgili vrscene parametrelerini geçersiz kılar .

# Fill the VFB layers settings from the VFB Layer Manager to the SettingsVFB plugin
renderer.vfb.fillSettingsVFB()
# Start rendering.
renderer.startSync()
# Wait for rendering to end.
renderer.waitForRenderEnd()

// Fill the VFB layers settings from the VFB Layer Manager to the SettingsVFB plugin
renderer.vfb.fillSettingsVFB();
// Start rendering.
renderer.startSync();
// Wait for rendering to end.
renderer.waitForRenderEnd();

// Fill the VFB layers settings from the VFB Layer Manager to the SettingsVFB plugin
renderer.Vfb.FillSettingsVFB();
// Start rendering.
renderer.StartSync();
// Wait for rendering to end.
renderer.WaitForRenderEnd();

// Fill the VFB layers settings from the SettingsVFB plugin to the VFB Layer Manager
renderer.vfb.fillSettingsVFB();
// Now you can access and modify the VFB layers settings coming with this vrscene
// Start rendering.
renderer.start(function(err) {
    if (err) {
        // Couldn't start rendering.
        throw err;
    }
 
    // Wait for rendering to end.
    renderer.waitForRenderEnd(function() {
 
        // Closes the renderer.
        // The renderer object is unusable after closing since its resources
        // are freed. It should be released for garbage collection.
        renderer.close();
    });
});

Daha önce de belirttiğimiz gibi, bir VFB katman örneği gerçek katmana bir referanstır, bu nedenle geçersiz kılınabilir. Bunun gerçekleşebileceği bazı olaylar şunlardır: başarılı bir şekilde silindikten sonra, bir yükleme veya ayarlama işleminden sonra, yeni bir render işlemi başladıktan sonra (  SettingsVFB  eklentisinin  dont_affect_settings parametresi ile Katman Yöneticisi içeriğinin, SettingsVFB  eklentisinden gelenlerle  (varsa) üzerine yazılmaması gerektiği belirtilmemişse), vb.

Tüm katman özelliklerinin her zaman değiştirilebilir olmadığını unutmayın . Örneğin, Görüntü Düzeltmeleri katmanının OCIO ile ilgili özellikleri, VFB yüklendikten ve doğru profil seçildikten sonra kullanılabilir hale gelir.

Örnek #


Bu örnekte, bu API ile bazı işlemleri nasıl yapacağımızı göstereceğiz. Tam örnek, examples/{language}/advanced klasöründe vfb-layers-api uzantısıyla bir dosya olarak mevcuttur .

# Load scene from a file.
renderer.load(os.path.join(SCENE_PATH, "intro.vrscene"))
 
# Fill the VFB layers settings from the SettingsVFB plugin to the VFB Layer Manager
renderer.vfb.applySettingsVFB()
 
lm = renderer.vfb.layerManager
 
# Lock the layers so it will be a thread-safe batch operation.
lm.lockLayers()
 
# Get a handle to the Display Correction (DC) layer.
dcLayer = lm.getDisplayCorrectionLayer()
 
# Create a cc exposure layer as a child of the DC layer.
# All of the creatable class name you can get as a list by calling the getCreatableLayerClasses method.
dcExpLayer = lm.createLayer("chaos.cc.exposure", dcLayer)
 
# Check validity of the handle. On an error, empty handles are returned.
if dcExpLayer.isValid():
# Set some properties of the exposure layer.
# All the methods may throw exceptions if an error occurs.
dcExpLayer.setBlendMode("BlendMode_Exclusion")
# All of the properties of a layer you can get as a list by calling getLayerPropertyNames.
dcExpLayer.hilight_burn = 0.5
 
# Create a MultiMatte mask layer whose parent is the exposure layer.
dcExpMMMaskLayer = lm.createLayer("chaos.ref.re.colormask", dcExpLayer)
if dcExpMMMaskLayer.isValid():
# If you are not sure whether a property exists, you can search it by getting a list of all
# modifiable layer fields.
propsNames = dcExpMMMaskLayer.getLayerPropertiesOfType("Bool")
for propName in propsNames:
if propName == "use_intensity":
dcExpMMMaskLayer.use_intensity = True
 
# Never forget to unlock the layers. Otherwise, the whole VFB freezes.
lm.unlockLayers()
 
# Fill the VFB layers settings from the VFB Layer Manager to the SettingsVFB plugin.
renderer.vfb.fillSettingsVFB()
 
# Start rendering.
renderer.startSync()
 
# Wait some time.
time.sleep(3)
 
# Lock the layers, so the user cannot access them from the UI.
lm.lockLayers()
 
# Get a new handle to the DC layer. The old one is invalid after the beginning of the rendering.
dcLayer = lm.getDisplayCorrectionLayer()
 
# Change the current DC profile to Gamma 2.2.
typeProfile = dcLayer.getLayerPropertyType("profile")
if  typeProfile == "IntEnum":
# You can know all the properties of an enumerable by calling getLayerPropertyIntEnumValues.
dcLayer.profile = "Gamma 2.2"
 
# Delete all mask layers.
masks = lm.findAllLayersWithLayerClass("chaos.ref.re.colormask")
for mask in masks:
if mask.canDelete():
lm.deleteLayer(mask)
 
# Set some Stamp layer parameters.
stampLayer = lm.getStampLayer()
stampLayer.stamp_font = {
"fontFamily": "stampFontFamily_modern",
"fontStyle": "stampFontStyle_italic",
}
stampLayer.stamp_string = "Incredible CCs"
stampLayer.stamp_color = vray.Color(1.0, 0.6, 0.6)
stampLayer.setEnabled(True)
 
# Never forget to unlock the layers. Otherwise the whole VFB freezes.
lm.unlockLayers()
 
# Wait for rendering to end.
renderer.waitForRenderEnd()
 
# If you want the changes you made while rendering to the layers to be saved to the vrscene.
renderer.vfb.fillSettingsVFB()
renderer.export("intro2.vrscene")
// Load scene from a file.
renderer.load("intro.vrscene");
 
// Fill the VFB layers settings from the SettingsVFB plugin to the VFB Layer Manager.
renderer.vfb.applySettingsVFB();
 
VRayRenderer::VFB::LayerManager& lm = renderer.vfb.layerManager;
 
// Lock the layers so it will be a thread-safe batch operation.
lm.lockLayers();
 
// Get a handle to the Display Correction (DC) layer.
VRayRenderer::VFB::Layer dcLayer = lm.getDisplayCorrectionLayer();
 
// Create a cc exposure layer as a child of the DC layer.
// All of the creatable class name you can get as a list by calling the getCreatableLayerClasses method.
VRayRenderer::VFB::Layer dcExpLayer = lm.createLayer("chaos.cc.exposure", dcLayer);
// Check validity of the handle. On an error, empty handles are returned.
if (dcExpLayer.isValid()) {
// Set some properties of the exposure layer.
// You can check if the operation has been successful by getting the return value.
dcExpLayer.setBlendMode(VFBLayerProperty::BlendMode::BlendMode_Exclusion);
// All of the properties of a layer you can get as a list by calling getLayerPropertyNames.
dcExpLayer.setLayerPropertyFloatValue("hilight_burn", 0.5f);
 
// Create a MultiMatte mask layer whose parent is the exposure layer.
VRayRenderer::VFB::Layer dcExpMMMaskLayer = lm.createLayer("chaos.ref.re.colormask", dcExpLayer);
if (dcExpMMMaskLayer.isValid()) {
// If you are not sure whether a property exists, you can search it by getting a list of all
// modifiable layer fields.
StringList propsNames;
if (dcExpMMMaskLayer.getLayerPropertiesOfType(VFBLayerProperty::Type::Bool, propsNames) == 0) {
for (size_t i = 0; i < propsNames.size(); i++) {
if (propsNames[i] == "use_intensity") {
dcExpMMMaskLayer.setLayerPropertyBoolValue("use_intensity", true);
}
}
}
}
}
// Never forget to unlock the layers. Otherwise, the whole VFB freezes.
lm.unlockLayers();
 
// Fill the VFB layers settings from the VFB Layer Manager to the SettingsVFB plugin.
renderer.vfb.fillSettingsVFB();
// Start rendering.
renderer.startSync();
 
// Wait some time.
Sleep(3000);
// Lock the layers, so the user cannot access them from the UI.
lm.lockLayers();
 
// Get a new handle to the DC layer. The old one is invalid after the beginning of the rendering.
dcLayer = lm.getDisplayCorrectionLayer();
 
// Change the current DC profile to Gamma 2.2.
VFBLayerProperty::Type type;
dcLayer.getLayerPropertyType("profile", type);
if (type == VFBLayerProperty::Type::IntEnum) {
// # You can know all the properties of an enumerable by calling getLayerPropertyIntEnumValues.
dcLayer.setLayerPropertyIntByEnumLabel("profile", "Gamma 2.2");
}
 
// Delete all mask layers.
vector<VRayRenderer::VFB::Layer> masks = lm.findAllLayersWithLayerClass("chaos.ref.re.colormask");
for (size_t i = 0; i < masks.size(); i++) {
bool isDeletable;
masks[i].canDelete(isDeletable);
if (isDeletable) {
lm.deleteLayer(masks[i]);
}
}
 
// Set some Stamp layer parameters.
VRayRenderer::VFB::Layer stampLayer = lm.getStampLayer();
VFBLayerProperty::StampFontDesc desc;
stampLayer.getLayerPropertyStampFontDescValue("stamp_font", desc);
desc.fontFamily = VFBLayerProperty::StampFontFamily::stampFontFamily_modern;
desc.fontStyle = VFBLayerProperty::StampFontStyle::stampFontStyle_italic;
stampLayer.setLayerPropertyStampFontDescValue("stamp_font", desc);
stampLayer.setLayerPropertyStampRawStringValue("stamp_string", "Incredible CCs");
stampLayer.setLayerPropertyColorValue("stamp_color", Color(1.0, 0.6, 0.6));
stampLayer.setEnabled(true);
 
// Never forget to unlock the layers. Otherwise the whole VFB freezes.
lm.unlockLayers();
 
// Wait for rendering to end.
renderer.waitForRenderEnd();
 
// If you want the changes you made while rendering to the layers to be saved to the vrscene.
renderer.vfb.fillSettingsVFB();
renderer.exportScene("intro2.vrscene");
// Load scene from a file.
renderer.Load("intro.vrscene");
 
// Fill the VFB layers settings from the SettingsVFB plugin to the VFB Layer Manager.
renderer.Vfb.ApplySettingsVFB();
 
VFB.VFBLayerManager lm = renderer.Vfb.LayerManager;
 
// Lock the layers so it will be a thread-safe batch operation.
lm.LockLayers();
 
// Get a handle to the Display Correction (DC) layer.
VFB.Layer dcLayer = lm.GetDisplayCorrectionLayer();
 
// Create a cc exposure layer as a child of the DC layer.
// All of the creatable class name you can get as a list by calling the GetCreatableLayerClasses method.
VFB.Layer dcExpLayer = lm.CreateLayer("chaos.cc.exposure", dcLayer);
// Check validity of the handle. On an error, empty handles are returned.
if (dcExpLayer.IsValid())
{
    // Set some properties of the exposure layer.
    // All the methods may throw exceptions if an error occurs.
    dcExpLayer.SetBlendMode(VRay.VFBLayerProperty.BlendMode.Exclusion);
    // All of the properties of a layer you can get as a list by calling GetLayerPropertyNames.
    dcExpLayer.SetLayerPropertyFloatValue("hilight_burn", 0.5f);
 
    // Create a MultiMatte mask layer whose parent is the exposure layer.
    VFB.Layer dcExpMMMaskLayer = lm.CreateLayer("chaos.ref.re.colormask", dcExpLayer);
    if (dcExpMMMaskLayer.IsValid())
    {
        // If you are not sure whether a property exists, you can search it by getting a list of all
        // modifiable layer fields.
        IEnumerable<string> propsNames = dcExpMMMaskLayer.GetLayerPropertiesOfType(VRay.VFBLayerProperty.Type.Bool);
        foreach (var propName in propsNames)
        {
            if (propName == "use_intensity")
            {
                dcExpMMMaskLayer.SetLayerPropertyBoolValue("use_intensity", true);
            }
        }
    }
}
 
// Never forget to unlock the layers. Otherwise, the whole VFB freezes.
lm.UnlockLayers();
 
// Fill the VFB layers settings from the VFB Layer Manager to the SettingsVFB plugin.
renderer.Vfb.FillSettingsVFB();
// Start rendering.
renderer.StartSync();
 
// Wait some time.
System.Threading.Thread.Sleep(3000);
// Lock the layers, so the user cannot access them from the UI.
lm.LockLayers();
 
// Get a new handle to the DC layer. The old one is invalid after the beginning of the rendering.
dcLayer = lm.GetDisplayCorrectionLayer();
 
// Change the current DC profile to Gamma 2.2.
VRay.VFBLayerProperty.Type type = dcLayer.GetLayerPropertyType("profile");
if (type == VRay.VFBLayerProperty.Type.IntEnum)
{
    // You can know all the properties of an enumerable by calling GetLayerPropertyIntEnumValues.
    dcLayer.SetLayerPropertyIntByEnumLabel("profile", "Gamma 2.2");
}
 
// Delete all mask layers.
IEnumerable<VFB.Layer> masks = lm.FindAllLayersWithLayerClass("chaos.ref.re.colormask");
foreach (var mask in masks)
{
    if (mask.CanDelete())
    {
        lm.DeleteLayer(mask);
    }
}
 
// Set some Stamp layer parameters.
VFB.Layer stampLayer = lm.GetStampLayer();
VRay.VFBLayerProperty.StampFontDesc desc = stampLayer.GetLayerPropertyStampFontDescValue("stamp_font");
desc.fontFamily = VRay.VFBLayerProperty.StampFontFamily.Modern;
desc.fontStyle = VRay.VFBLayerProperty.StampFontStyle.Italic;
stampLayer.SetLayerPropertyStampFontDescValue("stamp_font", desc);
stampLayer.SetLayerPropertyStampRawStringValue("stamp_string", "Incredible CCs");
stampLayer.SetLayerPropertyColorValue("stamp_color", new Color(1.0, 0.6, 0.6));
stampLayer.SetEnabled(true);
 
// Never forget to unlock the layers. Otherwise the whole VFB freezes.
lm.UnlockLayers();
 
// Wait for rendering to end.
renderer.WaitForRenderEnd();
 
// If you want the changes you made while rendering to the layers to be saved to the vrscene.
renderer.Vfb.FillSettingsVFB();
renderer.Export("intro2.vrscene");
// Load scene from a file asynchronously.
renderer.load('intro.vrscene', function (err) {
if (err) {
// Scene was not loaded.
throw err;
}
 
// Fill the VFB layers settings from the SettingsVFB plugin to the VFB Layer Manager
renderer.vfb.applySettingsVFB()
 
var lm = renderer.vfb.layerManager;
 
// Lock the layers so it will be a thread-safe batch operation.
lm.lockLayers();
 
// Get a handle to the Display Correction (DC) layer.
var dcLayer = lm.getDisplayCorrectionLayer();
 
// Create a cc exposure layer as a child of the DC layer.
// All of the creatable class name you can get as a list by calling the getCreatableLayerClasses method.
var dcExpLayer = lm.createLayer("chaos.cc.exposure", dcLayer);
 
// Check validity of the handle. On an error, empty handles are returned.
if (dcExpLayer.isValid()) {
// Set some properties of the exposure layer.
// All the methods may throw exceptions if an error occurs.
dcExpLayer.setBlendMode("BlendMode_Exclusion");
// All of the properties of a layer you can get as a list by calling getLayerPropertyNames.
dcExpLayer.hilight_burn = 0.5;
 
// Create a MultiMatte mask layer whose parent is the exposure layer.
var dcExpMMMaskLayer = lm.createLayer("chaos.ref.re.colormask", dcExpLayer);
if (dcExpMMMaskLayer.isValid()) {
// If you are not sure whether a property exists, you can search it by getting a list of all
// modifiable layer fields.
var propsNames = dcExpMMMaskLayer.getLayerPropertiesOfType("Bool");
for (var propName of propsNames) {
if (propName === "use_intensity") {
dcExpMMMaskLayer.use_intensity = true;
}
}
 
}
}
 
// Never forget to unlock the layers. Otherwise, the whole VFB freezes.
lm.unlockLayers();
 
// Fill the VFB layers settings from the VFB Layer Manager to the SettingsVFB plugin.
renderer.vfb.fillSettingsVFB();
 
// Start rendering.
renderer.start(function (err) {
if (err) {
// Couldn't start rendering.
throw err;
}
 
// Wait some time.
setTimeout(function () {
// Lock the layers, so the user cannot access them from the UI.
lm.lockLayers();
 
// Get a new handle to the DC layer. The old one is invalid after the beginning of the rendering.
dcLayer = lm.getDisplayCorrectionLayer();
 
// Change the current DC profile to Gamma 2.2.
var type = dcLayer.getLayerPropertyType("profile");
if (type === "IntEnum") {
// You can know all the properties of an enumerable by calling getLayerPropertyIntEnumValues.
dcLayer.profile = "Gamma 2.2";
}
 
// Delete all mask layers.
var masks = lm.findAllLayersWithLayerClass("chaos.ref.re.colormask");
for (var mask of masks) {
if (mask.canDelete()) {
lm.deleteLayer(mask);
}
}
 
// Set some Stamp layer parameters.
var stampLayer = lm.getStampLayer();
stampLayer.stamp_font = { "fontFamily": "stampFontFamily_modern", "fontStyle": "stampFontStyle_italic" };
stampLayer.stamp_string = "Incredible CCs";
stampLayer.stamp_color = vray.Color(1.0, 0.6, 0.6);
stampLayer.setEnabled(true);
 
// Never forget to unlock the layers. Otherwise the whole VFB freezes.
lm.unlockLayers();
 
// Wait for rendering to end.
renderer.waitForRenderEnd(function () {
// If you want the changes you made while rendering to the layers to be saved to the vrscene.
renderer.vfb.fillSettingsVFB();
renderer.export("intro2.vrscene", function () {
// Some other work if any and then renderer.close().
});
});
}, 3000);
});
});

Tarafından desteklenmektedir BetterDocs

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir