View Categories

Güneş Gökyüzü

19 dakika okuma

giriiş #


Bu bölümde, V-Ray’deki güneş ve gökyüzü sistemi adı verilen kendine özgü bir aydınlatma biçimini ele alacağız. Eklentinin amacı, güneş ışığının hassas bir fiziksel modelini temsil etmektir. Paralel ışınları simüle eder. Işınların yoğunluğunu ve boyutunu değiştirerek yumuşak gölgeler elde edilebilir. Simülasyonun rengi, ışınların yere düşme açısına bağlı olarak gerçek bir güneşin fiziksel modeline uyarlanır.

Güneş ışığını simüle etmek için küresel ışık  da kullanılabilir  , çünkü bu ışık türü Güneş Işığı’nın aksine Işınım Haritası’na katkıda bulunur. Bununla birlikte, bu bölümde yalnızca Güneş Işığı’ndan bahsedeceğiz.

Amaç #


Güneş-gökyüzü sisteminin ideal hedefi, şu biçimde bir fonksiyon bulmaktır:

  • Güneş

(konum, tarih, saat, koşullar) → spektral ışıma (güneş yönü, koşullar) → spektral ışıma

  • Gökyüzü

(görüş yönü, görüş konumu, tarih, saat, koşullar) → spektral parlaklık (görüş yönü, güneş yönü, koşullar) → spektral parlaklık

Güneş #


Aşağıdaki resim, güneş konusuyla ilgili yaygın terimleri göstermektedir:

  • Yeşil – yükseklik

  • Kırmızı – azimut

Güneşin fiziksel özelliklerinden biraz bahsedeceğiz, çünkü bunlar ışık spektrumunu etkiliyor:

  • Yarıçap – 695000 km

  • Dünyaya uzaklık – 149140000 km

  • Dünya Üzerine Toplam Güneş Işınımı – 1366 (1413 – 1321) W/m2

  • Katı Açı – 6×10-5 steradyan

İşte Güneş Spektrumunun bir resmi. Mavi çizgi Dünya’ya gelen ışığı, turuncu çizgi ise atmosferden geçtikten sonra geriye kalan ışığı temsil ediyor:

Atmosferik Olaylar #


Saçılma

Işık, izleyiciye ulaşana kadar birkaç kez saçılabilir, ancak genellikle birincil saçılma baskındır. Saçılma, parçacık boyutuyla ilişkilidir. Atmosferdeki saçılma olmasaydı, gökyüzü Ay’daki gibi siyah olurdu.

Saçılma

  • Reyleigh saçılması

Işığın dalga boyundan çok daha küçük parçacıklar (atomlar ve moleküller) için (< 0,1λ). Temelde saçılma λ −4 ile orantılıdır.

 

 

Saçılma

  • Mie saçılımı

  • Moleküllerden daha büyük, ancak sisten (pus, pus aerosolü) daha küçük parçacıklar için

  • Saçılma dalga boyuna göre daha homojendir ve gökyüzünün beyazlaşmasına neden olur.

  • Kaynaklar – volkanik patlamalar, orman yangınları, kozmik bombardıman, okyanuslar.

  • Parametrelendirme – bulanıklık. Aşağıdaki formülde tm moleküllerden kaynaklanan bulanıklığı, th ise nemden kaynaklanan bulanıklığı ifade eder.

  • Spektral Soğurma

Atmosferdeki farklı gazların farklı emilim frekansları vardır. Burada farklı elementleri görüyoruz: oksijen, ozon, buhar, karbondioksit.

Gökyüzü modelleri #


  • Ölçülen gökyüzü verilerini doğrudan kullanın – Uluslararası Gün Işığı Ölçüm Programı; spektral veri içermez.

  • Tam simülasyon – Keyfi olarak karmaşık atmosferik koşullarla çalışmak gerekiyor ve simülasyon çok yavaş.

  • Analitik model – Daha hızlı hesaplanır ve az sayıda parametre ile kontrol edilir.

Model Türleri #

Hosek ve ark. – Seçildiğinde, Gökyüzü prosedürel dokusu Hosek ve ark. yöntemine göre oluşturulur ve farklı bir zemin ve gökyüzü gradyanı kullanır.

Preetham ve ark.  – Seçildiğinde, gökyüzü prosedürel dokusu Preetham ve ark. yöntemine göre oluşturulur.

CIE Clear  – Seçildiğinde, gökyüzü prosedürel dokusu, açık gökyüzü için CIE yöntemine göre oluşturulur.

CIE Bulutlu Hava – Seçildiğinde, bulutlu gökyüzü için CIE yöntemine dayalı olarak gökyüzü prosedürel dokusu oluşturulur.

