View Categories

Kubbe Işığı

1 dakika okuma

Bu bölümde, V-Ray’de biraz daha karmaşık bir ışık kaynağı olan kubbe ışığını ele alacağız. Bu ışık kaynağı, sahneyi sonsuz bir şekilde çevreleyen ışık yayan bir kubbeyi temsil eder. Genellikle küresel doku dosyasıyla HDR görüntü tabanlı aydınlatma (IBL) için kullanılır.

Parametreler #


Işıklar için kullanılan genel parametrelerin yanı sıra,  LightDome eklentisinin bazı özel parametreleri de vardır:

  • dome_spherical – Kubbeyi tam bir küreye genişletmek için true olarak ayarlayın. Varsayılan olarak, sahnenin tepe noktasında merkezlenmiş yalnızca yarım bir kubbedir. SettingsUnitsInfo::scene_upDir’in doğru şekilde ayarlanması gerekir.

  • dome_tex  – Kullanılacak bir doku eklentisi. Bunun genellikle küresel haritalama gerektirdiğini unutmayın.

  • use_dome_tex  – Dome_tex’i kullanmak için bunu da true olarak ayarlamanız gerekiyor.

  • tex_resolution  – Doku aslında bu çözünürlükte yeniden örneklenir. Varsayılan değer 512’dir, bu nedenle yüksek çözünürlüklü bir görüntünüz olsa bile, bunu artırmazsanız pikselli görünebilir. Bu daha fazla bellek tüketecektir.

  • dome_targetRadius  – Foton haritalı kostikler veya küresel foton haritası kullanıldığında, fotonların fırlatıldığı ışık simgesinin etrafındaki bir küreyi tanımlar.

  • dome_emitRadius  – Işık simgesinin etrafında, fotonların hedef yarıçap alanına doğru fırlatıldığı bir küre tanımlar.

  • tex_adaptive  – Doku parlaklığına göre örneklemenin uyarlanabilirliği (0.0 – uyarlanabilirlik yok; 1.0 – tam uyarlanabilirlik).

  • dome_rayDistance  – Gölge ışınlarının izleneceği maksimum mesafeyi belirtmenizi sağlar.

  • dome_rayDistanceMode  – Gölge ışınlarının izleneceği maksimum mesafenin belirlenme yöntemini belirtir. 0: Yok , 1:  GI Ayarlarından  (Işın Mesafesi değeri, GI ayarlarındaki ışın mesafesi parametresi tarafından belirlenir) ve 2:  Açık  (ışın mesafesi değeri,  dome_rayDistance  parametresi tarafından belirlenir) olabilir.

  • affect_alpha  – Bu seçenek etkinleştirildiğinde, kubbe dokusunun eşlendiği sanal küre, alfa kanalında katı bir nesne olarak görünür olacaktır.

Örnek #


Burada bir sahneye LightDome eklemeyi göstereceğiz .

# 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"]
 
    # The UVWGenEnvironment allows spherical, cube, etc. textures to be
    # mapped on the environment color slot or dome lights.
    uvwgen = renderer.classes.UVWGenEnvironment()
    # Specify the type and shape of the texture.
    # Possible values are:
    #   angular
    #   cubic
    #   mirror_ball
    #   spherical - default
    #   screen
    #   max_spherical
    #   spherical_vray
    #   max_cylindrical
    #   max_shrink_wrap
    uvwgen.mapping_type = 'spherical'
    # Specify transformation of the input directions.
    uvwgen.uvw_matrix = vray.Matrix(
        vray.Vector(1, 0, 0),
        vray.Vector(0, 0, 1),
        vray.Vector(0, -1, 0))
    uvwgen.ground_on = 1
    bitmap = renderer.classes.BitmapBuffer()
    # unlike JPG files, HDR files are linear
    bitmap.transfer_function = 0
    bitmap.file = os.path.join(SCENE_PATH, 'assets', 'Sea_D.hdr')
    texture = renderer.classes.TexBitmap()
    # Specify UVW generator for the texture.
    texture.uvwgen = uvwgen
    # Specify the bitmap that the texture will be using.
    texture.bitmap = bitmap
    # LightDome is a light source plugin that can be used to create lights that
    # shine inward at the scene as if from a spherical or hemispherical light source outside the scene extents.
    # This light is frequently used for image-based lighting using panoramic HDR images used as environments.
    light = renderer.classes.LightDome()
    # Specify the light position, rotation and scale.
    light.transform = vray.Transform(
        vray.Matrix(
            vray.Vector(0, 0, 1),
            vray.Vector(1, 0, 0),
            vray.Vector(0, 1, 0)),
        vray.Vector(0, 0, 0))
    # Switches between a hemispherical or (full) spherical shape of the light.
    # Possible values are:
    #   True (Sphere)
    #   False (Hemisphere)
    light.dome_spherical = True
    # Specify the light intensity based on the 'units' parameter.
    light.intensity = 4
    # Specify the light texture.
    light.dome_tex = texture
    # Enable the use of a light texture.
    # If "use_dome_tex = False" the 'color' of the light will be used instead.
    light.use_dome_tex = True
    # 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
    # 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");
