Luces en Unity 3D

download Luces en Unity 3D

of 5

Transcript of Luces en Unity 3D

  • 7/30/2019 Luces en Unity 3D

    1/5

    Tema 7Light Tutorial

    will bring personality and flavor to your game. You use lights to illuminate the scenesobjects to create the perfect visual mood. Lights can be used to simulate the sun, burning match flashlights, gun-fire, or explosions, just to name a few.

    The Light

    There are three types of lights in Unity: shine from a location equally in all directions, like a light bulb. are placed infinitely far away and affect everything in the scene, like the sun. shine from a point in a direction and only illuminate objects within a cone - like the headliga car.

    Lights can also cast . Shadows are a Pro-only feature. Shadow properties can be adjusted on a perlight basis.

    The current type of light object:A light placed infinitely far away. It affects everything in the scene.A light that shines equally in all directions from its location, affecting all objects withinits .A light that shines everywhere within a cone defined byand . Only objectswithin this region are affected by the light.How far light is emitted from the center of the object./ light only.Determines the angle of the cone in degrees.light only.The color of the light emitted.Brightness of the light. Default value for a/ light is 1. Default value fora light is 0.5The alpha channel of this texture is used as a mask that determines how bright the light

    Tutorial de Unity 3DTema 7

  • 7/30/2019 Luces en Unity 3D

    2/5

    Tema 7Light Tutorial

    at different places. If the light is aor a light, this must be a 2D texture. Ifthe light is a light, it must be a .Scales the projection of a Cookie. light only.

    (Pro only), or shadowsthat will be cast by this light. Only applicable to desktop build

    targets. Soft shadows are more expensive.The darkness of the shadows. Values are between 0 and 1.Detail level of the shadows.Offset used when comparing the pixel position in light space with the value from theshadow map. When the value is too small the surfaces start to self-shadow themselves("shadow acne"), when too big - casters are disconnected from receivers ("peterpanning").Scales the penumbra region (the offset of blur samples). light only.Shadow softness fade based on the distance from the camera. light only.If checked, a spherical halo of light will be drawn with a radius equal to.Optional reference to theFlarethat will be rendered at the light's position.Importance of this light. This can affect lighting fidelity and performance, seePerformance Considerations below. Options include:The rendering method is determined at runtime depending on the brightness of nearbylights and currentQuality Settingsfor desktop build target.This light is always rendered at per-pixel quality. Use this for very important effects on(e.g. headlights of a player's car).This light is always rendered in a faster, vertex/object light mode.Use to selectively exclude groups of objects from being affected by the light; seeLayers.

    The Lightmapping mode: , or ; see theDualLightmapsdescription.

    There are three basic light types in Unity. Each type can be customized to fit your needs.

    You can create a texture that contains an alpha channel and assign it to thevariable of the light. TheCookie will be projected from the light. The Cookie's alpha mask modulates the light amount, creatinand dark spots on surfaces. They are a great way af adding lots of complexity or atmosphere to a scen

    Tutorial de Unity 3DTema 7

  • 7/30/2019 Luces en Unity 3D

    3/5

    Tema 7Light Tutorial

    Allbuilt-in shadersin Unity seamlessly work with any type of light.shaders cannot display Cookiesor Shadows, however.

    In Unity Pro with a build target of webplayer or standalone, all Lights can optionally castShadows. This isdone by selecting either or for the property of each individualLight. For more information about shadows, please read theShadowspage.

    Point lights shine out from a point in all directions. They are the most common lights in computer gamtypically used for explosions, light bulbs, etc. They have an average cost on the graphics processor (thpoint light shadows are the most expensive).

    Point Light

    Point lights can have cookies -Cubemaptexture with alpha channel. This Cubemap gets projected out in alldirections.

    Point Light with a Cookie

    Spot lights only shine in one direction, in a cone. They are perfect for flashlights, car headlights or lamposts. They are the most expensive on the graphics processor.

    Spot Light

    Spot lights can also have cookies - a texture projected down the cone of the light. This is good for crean effect of light shining through the window. It is very important that the texture is black at the edgeshas option on and its wrapping mode is set to. For more info on this, seeTextures.

    Tutorial de Unity 3DTema 7

  • 7/30/2019 Luces en Unity 3D

    4/5

    Tema 7Light Tutorial

    Spot Light with a Cookie

    Directional lights are used mainly in outdoor scenes for sun & moonlight. The light affect all surfacesobjects in your scene. They are the least expensive on the graphics processor. Shadows from directionlights (for platforms that support shadows) are explained in depth onthis page.

    Directional Light

    When directional light has a cookie, it is projected down the center of the light's Z axis. The size of this controlled with property. Set the cookie texture's wrapping mode toin the .

    Directional Light projecting a cloud-like cookie texture

    A cookie is a great way to add some quick detail to large outdoor scenes. You can even slide the light over the scene to give the impression of moving clouds.

    Lights can be rendered in one of two methods:lighting and lighting. Vertex lighting onlycalculates the lighting at the vertices of the game models and interpolates the lighting over the surfacethe models. Pixel lights are calculated at every screen pixel, and hence are much more expensive. Somolder graphics cards only support vertex lighting.

    While pixel lighting is slower to render, it does allow some effects that are not possible with vertex ligNormal-mapping, light cookies and realtime shadows are only rendered for pixel lights. Spotlight shaPoint light highlights are much better when rendered in pixel mode as well. The three light types abovlook like this when rendered in vertex light mode:

    Point light in Vertex lighting mode.

    Tutorial de Unity 3DTema 7

  • 7/30/2019 Luces en Unity 3D

    5/5

    Tema 7Light Tutorial

    Spot light in Vertex lighting mode.

    Directional light in Vertex lighting mode.

    Lights have a big impact on rendering speed - therefore a tradeoff has to be made betwen lighting qua

    and game speed. Since pixel lights are much more expensive than vertex lights, Unity will only rendebrightest lights at per-pixel quality. The actual number of pixel lights can be set in theQuality Settingsforwebplayer and standalone build targets.

    You can explicitly control if a light should be rendered as a vertex or pixel light using theproperty. By default Unity will classify the light automatically based on how much the object is a

    by the light.

    The actual lights that are rendered as pixel lights are determined on an object-by-object case. This me

    Huge objects with bright lights could use all the pixel lights (depending on the quality settings). If this far from these, nearby lights will be rendered as vertex lights. Therefore, it is better to split huge obup in a couple of small ones.

    See Optimizing Graphics performance onDesktop, iOSorAndroidpage for more information.

    For more information on creating cookies, please see thetutorial on how to create a Spot light cookie.

    Spot lights with cookies can be extremely effective for making light coming in from windows. Low-intensity point lights are good for providing depth to a scene. For maximum performance, use aVertexLitshader. This shader only does per-vertex lighting, giving a muchhigher throughput on low-end cards.

    Tutorial de Unity 3DTema 7