View Categories

Vantage’ı App SDK aracılığıyla kullanma

1 dakika okuma

0. Bu kimin için? #

Bu kılavuz, Chaos Vantage ile bir sahneyi render etmek isteyen App SDK kullanıcıları içindir. Burada App SDK ile kod yazma detaylarını ele almayacağız – bunun için SDK paketinde ayrı belgeler ve örnekler bulunmaktadır. Bunun yerine, Chaos Vantage kullanarak sahneyi render edebilmek için mevcut kodunuza birkaç satır eklemeyi ele alacağız.

Not: Bu belge zaman içinde güncellenecek ve genişletilecektir.

1.1. Adımlar #

İşte App SDK ile Vantage arasında canlı bağlantı kurmanın birkaç basit adımı:

  1. Vantage için sistem gereksinimlerini karşıladığınızdan emin olun .

  2. Uygulama SDK’sının en son sürümünü kullandığınızdan emin olun .

  3. Vantage’ı çalıştırın ve rölantide bırakın.

  4. Dağıtılmış İşleme için kodu ayarlayın . Kısaca adımlar şunlardır:

    1. Vantage, VFB’ye görüntü göndermediği ve penceresi siyah kalacağı için VFB’yi global olarak devre dışı bırakın .

    2. VRayRenderer sınıfından bir örnek oluşturun .

    3. Yerel makinenin render işleminden hariç tutulması için inProcess bayrağını (farklı dil bağlamlarında isimlendirmede farklılıklar olabilir) ayarlayın . Bu, V-Ray’in render işlemini engellemesini ve böylece Vantage’ın tüm kaynakları kullanmasını sağlar.

    4. Felaket kurtarmayı açıkça etkinleştirin .

    5. Sahneyi yükleyin.

    6. Dağıtılmış işleme için uzak sunucuyu (localhost veya Vantage’ın çalıştığı bilgisayarın IP adresi)  20701 numaralı port ile ekleyin . Port numarası belirtilmezse varsayılan olarak 20207 kullanılır.

    7. Etkileşimli modda render işlemine başlayın.

  5. Değişiklikleri yapın, Vantage buna göre güncelleyecektir.

Vantage’ın başarılı bir canlı bağlantı kurup kurmadığını görmek için, görüntüleme alanının sağ alt köşesindeki etikette  [CANLI BAĞLANTI] yazısının görünüp görünmediğini kontrol edin :

1.2. Kod örnekleri #

İşte SDK paketinde yer alan temel etkileşimli örneğimizin yukarıda açıklanan adımlar kullanılarak yeniden yazılmış bazı örnek kodları. Ayrıca SDK paketinde yer alan etkileşimli örneklere eklenen yeni örneğimizi de inceleyebilirsiniz:

# Import vray module and set the SCENE_PATH environment variable.
# ...
 
# Disable the VFB globally because Vantage doesn't send back images to VFB and its window would remain black.
# If we only set the RenderOptions flag enableFrameBuffer to be False it will hide the VFB
# but the libs associated with it will be loaded anyway.
vray.enableFrameBuffer(False)
 
# Create an instance of VRayRenderer with default options.
# The renderer is automatically closed after the `with` block.
with vray.VRayRenderer() as renderer:
# Set the inProcess flag to exclude the local machine from rendering.
    # This prevents V-Ray from rendering and thus allowing Vantage to use all resources.
    renderer.inProcess = False
 
    # Register a simple log callback. Always useful for debugging.
    # ...
 
# We have to explicitly enable DR first.
    renderer.setDREnabled(True)
 
    # Load scene from a file.
    renderer.load(os.path.join(SCENE_PATH, 'intro.vrscene'))
 
    # Add remote host for distributed rendering.
    # If port is omitted it defaults to 20207.
    # NOTE: Replace this address with the address of a host running
    # Vantage.
    renderer.addHosts('127.0.0.1:20701')
 
    # Start rendering.
    renderer.startSync()
 
    # Wait for rendering to end.
    renderer.waitForRenderEnd()