// The UVWGenEnvironment allows spherical, cube, etc.textures to be mapped on the environment color slot or dome lights.
UVWGenEnvironment uvwgen = renderer.newPlugin<UVWGenEnvironment>();
// Specify the type and shape of the texture.
// Possible values are:
//   angular
//   cubic
//   mirror_ball
//   spherical - default
//   screen
//   max_spherical
//   spherical_vray
//   max_cylindrical
//   max_shrink_wrap
uvwgen.set_mapping_type("spherical");
// Specify transformation of the input directions.
uvwgen.set_uvw_matrix(
Matrix(
Vector(1.0, 0.0, 0.0),
Vector(0.0, 0.0, 1.0),
Vector(0.0, -1.0, 0.0)));
uvwgen.set_ground_on(1);
BitmapBuffer bitmap = renderer.newPlugin<BitmapBuffer>();
// unlike JPG files, HDR files are linear
bitmap.set_transfer_function(0);
bitmap.set_file("assets/Sea_D.hdr");
TexBitmap texture = renderer.newPlugin<TexBitmap>();
// Specify UVW generator for the texture.
texture.set_uvwgen(uvwgen);
// Specify the bitmap that the texture will be using.
texture.set_bitmap(bitmap);
// LightDome is a light source plugin that can be used to create lights that
// shine inward at the scene as if from a spherical or hemispherical light source outside the scene extents.
// This light is frequently used for image-based lighting using panoramic HDR images used as environments.
LightDome light = renderer.newPlugin<LightDome>();
// Specify the light position, rotation and scale.
light.set_transform(Transform(
Matrix(
Vector(0.0, 0.0, 1.0),
Vector(1.0, 0.0, 0.0),
Vector(0.0, 1.0, 0.0)),
Vector(0.0, 0.0, 0.0)));
// Switches between a hemispherical or (full) spherical shape of the light.
// Possible values are:
//   true (Sphere)
//   false (Hemisphere) - default
light.set_dome_spherical(true);
// Specify the light intensity based on the 'units' parameter.
light.set_intensity(4);
// Specify the light texture.
light.set_dome_tex(texture);
// Enable the use of a light texture.
// If "use_dome_tex = false" the 'color' of the light will be used instead.
light.set_use_dome_tex(true);
// 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);
// Start rendering.
renderer.startSync();
// Wait for rendering to end.
renderer.waitForRenderEnd();
return 0;
}
using System;
using System.IO;
using VRay;
using VRay.Plugins;
 