PRG Clear Sky  – Gökyüzü prosedürel dokusu, geliştirilmiş gün doğumu ve gün batımı gökyüzü özelliklerine sahip PRG Clear Sky yöntemine göre oluşturulmuştur.


Örnek: Gökyüzü Modelleri #

Aşağıdaki örnekler farklı gökyüzü modeli  türlerini göstermektedir; bu örneklerde gökyüzü için varsayılan değerler kullanılmıştır.

Hosek ve ark.

Preetham ve ark.

CIE Clear

CIE Bulutlu

PRG Clear Sky

Parlaklık #

İşte Perez ve diğerlerinin parlaklık için geliştirdiği parametre modelinin bir örneği:

  • v – giriş görünüm yönü

  • Θ ve Θs – azimut açıları

  • γ – görüş ve güneş yönleri arasındaki açı. Bu girdi parametreleriyle amacımız, belirli bir noktadaki spektrumu bulmaktır.

Model aşağıdaki parametreleri dikkate alır: * Ufkun kararması veya aydınlanması * Ufuk yakınındaki parlaklık gradyanı * Güneş çevresi bölgesinin göreceli yoğunluğu * Güneş çevresi bölgesinin genişliği * Göreceli geri saçılan ışık

Renk #

Güneş ışığının rengini hesaplamak için kullanılan modeller de mevcuttur, ancak bunları ayrıntılı olarak ele almayacağız.

Geçirgenlik #

Simülasyonun son adımı, aşağıdaki faktörleri dikkate alarak, Dünya yüzeyine iletilen doğrudan uzaydan gelen ışık miktarını belirlemektir:

  • Reyleigh saçılması

  • Aerosol saçılması (bulanıklık)

  • Ozon emilimi

  • Karışık gazların emilimi

  • Su buharı emilimi

Havadan perspektif model #

V-Ray’de atmosferik perspektif etkilerini de hesaba katıyoruz, ancak burada bunlara değinmeyeceğiz.

Kod Örneği #

Python

