View Categories

Stereoskopik Görüntüleme

5 dakika okuma

Bu bölümde V-Ray’de stereoskopik görüntülemeyi ele alacağız. Bu efekti elde etmek için kullanılabilecek eklentileri inceleyeceğiz – VRayStereoscopicSettings .

VrayStereoskopikAyarları #


Bu, stereoskopik (yan yana) görüntüleme için yardımcı bir eklentidir. Kamerayı belirli bir mesafeye yerleştirilmiş 2 sanal kameraya dönüştürür. Ayrıca,  stereoskopik görüntülemeyi hızlandırmak için kullanılan Shademap modunu da uygular . Alan derinliğini ve hareket bulanıklığını hızlandırmak için de kullanılabilir.

Parametreler #


VRayStereoscopicSettings eklentisinde aşağıdaki parametreler yer almaktadır   :

  • eye_distance  – Stereoskopik görüntünün oluşturulacağı göz mesafesini belirtir.

  • specify_focus  – Etkinleştirildiğinde, odak mesafesi parametresiyle odak noktasını tanımlar.

  • focus_method  – İki görünüm için aşağıdaki üç odaklanma yönteminden birini belirtir.

    • Hiçbiri (0)  – Her iki kameranın da odak noktaları doğrudan önlerindedir.

    • Döndürme (1)  – Stereoskopik etki, sol ve sağ görünümlerin, her bir gözün görüş hatlarının birleştiği mesafede, yani füzyon mesafesinde, odak noktalarının çakışacak şekilde döndürülmesiyle elde edilir.

    • Kayma (2)  – Her iki görüşün yönü aynı kalır ancak her gözün görüşü z boyunca kaydırılır, böylece iki kesik koni birleşme mesafesinde yakınlaşır.

  • interocular_method  – İki sanal kameranın sahnedeki gerçek kameraya göre nasıl konumlandırılacağını belirtir.

    • İkisini de kaydır (0)  – Her iki sanal kamera da göz mesafesinin yarısına eşit bir mesafede zıt yönlere kaydırılacaktır.

    • Sola kaydırma (1)  – Sanal kameralar sola kaydırılır, böylece sağ kamera orijinal kameranın konumunu alır. Sol kamera, göz mesafesine eşit bir mesafede sola kaydırılır.

    • Sağa kaydırma (2)  – Sanal kameralar, sol kamera orijinal kameranın konumunu alacak şekilde sağa kaydırılır. Sağ kamera, göz mesafesine eşit bir mesafede sağa kaydırılır.

  • Görünüm  – Stereoskopik görünümlerden hangisinin oluşturulacağını belirtir.

    • İkisi de (0)  – Her iki görünüm de yan yana gösterilecektir.

    • Sol (1)  – Yalnızca sol görünüm oluşturulacaktır.

    • Sağ (2)  – Yalnızca sağ görünüm oluşturulacaktır.

  • adjust_resolution  – Etkinleştirildiğinde, bu seçenek oluşturulan son görüntünün çözünürlüğünü otomatik olarak ayarlar. Örneğin, görünüm için “Her İkisi” seçilirse ve oluşturma için belirtilen görüntü çözünürlüğü 640×480 ise, sonuçta elde edilen görüntü, her iki görünümün yan yana olduğu 1280×480 çözünürlüğünde tek bir görüntü olacaktır.

  • output_layout  – Stereoskopik görüntülerin V-Ray çerçeve arabelleğine hangi formatta aktarılacağını belirtir.

    • Yan Yana (0)  – Kameraları yan yana düzenler.

    • Üstten Alttan (1)  – Kameraları birbiri üstüne yerleştirir.

  • left_camera  – Sol göz için bir kamera eklentisi; belirtilmediği takdirde, sol kamera sahne kamerasına göre hesaplanır.

  • right_camera  – Sağ göz için bir kamera eklentisi; belirtilmediği takdirde, sağ kamera sahne kamerasına göre hesaplanır.

  • film_offset_x_left  – Sol kamera için yatay film kaydırma mesafesi

  • film_offset_x_right  – Sağ kamera için yatay film kaydırma mesafesi

  • film_offset_y_left  – Sol kamera için dikey film ofseti

  • film_offset_y_right  – Sağ kamera için dikey film kaydırma

Panoramik kutup birleşmesi #

