View Categories

V-Ray Kırpıcı

2 dakika okuma

giriiş #


Bu bölümde geometri kırpma konusundan bahsedeceğiz. VRayClipper, sahnenin bazı kısımlarını basit bir düzlemle kırpmak için kullanılabilen geometrik bir temel öğedir. Bu, render zamanında gerçekleşen bir efekttir ve sahnenin gerçek geometrisini hiçbir şekilde değiştirmez.

Parametreler #


İlgilendiğimiz eklentinin adı  VRayClipper .

  • enabled  – kırpma efektini açar ve kapatır.

  • affect_light  – etkinleştirilirse, kırpma aracı alan ışık kaynaklarını da etkileyecektir.

  • only_camera_rays  – kırpma işlemi, nesneleri kamera tarafından doğrudan görüldükleri şekilde etkileyecektir, ancak yansıma/kırılma/GI ışınlarına karşı değişmemiş görüneceklerdir.

  • clip_lights – ışık geometrisinin (örneğin bir  ağ ışığının )  kırpılmasını etkinleştirir veya devre dışı bırakır .

  • use_obj_mtl  – etkinleştirildiğinde, kırpma aracı, oluşan delikleri doldurmak için kırpılan her nesnenin malzemesini kullanır. Bu devre dışı bırakıldığında, kırpma nesnesinin kendisine uygulanan malzeme kullanılır.

  • set_material_id  – etkinleştirildiğinde, kırpma nesnesi için bir yüzey malzemesi kimliği belirtebilirsiniz. Daha sonra bu kimliği, farklı nesneler için farklı dolgu malzemesi belirtmek üzere Çoklu/Alt nesne malzemesi içinde kullanabilirsiniz.

  • material_id  – “Malzeme Kimliğini Ayarla” seçeneği etkinleştirildiğinde kırpılan yüzeyler için yüzey malzeme kimliği.

  • invert_inside  – Mesh modu etkinleştirildiğinde mesh’in nasıl kullanılacağını belirler:

    • 0 – Kesişim  – Belirtilen ağın dışında kalan her şeyi kırpıp atar; yalnızca belirtilen ağın içindeki nesneleri ve nesne parçalarını işler;

    • 1 – Çıkarma  – Belirtilen ağın içindeki her şeyi kırpar; yalnızca belirtilen ağın dışındaki nesneleri ve nesne parçalarını işler.

  • exclusion_nodes  – hangi sahne nesnelerinin kırpılacağını seçmenize olanak tanıyan bir dahil etme/hariç tutma listesi.

  • `exclusion_mode`  – Listelenen düğümleri dahil etmek için `false`, listelenen düğümleri hariç tutmak için `true`.

  • clip_mesh  – Basit düzlem yerine kırpma ağı olarak kullanılacak ağ eklentisi

Örnek #


 Aşağıdaki sahneler bu sahne paketi kullanılarak oluşturulmuştur .

Clipper Hariç Tut #

Clipper Mesh #

Kırpıcı #

Clipper Plane #

# 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, 'cornell_new.vrscene'))
    # Create a VRayClipper plugin
    clipper = renderer.classes.VRayClipper()
    # Don't assign a node to get mesh from; clip against a plane instead
    # Enable the clipper
    clipper.enabled = True
    # List of exclusion nodes
    exclusionNodes = [ 
        renderer.plugins['Sphere0Shape1@node'],
        renderer.plugins['Sphere0Shape4@node']
    ]
    clipper.exclusion_nodes = exclusionNodes
    # Exclude the nodes from the list; all other nodes will be clipped
    clipper.exclusion_mode = True
    # Perform subtraction
    clipper.invert_inside = 1
    # Attach the blue material
    clipper.material = renderer.plugins['Blue_Mtl@mtlsingle']
    # Assign a transform to the clipper plane
    clipper.transform = vray.Transform(vray.Matrix(vray.Vector(1, 0, 0), vray.Vector(0, 0.5, 0.87), vray.Vector(0, -0.87, 0.5)), vray.Vector(0, 20, 0))
 
    # 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("cornell_new.vrscene");
 