// Include VRay headers and set the SCENE_PATH environment variable.
// ...
 
// Load V-Ray SDK library.
// The directory containing the vray shared object should be present in
// the PATH environment variable.
// Disable the VFB globally because Vantage doesn't send back images to VFB and its window would remain black.
// If we only set the RendererOptions flag enableFrameBuffer to be false it will hide the VFB
// but the libs associated with it will be loaded anyway.
VRayInit init(NULL, false);
 
// Create an instance of VRayRenderer with default options.
// The renderer is automatically closed at the end of the current scope.
VRayRenderer renderer;
 
// Set the inProcess flag to exclude the local machine from rendering.
// This prevents V-Ray from rendering and thus allowing Vantage to use all resources.
renderer.inProcess = false;
 
// It's recommended to always have a console log
renderer.setOnLogMessage(logMessage);
 
// We have to explicitly enable DR first.
renderer.setDREnabled(true);
 
// Load scene from a file.
renderer.load("intro.vrscene");
 
// Add remote host for distributed rendering.
// If port is omitted it defaults to 20207.
// NOTE: Replace this address with the address of a host running
// Vantage.
renderer.addHosts("127.0.0.1:20701");
 
// Start rendering.
renderer.startSync();
 
// Wait for rendering to end.
renderer.waitForRenderEnd();

// Use VRay related namespaces and set the SCENE_PATH environment variable.
// ...
 
// Disable the VFB globally because Vantage doesn't send back images to VFB and its window would remain black.
// If we only set the RendererOptions flag IsFrameBufferEnabled to be false it will hide the VFB
// but the libs associated with it will be loaded anyway.
VFB.Enable(false);
 
// Create an instance of VRayRenderer with default options.
// The renderer is automatically closed after the `using` block.
using (VRayRenderer renderer = new VRayRenderer())
{
// Set the InProcess flag to exclude the local machine from rendering.
    // This prevents V-Ray from rendering and thus allowing Vantage to use all resources.
    renderer.InProcess = false;
 
// Add a listener for any type of log message.
// ...
 
// We have to explicitly enable DR first.
renderer.SetDREnabled(true);
 
// Load scene from a file.
    renderer.Load("intro.vrscene");
 
// Add remote host for distributed rendering.
    // If port is omitted it defaults to 20207.
    // NOTE: Replace this address with the address of a host running
    // Vantage.
    renderer.AddHosts("127.0.0.1:20701");
 
    // Start rendering.
    renderer.StartSync();
 
    // Wait for rendering to end.
    renderer.WaitForRenderEnd();
}
// Import vray module and set the SCENE_PATH environment variable.
// ...
 
// Disable the VFB globally because Vantage doesn't send back images to VFB and its window would remain black.
// If we only set the RendererOptions flag enableFrameBuffer to be false it will hide the VFB
// but the libs associated with it will be loaded anyway.
vray.enableFrameBuffer(false);
 
// Create an instance of VRayRenderer with default options.
var renderer = vray.VRayRenderer();
 
// Set the inProcess flag to exclude the local machine from rendering.
// This prevents V-Ray from rendering and thus allowing Vantage to use all resources.
renderer.inProcess = false;
 
// It's recommended to always have a console log callback.
// ...
 
// We have to explicitly enable DR first.
renderer.setDREnabled(true);
 
// Load scene from a file asynchronously.
renderer.load('intro.vrscene', function(err) {
    if (err) {
        // Scene was not loaded.
        throw err;
    }
 
    // Add remote host for distributed rendering.
    // If port is omitted it defaults to 20207.
    // NOTE: Replace this address with the address of a host running
    // Vantage.
    renderer.addHosts('127.0.0.1:20701');
 
    // 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();
        });
    });
});
 

Tarafından desteklenmektedir BetterDocs

Bir yanıt yazın

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