Bu bölümdeki seçenekler, stereoskopi ile panoramik bir görünüm oluşturulurken (örneğin, görüş alanı 360 derece olan küresel bir kamera) kullanılır. Bu seçenekler, yukarı ve aşağı bakarken oluşabilecek bozulmaları önlememizi sağlar. Bu, göz mesafesinin ve dolayısıyla stereoskopik etkinin kademeli olarak azaltılmasıyla elde edilir. Göz mesafesi değeri, görüş açısı aşağıdaki özelliklerde belirtilen açılara ulaşana kadar aynı tutulur; daha sonra, doğrudan aşağı veya yukarı bakarken göz mesafesi kademeli olarak azaltılarak 0 değerine ulaşır.

  • top_merge_angle  – Panoramik kutup birleştirme: Küresel panorama kamerasıyla render alırken, üst kısma yakın hangi açıdan itibaren stereo efekti solmaya başlar?

  • bottom_merge_angle  – Panoramik kutup birleştirme: Küresel panorama kamerasıyla render alırken, alt kısma yakın hangi açıdan itibaren stereo efekti solmaya başlar?

Gölge Haritası Parametreleri #

Gölge haritası parametreleri, stereoskopik görüntülerin yanı sıra alan derinliği içeren görüntülerin işlenmesini hızlandırabilir. Gölge haritalarıyla çalışma akışı iki aşamadan oluşur. İlk aşamada, Gölge Haritası modu “Gölge  haritası oluştur” olarak ayarlanarak  ve işleme yapılarak bir gölge haritası oluşturulur. Gerçek işleme başlamadan önce, Gözat düğmesine tıklanarak gölge haritasının kaydedileceği dosya belirtilmelidir. Bu, görünür gölgeli noktalar hakkında önemli bilgiler içeren bir dosya kaydedecektir. Bu bilgiler daha sonra kullanılabilir.  Gölge haritası  modunu kullanarak stereoskopik görüntüler veya alan derinliği içeren görüntüler çok daha hızlı işlenebilir.

  • sm_mode  – Gölge haritasının çalışma modunu belirtmemizi sağlar (0 – devre dışı; 1 – gölge haritasını oluştur; 2 – gölge haritasını kullan).

  • reuse_threshold  – Daha düşük değerler, V-Ray’in gölge haritasını daha az kullanmasını ve daha gerçekçi gölgelendirme yapmasını sağlayacaktır.

  • shademap_file  – Gölge haritası bilgilerinin saklandığı dosyanın adı.

  • float_colors_mode  – Gölge haritasında 32 bit (tek hassasiyetli) renk kanallarını saklar. Kapalıyken 16 bit (yarım hassasiyetli) değerler saklanır.

  • vrst_compression  – .vrst dosyaları için sıkıştırma türü (0 – sıkıştırma yok, 1 – ZLIB sıkıştırma)

  • exr_compression  – .exr dosyaları için sıkıştırma türü (0 – sıkıştırma yok, 1 – RLE sıkıştırma, 2 – ZIPS sıkıştırma)

  • exclude_list –  Gölge haritasının kullanılmayacağı  eklentilerin  listesi .

  • exclude_list_inclusive  – Bu seçenek etkinleştirildiğinde, exclude_list “Dahil edilecekler listesi” olarak kabul edilir; etkinleştirilmediğinde ise sonuç “Hariç tutulacaklar listesi” olarak kabul edilir.

Genel yönergeler #

Küresel panorama oluşturma için şunları yapmanız gerekir:

  • SettingsCamera’nın type parametresini   9 olarak değiştirin. (Type=1’in küresel olduğunu, ancak panoramalar için geçerli olmadığını unutmayın.)

  • Görüş alanını 360 dereceye veya daha doğrusu  2*pi’ye ayarlayın, çünkü fov parametresi radyan cinsindendir. Bunu RenderView  eklentisi ve  SettingsCamera ile yapmanız gerekiyor  ; her ikisinde de fov parametresi bulunur. Ayrıca, specify_fov=1  ile  CameraPhysical  kullanıyorsanız  , orada da fov’u ayarlayın.

  • Dikey görüş alanını 180 dereceye ayarlayın. Bu biraz kafa karıştırıcı olabilir: Ayarlar Kamerası’nın yükseklik parametresi üzerinden ayarlanır  . Ayrıca değer radyan cinsinden değil, derece cinsindendir.