namespace _04_dome
{
    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");
                // The UVWGenEnvironment allows spherical, cube, etc. textures to be mapped on the environment color slot or dome lights.
                UVWGenEnvironment uvwgen = renderer.NewPlugin<UVWGenEnvironment>();
                // Specify the type and shape of the texture.
                // Possible values are:
                //   angular
                //   cubic
                //   mirror_ball
                //   spherical - default
                //   screen
                //   max_spherical
                //   spherical_vray
                //   max_cylindrical
                //   max_shrink_wrap
                uvwgen.MappingType = "spherical";
                // Specify transformation of the input directions.
                uvwgen.UvwMatrix = new Matrix(
                    new Vector(1, 0, 0),
                    new Vector(0, 0, 1),
                    new Vector(0, -1, 0));
                uvwgen.GroundOn = 1;
                BitmapBuffer bitmap = renderer.NewPlugin<BitmapBuffer>();
                // unlike JPG files, HDR files are linear
                bitmap.TransferFunction = 0;
                bitmap.File = Path.Combine("assets", "Sea_D.hdr");
                TexBitmap texture = renderer.NewPlugin<TexBitmap>();
                // Specify UVW generator for the texture.
                texture.Uvwgen = uvwgen;
                // Specify the bitmap that the texture will be using.
                texture.Bitmap = bitmap;
                // LightDome is a light source plugin that can be used to create lights that
                // shine inward at the scene as if from a spherical or hemispherical light source outside the scene extents.
                // This light is frequently used for image-based lighting using panoramic HDR images used as environments.
                LightDome light = renderer.NewPlugin<LightDome>();
                // Specify the light position, rotation and scale.
                light.Transform = new Transform(
                    new Matrix(
                        new Vector(0, 0, 1),
                        new Vector(1, 0, 0),
                        new Vector(0, 1, 0)),
                    new Vector(0, 0, 0));
                // Switches between a hemispherical or (full) spherical shape of the light.
                // Possible values are:
                //   true (Sphere)
                //   false (Hemisphere)
                light.DomeSpherical = true;
                // Specify the light intensity based on the 'units' parameter.
                light.Intensity = 4;
                // Specify the light texture.
                light.DomeTex = texture;
                // Enable the use of a light texture.
                // If "use_dome_tex = False" the 'color' of the light will be used instead.
                light.UseDomeTex = true;
                // 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;
                // 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"];
    // The UVWGenEnvironment allows spherical, cube, etc. textures to be mapped on the environment color slot or dome lights.
    var uvwgen = renderer.classes.UVWGenEnvironment();
    // Specify transformation of the input directions.
    uvwgen.uvw_matrix = vray.Matrix(
        vray.Vector(1, 0, 0),
        vray.Vector(0, 0, 1),
        vray.Vector(0, -1, 0));
    uvwgen.ground_on = 1;
    // Specify the type and shape of the texture.
    // Possible values are:
    //   angular
    //   cubic
    //   mirror_ball
    //   spherical - default
    //   screen
    //   max_spherical
    //   spherical_vray
    //   max_cylindrical
    //   max_shrink_wrap
    uvwgen.mapping_type = "spherical";
    var bitmap = renderer.classes.BitmapBuffer();
// unlike JPG files, HDR files are linear
    bitmap.transfer_function = 0;
    bitmap.file = path.join(SCENE_PATH, "assets", "Sea_D.hdr");
    var texture = renderer.classes.TexBitmap();
    // Specify UVW generator for the texture.
    texture.uvwgen = uvwgen;
    // Specify the bitmap that the texture will be using.
    texture.bitmap = bitmap;
    // LightDome is a light source plugin that can be used to create lights that
    // shine inward at the scene as if from a spherical or hemispherical light source outside the scene extents.
    // This light is frequently used for image-based lighting using panoramic HDR images used as environments.
    var light = renderer.classes.LightDome();
    // Specify the light position, rotation and scale.
    light.transform = vray.Transform(
        vray.Matrix(
            vray.Vector(0, 0, 1),
            vray.Vector(1, 0, 0),
            vray.Vector(0, 1, 0)),
        vray.Vector(0, 0, 0));
    // Switches between a hemispherical or (full) spherical shape of the light.
    // Possible values are:
    //   true (Sphere)
    //   false (Hemisphere)
    light.dome_spherical = true;
    // Specify the light intensity based on the 'units' parameter.
    light.intensity = 4;
    // Specify the light texture.
    light.dome_tex = texture;
    // Enable the use of a light texture.
    // If "use_dome_tex = false" the 'color' of the light will be used instead.
    light.use_dome_tex = true;
    // 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;
    // 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_Dome.vrscene” olarak adlandırılır ve sahne paketinde bulunabilir   (içinde bulunan farklı parametrelere ilişkin yorumlar mevcuttur).

Bunu yerel olarak test etmek için, kubbe dokusunun mutlak yolunu değiştirmeniz gerekecek (dahil edilen sahnede bulunur: “vrscenes/light_dome.vrscene”).

Tarafından desteklenmektedir BetterDocs

Bir yanıt yazın

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