</p>
<div># Compatibility with Python 2.7.</div>
<div>from __future__ import print_function</div>
<div></div>
<div># The directory containing the vray shared object should be present in the PYTHONPATH environment variable.</div>
<div># Try to import the vray module from VRAY_SDK/python, if it is not in PYTHONPATH</div>
<div>import sys, os</div>
<div>VRAY_SDK = os.environ.get('VRAY_SDK')</div>
<div>if VRAY_SDK:</div>
<div>    sys.path.append(os.path.join(VRAY_SDK, 'python'))</div>
<div>import vray</div>
<div></div>
<div>SCENE_PATH = os.path.join(os.environ.get('VRAY_SDK'), 'scenes')</div>
<div># Change process working directory to SCENE_PATH in order to be able to load relative scene resources.</div>
<div>os.chdir(SCENE_PATH)</div>
<div></div>
<div># Create an instance of VRayRenderer with default options.</div>
<div># The renderer is automatically closed after the `with` block.</div>
<div>with vray.VRayRenderer() as renderer:</div>
<div>    # Register a simple log callback. Always useful for debugging.</div>
<div>    def dumpMsg(renderer, message, level, instant):</div>
<div>        if level == vray.LOGLEVEL_ERROR:</div>
<div>            print("[ERROR]", message)</div>
<div>        elif level == vray.LOGLEVEL_WARNING:</div>
<div>            print("[Warning]", message)</div>
<div>        elif level == vray.LOGLEVEL_INFO:</div>
<div>            print("[info]", message)</div>
<div>        # Uncomment for testing, but you might want to ignore these in real code</div>
<div>        #else: print("[debug]", message)</div>
<div>    renderer.setOnLogMessage(dumpMsg)</div>
<div>    # Load scene from a file.</div>
<div>    renderer.load(os.path.join(SCENE_PATH, 'lighting.vrscene'))</div>
<div>    # Remove original light source from the scene.</div>
<div>    del renderer.plugins["VRayLightDomeShape1"]</div>
<div>    # Add a physical camera and allowed it to affect exposure.</div>
<div>    # Otherwise the Sun produces overbright values if not using a physical</div>
<div>    # setup and without changing its intensity.</div>
<div>    camera = renderer.classes.CameraPhysical.getInstanceOrCreate()</div>
<div>    camera.exposure = 1</div>
<div>    # The V-Ray Sun light together with the Sky texture plugin provides a</div>
<div>    # realistic outdoor illumination system that can be tuned to a specific</div>
<div>    # time of day and athmospheric contents (without clouds). The Sun is</div>
<div>    # represented as a light source at "infinity" similar to a directional</div>
<div>    # light, but with a real radius causing soft shadows.</div>
<div>    sun = renderer.classes.SunLight()</div>
<div>    # Specify the sun rotation.</div>
<div>    # The rotation matrix defines the direction vector of the light. Even</div>
<div>    # though it should be an omni light very far away, it's set as a directional light.</div>
<div>    # Note: The translation vector does NOT affect position as the Sun light</div>
<div>    # source is positioned at "infinity". It is only used by some 3D</div>
<div>    # applications to represent the Sun within the scene with an OpenGL gizmo.</div>
<div>    sun.transform = vray.Transform(</div>
<div>        vray.Matrix(</div>
<div>            vray.Vector(0.9563327, 0, 0.2922803),</div>
<div>            vray.Vector(0.2010161, 0.7259465, -0.6577188),</div>
<div>            vray.Vector(-0.2121799, 0.6877511, 0.6942464)),</div>
<div>        vray.Vector(-94.70224040070444, 306.9639183671097, 309.8629632135933))</div>
<div>    # Initialize the target position.</div>
<div>    # It is used only for caustic effects. Only the translation vector matters.</div>
<div>    sun.target_transform = vray.Transform(</div>
<div>        vray.Matrix(</div>
<div>            vray.Vector(1, 0, 0),</div>
<div>            vray.Vector(0, 1, 0),</div>
<div>            vray.Vector(0, 0, 1)),</div>
<div>        vray.Vector(0, 0, 0))</div>
<div>    # Specify the amount of dust in the air.</div>
<div>    # This property affects the color of the sun and the sky. Smaller values</div>
<div>    # produce a clear and blue sky and sun as you get in the country, while</div>
<div>    # larger values make them yellow and orange as, for example, in a big city.</div>
<div>    sun.turbidity = 2.5</div>
<div>    # Specify the reflective property of the "ground".</div>
<div>    # This property affects sky-dome brightness and color.</div>
<div>    sun.ground_albedo = vray.Color(0.5, 0.5, 0.5)</div>
<div>    # Specify the rotation of the sky texture based on a up vector.</div>
<div>    sun.up_vector = vray.Vector(0, 1, 0)</div>
<div>    # Specify the procedural model that will be used to generate the V-Ray Sky texture.</div>
<div>    # Possible values are:</div>
<div>    #   0 (Preethem)</div>
<div>    #   1 (CIE Clear)</div>
<div>    #   2 (CIE Overcast)</div>
<div>    #   3 (Hosek)</div>
<div>    sun.sky_model = 3</div>
<div>    # Specify shadow offset from the surface. Helps to prevent polygonal shadow artifacts on low-poly surfaces.</div>
<div>    sun.shadowBias = 0.02</div>
<div>    # Specify a color texture for shadows. Overrides the 'shadowColor' parameter.</div>
<div>    sun.shadow_color_tex = vray.AColor(0, 0, 0, 1)</div>
<div>    # The Sky texture emits blue (or warm around dusk and dawn) light from all</div>
<div>    # directions and it is used as an environment texture.</div>
<div>    texture = renderer.classes.TexSky()</div>
<div>    # The Sky texture takes its parameters from a SunLight through this connection.</div>
<div>    # If you don't want a Sun you can set the same parameters on this plugin.</div>
<div>    texture.sun = sun</div>
<div>    # Environment plugin with the V-Ray Sky texture used as an input.</div>
<div>    # It is recommended to use the 'getInstanceOrCreate' method when a settings</div>
<div>    # plugin is needed because there should be at most one instance of its type in the scene.</div>
<div>    environment = renderer.classes.SettingsEnvironment.getInstanceOrCreate()</div>
<div>    environment.bg_tex = texture</div>
<div>    environment.gi_tex = texture</div>
<div>    environment.reflect_tex = texture</div>
<div>    environment.refract_tex = texture</div>
<div>    # Start rendering.</div>
<div>    renderer.startSync()</div>
<div>    # Wait for rendering to end.</div>
<div>    renderer.waitForRenderEnd()</div>
<p>

C++

