/****************************************************************************
**
** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Design Studio.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
    \page studio-3d-lights.html
    \previouspage studio-3d-custom-effects-materials.html
    \nextpage studio-3d-camera.html

    \title Using Lights

    Light components are the primary source of lighting in a \QDS scene.
    As a secondary light source, you can use \l{Using Image-based Lighting}
    {image-based lighting}.

    By default, all imported scenes are created with one directional light.
    You can use the following \l{Qt Quick 3D} components to add lights:

    \list
        \li \l{DirectionalLight}{Light Directional}
        \li \l{PointLight}{Light Point}
        \li \l{SpotLight}{Light Spot}
        \li \l{AreaLight}{Light Area}
    \endlist

    \note Each additional light negatively effects the rendering performance
    of your scene. Keep scenes as simple as possible and use lights sparingly.
    Use a \l{SceneEnvironment}{Scene Environment} component to apply image-based
    lighting that can produce soft and subtle lighting.

    You can edit light properties in the \uicontrol Properties view. The
    \uicontrol Scope property specifies which node, with it's children,
    is illuminated by a light.

    Set the \uicontrol {Color} property to specify the color applied to models
    illuminated by a light. Set the \uicontrol {Ambient color} property to
    specify the ambient color applied to materials before being illuminated by
    the light.

    You can animate light properties in the \uicontrol Timeline view.

    \section1 Directional Light

    A directional light emits light in one direction from a unidentifiable
    source located infinitely far away. This is similar to sunlight.

    \image studio-3d-directional-light.png "Models lit by a dirctional light"

    If the \uicontrol {Casts shadow} property is enabled, shadows are positioned
    parallel to the light direction. A directional light has infinite range and
    does not diminish.

    Moving a directional light does not have any effect. The light will always
    be emitted in the direction of the light's z axis. Rotating the light along
    its x or y axis will change the direction in which the light is emitted.

    Scaling a directional light will only have an effect in the following cases:

    \list
        \li If the z scale is set to a negative number, the light will be
            emitted in the opposite direction.
        \li If the scale of any axis is set to 0, the light will be emitted
            along the world's z axis. Rotating the light has no effect.
    \endlist

    \section1 Point Light

    A point light can be described as a sphere, emitting light with equal
    strength in all directions from the center of the light. This is similar
    to the way a light bulb emits light.

    \image studio-3d-point-light.png "Models lit by a point light"

    Lighting is applied outwards from the center of a point light, becoming
    increasingly dim away from the center. Moving a point light changes the
    position from where the light is emitted. Rotating or scaling a point
    light does not have any effect.

    To specify an overall multiplier for a point light's effects, set the
    \uicontrol Brightness property.

    To control the fade-off and range of a point light, set the
    \uicontrol {Constant fade}, \uicontrol {Linear fade}, and
    \uicontrol {Quadratic fade} properties. Constant fade is the constant
    factor of the \e attenuation term of the light. Attenuation refers to
    the reduction in the intensity of light as it travels through a medium
    due to absorption or scattering of photons.

    Turn up the linear fade value to increase the rate at which the lighting
    effect dims the light in proportion to the distance to the light. The value
    0.0 means that the light doesn't have linear fade.

    Turn up the quadratic fade to increase the rate at which the lighting effect
    dims on surfaces that are far away from the light. The value 1.0 means that
    the point light fade exactly follows the inverse square law. For example,
    when the distance to an object doubles, the light intensity decreases to one
    fourth.

    Aside from fade, a point light has the same properties as a directional
    light.

    \section1 Spot Light

    A spot light emits light towards one direction in a cone shape.
    The light intensity diminishes when approaching the value of the
    \uicontrol {Cone angle} property. The angle at which the light
    intensity starts to diminish is defined by the
    \uicontrol {Inner cone angle} property. Both angles are defined in degrees.

    Inside the inner cone angle, the spot light behaves similarly to the point
    light. There the light intensity diminishes according to inverse-square-law.
    However, the fade-off (and range) can be controlled with the
    \uicontrol {Constant fade}, \uicontrol {Linear fade}, and
    \uicontrol {Quadratic fade} properties.

    \image studio-3d-spot-light.png

    \section1 Area Light

    An area light is similar to the directional light. However, instead of
    emitting an equally bright light across the whole scene, the area light
    emits directional light from a rectangle shaped object. You can set the
    \uicontrol Width and \uicontrol Height properties to determine the size
    of the area light.

    Aside from the size, an area light has the same properties as a directional
    light.

    The image below shows an example on how to light an object with different
    colors using two different area lights.

    \image studio-3d-area-light.png

    You can rotate, scale, and move area lights.

    \section1 Shadows

    To simulate shadows using this light, enable the \uicontrol {Cast shadows}
    check box. Cast shadows work best with area or point lights.

    To specify the darkness of the shadows, set the \uicontrol {Shadow factor}
    property. The value 0 means no shadows are cast.

    To specify the amount of blur applied to the shadows, set the
    \uicontrol {Shadow filter} property.

    Tweak the \uicontrol {Shadow bias} property value by small amounts
    if you see objects casting shadows on themselves.

    To specify the quality of the shadow map created for shadow rendering, set
    the \uicontrol {Shadow map quality} property. Lower quality uses less
    resources, but produces lower quality shadows, while higher quality uses
    more resources to produce better quality shadows.

    To specify the maximum distance for the shadow map, set the
    \uicontrol {Shadow map far} property value. Using smaller values
    may improve the precision and effects of the map.
*/
