View Categories

Işık Omni

< 1 dakika okuma

Bu bölümde V-Ray’deki en basit ışık kaynağı olan çok yönlü ışığı ele alacağız. Çok yönlü ışık, noktasal bir ışık kaynağını temsil eder. Işık şiddetinin azalma hızı ve yumuşak gölgeler oluşturma (aşağıda shadowRadius) parametrelerine sahiptir.

Belirli parametreler #


Genel ışık parametrelerinin yanı sıra, çok yönlü ışık kaynağının kendine özgü bazı parametreleri de vardır:

  • areaSpeculars  – Doğruysa, vurgular ışığın şekliyle eşleşir; yanlışsa, vurgular her zaman noktasal bir ışıktan hesaplanmış gibi hesaplanır.

  • shadowRadius  – Işığın boyutu; 0.0 noktasal ışık anlamına gelir, daha büyük değerler yumuşak (alan) gölgeler oluşturur.

  • shadowRadius_tex  – Mevcut olması durumunda gölge yarıçapı parametresini geçersiz kılacak bir float doku.

  • shadowSubdivs  – Aydınlatmayı hesaplamak için kullanılan örnek sayısını kontrol eder.

  • bozunma  – Mesafe bozunma fonksiyonunun üssü. Varsayılan değer ters kare yasasıdır. 0 bozunmayı devre dışı bırakır.

Örnek #


Aşağıdaki örnek, LightOmni’nin alan gölgeleriyle birlikte kullanımını göstermektedir .

#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("lighting.vrscene");
// Remove original light source from the scene.
renderer.deletePlugin("VRayLightDomeShape1");
// LightOmni is a light source plugin that can be used to create physically accurate 
// omnidirectional lights that cast rays in all directions from a single source.
LightOmni light = renderer.newPlugin<LightOmni>();
// Specify the light position, rotation and scale.
light.set_transform(Transform(
Matrix(
Vector(1.0, 0.0, 0.0),
Vector(0.0, 1.0, 0.0),
Vector(0.0, 0.0, 1.0)),
Vector(0.0, 100.7851212422053, 48.17329059810792)));
// Specify the light intensity based on the 'units' parameter.
light.set_intensity(44000);
// Specify the size of the light for shadows. The light is not directly visible to the camera.
// This parameter controls the softness of the shadows. A value of 0.0 produces a point light. Larger values result in soft (area) shadows.
light.set_shadowRadius(1.2f);
// Specify shadow offset from the surface. Helps to prevent polygonal shadow artifacts on low-poly surfaces.
light.set_shadowBias(0.02f);
// Specify a threshold for the light intensity, below which the light will
// not be computed. This can be useful in scenes with many lights, where you
// want to limit the effect of the lights to some distance around them.
// Larger values cut away more from the light; lower values make the light
// range larger. If you specify 0.0, the light will be calculated for all surfaces.
light.set_cutoffThreshold(0.005f);
// Specify that the bumped normal should be used to check if the light direction is below the surface.
light.set_bumped_below_surface_check(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 _02_omni
{
    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("lighting.vrscene");
                // Remove original light source from the scene.
                renderer.DeletePlugin("VRayLightDomeShape1");
                // LightOmni is a light source plugin that can be used to create physically accurate 
                // omnidirectional lights that cast rays in all directions from a single source.
                LightOmni light = renderer.NewPlugin<LightOmni>();
                // Specify the light position, rotation and scale.
                light.Transform = new Transform(
                    new Matrix(
                        new Vector(1.0, 0, 0),
                        new Vector(0, 1.0, 0),
                        new Vector(0, 0, 1.0)),
                    new Vector(0, 100.7851212422053, 48.17329059810792));
                // Specify the light intensity based on the 'units' parameter.
                light.Intensity = 44000;
                // Specify the size of the light for shadows. The light is not directly visible to the camera.
                // This parameter controls the softness of the shadows. A value of 0.0 produces a point light. Larger values result in soft (area) shadows.
                light.ShadowRadius = 1.2F;
                // Specify shadow offset from the surface. Helps to prevent polygonal shadow artifacts on low-poly surfaces.
                light.ShadowBias = 0.02F;
                // Specify a threshold for the light intensity, below which the light will
                // not be computed. This can be useful in scenes with many lights, where you
                // want to limit the effect of the lights to some distance around them.
                // Larger values cut away more from the light; lower values make the light
                // range larger. If you specify 0.0, the light will be calculated for all surfaces.
                light.CutoffThreshold = 0.005F;
                // Specify that the bumped normal should be used to check if the light direction is below the surface.
                light.BumpedBelowSurfaceCheck = 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("lighting.vrscene", function(err) {
    if (err) throw err;
    // Remove original light source from the scene.
    delete renderer.plugins["VRayLightDomeShape1"];
    // LightOmni is a light source plugin that can be used to create physically accurate 
    // omnidirectional lights that cast rays in all directions from a single source.
    var light = renderer.classes.LightOmni();
    // Specify the light position, rotation and scale.
    light.transform = vray.Transform(
        vray.Matrix(
            vray.Vector(1.0, 0, 0),
            vray.Vector(0, 1.0, 0),
            vray.Vector(0, 0, 1.0)),
        vray.Vector(0, 100.7851212422053, 48.17329059810792));
    // Specify the light intensity based on the 'units' parameter.
    light.intensity = 44000;
    // Specify the size of the light for shadows. The light is not directly visible to the camera.
    // This parameter controls the softness of the shadows. A value of 0.0 produces a point light. Larger values result in soft (area) shadows.
    light.shadowRadius = 1.2;
    // Specify shadow offset from the surface. Helps to prevent polygonal shadow artifacts on low-poly surfaces.
    light.shadowBias = 0.02;
    // Specify a threshold for the light intensity, below which the light will
    // not be computed. This can be useful in scenes with many lights, where you
    // want to limit the effect of the lights to some distance around them.
    // Larger values cut away more from the light; lower values make the light
    // range larger. If you specify 0.0, the light will be calculated for all surfaces.
    light.cutoffThreshold = 0.005;
    // Specify that the bumped normal should be used to check if the light direction is below the surface.
    light.bumped_below_surface_check = true;
    // Start rendering.
    renderer.start(function(err) {
        if (err) throw err;
        // Wait for rendering to end.
        renderer.waitForRenderEnd(function() {
            renderer.close();
        });
    });

Sonuç #


 

Bu render için kullanılan sahne “Lighting_Omni.vrscene” olarak adlandırılır ve sahne paketinde bulunabilir (içinde bulunan farklı parametrelere ilişkin yorumlar mevcuttur). 

Tarafından desteklenmektedir BetterDocs

Bir yanıt yazın

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