</p>
<div>#define VRAY_RUNTIME_LOAD_PRIMARY</div>
<div></div>
<div>#include "vraysdk.hpp"</div>
<div>#include "vrayplugins.hpp"</div>
<div>#include "utils.h"</div>
<div></div>
<div>using namespace VRay;</div>
<div>using namespace VRay::Plugins;</div>
<div>using namespace std;</div>
<div></div>
<div>const char *BASE_PATH = getenv("VRAY_SDK");</div>
<div>string SCENE_PATH = (BASE_PATH ? string(BASE_PATH) : string(".")) + PATH_DELIMITER + "scenes";</div>
<div></div>
<div>int main() {</div>
<div>// Change process working directory to SCENE_PATH in order to be able to load relative scene resources.</div>
<div>changeCurrentDir(SCENE_PATH.c_str());</div>
<div>// Load V-Ray SDK library.</div>
<div>VRayInit init(NULL, true);</div>
<div>// Create an instance of VRayRenderer with default options.</div>
<div>// The renderer is automatically closed at the end of the current scope.</div>
<div>VRayRenderer renderer;</div>
<div>// It's recommended to always have a console log</div>
<div>renderer.setOnLogMessage(logMessage);</div>
<div>// Load scene from a file.</div>
<div>renderer.load("lighting.vrscene");</div>
<div>// Remove original light source from the scene.</div>
<div>renderer.deletePlugin("VRayLightDomeShape1");</div>
<div>// Add a physical camera and allowed it to affect exposure.</div>
<div>// Otherwise the Sun produces overbright values if not using a physical</div>
<div>// setup and without changing its intensity.</div>
<div>CameraPhysical camera = renderer.getInstanceOrCreate&lt;CameraPhysical&gt;();</div>
<div>camera.set_exposure(1);</div>
<div>// The V-Ray Sun light together with the Sky texture plugin provides a</div>
<div>// realistic outdoor illumination system that can be tuned to a specific</div>
<div>// time of day and athmospheric contents (without clouds). The Sun is</div>
<div>// represented as a light source at "infinity" similar to a directional</div>
<div>// light, but with a real radius causing soft shadows.</div>
<div>SunLight sun = renderer.newPlugin&lt;SunLight&gt;();</div>
<div>// Specify the light rotation.</div>
<div>// The rotation matrix defines the direction vector of the light. Even</div>
<div>// though it should be an omni light very far away, it's set as a directional light.</div>
<div>// Note: The translation vector does NOT affect position as the Sun light</div>
<div>// source is positioned at "infinity". It is only used by some 3D</div>
<div>// applications to represent the Sun within the scene with an OpenGL gizmo.</div>
<div>sun.set_transform(Transform(</div>
<div>Matrix(</div>
<div>Vector(0.9563327, 0.0, 0.2922803),</div>
<div>Vector(0.2010161, 0.7259465, -0.6577188),</div>
<div>Vector(-0.2121799, 0.6877511, 0.6942464)),</div>
<div>Vector(-94.70224040070444, 306.9639183671097, 309.8629632135933)));</div>
<div>// Initialize the target position.</div>
<div>// It is used only for caustic effects.Only the translation vector matters.</div>
<div>sun.set_target_transform(Transform(</div>
<div>Matrix(</div>
<div>Vector(1.0, 0.0, 0.0),</div>
<div>Vector(0.0, 1.0, 0.0),</div>
<div>Vector(0.0, 0.0, 1.0)),</div>
<div>Vector(0.0, 0.0, 0.0)));</div>
<div>// Specify the amount of dust in the air.</div>
<div>// This property affects the color of the sun and the sky. Smaller values</div>
<div>// produce a clear and blue sky and sun as you get in the country, while</div>
<div>// larger values make them yellow and orange as, for example, in a big city.</div>
<div>sun.set_turbidity(2.5);</div>
<div>// Specify the reflective property of the "ground".</div>
<div>// This property affects sky-dome brightness and color.</div>
<div>sun.set_ground_albedo(Color(0.5, 0.5, 0.5));</div>
<div>// Specify the rotation of the sky texture based on a up vector.</div>
<div>sun.set_up_vector(Vector(0.0, 1.0, 0.0));</div>
<div>// Specify the procedural model that will be used to generate the V-Ray Sky texture.</div>
<div>// Possible values are:</div>
<div>//   0 (Preethem) - default</div>
<div>//   1 (CIE Clear)</div>
<div>//   2 (CIE Overcast)</div>
<div>//   3 (Hosek)</div>
<div>sun.set_sky_model(3);</div>
<div>// Specify shadow offset from the surface. Helps to prevent polygonal shadow artifacts on low-poly surfaces.</div>
<div>sun.set_shadowBias(0.02f);</div>
<div>// Specify a color texture for shadows. Overrides the 'shadowColor' parameter.</div>
<div>sun.set_shadow_color_tex(AColor(0.0, 0.0, 0.0, 1.0));</div>
<div>// The Sky texture emits blue(or warm around dusk and dawn) light from all</div>
<div>// directions and it is used as an environment texture.</div>
<div>TexSky texture = renderer.newPlugin&lt;TexSky&gt;();</div>
<div>// The Sky texture takes its parameters from a SunLight through this connection.</div>
<div>// If you don't want a Sun you can set the same parameters on this plugin.</div>
<div>texture.set_sun(sun);</div>
<div>// Environment plugin with the V-Ray Sky texture used as an input.</div>
<div>// It is recommended to use the 'getInstanceOrCreate' method when a settings</div>
<div>// plugin is needed because there should be at most one instance of its type in the scene.</div>
<div>SettingsEnvironment environment = renderer.getInstanceOrCreate&lt;SettingsEnvironment&gt;();</div>
<div>environment.set_bg_tex(texture);</div>
<div>environment.set_gi_tex(texture);</div>
<div>environment.set_reflect_tex(texture);</div>
<div>environment.set_refract_tex(texture);</div>
<div>// Start rendering.</div>
<div>renderer.startSync();</div>
<div>// Wait for rendering to end.</div>
<div>renderer.waitForRenderEnd();</div>
<div>return 0;</div>
<div>}</div>
<p>

