Support Forum G3D Web Page |
An (invisible) emitting surface (AREA) or point (DIRECTIONAL, SPOT, OMNI) light. More...
Inherits G3D::VisibleEntity.
Classes | |
class | Type |
Public Types | |
enum | VisualizationMode { SKELETON, BOUNDS, SKELETON_AND_BOUNDS } |
Public Member Functions | |
Light () | |
float | areaLightPullback () const |
Distance in meters to pull point light approximations of area lights back by. More... | |
ArticulatedModel::Pose & | articulatedModelPose () |
Biradiance3 | biradiance (const Point3 &X) const |
Biradiance (radiant flux per area) due to the entire emitter to point X, using the light's specified falloff and spotlight doors. More... | |
Biradiance3 | biradiance (const Point3 &X, const Point3 &pointOnAreaLight) const |
Power3 | bulbPower () const |
For a SPOT or OMNI light, the power of the bulb. More... | |
bool | canCauseCollisions () const |
bool | canChange () const |
True if this Entity can change (when not Scene::editing(); all objects can change when in editing mode). More... | |
bool | castsShadows () const |
float | distance (const Point3 &p) const |
Distance from the point to the light (infinity for DIRECTIONAL lights). More... | |
class Sphere | effectSphere (float cutoff=30.0f/255) const |
Returns the sphere within which this light has some noticable effect. More... | |
Power3 | emittedPower () const |
For a SPOT or OMNI light, the power leaving the light into the scene. More... | |
bool | enabled () const |
const Surface::ExpressiveLightScatteringProperties & | expressiveLightScatteringProperties () const |
const Vector2 & | extent () const |
The size ("diameter") of the emitter along the x and y axes of its frame(). More... | |
float | farPlaneZ () const |
Position of the light's shadow map clipping plane along the light's z-axis. More... | |
float | farPlaneZLimit () const |
Farthest that the farPlaneZ() is ever allowed to be (part of the Light's specification) More... | |
const CoordinateFrame & | frame () const |
The translation of a DIRECTIONAL light is infinite. More... | |
virtual void | getLastBounds (class AABox &box) const |
Return a world-space axis-aligned bounding box as of the last call to onPose(). More... | |
virtual void | getLastBounds (class Sphere &sphere) const |
Return a world-space bounding sphere as of the last call to onPose(). More... | |
virtual void | getLastBounds (class Box &box) const |
Return a world-space bounding box as of the last call to onPose(). More... | |
void | getRectangularAreaLightVertices (Point3 position[4]) const |
Assumes type() == AREA and isRectangular = true. More... | |
void | getSpotConstants (float &cosHalfAngle, float &softnessConstant) const |
Returns the cosine of the spot light's half angle, and the softness constant used in G3D's lighting model. More... | |
bool | inFieldOfView (const Vector3 &w_i) const |
Is vector w_i (from a point in the scene to the light) within the field of view (e.g., spotlight cone) of this light? Called from biradiance(). More... | |
virtual bool | intersect (const Ray &R, float &maxDistance, Model::HitInfo &info=Model::HitInfo::ignore) const override |
virtual bool | intersectBounds (const Ray &R, float &maxDistance, Model::HitInfo &info) const override |
Returns true if there is conservatively some intersection with the object's bounds closer than maxDistance to the ray origin. More... | |
virtual const Array< Box > & | lastBoxBoundArray () const |
Return a world-space bounding box array for all surfaces produced by this Entity as of the last call to onPose(). More... | |
bool | lastBoxBoundArraysOverlap (const shared_ptr< Entity > &other) const |
Returns true if the world space bounds of these two entities overlap. More... | |
RealTime | lastChangeTime () const |
Wall-clock time at which this entity changed in some way, e.g., that might require recomputing a spatial data structure. More... | |
Point3 | lowDiscrepancyAreaPosition (int pixelIndex, int lightIndex, int sampleIndex, int numSamples) const |
Low-discrepancy distributed positions on the light based on screen pixel and light index. More... | |
Point2 | lowDiscrepancySample (int pixelIndex, int lightIndex, int sampleIndex, int numSamples) const |
Helper function to generate low-discrepancy sample points in 2D. More... | |
Point3 | lowDiscrepancySolidAnglePosition (int pixelIndex, int lightIndex, int sampleIndex, int numSamples, const Point3 &X, float &areaTimesPDFValue) const |
Low-discrepancy distributed positions on the solid angle subtended by the light relative to the samplePosition, based on screen pixel and light index. More... | |
virtual void | makeGUI (class GuiPane *pane, class GApp *app) override |
Create a user interface for controlling the properties of this Entity. More... | |
void | markChanged () |
Sets the lastChangeTime() to the current System::time() More... | |
float | mass () const |
const shared_ptr< Model > & | model () const |
const String & | name () const |
float | nearPlaneZ () const |
Position of the light's shadow map clipping plane along the light's z-axis. More... | |
float | nearPlaneZLimit () const |
Closest that the nearPlaneZ() is ever allowed to be (part of the Light's specification) More... | |
virtual void | onPose (Array< shared_ptr< Surface > > &surfaceArray) override |
Constructs geometry as needed if visible() and no model() is set already. More... | |
virtual void | onSimulation (SimTime absoluteTime, SimTime deltaTime) override |
If there is a bulbPowerTrack, then the bulbPower will be overwritten from it during simulation. More... | |
bool | physicalSimulation () const |
virtual shared_ptr< SoundEntity > | playSound (const shared_ptr< Sound > &sound, const CFrame &childFrame=CFrame(), bool attach=true) |
Creates a new G3D::SoundEntity attached to this Entity at childFrame by an Entity::EntityTrack and returns it. More... | |
virtual const shared_ptr< Model::Pose > & | pose () const |
Vector4 | position () const |
Homogeneous world space position of the center of the light source (for a DIRECTIONAL light, w = 0) More... | |
Vector4 | position (float u, float v) const |
Position on the light at coordinates (u, v) in light space, where u and v are each on [-1, 1]. More... | |
bool | possiblyIlluminates (const class Sphere &sphere) const |
Can this light possibly illuminate anything in the box based on the spotlight and attenuation? More... | |
const CoordinateFrame & | previousFrame () const |
bool | producesDirectIllumination () const |
bool | producesIndirectIllumination () const |
In a global illumination renderer, should this light create indirect illumination (in addition to direct illumination) effects (e.g., by emitting photons in a photon mapper)? More... | |
Vector3 | randomEmissionDirection (class Random &rng) const |
Returns a unit vector selected uniformly at random within the world-space solid angle of the emission cone, frustum, or sphere of the light source. More... | |
Vector4 | randomPosition (Random &r=Random::threadCommon()) const |
Does not include the areaLightPullback. More... | |
bool | rectangular () const |
If true, the emitter (and its emission cone for a spot light) is rectangular instead elliptical. More... | |
void | setAreaLightPullback (float p) |
virtual void | setCanCauseCollisions (bool c) |
If true, causes collisions for other objects during physical simulation. More... | |
void | setCastsShadows (bool b) |
void | setEnabled (bool enabled) |
virtual void | setFrame (const CFrame &f, bool updatePreviousFrame=true) |
This sets the position of the Entity for the current simulation step. More... | |
virtual void | setFrame (const CoordinateFrame &c, bool updatePreviousFrame=true) override |
Sends directional lights to infinity. More... | |
virtual void | setFrameSpline (const PhysicsFrameSpline &spline) |
If there is a controller on this object and it is a SplineTrack, mutate it to store this value. More... | |
virtual void | setMass (float m) |
Set to a negative number to tell the physics system to use the absolute value as a density and infer the mass from the mesh on load. More... | |
virtual void | setModel (const shared_ptr< Model > &model) |
Not all VisibleEntity subclasses will accept all models. More... | |
virtual void | setPhysicalSimulation (bool s) |
If true, this object should receive physical simulation for its motion. More... | |
virtual void | setPose (const shared_ptr< Model::Pose > &pose) |
virtual void | setPreviousFrame (const CFrame &f) |
Explicitly override the previous frame value used for computing motion vectors. More... | |
void | setShaderArgs (class UniformTable &args, const String &prefix) const |
Sets the following arguments in. More... | |
void | setShadowsEnabled (bool shadowsEnabled) |
void | setShouldBeSaved (bool b) |
void | setSpotHalfAngle (float rad) |
void | setSpotHardness (float f) |
virtual void | setTrack (const shared_ptr< Track > &c) |
virtual void | setVisible (bool b) |
CullFace | shadowCullFace () const |
const shared_ptr< class ShadowMap > & | shadowMap () const |
Optional shadow map. More... | |
bool | shadowsEnabled () const |
When this light is enabled, does it cast shadows? More... | |
bool | shouldBeSaved () const |
True if this Entity should be saved when the scene is converted to Any for saving/serialization. More... | |
float | spotHalfAngle () const |
Spot light cutoff half-angle in radians. More... | |
float | spotHardness () const |
Like Photoshop brush hardness. More... | |
float | spotLightFalloff (const Vector3 &w_i) const |
Returns a number between 0 and 1 for how the light falls off due to the spot light's cone. More... | |
bool | spotSquare () const |
Point3 | stratifiedAreaPosition (int pixelIndex, int sampleIndex, int numSamples) const |
virtual Any | toAny (const bool forceAll=false) const override |
Converts the current VisibleEntity to an Any. More... | |
virtual shared_ptr< Track > | track () const |
Type | type () const |
Point3 | uniformAreaPosition () const |
bool | visible () const |
virtual void | visualize (RenderDevice *rd, bool isSelected, const class SceneVisualizationSettings &s, const shared_ptr< GFont > &font, const shared_ptr< Camera > &camera) |
Called by Scene::visualize every frame. More... | |
Static Public Member Functions | |
static shared_ptr< VisibleEntity > | create (const String &name, Scene *scene, const shared_ptr< Model > &model, const CFrame &frame=CFrame(), const shared_ptr< Track > &track=shared_ptr< Entity::Track >(), bool canChange=true, bool shouldBeSaved=true, bool visible=true, const Surface::ExpressiveLightScatteringProperties &expressiveLightScatteringProperties=Surface::ExpressiveLightScatteringProperties(), const ArticulatedModel::PoseSpline &artPoseSpline=ArticulatedModel::PoseSpline(), const shared_ptr< Model::Pose > &pose=nullptr) |
static shared_ptr< Entity > | create (const String &name, Scene *scene, AnyTableReader &propertyTable, const ModelTable &modelTable=ModelTable(), const Scene::LoadOptions &options=Scene::LoadOptions()) |
static shared_ptr< Light > | directional (const String &name, const Vector3 &toLight, const Radiance3 &color, bool shadowsEnabled=true, int shadowMapRes=2048) |
More... | |
static shared_ptr< Light > | findBrightestLight (const Array< shared_ptr< Light > > &array, const Point3 &point) |
static int | findBrightestLightIndex (const Array< shared_ptr< Light > > &array, const Point3 &point) |
static shared_ptr< Light > | point (const String &name, const Point3 &pos, const Power3 &color, float constAtt=0.01f, float linAtt=0, float quadAtt=1.0f, bool shadowsEnabled=true, int shadowMapRes=2048) |
static void | renderShadowMaps (RenderDevice *rd, const Array< shared_ptr< Light > > &lightArray, const Array< shared_ptr< Surface > > &allSurfaces, CullFace cullFace=CullFace::CURRENT) |
Update the shadow maps in the enabled shadow casting lights from the array of surfaces. More... | |
static shared_ptr< Light > | spot (const String &name, const Point3 &pos, const Vector3 &pointDirection, float halfAngleRadians, const Color3 &color, float constAtt=0.01f, float linAtt=0, float quadAtt=1.0f, bool shadowsEnabled=true, int shadowMapRes=2048) |
static shared_ptr< Light > | spotTarget (const String &name, const Point3 &pos, const Point3 &target, float halfAngleRadians, const Color3 &color, float constAtt=0.01f, float linAtt=0, float quadAtt=1.0f, bool shadowsEnabled=true, int shadowMapRes=2048) |
Creates a spot light that looks at a specific point (by calling spot()) More... | |
Public Attributes | |
float | attenuation [3] |
The attenuation observed by an omni or spot light is. More... | |
Color3 | color |
Point light: this is the the total power ( ) emitted uniformly over the sphere. More... | |
Protected Member Functions | |
void | computeFrame (const Vector3 &spotDirection, const Vector3 &rightDirection) |
Update m_frame's rotation from spotDirection and spotTarget. More... | |
void | init (AnyTableReader &propertyTable, const ModelTable &modelTable) |
void | init (const shared_ptr< Model > &model, bool visible, const Surface::ExpressiveLightScatteringProperties &expressiveLightScatteringProperties, const ArticulatedModel::PoseSpline &artPoseSpline, const MD3Model::PoseSequence &md3PoseSequence=MD3Model::PoseSequence(), const shared_ptr< Model::Pose > &pose=nullptr) |
void | init (const String &name, AnyTableReader &propertyTable) |
void | init (const String &name, Scene *scene, AnyTableReader &propertyTable) |
The initialization sequence for Entity and its subclasses is different than for typical C++ classes. More... | |
void | init (const String &name, Scene *scene, const CFrame &frame, const shared_ptr< Track > &controller, bool canChange, bool shouldBeSaved) |
void | onModelDropDownAction () |
GUI callback. More... | |
virtual void | poseModel (Array< shared_ptr< Surface > > &surfaceArray) const |
Called from VisibleEntity::onPose to extract surfaces from the model. More... | |
Vector3 | sampleSphericalQuad (const Point3 &origin, float u, float v, float &solidAngle) const |
Takes a 2D random vector, samples that point in the projected spherical quad, then returns the world-space position on the light of that sample. More... | |
virtual void | simulatePose (SimTime absoluteTime, SimTime deltaTime) |
Animates the appropriate pose type for the model selected. More... | |
Static Protected Member Functions | |
template<class T , class ... ArgTypes> | |
static shared_ptr< T > | createShared (ArgTypes &&... args) |
Like std::make_shared, but works for protected constructors. More... | |
Protected Attributes | |
float | m_areaLightPullback = 0.1f |
ArticulatedModel::PoseSpline | m_artPoseSpline |
Pose over time. More... | |
Power3Spline | m_bulbPowerTrack |
If set, this is used in onSimulation. More... | |
bool | m_canCauseCollisions = false |
bool | m_canChange |
If true, the canChange() method returns true. More... | |
bool | m_enabled |
If false, this light is ignored. More... | |
Surface::ExpressiveLightScatteringProperties | m_expressiveLightScatteringProperties |
Vector2 | m_extent |
The size ("diameter") of the emitter along the x and y axes of its frame(). More... | |
float | m_farPlaneZLimit |
CoordinateFrame | m_frame |
Current position. More... | |
AABox | m_lastAABoxBounds |
Bounds at the last pose() call, in world space. More... | |
RealTime | m_lastBoundsTime |
Time at which the bounds were computed. More... | |
Array< Box > | m_lastBoxBoundArray |
Bounds on all of the surfaces from the last pose() call, in world space. More... | |
Box | m_lastBoxBounds |
Bounds at the last pose() call, in world space. More... | |
RealTime | m_lastChangeTime |
AABox | m_lastObjectSpaceAABoxBounds |
Bounds at the last pose() call, in object space. More... | |
Sphere | m_lastSphereBounds |
Bounds at the last pose() call, in world space. More... | |
float | m_mass = 1 |
MD3Model::PoseSequence | m_md3PoseSequence |
shared_ptr< Model > | m_model |
class GuiDropDownList * | m_modelDropDownList |
bool | m_movedSinceLoad |
True if the frame has changed since load. More... | |
bool | m_movedSinceSimulation = false |
Has this Entity been explicitly moved by setFrame() since it was last simulated? If so, onSimulation will not update the m_previousFrame because it assumes some external logic is moving the Entity. More... | |
String | m_name |
float | m_nearPlaneZLimit |
bool | m_physicalSimulation = false |
shared_ptr< Model::Pose > | m_pose |
CoordinateFrame | m_previousFrame |
Frame before onSimulation(). More... | |
shared_ptr< Model::Pose > | m_previousPose |
bool | m_producesDirectIllumination |
bool | m_producesIndirectIllumination |
bool | m_rectangular |
If true, setShaderArgs will bind a spotHalfAngle large enough to encompass the entire square that bounds the cutoff angle. More... | |
Scene * | m_scene |
CullFace | m_shadowCullFace |
shared_ptr< ShadowMap > | m_shadowMap |
Optional shadow map. More... | |
bool | m_shadowsEnabled |
bool | m_shouldBeSaved |
True if this Entity should be saved when the scene is converted to Any for saving/serialization. More... | |
Any | m_sourceAny |
The Any from which this was originally constructed. More... | |
float | m_spotHalfAngle |
Spotlight cutoff half-angle in radians. More... | |
float | m_spotHardness |
1 = hard cutoff (default). More... | |
shared_ptr< Track > | m_track |
Basic simulation behavior for the Entity. More... | |
Type | m_type |
ShadowMap::VSMSettings | m_varianceShadowSettings |
bool | m_visible |
Should this Entity currently be allowed to affect any part of the rendering pipeline (e.g., shadows, primary rays, indirect light)? If false, the Entity never returns any surfaces from onPose(). More... | |
An (invisible) emitting surface (AREA) or point (DIRECTIONAL, SPOT, OMNI) light.
The light "faces" along the negative-z axis of its frame(), like all other G3D objects.
The light properties do not change when it is disabled (except for the enabled() value, of course). The caller is responsible for ensuring that lights are enabled when using them.
For parameterizing the light's power, imagine putting a bulb with a given bulbPower() in a light fixture. (Keep in mind that bulbs you buy in a store are marked with their equivalent power consumption for a ~5% efficient incandescent, so a "100W" bulb is really a "5W" emitter.) The shape of the light fixture determines the emittedPower():
This conceptual model of luminaires makes it easy to adjust light types in a scene. Turning an omni light into a spot light or a (small) area light preserves the observed intensity of objects directly under the light source. Be careful when comparing to published results; in many cases a rendering paper describes the emittedPower instead of the bulbPower, so a "1m^2 1W area light" would be a "1m^2 4w bulb area light" in G3D.
For reading from an Any, the following fields are supported:
plus all G3D::Entity fields.
A directional light has position.w == 0. A spot light has spotHalfAngle < pi() / 2 and position.w == 1. An omni light has spotHalfAngle == pi() and position.w == 1.
For a physically correct light, set attenuation = (0,0,1) for SPOT and OMNI lights (the default). UniversalSurface ignores attenuation on directional lights, although in general it should be (1,0,0).
|
inherited |
G3D::Light::Light | ( | ) |
|
inline |
Distance in meters to pull point light approximations of area lights back by.
|
inlineinherited |
Biradiance3 G3D::Light::biradiance | ( | const Point3 & | X | ) | const |
Biradiance (radiant flux per area) due to the entire emitter to point X, using the light's specified falloff and spotlight doors.
Biradiance3 G3D::Light::biradiance | ( | const Point3 & | X, |
const Point3 & | pointOnAreaLight | ||
) | const |
Power3 G3D::Light::bulbPower | ( | ) | const |
For a SPOT or OMNI light, the power of the bulb.
A SPOT light also has "barn doors" that absorb the light leaving in most directions, so their emittedPower() is less.
For an AREA light, this is 1/4 the power emitted by the surface, since the area light only emits forward (the back half is black, so there's a factor of 1/2) and it emits uniformly from a planar surface so has a cosine falloff with angle that integrates to another 1/2 over the hemisphere.
If a SPOT light uses a spotLightFalloff(), then it not simulated correctly for indirect light by G3D::PathTracer or the rasterization renderer when looking directly at the light because the cosine spotlight falloff isn't taken into account by the assumed uniform emission model of the emissive textures.
This is infinite for directional lights.
|
inlineinherited |
|
inlineinherited |
True if this Entity can change (when not Scene::editing(); all objects can change when in editing mode).
It is safe to build static data structures over Entitys that cannot change.
|
inlineinherited |
|
protected |
Update m_frame's rotation from spotDirection and spotTarget.
Called from factory methods to support the old API interface.
|
staticinherited |
|
static |
scene | may be nullptr |
|
inlinestaticprotectedinherited |
Like std::make_shared, but works for protected constructors.
Call as createShared<myclass>.
|
static |
toLight | will be normalized Only allocates the shadow map if shadowMapRes is greater than zero and shadowsEnabled is true |
|
inline |
Distance from the point to the light (infinity for DIRECTIONAL lights).
class Sphere G3D::Light::effectSphere | ( | float | cutoff = 30.0f/255 | ) | const |
Returns the sphere within which this light has some noticable effect.
May be infinite.
cutoff | The value at which the light intensity is considered negligible. |
Power3 G3D::Light::emittedPower | ( | ) | const |
For a SPOT or OMNI light, the power leaving the light into the scene.
A SPOT light's "barn doors" absorb most of the light. (A real spot light has a reflector at the back so that the first half of the emitted light is not also lost, however this model is easier to use when specifying scenes.)
Useful for photon emission. This is infinite for directional lights.
|
inline |
Referenced by setEnabled().
|
inlineinherited |
|
inline |
The size ("diameter") of the emitter along the x and y axes of its frame().
AREA and DIRECTIONAL lights emit from the entire surface. POINT and SPOT lights only emit from the center, although they use the extent for radial falloff to avoid superbrightenening. Extent is also used for Draw::light, debugging and selection by SceneEditorWindow.
float G3D::Light::farPlaneZ | ( | ) | const |
Position of the light's shadow map clipping plane along the light's z-axis.
float G3D::Light::farPlaneZLimit | ( | ) | const |
Farthest that the farPlaneZ() is ever allowed to be (part of the Light's specification)
|
static |
|
static |
|
inline |
The translation of a DIRECTIONAL light is infinite.
While this is often inconvenient, that inconvenience is intended to force separate handling of directional sources.
Use position() to find the homogeneneous position.
|
virtualinherited |
Return a world-space axis-aligned bounding box as of the last call to onPose().
|
virtualinherited |
Return a world-space bounding sphere as of the last call to onPose().
|
virtualinherited |
void G3D::Light::getRectangularAreaLightVertices | ( | Point3 | position[4] | ) | const |
Assumes type() == AREA and isRectangular = true.
Returns the world space position of the vertices.
Iterates counter-clockwise from the center - extent/2 corner.
void G3D::Light::getSpotConstants | ( | float & | cosHalfAngle, |
float & | softnessConstant | ||
) | const |
Returns the cosine of the spot light's half angle, and the softness constant used in G3D's lighting model.
Only useful for spot lights
bool G3D::Light::inFieldOfView | ( | const Vector3 & | w_i | ) | const |
Is vector w_i (from a point in the scene to the light) within the field of view (e.g., spotlight cone) of this light? Called from biradiance().
|
protectedinherited |
|
protectedinherited |
|
protected |
|
protectedinherited |
The initialization sequence for Entity and its subclasses is different than for typical C++ classes.
That is because they must avoid throwing exceptions from a constructor when parsing, need to support both AnyTableReader and direct parameter versions, and have to verify that all fields from an AnyTableReader are actually consumed. See samples/entity and G3D::VisibleEntity for examples of how to initialize an Entity subclass.
name | The name of this Entity, e.g., "Player 1" |
propertyTable | The form is given below. It is intended that subclasses replace the table name and add new fields. <some base class name> { model = <modelname>; frame = <initial CFrame or equivalent; overriden if a controller is present> track = <see Entity::Track>; canChange = <boolean> }
|
scene | May be nullptr so long as no entity() controller is used |
|
protectedinherited |
|
overridevirtualinherited |
Reimplemented from G3D::Entity.
|
overridevirtualinherited |
Returns true if there is conservatively some intersection with the object's bounds closer than maxDistance to the ray origin.
If so, updates maxDistance with the intersection distance.
The bounds used may be more accurate than any of the given getLastBounds() results because the method may recurse into individual parts of the scene graph within the Entity.
Reimplemented from G3D::Entity.
|
inherited |
Returns true if the world space bounds of these two entities overlap.
|
inlineinherited |
Wall-clock time at which this entity changed in some way, e.g., that might require recomputing a spatial data structure.
Point3 G3D::Light::lowDiscrepancyAreaPosition | ( | int | pixelIndex, |
int | lightIndex, | ||
int | sampleIndex, | ||
int | numSamples | ||
) | const |
Low-discrepancy distributed positions on the light based on screen pixel and light index.
The sequence is unique for each pixel and lightIndex. It repeats every numSamples. Does not include the areaLightPullback.
Point2 G3D::Light::lowDiscrepancySample | ( | int | pixelIndex, |
int | lightIndex, | ||
int | sampleIndex, | ||
int | numSamples | ||
) | const |
Helper function to generate low-discrepancy sample points in 2D.
Point3 G3D::Light::lowDiscrepancySolidAnglePosition | ( | int | pixelIndex, |
int | lightIndex, | ||
int | sampleIndex, | ||
int | numSamples, | ||
const Point3 & | X, | ||
float & | areaTimesPDFValue | ||
) | const |
Low-discrepancy distributed positions on the solid angle subtended by the light relative to the samplePosition, based on screen pixel and light index.
The sequence is unique for each pixel and lightIndex. It repeats every numSamples. Does not include the areaLightPullback. Returns probability in w channel.
Create a user interface for controlling the properties of this Entity.
Called by SceneEditorWindow on selection.
app | May be nullptr. |
Reimplemented from G3D::VisibleEntity.
|
inlineinherited |
Sets the lastChangeTime() to the current System::time()
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
Referenced by spotTarget().
float G3D::Light::nearPlaneZ | ( | ) | const |
Position of the light's shadow map clipping plane along the light's z-axis.
float G3D::Light::nearPlaneZLimit | ( | ) | const |
Closest that the nearPlaneZ() is ever allowed to be (part of the Light's specification)
|
protectedinherited |
GUI callback.
Constructs geometry as needed if visible() and no model() is set already.
Reimplemented from G3D::VisibleEntity.
If there is a bulbPowerTrack, then the bulbPower will be overwritten from it during simulation.
Reimplemented from G3D::VisibleEntity.
|
inlineinherited |
|
virtualinherited |
Creates a new G3D::SoundEntity attached to this Entity at childFrame by an Entity::EntityTrack and returns it.
The new SoundEntity is automatically added to the Scene and will remain rigidly attached to the Entity.
You do not need to retain the pointer to the created sound for it to remain playing and in the scene. The SoundEntity will automatically remove itself from the Scene when it stops playing.
If attach == false, then the EntityTrack is not created and the sound will remain fixed in space.
|
static |
|
inlinevirtualinherited |
|
protectedvirtualinherited |
Called from VisibleEntity::onPose to extract surfaces from the model.
If you subclass VisibleEntity to support a new model type, override this method. onPose will then still compute bounds correctly for your model.
|
inline |
Homogeneous world space position of the center of the light source (for a DIRECTIONAL light, w = 0)
Referenced by randomPosition().
|
inline |
Position on the light at coordinates (u, v) in light space, where u and v are each on [-1, 1].
Does not include the areaLightPullback.
bool G3D::Light::possiblyIlluminates | ( | const class Sphere & | sphere | ) | const |
Can this light possibly illuminate anything in the box based on the spotlight and attenuation?
|
inlineinherited |
|
inline |
|
inline |
In a global illumination renderer, should this light create indirect illumination (in addition to direct illumination) effects (e.g., by emitting photons in a photon mapper)?
Defaults to true.
Returns a unit vector selected uniformly at random within the world-space solid angle of the emission cone, frustum, or sphere of the light source.
For a directional light, simply returns the light direction.
|
inline |
Does not include the areaLightPullback.
|
inline |
If true, the emitter (and its emission cone for a spot light) is rectangular instead elliptical.
Defaults to false.
|
static |
Update the shadow maps in the enabled shadow casting lights from the array of surfaces.
cullFace | If CullFace::CURRENT, the Light::shadowCullFace is used for each light. |
|
protected |
Takes a 2D random vector, samples that point in the projected spherical quad, then returns the world-space position on the light of that sample.
(Urena, 2013)
|
inline |
|
inlinevirtualinherited |
If true, causes collisions for other objects during physical simulation.
It may not react to those collisions if physicalSimulation is false. Default is true for VisibleEntity and false for other subclasses.
|
inlineinherited |
|
inline |
|
virtualinherited |
This sets the position of the Entity for the current simulation step.
If there is a controller set and the base class Entity::onSimulation is invoked, it will override the value assigned here.
|
overridevirtual |
Sends directional lights to infinity.
|
virtualinherited |
If there is a controller on this object and it is a SplineTrack, mutate it to store this value.
Otherwise, create a new SplineTrack to overwrite the current controller.
Used by SceneEditorWindow
|
inlinevirtualinherited |
Set to a negative number to tell the physics system to use the absolute value as a density and infer the mass from the mesh on load.
Default is -10 (kg/m^3).
|
virtualinherited |
Not all VisibleEntity subclasses will accept all models.
If this model is not appropriate for this subclass, then the model() will not change.
|
inlinevirtualinherited |
If true, this object should receive physical simulation for its motion.
If true, canMove must also be true and there must be no Track on this Entity.
|
virtualinherited |
|
inlinevirtualinherited |
Explicitly override the previous frame value used for computing motion vectors.
This is very rarely needed because simulation automatically updates this value.
void G3D::Light::setShaderArgs | ( | class UniformTable & | args, |
const String & | prefix | ||
) | const |
Sets the following arguments in.
args | vec4 prefix+position; vec3 prefix+color; vec4 prefix+attenuation; vec3 prefix+direction; bool prefix+rectangular; vec3 prefix+up; vec3 prefix+right; float prefix+radius; prefix+shadowMap...[See ShadowMap::setShaderArgs] |
|
inline |
|
inlineinherited |
|
inline |
|
inline |
|
inlinevirtualinherited |
|
inlinevirtualinherited |
|
inline |
|
inline |
Optional shadow map.
May be nullptr
|
inline |
When this light is enabled, does it cast shadows?
Referenced by setShadowsEnabled(), and spotTarget().
|
inlineinherited |
True if this Entity should be saved when the scene is converted to Any for saving/serialization.
Defaults to true. Set to false for transient objects. For example, a character's spawn point Entity might have shouldBeSaved() = true, while the character itself might have shouldBeSaved() = false. This would allow editing of the scene while the simulation loop is running without having the scene at the end of the editing session reflecting the result of the character moving about.
|
protectedvirtualinherited |
Animates the appropriate pose type for the model selected.
Called from onSimulation. Subclasses will frequently replace onSimulation but retain this helper method.
|
static |
pointDirection | Will be normalized. Points in the direction that light propagates. |
halfAngleRadians | Must be on the range [0, pi()/2]. This is the angle from the point direction to the edge of the light cone. I.e., a value of pi() / 4 produces a light with a pi() / 2-degree cone of view. |
Referenced by spotTarget().
|
inline |
Spot light cutoff half-angle in radians.
pi() = no cutoff (point/dir). Values less than pi()/2 = spot light.
A rectangular spot light circumscribes the cone of this angle. That is, spotHalfAngle() is the measure of the angle from the center to each edge along the orthogonal axis.
|
inline |
Like Photoshop brush hardness.
1.0 = abrupt cutoff at the half angle (default), 0.0 = gradual falloff within the cone.
float G3D::Light::spotLightFalloff | ( | const Vector3 & | w_i | ) | const |
Returns a number between 0 and 1 for how the light falls off due to the spot light's cone.
|
inline |
|
inlinestatic |
Creates a spot light that looks at a specific point (by calling spot())
Point3 G3D::Light::stratifiedAreaPosition | ( | int | pixelIndex, |
int | sampleIndex, | ||
int | numSamples | ||
) | const |
|
overridevirtual |
Converts the current VisibleEntity to an Any.
Subclasses should modify at least the name of the Table returned by the base class, which will be "Entity" if not changed.
Reimplemented from G3D::VisibleEntity.
|
inlinevirtualinherited |
|
inline |
Point3 G3D::Light::uniformAreaPosition | ( | ) | const |
|
inlineinherited |
|
virtualinherited |
Called by Scene::visualize every frame.
During this, Entitys may make rendering calls according to the SceneVisualizationSettings to display control points and other features.
isSelected | True if this entity is selected by a sceneEditorWindow, which may trigger additional visualization for it. |
Reimplemented in G3D::MarkerEntity, and G3D::SoundEntity.
float G3D::Light::attenuation[3] |
The attenuation observed by an omni or spot light is.
where = attenuation[i]
and is the distance to the source.
Directional lights ignore attenuation. A physically correct light source should have $ , but it may be artistically desirable to alter the falloff function.
To create a local light where the biradiance is equal to the bulbPower with "no attenuation", use $ .
Color3 G3D::Light::color |
Point light: this is the the total power ( ) emitted uniformly over the sphere.
The incident normal irradiance at a point distance from the light is .
Spot light: the power is the same as for a point light, but line of sight is zero outside the spot cone. Thus the area within the spot cone does not change illumination when the cone shrinks.
Directional light: this is the incident normal irradiance in the light's direction, .
Referenced by spotTarget().
|
protected |
Referenced by areaLightPullback(), and setAreaLightPullback().
|
protectedinherited |
Pose over time.
|
protected |
If set, this is used in onSimulation.
|
protectedinherited |
Referenced by G3D::Entity::canCauseCollisions(), and G3D::Entity::setCanCauseCollisions().
|
protectedinherited |
If true, the canChange() method returns true.
Defaults to true.
It is illegal to set m_canChange to false if m_frameSpline has more than one control point because a spline implies animation.
Subclasses should set this to false during initialization if the object will never move so that other classes can precompute data structures that are affected by the Entity.
Referenced by G3D::Entity::canChange().
|
protected |
If false, this light is ignored.
Referenced by enabled(), and setEnabled().
|
protectedinherited |
|
protected |
The size ("diameter") of the emitter along the x and y axes of its frame().
AREA and DIRECTIONAL lights emit from the entire surface. POINT and SPOT lights only emit from the center, although they use the extent for radial falloff to avoid superbrightenening. Extent is also used for Draw::light, debugging and selection by SceneEditorWindow.
Referenced by extent(), and position().
|
protected |
|
protectedinherited |
Current position.
Do not directly mutate–invoke setFrame() to ensure that times are modified correctly.
Referenced by distance(), G3D::Entity::frame(), frame(), and position().
|
protectedinherited |
Bounds at the last pose() call, in world space.
|
protectedinherited |
Time at which the bounds were computed.
Bounds on all of the surfaces from the last pose() call, in world space.
Referenced by G3D::Entity::lastBoxBoundArray().
|
protectedinherited |
Referenced by G3D::Entity::lastChangeTime(), G3D::Entity::markChanged(), setEnabled(), and setShadowsEnabled().
|
protectedinherited |
Bounds at the last pose() call, in object space.
|
protectedinherited |
Bounds at the last pose() call, in world space.
|
protectedinherited |
Referenced by G3D::Entity::mass(), and G3D::Entity::setMass().
|
protectedinherited |
|
protectedinherited |
Referenced by G3D::VisibleEntity::model().
|
protectedinherited |
|
protectedinherited |
True if the frame has changed since load.
Used by toAny() to decide if m_sourceAny is out of date.
|
protectedinherited |
Has this Entity been explicitly moved by setFrame() since it was last simulated? If so, onSimulation will not update the m_previousFrame because it assumes some external logic is moving the Entity.
|
protectedinherited |
Referenced by G3D::Entity::name().
|
protected |
|
protectedinherited |
Referenced by G3D::Entity::physicalSimulation(), and G3D::Entity::setPhysicalSimulation().
|
protectedinherited |
Referenced by G3D::VisibleEntity::articulatedModelPose(), and G3D::VisibleEntity::pose().
|
protectedinherited |
Frame before onSimulation().
Used for tracking poses and for velocity estimation.
Referenced by G3D::Entity::previousFrame(), and G3D::Entity::setPreviousFrame().
|
protectedinherited |
|
protected |
Referenced by producesDirectIllumination().
|
protected |
Referenced by producesIndirectIllumination().
|
protected |
If true, setShaderArgs will bind a spotHalfAngle large enough to encompass the entire square that bounds the cutoff angle.
This produces a frustum instead of a cone of light when used with a G3D::ShadowMap. for an unshadowed light this has no effect.
Referenced by randomPosition(), rectangular(), and spotSquare().
|
protectedinherited |
|
protected |
Referenced by shadowCullFace().
|
protected |
Optional shadow map.
Referenced by shadowMap().
|
protected |
Referenced by setShadowsEnabled(), and shadowsEnabled().
|
protectedinherited |
True if this Entity should be saved when the scene is converted to Any for saving/serialization.
Defaults to true. Set to false for transient objects. For example, a character's spawn point Entity might have shouldBeSaved() = true, while the character itself might have shouldBeSaved() = false. This would allow editing of the scene while the simulation loop is running without having the scene at the end of the editing session reflecting the result of the character moving about.
Referenced by G3D::Entity::setShouldBeSaved(), and G3D::Entity::shouldBeSaved().
|
protected |
Spotlight cutoff half-angle in radians.
pi() = no cutoff (point/dir). Values less than pi()/2 = spot light
Referenced by setSpotHalfAngle(), and spotHalfAngle().
|
protected |
1 = hard cutoff (default).
0 = cosine falloff within cone (like photoshop's brush hardness)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ float t = dir.dot(lightDir) - cosHalfAngle; t /= 1 - cosHalfAngle; // On [0, 1] float softness = (1 - hardness);
Avoid Nan from 0/0 float brightness = clamp(t / (softness + eps), 0, 1);
//////////////////////////////////////// Using precomputed values: const float lightSoftnessConstant = 1.0 / ((1 - hardness + eps) * (1 - cosHalfAngle)); float brightness = clamp((dir.dot(lightDir) - cosHalfAngle) * lightSoftnessConstant, 0, 1); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Referenced by setSpotHardness(), and spotHardness().
|
protectedinherited |
Basic simulation behavior for the Entity.
If nullptr, the Entity is never moved by the base class' onSimulation method. You can subclass Track, but it is usually easier to subclass Entity and override onSimulation directly when creating behaviors more complex than those supported by the default Track language.
Referenced by G3D::Entity::setTrack(), and G3D::Entity::track().
|
protected |
Referenced by distance(), position(), randomPosition(), and type().
|
protected |
|
protectedinherited |
Should this Entity currently be allowed to affect any part of the rendering pipeline (e.g., shadows, primary rays, indirect light)? If false, the Entity never returns any surfaces from onPose().
Does not necessarily mean that the underlying model is visible to primary rays.
Referenced by G3D::VisibleEntity::setVisible(), and G3D::VisibleEntity::visible().