Kübik (6×1) panorama oluşturma için şunları yapmanız gerekir:

  • SettingsCamera’nın type parametresini   10 olarak değiştirin.

  • Çözünürlüğü 6:1 en boy oranıyla (veya stereo yapıyorsanız 12:1) ayarlayın. Yani 1000×1000 piksel küp kenarlarına sahip stereo kübik panorama için 12000×1000 çözünürlükte render alacaksınız.

Stereo görüntüleme için:

  • CPU (Üretim veya Etkileşimli) renderlama için bir VRayStereoscopicSettings eklentisi oluşturmanız gerekir  . Bu eklenti, SettingsCamera  ve  SettingsOutput  eklentilerinden sonra oluşturulmalıdır   , aksi takdirde çalışmaz!  Panorama için VRayStereoscopicSettings::focus_method  parametresini 1’e, normal kamera için ise 2’ye değiştirmeniz önerilir.

  • GPU ile görüntüleme için RenderView::stereo_on değerini 1 olarak ayarlamanız gerekir  . Ayrıca, varsayılan 1.0 yerine RenderView::stereo_eye_distance değerini 6.5 (ortalama insan) gibi bir değere  ayarlamak isteyebilirsiniz  . Panorama için RenderView::stereo_focus_method  parametresini 1’e, normal kamera için ise 2’ye  değiştirmeniz önerilir  .

Stereo için yatay çözünürlüğü iki katına çıkarmayı da unutmayın. Yani normal render çözünürlüğünüz 640×480 ise, bunu 1280×480 yapın. Görüntünün sol yarısı sol göz görüntüsü, sağ yarısı ise sağ göz görüntüsü olacaktır.

Örnekler #


6×1 küp #

vrscenes/vr_cube6x1_camera.vrscene sahne dosyasındaki yorumları kontrol edin  .

Stereo Küp 6×1 #

vrscenes/vr_cube6x1_stereo.vrscene dosyasındaki yorumları kontrol edin  .

Küresel #

vrscenes/vr_sphericalPanorama_camera.vrscene sahne dosyasındaki yorumları kontrol edin  .

Stereo Küresel #

vrscenes/vr_sphericalPanorama_stereo.vrscene sahne dosyasındaki yorumları kontrol edin  .

Kod örneği #


İşte Cube6x1’in işlenmesi için örnek bir kod:

# Compatibility with Python 2.7.
from __future__ import print_function
 
# The directory containing the vray shared object should be present in the PYTHONPATH environment variable.
# Try to import the vray module from VRAY_SDK/python, if it is not in PYTHONPATH
import sys, os
VRAY_SDK = os.environ.get('VRAY_SDK')
if VRAY_SDK:
    sys.path.append(os.path.join(VRAY_SDK, 'python'))
import vray
 
SCENE_PATH = os.path.join(os.environ.get('VRAY_SDK'), 'scenes')
# Change process working directory to SCENE_PATH in order to be able to load relative scene resources.
os.chdir(SCENE_PATH)
 
