Skip to content

PositionalLight

A positional light illuminating the scene.The light has a location from which the ray are starting in all direction (cannot cast shadows for now)

Target: Sofa.GL.Component.Shader

namespace: sofa::gl::component::shader

parents:

  • Light

Data

Name Description Default value
name object name unnamed
printLog if true, emits extra messages at runtime. 0
tags list of the subsets the object belongs to
bbox this object bounding box
componentState The state of the component among (Dirty, Valid, Undefined, Loading, Invalid). Undefined
listening if true, handle the events, otherwise ignore the events 0
enable Display the object or not 1
color Set the color of the light. (default=[1.0,1.0,1.0,1.0]) 1 1 1 1
shadowTextureSize [Shadowing] Set size for shadow texture 0
zNear [Shadowing] Light's ZNear
zFar [Shadowing] Light's ZFar
shadowsEnabled [Shadowing] Enable Shadow from this light 1
softShadows [Shadowing] Turn on Soft Shadow from this light 0
shadowFactor [Shadowing] Shadow Factor (decrease/increase darkness) 1
VSMLightBleeding [Shadowing] (VSM only) Light bleeding parameter 0.05
VSMMinVariance [Shadowing] (VSM only) Minimum variance parameter 0.001
textureUnit [Shadowing] Texture unit for the generated shadow texture 1
modelViewMatrix [Shadowing] ModelView Matrix
projectionMatrix [Shadowing] Projection Matrix
fixed Fix light position from the camera 0
position Set the position of the light -0.7 0.3 0
attenuation Set the attenuation of the light 0
Visualization
drawSource Draw Light Source 0
Name Description Destination type name
context Graph Node containing this object (or BaseContext::getDefault() if no graph is used) BaseContext
slaves Sub-objects used internally by this object BaseObject
master nullptr for regular objects, or master object for which this object is one sub-objects BaseObject

Examples

PositionalLight.scn

<Node name="root" dt="0.01" gravity="0 0 -10" showBoundingTree="0">
    <RequiredPlugin name="Sofa.Component.Collision.Detection.Algorithm"/> <!-- Needed to use components [BVHNarrowPhase BruteForceBroadPhase CollisionPipeline] -->
    <RequiredPlugin name="Sofa.Component.Collision.Detection.Intersection"/> <!-- Needed to use components [MinProximityIntersection] -->
    <RequiredPlugin name="Sofa.Component.Collision.Geometry"/> <!-- Needed to use components [LineCollisionModel PointCollisionModel TriangleCollisionModel] -->
    <RequiredPlugin name="Sofa.Component.Collision.Response.Contact"/> <!-- Needed to use components [CollisionResponse] -->
    <RequiredPlugin name="Sofa.Component.IO.Mesh"/> <!-- Needed to use components [MeshOBJLoader] -->
    <RequiredPlugin name="Sofa.Component.LinearSolver.Iterative"/> <!-- Needed to use components [CGLinearSolver] -->
    <RequiredPlugin name="Sofa.Component.Mapping.NonLinear"/> <!-- Needed to use components [RigidMapping] -->
    <RequiredPlugin name="Sofa.Component.Mass"/> <!-- Needed to use components [UniformMass] -->
    <RequiredPlugin name="Sofa.Component.ODESolver.Backward"/> <!-- Needed to use components [EulerImplicitSolver] -->
    <RequiredPlugin name="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
    <RequiredPlugin name="Sofa.Component.Topology.Container.Constant"/> <!-- Needed to use components [MeshTopology] -->
    <RequiredPlugin name="Sofa.GL.Component.Rendering3D"/> <!-- Needed to use components [OglModel] -->
    <RequiredPlugin name="Sofa.GL.Component.Shader"/> <!-- Needed to use components [LightManager PositionalLight] -->
    <CollisionPipeline verbose="0" />
    <BruteForceBroadPhase/>
    <BVHNarrowPhase/>
    <CollisionResponse response="PenalityContactForceField" />
    <MinProximityIntersection name="Proximity" alarmDistance="0.02" contactDistance="0.02" />
    <DefaultAnimationLoop/>

    <LightManager />
    <PositionalLight name="light1" color="1 0 0" attenuation="0.4" position="0.5 0.7 2" />
    <PositionalLight name="light2" color="0 1 0" attenuation="0.4" position="0.5 -0.7 2" />
    <PositionalLight name="light3" color="0 0 1" attenuation="0.4" position="-0.8 0 2" />
    <include href="Objects/SaladBowl.xml" />
    <include href="Objects/TorusRigid.xml" scale="0.05" rx="30" ry="15" dz="0.5" />
</Node>
def createScene(root_node):

   root = root_node.addChild('root', dt="0.01", gravity="0 0 -10", showBoundingTree="0")

   root.addObject('RequiredPlugin', name="Sofa.Component.Collision.Detection.Algorithm")
   root.addObject('RequiredPlugin', name="Sofa.Component.Collision.Detection.Intersection")
   root.addObject('RequiredPlugin', name="Sofa.Component.Collision.Geometry")
   root.addObject('RequiredPlugin', name="Sofa.Component.Collision.Response.Contact")
   root.addObject('RequiredPlugin', name="Sofa.Component.IO.Mesh")
   root.addObject('RequiredPlugin', name="Sofa.Component.LinearSolver.Iterative")
   root.addObject('RequiredPlugin', name="Sofa.Component.Mapping.NonLinear")
   root.addObject('RequiredPlugin', name="Sofa.Component.Mass")
   root.addObject('RequiredPlugin', name="Sofa.Component.ODESolver.Backward")
   root.addObject('RequiredPlugin', name="Sofa.Component.StateContainer")
   root.addObject('RequiredPlugin', name="Sofa.Component.Topology.Container.Constant")
   root.addObject('RequiredPlugin', name="Sofa.GL.Component.Rendering3D")
   root.addObject('RequiredPlugin', name="Sofa.GL.Component.Shader")
   root.addObject('CollisionPipeline', verbose="0")
   root.addObject('BruteForceBroadPhase', )
   root.addObject('BVHNarrowPhase', )
   root.addObject('CollisionResponse', response="PenalityContactForceField")
   root.addObject('MinProximityIntersection', name="Proximity", alarmDistance="0.02", contactDistance="0.02")
   root.addObject('DefaultAnimationLoop', )
   root.addObject('LightManager', )
   root.addObject('PositionalLight', name="light1", color="1 0 0", attenuation="0.4", position="0.5 0.7 2")
   root.addObject('PositionalLight', name="light2", color="0 1 0", attenuation="0.4", position="0.5 -0.7 2")
   root.addObject('PositionalLight', name="light3", color="0 0 1", attenuation="0.4", position="-0.8 0 2")
   root.addObject('include', href="Objects/SaladBowl.xml")
   root.addObject('include', href="Objects/TorusRigid.xml", scale="0.05", rx="30", ry="15", dz="0.5")