// Create a VRayClipper plugin
VRayClipper clipper = renderer.newPlugin<VRayClipper>();
// Don't assign a node to get mesh from; clip against a plane instead
// Enable the clipper
clipper.set_enabled(true);
// List of exclusion nodes
ValueList exclusionNodes;
exclusionNodes = {
Value(renderer.getPlugin("Sphere0Shape1@node")),
Value(renderer.getPlugin("Sphere0Shape4@node"))
};
clipper.set_exclusion_nodes(exclusionNodes);
// Exclude the nodes from the list; all other nodes will be clipped
clipper.set_exclusion_mode(true);
// Perform subtraction
clipper.set_invert_inside(1);
// Attach the blue material
clipper.set_material(renderer.getPlugin("Blue_Mtl@mtlsingle"));
// Assign a transform to the clipper plane
clipper.set_transform(Transform(Matrix(Vector(1, 0, 0), Vector(0, 0.5, 0.87), Vector(0, -0.87, 0.5)), Vector(0, 20, 0)));
 
// Start rendering.
renderer.startSync();
// Wait for rendering to end.
renderer.waitForRenderEnd();
 
return 0;
}
using System;
using System.IO;
using System.Collections.Generic;
using VRay;
using VRay.Plugins;
 
namespace _clipperPlane
{
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("cornell_new.vrscene");
 
// Create a VRayClipper plugin
VRayClipper clipper = renderer.NewPlugin<VRayClipper>();
// Don't assign a node to get mesh from; clip against a plane instead
// Enable the clipper
clipper.Enabled = true;
// List of exclusion nodes
List<object> exclusionNodes = new List<object> {
renderer.GetPlugin("Sphere0Shape1@node"),
renderer.GetPlugin("Sphere0Shape4@node")
};
clipper.ExclusionNodes = exclusionNodes;
// Exclude the nodes from the list; all other nodes will be clipped
clipper.ExclusionMode = true;
// Perform subtraction
clipper.InvertInside = 1;
// Attach the blue material
clipper.Material = renderer.GetPlugin("Blue_Mtl@mtlsingle");
// Assign a transform to the clipper plane
clipper.Transform = new Transform(new Matrix(new Vector(1, 0, 0), new Vector(0, 0.5, 0.87), new Vector(0, -0.87, 0.5)), new Vector(0, 20, 0));
 
// 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("cornell_new.vrscene", function(err) {
if (err) throw err;
 
// Create a VRayClipper plugin
var clipper = renderer.classes.VRayClipper();
// Don't assign a node to get mesh from; clip against a plane instead
// Enable the clipper
clipper.enabled = true;
// List of exclusion nodes
var exclusionNodes = vray.List(
renderer.plugins["Sphere0Shape1@node"],
renderer.plugins["Sphere0Shape4@node"]
);
clipper.exclusion_nodes = exclusionNodes;
// Exclude the nodes from the list; all other nodes will be clipped
clipper.exclusion_mode = true;
// Perform subtraction
clipper.invert_inside = 1;
// Attach the blue material
clipper.material = renderer.plugins["Blue_Mtl@mtlsingle"];
// Assign a transform to the clipper plane
clipper.transform = vray.Transform(vray.Matrix(vray.Vector(1, 0, 0), vray.Vector(0, 0.5, 0.87), vray.Vector(0, -0.87, 0.5)), vray.Vector(0, 20, 0));
 
// Start rendering.
renderer.start(function(err) {
if (err) throw err;
// Wait for rendering to end.
renderer.waitForRenderEnd(function() {
renderer.close();
});
});
});

Sonuç #

Kırpma Nesnesi #

# 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, 'cornell_new.vrscene'))
 
    clipMesh = renderer.plugins['Sphere0Shape2@node']
    updatedTransform = clipMesh.transform
    # Modify the copy of the clipMesh transform.
    updatedTransform = updatedTransform.replaceOffset(updatedTransform.offset + vray.Vector(0, -20, 0))
    # Update the transform value in clipMesh (applying the changes above).
    clipMesh.transform = updatedTransform
 
    # Create a VRayClipper plugin
    clipper = renderer.classes.VRayClipper()
    # Assign a node to get mesh from
    clipper.clip_mesh = clipMesh
    # Enable the clipper
    clipper.enabled = True
    # List of exclusion nodes
    exclusionNodes = [ 
        renderer.plugins['FloorShape@node']
    ]
    clipper.exclusion_nodes = exclusionNodes
    # Include the nodes from the list
    clipper.exclusion_mode = False
    # Perform subtraction
    clipper.invert_inside = 1
    # Attach the blue material
    clipper.material = renderer.plugins['Blue_Mtl@mtlsingle']
 
    # 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("cornell_new.vrscene");
 