C#

</p>
<div>using System;</div>
<div>using System.IO;</div>
<div>using VRay;</div>
<div>using VRay.Plugins;</div>
<div></div>
<div>namespace _11_sun</div>
<div>{</div>
<div>    class Program</div>
<div>    {</div>
<div>        static void Main(string[] args)</div>
<div>        {</div>
<div>            string SCENE_PATH = Path.Combine(Environment.GetEnvironmentVariable("VRAY_SDK"), "scenes");</div>
<div>            // Change process working directory to SCENE_PATH in order to be able to load relative scene resources.</div>
<div>            Directory.SetCurrentDirectory(SCENE_PATH);</div>
<div></div>
<div>            // Create an instance of VRayRenderer with default options. The renderer is automatically closed after the `using` block.</div>
<div>using (VRayRenderer renderer = new VRayRenderer())</div>
<div>            {</div>
<div>                // Add a listener for any type of log message.</div>
<div>                renderer.LogMessage += new EventHandler&lt;MessageEventArgs&gt;((source, e) =&gt;</div>
<div>                {</div>
<div>                    // You can remove the if for testing, but you might want to ignore Debug in real code</div>
<div>                    if (e.LogLevel != LogLevelType.Debug)</div>
<div>                    {</div>
<div>                        Console.WriteLine(String.Format("[{0}] {1}", e.LogLevel.ToString(), e.Message));</div>
<div>                    }</div>
<div>                });</div>
<div>                // Load scene from a file.</div>
<div>                renderer.Load("lighting.vrscene");</div>
<div>                // Remove original light source from the scene.</div>
<div>                renderer.DeletePlugin("VRayLightDomeShape1");</div>
<div>                // Add a physical camera and allowed it to affect exposure.</div>
<div>                // Otherwise the Sun produces overbright values if not using a physical</div>
<div>                // setup and without changing its intensity.</div>
<div>                CameraPhysical camera = renderer.GetInstanceOrCreate&lt;CameraPhysical&gt;();</div>
<div>                camera.Exposure = 1;</div>
<div>                // The V-Ray Sun light together with the Sky texture plugin provides a</div>
<div>                // realistic outdoor illumination system that can be tuned to a specific</div>
<div>                // time of day and athmospheric contents (without clouds). The Sun is</div>
<div>                // represented as a light source at "infinity" similar to a directional</div>
<div>                // light, but with a real radius causing soft shadows.</div>
<div>                SunLight sun = renderer.NewPlugin&lt;SunLight&gt;();</div>
<div>                // Specify the sun rotation.</div>
<div>                // The rotation matrix defines the direction vector of the light. Even</div>
<div>                // though it should be an omni light very far away, it's set as a directional light.</div>
<div>                // Note: The translation vector does NOT affect position as the Sun light</div>
<div>                // source is positioned at "infinity". It is only used by some 3D</div>
<div>                // applications to represent the Sun within the scene with an OpenGL gizmo.</div>
<div>                sun.Transform = new Transform(</div>
<div>                    new Matrix(</div>
<div>                        new Vector(0.9563327, 0, 0.2922803),</div>
<div>                        new Vector(0.2010161, 0.7259465, -0.6577188),</div>
<div>                        new Vector(-0.2121799, 0.6877511, 0.6942464)),</div>
<div>                    new Vector(-94.70224040070444, 306.9639183671097, 309.8629632135933));</div>
<div>                // Initialize the target position.</div>
<div>                // It is used only for caustic effects. Only the translation vector matters.</div>
<div>                sun.TargetTransform = new Transform(</div>
<div>                    new Matrix(</div>
<div>                        new Vector(1, 0, 0),</div>
<div>                        new Vector(0, 1, 0),</div>
<div>                        new Vector(0, 0, 1)),</div>
<div>                    new Vector(0, 0, 0));</div>
<div>                // Specify the amount of dust in the air.</div>
<div>                // This property affects the color of the sun and the sky. Smaller values</div>
<div>                // produce a clear and blue sky and sun as you get in the country, while</div>
<div>                // larger values make them yellow and orange as, for example, in a big city.</div>
<div>                sun.Turbidity = 2.5F;</div>
<div>                // Specify the reflective property of the "ground".</div>
<div>                // This property affects sky-dome brightness and color.</div>
<div>                sun.GroundAlbedo = new Color(0.5, 0.5, 0.5);</div>
<div>                // Specify the rotation of the sky texture based on a up vector.</div>
<div>                sun.UpVector = new Vector(0, 1, 0);</div>
<div>                // Specify the procedural model that will be used to generate the V-Ray Sky texture.</div>
<div>                // Possible values are:</div>
<div>                //   0 (Preethem)</div>
<div>                //   1 (CIE Clear)</div>
<div>                //   2 (CIE Overcast)</div>
<div>                //   3 (Hosek)</div>
<div>                sun.SkyModel = 3;</div>
<div>                // Specify shadow offset from the surface. Helps to prevent polygonal shadow artifacts on low-poly surfaces.</div>
<div>                sun.ShadowBias = 0.02F;</div>
<div>                // Specify a color texture for shadows. Overrides the 'shadowColor' parameter.</div>
<div>                sun.ShadowColorTex = new AColor(0, 0, 0, 1);</div>
<div>                // The Sky texture emits blue (or warm around dusk and dawn) light from all</div>
<div>                // directions and it is used as an environment texture.</div>
<div>                TexSky texture = renderer.NewPlugin&lt;TexSky&gt;();</div>
<div>                // The Sky texture takes its parameters from a SunLight through this connection.</div>
<div>                // If you don't want a Sun you can set the same parameters on this plugin.</div>
<div>                texture.Sun = sun;</div>
<div>                // Environment plugin with the V-Ray Sky texture used as an input.</div>
<div>                // It is recommended to use the 'GetInstanceOrCreate' method when a settings</div>
<div>                // plugin is needed because there should be at most one instance of its type in the scene.</div>
<div>                SettingsEnvironment environment = renderer.GetInstanceOrCreate&lt;SettingsEnvironment&gt;();</div>
<div>                environment.BgTex = texture;</div>
<div>                environment.GiTex = texture;</div>
<div>                environment.ReflectTex = texture;</div>
<div>                environment.RefractTex = texture;</div>
<div>                // Start rendering.</div>
<div>                renderer.StartSync();</div>
<div>                // Wait for rendering to end.</div>
<div>                renderer.WaitForRenderEnd();</div>
<div>            }</div>
<div>        }</div>
<div>    }</div>
<div>}</div>
<p>

