#include <lightcomponent.h>
Classes | |
struct | Locator |
Public Member Functions | |
virtual void | getDependentComponents (std::vector< rtti::TypeInfo > &components) const override |
![]() | |
virtual const rtti::TypeInfo | getInstanceType () const =0 |
![]() | |
Resource () | |
![]() | |
Object () | |
virtual | ~Object () |
virtual bool | init (utility::ErrorState &errorState) |
virtual void | onDestroy () |
Object (Object &)=delete | |
Object & | operator= (const Object &)=delete |
Object (Object &&)=delete | |
Object & | operator= (Object &&)=delete |
Public Attributes | |
bool | mEnabled = true |
Property: 'Enabled' Whether the light is enabled. More... | |
bool | mCastShadows = false |
Property: 'CastShadows' Enables shadows and creates shadow map resources for this light. More... | |
RGBColorFloat | mColor = {1.0f, 1.0f, 1.0f} |
Property: 'Color' The light color. More... | |
float | mIntensity = 1.0f |
Property: 'Intensity' The light intensity. More... | |
float | mShadowStrength = 1.0f |
Property: 'ShadowStrength' The amount of light the shadow consumes. More... | |
float | mShadowSpread = 2.0f |
Property: 'ShadowSpread' The spread radius of the shadow samples. More... | |
Locator | mLocator |
Property: 'Locator' Locator settings. More... | |
![]() | |
std::string | mID |
Property: 'mID' unique name of the object. Used as an identifier by the system. More... | |
Additional Inherited Members | |
![]() | |
static bool | isIDProperty (rtti::Instance &object, const rtti::Property &property) |
Base class of light components for NAP RenderAdvanced's light system.
When present in the scene, the render advanced service can update light uniform data for material instances that are compatible with the light's shader interface. On initialization, each light component sets up its own registry of light uniform data and registers itself at the render advanced service. This way, the service is aware of the lights in the scene and creates the necessary resources for light information and shadow maps. NAP supports a limited number of lights per scene (RenderAdvancedService::getMaximumLightCount
). The way in which these blend/interact depends on the implementation of the shader program. Increasing the maximum number of lights is trivial, however, with the current implementation it would take up more shader resource slots.
Each light component has three default uniforms that are set by the RenderAdvanced service:
origin
: vec3
world position of the light.direction
: vec3
direction of the light. Some lights may choose to ignore this however (e.g. point lights).flags
: an unsigned integer encoding information such as whether shadows are enabled, see lightflags.h
.Other uniforms may be defined by derived light types. They must be in accordance with the data and shader interface in the light.glslinc
file in the RenderAdvanced shader folder. New light types can be added here in the future, or user implementations can use the 'Custom' enum.
NAP comes with a default nap::BlinnPhongShader that is compatible with the light system. Hooking this up to a nap::Material allows for quick scene lighting setups. Material surface uniforms as defined by the shader interface must be set in data or at runtime. A description of these can be found in the documentation of the shader or its source file.
The depth format of shadow maps can be configured in the nap::RenderAdvancedServiceConfiguration
.
Rendering with lights requires an additional call to the render advanced service. You can either use pushLights
on the render components you wish to render or renderShadows
with the updateMaterials
argument set to true
if you wish to use shadows too.
Update light uniforms of lit components when shadows are disabled.
Re-render shadow map and update light uniforms.
|
overridevirtual |
Get a list of all component types that this component is dependent on (i.e. must be initialized before this one)
components | the components this object depends on |
Reimplemented from Component.
bool mCastShadows = false |
Property: 'CastShadows' Enables shadows and creates shadow map resources for this light.
RGBColorFloat mColor = {1.0f, 1.0f, 1.0f} |
Property: 'Color' The light color.
bool mEnabled = true |
Property: 'Enabled' Whether the light is enabled.
float mIntensity = 1.0f |
Property: 'Intensity' The light intensity.
float mShadowSpread = 2.0f |
Property: 'ShadowSpread' The spread radius of the shadow samples.
float mShadowStrength = 1.0f |
Property: 'ShadowStrength' The amount of light the shadow consumes.