# Create an instance of VRayRenderer with default options.
# The renderer is automatically closed after the `with` block.
with vray.VRayRenderer() as renderer:
    # Register a simple log callback. Always useful for debugging.
    def dumpMsg(renderer, message, level, instant):
        if level == vray.LOGLEVEL_ERROR:
            print("[ERROR]", message)
        elif level == vray.LOGLEVEL_WARNING:
            print("[Warning]", message)
        elif level == vray.LOGLEVEL_INFO:
            print("[info]", message)
        # Uncomment for testing, but you might want to ignore these in real code
        #else: print("[debug]", message)
    renderer.setOnLogMessage(dumpMsg)
    # Load scene from a file.
    renderer.load(os.path.join(SCENE_PATH, 'stereo.vrscene'))
    # The original image size is 3000x500px.
    # In this example 2 images are rendered side-by-side for the stereo effect
    # and the image width had to be doubled (6000px).
    renderer.size = (6000, 500)
    # The SettingsCamera plugin controls the way the scene geometry is
    # projected onto the image (camera type, motion blur and depth of field).
    settingsCamera = renderer.classes.SettingsCamera.getInstanceOrCreate()
    # Specifies the type of the camera
    # Possible values are:
    #   0 - default - Allows for the current scene camera to be used (usually a
    #       pinhole camera).
    #   1 (Spherical) - A camera with a spherical lens.
    #   2 (Cylindrical (point)) - This camera casts all rays from the center of
    #      a cylinder. In the vertical direction the camera acts as a pinhole
    #      camera, and in the horizontal direction the camera acts as a
    #      spherical camera.
    #   3 (Cylindrical (ortho)) - This camera casts all rays from the center of
    #      a cylinder. In the vertical direction the camera acts as an
    #      orthographic view, and in the horizontal direction the camera acts
    #      as a spherical camera.
    #   4 (Box) - Six standard cameras placed on the sides of a box, generating
    #      a vertical cross format image. This type of camera is excellent for
    #      generation of environment maps for cube mapping. The Box camera can
    #      also be used for generating irradiance maps for GI: First you would
    #      calculate the irradiance map with a Box camera, then save it to a
    #      file and finally reuse it with a Default camera that can be pointed
    #      in any direction.
    #   5 (Fish eye) - This special type of camera captures the scene as if it
    #      is a pinhole camera pointed at a 100% reflective sphere that
    #      reflects the scene back into the camera's shutter, as with using a
    #      light probe in HDRI photography. You can use the Dist and FOV
    #      settings to control which part of the sphere is captured by the
    #      camera. Note that the virtual reflective sphere has always a radius
    #      of 1.0.
    #   6 (Warped spherical (old-style)) - A spherical camera with slightly
    #      different mapping formula than the Spherical camera.
    #   7 (Orthographic) - A camera enabling a non-perspective view.
    #   8 (Perspective) - Overrides the scene camera to force it to be a
    #      pinhole camera.
    #   9 (Spherical panorama) - A spherical camera with independent horizontal
    #      and vertical FOV selection that is useful for generating latlong
    #      images for spherical VR use.
    #  10 (Cube6x1) - A variant of the Box camera with the cube sides arranged
    #      in a single row. Unlike the Box camera's output, Cube6x1 does not
    #      produce an empty space in the output image and is quite useful in
    #      generating cubic VR output.
    settingsCamera.type = 10
    renderView = renderer.classes.RenderView.getInstanceOrCreate()
    # Specify active camera (render camera) position and orientation.
    renderView.transform = vray.Transform(
        vray.Matrix(
            vray.Vector(0.9999999, 0, 0),
            vray.Vector(0, 0.9999999, 0),
            vray.Vector(0, 0, 0.9999999)),
        vray.Vector(0, 160, -144.4429302328891))
    # Update field of view value.
    renderView.fov = 6.283185
    # Specify near clipping plane.
    renderView.clipping_near = 0.1
    # Specify far clipping plane.
    renderView.clipping_far = 10000
    # The "VRayStereoscopicSettings" enables the stereoscopic rendering.
    stereo = renderer.classes.VRayStereoscopicSettings.getInstanceOrCreate()
    # Specify the focus method for the two views.
    # Possible values are:
    #   0 (None/Parallel) - default
    #   1 (Rotation)
    #   2 (Shear)
    stereo.focus_method = 2
    # Automatically adjust the resolution for the final image rendererd.
    stereo.adjust_resolution = True
    # Start rendering.
    renderer.startSync()
    # Wait for rendering to end.
    renderer.waitForRenderEnd()
 
#define VRAY_RUNTIME_LOAD_PRIMARY
 
#include "vraysdk.hpp"
#include "vrayplugins.hpp"
#include "utils.h"
 
using namespace VRay;
using namespace VRay::Plugins;
using namespace std;
 
const char *BASE_PATH = getenv("VRAY_SDK");
string SCENE_PATH = (BASE_PATH ? string(BASE_PATH) : string(".")) + PATH_DELIMITER + "scenes";
 