Node.js

</p>
<div>var path = require('path');</div>
<div>var vray = require(path.join(process.env.VRAY_SDK, 'node', 'vray'));</div>
<div></div>
<div>var SCENE_PATH = path.join(process.env.VRAY_SDK, 'scenes');</div>
<div>// Change process working directory to SCENE_PATH in order to be able to load relative scene resources.</div>
<div>process.chdir(SCENE_PATH);</div>
<div></div>
<div>// Create an instance of VRayRenderer with default options.</div>
<div>var renderer = vray.VRayRenderer();</div>
<div>// It's recommended to always have a console log callback</div>
<div>renderer.on("logMessage", function(message, level, instant) {</div>
<div>if (level == vray.LOGLEVEL_ERROR)</div>
<div>console.log("[ERROR] ", message);</div>
<div>else if (level == vray.LOGLEVEL_WARNING)</div>
<div>console.log("[Warning] ", message);</div>
<div>else if (level == vray.LOGLEVEL_INFO)</div>
<div>console.log("[info] ", message);</div>
<div>// Uncomment for testing, but you might want to ignore these in real code</div>
<div>//else console.log("[debug] ", message);</div>
<div>});</div>
<div>// Load scene from a file asynchronously.</div>
<div>renderer.load("lighting.vrscene", function(err) {</div>
<div>    if (err) throw err;</div>
<div>    // Remove original light source from the scene.</div>
<div>    delete renderer.plugins["VRayLightDomeShape1"];</div>
<div>    // Add a physical camera and allowed it to affect exposure.</div>
<div>    // Otherwise the Sun produces overbright values if not using a physical</div>
<div>    // setup and without changing its intensity.</div>
<div>    var camera = renderer.classes.CameraPhysical.getInstanceOrCreate();</div>
<div>    camera.exposure = 1;</div>
<div>    // The V-Ray Sun light together with the Sky texture plugin provides a</div>
<div>    // realistic outdoor illumination system that can be tuned to a specific</div>
<div>    // time of day and athmospheric contents (without clouds). The Sun is</div>
<div>    // represented as a light source at "infinity" similar to a directional</div>
<div>    // light, but with a real radius causing soft shadows.</div>
<div>    var sun = renderer.classes.SunLight();</div>
<div>    // Specify the sun rotation.</div>
<div>    // The rotation matrix defines the direction vector of the light. Even</div>
<div>    // though it should be an omni light very far away, it's set as a directional light.</div>
<div>    // Note: The translation vector does NOT affect position as the Sun light</div>
<div>    // source is positioned at "infinity". It is only used by some 3D</div>
<div>// applications to represent the Sun within the scene with an OpenGL gizmo.</div>
<div>    sun.transform = vray.Transform(</div>
<div>        vray.Matrix(</div>
<div>            vray.Vector(0.9563327, 0, 0.2922803),</div>
<div>            vray.Vector(0.2010161, 0.7259465, -0.6577188),</div>
<div>            vray.Vector(-0.2121799, 0.6877511, 0.6942464)),</div>
<div>        vray.Vector(-94.70224040070444, 306.9639183671097, 309.8629632135933));</div>
<div>    // Initialize the target position.</div>
<div>    // It is used only for caustic effects. Only the translation vector matters.</div>
<div>    sun.target_transform = vray.Transform(</div>
<div>        vray.Matrix(</div>
<div>            vray.Vector(1, 0, 0),</div>
<div>            vray.Vector(0, 1, 0),</div>
<div>            vray.Vector(0, 0, 1)),</div>
<div>        vray.Vector(0, 0, 0));</div>
<div>    // Specify the amount of dust in the air.</div>
<div>    // This property affects the color of the sun and the sky. Smaller values</div>
<div>    // produce a clear and blue sky and sun as you get in the country, while</div>
<div>    // larger values make them yellow and orange as, for example, in a big city.</div>
<div>    sun.turbidity = 2.5;</div>
<div>    // Specify the reflective property of the "ground".</div>
<div>    // This property affects sky-dome brightness and color.</div>
<div>    sun.ground_albedo = vray.Color(0.5, 0.5, 0.5);</div>
<div>    // Specify the rotation of the sky texture based on a up vector.</div>
<div>    sun.up_vector = vray.Vector(0, 1, 0);</div>
<div>    // Specify the procedural model that will be used to generate the V-Ray Sky texture.</div>
<div>    // Possible values are:</div>
<div>    //   0 (Preethem)</div>
<div>    //   1 (CIE Clear)</div>
<div>    //   2 (CIE Overcast)</div>
<div>    //   3 (Hosek)</div>
<div>    sun.sky_model = 3;</div>
<div>    // Specify shadow offset from the surface. Helps to prevent polygonal shadow artifacts on low-poly surfaces.</div>
<div>    sun.shadowBias = 0.02;</div>
<div>    // Specify a color texture for shadows. Overrides the 'shadowColor' parameter.</div>
<div>    sun.shadow_color_tex = vray.AColor(0, 0, 0, 1);</div>
<div>    // The Sky texture emits blue (or warm around dusk and dawn) light from all</div>
<div>    // directions and it is used as an environment texture.</div>
<div>    var texture = renderer.classes.TexSky();</div>
<div>    // The Sky texture takes its parameters from a SunLight through this connection.</div>
<div>    // If you don't want a Sun you can set the same parameters on this plugin.</div>
<div>    texture.sun = sun;</div>
<div>    // Environment plugin with the V-Ray Sky texture used as an input.</div>
<div>    // It is recommended to use the 'getInstanceOrCreate' method when a settings</div>
<div>    // plugin is needed because there should be at most one instance of its type in the scene.</div>
<div>    var environment = renderer.classes.SettingsEnvironment.getInstanceOrCreate();</div>
<div>    environment.bg_tex = texture;</div>
<div>    environment.gi_tex = texture;</div>
<div>    environment.reflect_tex = texture;</div>
<div>    environment.refract_tex = texture;</div>
<div>    // Start rendering.</div>
<div>    renderer.start(function(err) {</div>
<div>        if (err) throw err;</div>
<div>        // Wait for rendering to end.</div>
<div>        renderer.waitForRenderEnd(function() {</div>
<div>            renderer.close();</div>
<div>        });</div>
<div>    });</div>
<div>});</div>
<p>