Node clipMesh = renderer.getPlugin<Node>("Sphere0Shape2@node");
Transform updatedTransform = clipMesh.get_transform();
// Modify the copy of the clipMesh transform.
updatedTransform.offset += Vector(0, -20, 0);
// Update the transform value in clipMesh (applying the changes above).
clipMesh.set_transform(updatedTransform);
 
// Create a VRayClipper plugin
VRayClipper clipper = renderer.newPlugin<VRayClipper>();
// Assign a node to get mesh from
clipper.set_clip_mesh(clipMesh);
// Enable the clipper
clipper.set_enabled(true);
// List of exclusion nodes
ValueList exclusionNodes;
exclusionNodes = {
Value(renderer.getPlugin("FloorShape@node"))
};
clipper.set_exclusion_nodes(exclusionNodes);
// Include the nodes from the list
clipper.set_exclusion_mode(false);
// Perform subtraction
clipper.set_invert_inside(1);
// Attach the blue material
clipper.set_material(renderer.getPlugin("Blue_Mtl@mtlsingle"));
 
// Start rendering.
renderer.startSync();
// Wait for rendering to end.
renderer.waitForRenderEnd();
 
return 0;
}
using System;
using System.IO;
using System.Collections.Generic;
using VRay;
using VRay.Plugins;
 
namespace _clipperMesh
{
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("cornell_new.vrscene");
 
Node clipMesh = renderer.GetPlugin<Node>("Sphere0Shape2@node");
Transform updatedTransform = clipMesh.Transform;
// Modify the copy of the clipMesh transform.
updatedTransform = updatedTransform.ReplaceOffset(updatedTransform.Offset + new Vector(0, -20, 0));
// Update the transform value in clipMesh (applying the changes above).
clipMesh.Transform = updatedTransform;
 
// Create a VRayClipper plugin
VRayClipper clipper = renderer.NewPlugin<VRayClipper>();
// Assign a node to get mesh from
clipper.ClipMesh = clipMesh;
// Enable the clipper
clipper.Enabled = true;
// List of exclusion nodes
List<object> exclusionNodes = new List<object> {
renderer.GetPlugin("FloorShape@node")
};
clipper.ExclusionNodes = exclusionNodes;
// Include the nodes from the list
clipper.ExclusionMode = false;
// Perform subtraction
clipper.InvertInside = 1;
// Attach the blue material
clipper.Material = renderer.GetPlugin("Blue_Mtl@mtlsingle");
 
// 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("cornell_new.vrscene", function(err) {
if (err) throw err;
 
var clipMesh = renderer.plugins["Sphere0Shape2@node"];
var updatedTransform = clipMesh.transform;
// Modify the copy of the clipMesh transform.
updatedTransform = updatedTransform.replaceOffset(updatedTransform.offset.add(vray.Vector(0, -20, 0)));
// Update the transform value in clipMesh (applying the changes above).
clipMesh.transform = updatedTransform;
 
// Create a VRayClipper plugin
var clipper = renderer.classes.VRayClipper();
// Assign a node to get mesh from
clipper.clip_mesh = clipMesh;
// Enable the clipper
clipper.enabled = true;
// List of exclusion nodes
var exclusionNodes = vray.List(
renderer.plugins["FloorShape@node"]
);
clipper.exclusion_nodes = exclusionNodes;
// Include the nodes from the list
clipper.exclusion_mode = false;
// Perform subtraction
clipper.invert_inside = 1;
// Attach the blue material
clipper.material = renderer.plugins["Blue_Mtl@mtlsingle"];
 
// Start rendering.
renderer.start(function(err) {
if (err) throw err;
// Wait for rendering to end.
renderer.waitForRenderEnd(function() {
renderer.close();
});
});
});

Sonuç #

Notlar #


  • VRayClipper en iyi “kapalı” nesnelerle çalışır. Açık nesnelerde (karşılık gelen bir arka yüzü olmayan) sonuçlar iyi tanımlı değildir.

  • Şu anda VRayClipper, sahnede üst üste binen üçgenler varsa, bunların aynı nesnenin parçası olup olmamasına bakılmaksızın, görüntüde bozulmalara neden olabilir.

  • Çoklu/Alt nesne için Malzeme Kimliği Ayarla seçeneğinin kullanılması gerektiğini unutmayın  ; bu,  MultiMatteElement’te Malzeme Kimliği  gibi davranmaz  .

Tarafından desteklenmektedir BetterDocs

Bir yanıt yazın

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