int main() {
// Change process working directory to SCENE_PATH in order to be able to load relative scene resources.
changeCurrentDir(SCENE_PATH.c_str());
// Load V-Ray SDK library.
VRayInit init(NULL, true);
// Create an instance of VRayRenderer with default options.
// The renderer is automatically closed at the end of the current scope.
VRayRenderer renderer;
// It's recommended to always have a console log
renderer.setOnLogMessage(logMessage);
// Load scene from a file.
renderer.load("stereo.vrscene");
// The original image size is 3000x500px.
// In this example 2 images are rendered side-by-side for the stereo effect
// and the image width had to be doubled (6000px).
renderer.setImageSize(6000, 500);
// The SettingsCamera plugin controls the way the scene geometry is
// projected onto the image(camera type, motion blur and depth of field).
SettingsCamera settingsCamera = renderer.getInstanceOrCreate<SettingsCamera>();
// Specifies the type of the camera
// Possible values are:
//   0 - default - Allows for the current scene camera to be used (usually a pinhole camera).
//   1 (Spherical) - A camera with a spherical lens.
//   2 (Cylindrical(point)) - This camera casts all rays from the center of a cylinder. 
//      In the vertical direction the camera acts as a pinhole camera, and in the horizontal direction the camera acts as a spherical camera.
//   3 (Cylindrical(ortho)) - This camera casts all rays from the center of a cylinder. 
//      In the vertical direction the camera acts as an orthographic view, and in the horizontal direction the camera acts as a spherical camera.
//   4 (Box) - Six standard cameras placed on the sides of a box, generating a vertical cross format image. 
//      This type of camera is excellent for generation of environment maps for cube mapping. 
//      The Box camera can also be used for generating irradiance maps for GI: 
//      First you would calculate the irradiance map with a Box camera, then save it to a
//      file and finally reuse it with a Default camera that can be pointed in any direction.
//   5 (Fish eye) - This special type of camera captures the scene as if it is a pinhole camera pointed at a 100% reflective sphere that
//      reflects the scene back into the camera's shutter, as with using a light probe in HDRI photography. You can use the Dist and FOV
//      settings to control which part of the sphere is captured by the camera. Note that the virtual reflective sphere has always a radius of 1.0.
//   6 (Warped spherical (old-style)) - A spherical camera with slightly different mapping formula than the Spherical camera.
//   7 (Orthographic) - A camera enabling a non-perspective view.
//   8 (Perspective) - Overrides the scene camera to force it to be a pinhole camera.
//   9 (Spherical panorama) - A spherical camera with independent horizontal
//      and vertical FOV selection that is useful for generating latlong images for spherical VR use.
//  10 (Cube6x1) - A variant of the Box camera with the cube sides arranged in a single row. Unlike the Box camera's output, 
//      Cube6x1 does not produce an empty space in the output image and is quite useful in generating cubic VR output.
settingsCamera.set_type(10);
RenderView renderView = renderer.getInstanceOrCreate<RenderView>();
// Specify active camera(render camera) position and orientation.
renderView.set_transform(Transform(
Matrix(
Vector(0.9999999, 0.0, 0.0),
Vector(0.0, 0.9999999, 0.0),
Vector(0.0, 0.0, 0.9999999)),
Vector(0.0, 160.0, -144.4429302328891)));
// Update field of view value.
renderView.set_fov(6.283185f);
// Specify near clipping plane.
renderView.set_clipping_near(0.1f);
// Specify far clipping plane.
renderView.set_clipping_far(10000);
// The "VRayStereoscopicSettings" enables the stereoscopic rendering.
VRayStereoscopicSettings stereo = renderer.getInstanceOrCreate<VRayStereoscopicSettings>();
// Specify the focus method for the two views.
// Possible values are :
//   0 (None / Parallel) - default
//   1 (Rotation)
//   2 (Shear)
stereo.set_focus_method(2);
// Automatically adjust the resolution for the final image rendererd.
stereo.set_adjust_resolution(true);
// Start rendering.
renderer.startSync();
// Wait for rendering to end.
renderer.waitForRenderEnd();
return 0;
}
using System;
using System.IO;
using VRay;
using VRay.Plugins;
 