Gece Gökyüzü #


Ay, yıldızlar ve Samanyolu galaksisi de dahil olmak üzere gerçekçi bir gece gökyüzü simülasyonu yapar. Gece Gökyüzü, kullanıcıların gerçek dünya konumlandırmasına dayalı olarak doğru gece ortamları oluşturmasına olanak tanır.

moon_on (boolean) – Ay’ın gece gökyüzünde görünmesini etkinleştirir.
moon_size_multiplier (float) –  Ay’ın görünür boyutunu kontrol eder. Kamera ve yansımalar tarafından görülen Ay diskinin görünümünü ve Ay gölgelerinin bulanıklığını etkiler. moon_direct_intensity_multiplier (float) – Gökyüzünde doğrudan veya mükemmel ayna yansımalarında/kırılmalarında görülen Ay’ın parlaklığını kontrol eder.
moon_indirect_intensity_multiplier ( float) – Ay tarafından oluşturulan sahne aydınlatmasının yoğunluğunu kontrol eder. moon_glow_multiplier (float) – Bu Ay’ın etrafındaki parıltı için bir çarpandır. 0 değeri parıltı efektini devre dışı bırakır. moon_filter_color (Renk) – Filtre rengi, Ay’ın görünümü ve yaydığı aydınlatma için bir renk tonudur. Varsayılan beyaz (1, 1, 1) renk, renk değişikliği olmadığı anlamına gelir. moon_override_azimuth (boolean): Ayın azimutunu geçersiz kılar. moon_azimuth (float) – Sahnenin kuzeyinden doğusuna doğru ölçülen Ay azimut açısını belirtir. 90 değeri, 3ds Max’te X ekseni veya doğu ile hizalanır.  moon_override_elevation (boolean) – Ayın yüksekliğini geçersiz kılar. moon_elevation (float) – Ay ile yer arasındaki açıyı kontrol eder. 0 değeri Ay’ı tam ufukta, 90 değeri ise Ay’ı zenitte yapar. moon_override_phase (boolean) – Ay evresini geçersiz kılar. moon_phase (float) – Ay’ın evresini belirtir; 0 değeri dolunay, 90 değeri ilk dördün, 180 değeri yeni ay ve 270 değeri son dördün anlamına gelir. moon_override_rotation (boolean) – Ay diskinin dönüşünü geçersiz kılar. moon_rotation (float) – Ay diskinin gökyüzündeki dönüşünü ayarlar; 0 değeri, Kuzey yarımkürede gözlemlendiğinde Ay’ın en yüksek noktasındaki görünümüne uymasını sağlar ve 180 değeri Güney yarımküreye karşılık gelir. stars_on (boolean) – Gece gökyüzünde yıldızların görünmesini sağlar. stars_size_multiplier (float) – Yıldızların boyutunu kontrol eder. Varsayılan 1 değeri, yıldızları 1 piksel yarıçapla gösterir, 2 değeri yıldızları iki kat daha büyük yapar. 0 olarak ayarlanırsa, yıldızlar mümkün olan en küçük boyutta gösterilir. stars_size_difference (float) – Sönük ve parlak yıldızlar arasındaki boyut farkını kontrol eder. 0 olarak ayarlandığında, tüm yıldızlar aynı boyutta olur ve 1 değeri en parlak yıldızları iki kat daha büyük yapar, ikinci kadirdeki yıldızlar (örneğin Polaris) boyutlarını korur ve en sönük yıldızlar kaybolur. stars_direct_intensity_multiplier














