View Categories

Spot Işık

< 1 dakika okuma

Ele alacağımız bir sonraki ışık türü spot ışığıdır. Bu, el fenerinden gelen ışık gibi konik spot ışığını temsil eder.

Parametreler #


Light Rectangle  ve  Light Omni eklentilerinin ortak parametrelerine ek olarak  ,  LightSpot eklentisi aşağıdaki özel parametrelerden de etkilenir:

  • koni açısı  – Tüm spot konisinin açısı, radyan cinsinden.

  • PenumbraAngle  – Yarı gölge bölgesi, radyan cinsinden; pozitif değer leke konisinin dışında, negatif değer ise içindedir.

  • dropOff  – dropOff özniteliği

  • falloffType  – Yarı gölge bölgesindeki geçiş türü; 0 – doğrusal; 1 – düzgün kübik

  • barnDoor  – gerçek bir ahır kapısı efekti oluşturmak için kullanılır.

  • barnDoorLeft  – ışık yönü ile sol ahır kapısı arasındaki açı

  • barnDoorRight  – ışık yönü ile sağ ahır kapısı arasındaki açı

  • barnDoorTop  – ışık yönü ile üst ahır kapısı arasındaki açı

  • barnDoorBottom  – ışık yönü ile ahır kapısının alt kısmı arasındaki açı

  • useDecayRegions  – Bozunma bölgelerini kullanmak için True değeri.

  • startDistance1  – İlk bozunma bölgesinin başlangıcı

  • endDistance1  – İlk bozunma bölgesinin sonu

  • startDistance2  – İkinci bozunma bölgesinin başlangıcı

  • endDistance2  – İkinci bozunma bölgesinin sonu

  • startDistance3  – Üçüncü bozunma bölgesinin başlangıcı

  • endDistance3 – Üçüncü bozunma bölgesinin sonu

# 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)
 
# 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, 'lighting.vrscene'))
    # Remove original light source from the scene.
    del renderer.plugins["VRayLightDomeShape1"]
    # LightSpot is a light source plugin that can be used to simulate lights created by a spotlight.
    light = renderer.classes.LightSpot()
    # Specify the light position, rotation and scale.
    light.transform = vray.Transform(
        vray.Matrix(
            vray.Vector(2.220446e-016, 5.551115e-017, 1),
            vray.Vector(0.8358706, 0.5489266, -2.160721e-016),
            vray.Vector(-0.5489266, 0.8358706, 7.548605e-017)),
        vray.Vector(0, 197.3685320682933, 76.22419500664734))
    # Specify the light intensity based on the 'units' parameter.
    light.intensity = 800
    # Specify the color of the light in RGB float values and alpha(1.0f)
    light.color = vray.AColor(1, 0.85, 0.5)
    # Specify the cone angle of the spot in radians.
    light.coneAngle = 0.69
    # Specify the penumbra angle of the spot in radians. Positive is outside the spot cone, negative is inside.
    light.penumbraAngle = 0.07
    # Specify the light decay type.
    # Possible values are:
    #   0 (No Decay)
    #   1 (Linear)
    #   2 (Quadratic) - default
    #   3 (Cubic)
    light.decay = 1
    # Specify shadow offset from the surface. Helps to prevent polygonal shadow artifacts on low-poly surfaces.
    light.shadowBias = 0.02
    # Specify that the bumped normal should be used to check if the light direction is below the surface.
    light.bumped_below_surface_check = True
    # 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
    # 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("lighting.vrscene");