namespace _08_stereo_panorama
{
class Program
{
static void Main(string[] args)
{
string SCENE_PATH = Path.Combine(Environment.GetEnvironmentVariable("VRAY_SDK"), "scenes");
// Change process working directory to SCENE_PATH in order to be able to load relative scene resources.
Directory.SetCurrentDirectory(SCENE_PATH);
// Create an instance of VRayRenderer with default options.
// The renderer is automatically closed after the `using` block.
using (VRayRenderer renderer = new VRayRenderer())
{
// Add a listener for any type of log message.
renderer.LogMessage += new EventHandler<MessageEventArgs>((source, e) =>
{
// You can remove the if for testing, but you might want to ignore Debug in real code
if (e.LogLevel != LogLevelType.Debug)
{
Console.WriteLine(String.Format("[{0}] {1}", e.LogLevel.ToString(), e.Message));
}
});
// Load scene from a file.
renderer.Load("stereo.vrscene");
// The original image size is 3000x500px.
// In this example 2 images are rendered side-by-side for the stereo effect
// and the image width had to be doubled (6000px).
renderer.SetImageSize(6000, 500);
// The SettingsCamera plugin controls the way the scene geometry is
// projected onto the image (camera type, motion blur and depth of field).
SettingsCamera settingsCamera = renderer.GetInstanceOrCreate<SettingsCamera>();
// Specifies the type of the camera
// Possible values are:
//   0 - default - Allows for the current scene camera to be used (usually a pinhole camera).
//   1 (Spherical) - A camera with a spherical lens.
//   2 (Cylindrical(point)) - This camera casts all rays from the center of a cylinder. 
//      In the vertical direction the camera acts as a pinhole camera, and in the horizontal direction the camera acts as a spherical camera.
//   3 (Cylindrical(ortho)) - This camera casts all rays from the center of a cylinder. 
//      In the vertical direction the camera acts as an orthographic view, and in the horizontal direction the camera acts as a spherical camera.
//   4 (Box) - Six standard cameras placed on the sides of a box, generating a vertical cross format image. 
//      This type of camera is excellent for generation of environment maps for cube mapping. 
//      The Box camera can also be used for generating irradiance maps for GI: 
//      First you would calculate the irradiance map with a Box camera, then save it to a
//      file and finally reuse it with a Default camera that can be pointed in any direction.
//   5 (Fish eye) - This special type of camera captures the scene as if it is a pinhole camera pointed at a 100% reflective sphere that
//      reflects the scene back into the camera's shutter, as with using a light probe in HDRI photography. You can use the Dist and FOV
//      settings to control which part of the sphere is captured by the camera. Note that the virtual reflective sphere has always a radius of 1.0.
//   6 (Warped spherical (old-style)) - A spherical camera with slightly different mapping formula than the Spherical camera.
//   7 (Orthographic) - A camera enabling a non-perspective view.
//   8 (Perspective) - Overrides the scene camera to force it to be a pinhole camera.
//   9 (Spherical panorama) - A spherical camera with independent horizontal
//      and vertical FOV selection that is useful for generating latlong images for spherical VR use.
//  10 (Cube6x1) - A variant of the Box camera with the cube sides arranged in a single row. Unlike the Box camera's output, 
//      Cube6x1 does not produce an empty space in the output image and is quite useful in generating cubic VR output.
settingsCamera.SettingsCameraType = 10;
RenderView renderView = renderer.GetInstanceOrCreate<RenderView>();
// Specify active camera (render camera) position and orientation.
renderView.Transform = new Transform(
new Matrix(
new Vector(0.9999999, 0, 0),
new Vector(0, 0.9999999, 0),
new Vector(0, 0, 0.9999999)),
new Vector(0, 160, -144.4429302328891));
// Update field of view value.
renderView.Fov = 6.283185F;
// Specify near clipping plane.
renderView.ClippingNear = 0.1F;
// Specify far clipping plane.
renderView.ClippingFar = 10000;
// The "VRayStereoscopicSettings" enables the stereoscopic rendering.
VRayStereoscopicSettings stereo = renderer.GetInstanceOrCreate<VRayStereoscopicSettings>();
// Specify the focus method for the two views.
// Possible values are:
//   0 (None/Parallel) - default
//   1 (Rotation)
//   2 (Shear)
stereo.FocusMethod = 2;
// Automatically adjust the resolution for the final image rendererd.
stereo.AdjustResolution = true;
// Start rendering.
renderer.StartSync();
// Wait for rendering to end.
renderer.WaitForRenderEnd();
}
}
}
}
var path = require('path');
var vray = require(path.join(process.env.VRAY_SDK, 'node', 'vray'));
 
var SCENE_PATH = path.join(process.env.VRAY_SDK, 'scenes');
// Change process working directory to SCENE_PATH in order to be able to load relative scene resources.
process.chdir(SCENE_PATH);
 