(float) – Doğrudan gökyüzünde veya mükemmel ayna yansımalarında/kırılmalarında görülen yıldızların parlaklığını kontrol eder.
stars_indirect_intensity_multiplier (float) – Yıldızların yaydığı sahne aydınlatmasının yoğunluğunu kontrol eder.
stars_milkyway_multiplier (float) – Bu, Samanyolu’nun parlaklığının bir çarpanıdır.
stars_latitude (float) – Gece gökyüzünün enlemini belirler; -90° gökyüzünün Güney Kutbu üzerinden, 90° ise Kuzey Kutbu üzerinden göründüğü anlamına gelir. 
stars_longitude (float) – Gece gökyüzünün boylamını belirler; 0 Baş Meridyen, 90 ise Baş Meridyenin 90° doğusundaki boylamdır.
stars_date_day (int) – Yıldızların konumlandırılması için kullanılan tarihin gün kısmı.
stars_date_month (int) – Yıldızların konumlandırılması için kullanılan tarihin ay kısmı.
stars_date_year (int) – Yıldızların konumlandırılması için kullanılan tarihin yıl kısmı.
stars_time_hours (int) – Yıldızların konumlandırılması için kullanılan zamanın saat kısmı.
stars_time_minutes (int) – Yıldızların konumlandırılması için kullanılan zamanın dakika kısmı.
stars_time_seconds (int) – Yıldızların konumlandırılması için kullanılan zamanın saniye kısmı.
stars_time_zone (int) – Yıldızların konumlandırılması için kullanılan zamana uygulanan saat dilimi.
stars_time_dst (boolean) – Yıldızların konumlandırılması için kullanılan zamana Yaz Saati Uygulamasının uygulanıp uygulanmadığını belirtir.
stars_north_vector (Vector) – Kuzeye olan yönü belirtir.

Sonuç #


Bu render için kullanılan sahne “Lighting_Sun.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