// Remove original light source from the scene.
renderer.deletePlugin("VRayLightDomeShape1");
// LightSpot is a light source plugin that can be used to simulate lights created by a spotlight.
LightSpot light = renderer.newPlugin<LightSpot>();
// Specify the light position, rotation and scale.
light.set_transform(Transform(
Matrix(
Vector(2.220446e-016, 5.551115e-017, 1.0),
Vector(0.8358706, 0.5489266, -2.160721e-016),
Vector(-0.5489266, 0.8358706, 7.548605e-017)),
Vector(0.0, 197.3685320682933, 76.22419500664734)));
// Specify the light intensity based on the 'units' parameter.
light.set_intensity(800);
// Specify the color of the light in RGB float values and alpha(1.0f)
light.set_color(AColor(1, 0.85, 0.5));
// Specify the cone angle of the spot in radians.
light.set_coneAngle(0.69f);
// Specify the penumbra angle of the spot in radians. Positive is outside the spot cone, negative is inside.
light.set_penumbraAngle(0.07f);
// Specify the light decay type. Possible values are:
//   0 (No Decay)
//   1 (Linear)
//   2 (Quadratic) - default
//   3 (Cubic)
light.set_decay(1);
// Specify shadow offset from the surface. Helps to prevent polygonal shadow artifacts on low-poly surfaces.
light.set_shadowBias(0.02f);
// 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);
// 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);
// Start rendering.
renderer.startSync();
// Wait for rendering to end.
renderer.waitForRenderEnd();
return 0;
}
using System;
using System.IO;
using VRay;
using VRay.Plugins;
 
namespace _10_spot
{
    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");
                // LightSpot is a light source plugin that can be used to simulate lights created by a spotlight.
                LightSpot light = renderer.NewPlugin<LightSpot>();
                // Specify the light position, rotation and scale.
                light.Transform = new Transform(
                    new Matrix(
                        new Vector(2.220446e-016, 5.551115e-017, 1),
                        new Vector(0.8358706, 0.5489266, -2.160721e-016),
                        new Vector(-0.5489266, 0.8358706, 7.548605e-017)),
                    new Vector(0, 197.3685320682933, 76.22419500664734));
                // Specify the light intensity based on the 'units' parameter.
                light.Intensity = 800;
                // Specify the color of the light in RGB float values and alpha = 1.
                light.Color = new AColor(1, 0.85, 0.5);
                // Specify the cone angle of the spot in radians.
                light.ConeAngle = 0.69F;
                // Specify the penumbra angle of the spot in radians. Positive is outside the spot cone, negative is inside.
                light.PenumbraAngle = 0.07F;
                // Specify the light decay type. Possible values are:
                //   0 (No Decay)
                //   1 (Linear)
                //   2 (Quadratic) - default
                //   3 (Cubic)
                light.Decay = 1;
                // Specify shadow offset from the surface. Helps to prevent polygonal shadow artifacts on low-poly surfaces.
                light.ShadowBias = 0.02F;
                // Specify that the bumped normal should be used to check if the light direction is below the surface.
                light.BumpedBelowSurfaceCheck = true;
                // Specify the number of parameter samples for motion blur.
                light.Nsamples = 1;
                // 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;
                // 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"];
    // LightSpot is a light source plugin that can be used to simulate lights created by a spotlight.
    var light = renderer.classes.LightSpot();
    // Specify the light position, rotation and scale.
    light.transform = vray.Transform(
        vray.Matrix(
            vray.Vector(2.220446e-016, 5.551115e-017, 1),
            vray.Vector(0.8358706, 0.5489266, -2.160721e-016),
            vray.Vector(-0.5489266, 0.8358706, 7.548605e-017)),
        vray.Vector(0, 197.3685320682933, 76.22419500664734));
    // Specify the light intensity based on the 'units' parameter.
    light.intensity = 800;
    // Specify the color of the light in RGB float values and alpha(1.0f)
    light.color = vray.AColor(1, 0.85, 0.5);
    // Specify the cone angle of the spot in radians.
    light.coneAngle = 0.69;
    // Specify the penumbra angle of the spot in radians. Positive is outside the spot cone, negative is inside.
    light.penumbraAngle = 0.07;
    // Specify the light decay type. Possible values are:
    //   0 (No Decay)
    //   1 (Linear)
    //   2 (Quadratic) - default
    //   3 (Cubic)
    light.decay = 1;
    // Specify shadow offset from the surface. Helps to prevent polygonal shadow artifacts on low-poly surfaces.
    light.shadowBias = 0.02;
    // Specify that the bumped normal should be used to check if the light direction is below the surface.
    light.bumped_below_surface_check = true;
    // 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;
    // 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_Spot.vrscene” olarak adlandırılır ve sahne paketinde bulunabilir   (içinde bulunan farklı parametrelere ilişkin yorumlar mevcuttur).

Örnek #


 Burada bir sahneye nasıl LightSpot ekleneceğini göstereceğiz .

Tarafından desteklenmektedir BetterDocs

Bir yanıt yazın

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