// Create an instance of VRayRenderer with default options.
var renderer = vray.VRayRenderer();
// It's recommended to always have a console log callback
renderer.on("logMessage", function(message, level, instant) {
if (level == vray.LOGLEVEL_ERROR)
console.log("[ERROR] ", message);
else if (level == vray.LOGLEVEL_WARNING)
console.log("[Warning] ", message);
else if (level == vray.LOGLEVEL_INFO)
console.log("[info] ", message);
// Uncomment for testing, but you might want to ignore these in real code
//else console.log("[debug] ", message);
});
 
// Load scene from a file asynchronously.
renderer.load("stereo.vrscene", function(err) {
    if (err) throw err;
    // The original image size is 3000x500px.
    // In this example 2 images are rendered side-by-side for the stereo effect
    // and the image width had to be doubled (6000px).
    renderer.size = {"width": 6000, "height": 500};
    // The SettingsCamera plugin controls the way the scene geometry is
    // projected onto the image (camera type, motion blur and depth of field).
    var settingsCamera = renderer.classes.SettingsCamera.getInstanceOrCreate();
// Specifies the type of the camera
// Possible values are:
//   0 - default - Allows for the current scene camera to be used (usually a
//       pinhole camera).
//   1 (Spherical) - A camera with a spherical lens.
//   2 (Cylindrical(point)) - This camera casts all rays from the center of
//      a cylinder. In the vertical direction the camera acts as a pinhole
//      camera, and in the horizontal direction the camera acts as a
//      spherical camera.
//   3 (Cylindrical(ortho)) - This camera casts all rays from the center of
//      a cylinder. In the vertical direction the camera acts as an
//      orthographic view, and in the horizontal direction the camera acts
//      as a spherical camera.
//   4 (Box) - Six standard cameras placed on the sides of a box, generating
//      a vertical cross format image. This type of camera is excellent for
//      generation of environment maps for cube mapping. The Box camera can
//      also be used for generating irradiance maps for GI: First you would
//      calculate the irradiance map with a Box camera, then save it to a
//      file and finally reuse it with a Default camera that can be pointed
//      in any direction.
//   5 (Fish eye) - This special type of camera captures the scene as if it
//      is a pinhole camera pointed at a 100% reflective sphere that
//      reflects the scene back into the camera's shutter, as with using a
//      light probe in HDRI photography. You can use the Dist and FOV
//      settings to control which part of the sphere is captured by the
//      camera. Note that the virtual reflective sphere has always a radius
//      of 1.0.
//   6 (Warped spherical (old-style)) - A spherical camera with slightly
//      different mapping formula than the Spherical camera.
//   7 (Orthographic) - A camera enabling a non-perspective view.
//   8 (Perspective) - Overrides the scene camera to force it to be a
//      pinhole camera.
//   9 (Spherical panorama) - A spherical camera with independent horizontal
//      and vertical FOV selection that is useful for generating latlong
//      images for spherical VR use.
//  10 (Cube6x1) - A variant of the Box camera with the cube sides arranged
//      in a single row. Unlike the Box camera's output, Cube6x1 does not
//      produce an empty space in the output image and is quite useful in
//      generating cubic VR output.
    settingsCamera.type = 10;
 
    var renderView = renderer.classes.RenderView.getInstanceOrCreate();
    // Specify active camera (render camera) position and orientation.
    renderView.transform = vray.Transform(
        vray.Matrix(
            vray.Vector(0.9999999, 0, 0),
            vray.Vector(0, 0.9999999, 0),
            vray.Vector(0, 0, 0.9999999)),
        vray.Vector(0, 160, -144.4429302328891));
    // Update field of view value.
    renderView.fov = 6.283185;
    // Specify near clipping plane.
    renderView.clipping_near = 0.1;
    // Specify far clipping plane.
    renderView.clipping_far = 10000;
    // The "VRayStereoscopicSettings" enables the stereoscopic rendering.
    var stereo = renderer.classes.VRayStereoscopicSettings.getInstanceOrCreate();
    // Specify the focus method for the two views.
    // Possible values are:
    //   0 (None/Parallel) - default
    //   1 (Rotation)
    //   2 (Shear)
    stereo.focus_method = 2;
    // Automatically adjust the resolution for the final image rendererd.
    stereo.adjust_resolution = true;
    // Start rendering.
    renderer.start(function(err) {
        if (err) throw err;
        // Wait for rendering to end.
        renderer.waitForRenderEnd(function() {
            renderer.close();
        });
    });
});

Tarafından desteklenmektedir BetterDocs

Bir yanıt yazın

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