Skip to content

DirectionalLight

A directional light illuminating the scene with parallel rays of light (can cast shadows).

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 objet 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 paramter 0.05
VSMMinVariance [Shadowing] (VSM only) Minimum variance parameter 0.001
textureUnit [Shadowing] Texture unit for the genereated shadow texture 1
modelViewMatrix [Shadowing] ModelView Matrix
projectionMatrix [Shadowing] Projection Matrix
direction Set the direction of the light 0 0 -1
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

DirectionalLight.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 [DirectionalLight LightManager] -->

    <DefaultAnimationLoop/>
    <CollisionPipeline verbose="0" />
    <BruteForceBroadPhase/>
    <BVHNarrowPhase/>
    <CollisionResponse response="PenalityContactForceField" />
    <MinProximityIntersection name="Proximity" alarmDistance="0.02" contactDistance="0.02" />
    <LightManager />
    <DirectionalLight name="light1" color="1 0 0" direction="0 -1 -1" />
    <DirectionalLight name="light2" color="0 1 0" direction="1 1 0" />
    <include href="Objects/SaladBowl.xml" />
    <include href="Objects/TorusRigid.xml" scale="0.05" rx="30" ry="15" dz="1" />
</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('DefaultAnimationLoop', )
   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('LightManager', )
   root.addObject('DirectionalLight', name="light1", color="1 0 0", direction="0 -1 -1")
   root.addObject('DirectionalLight', name="light2", color="0 1 0", direction="1 1 0")
   root.addObject('include', href="Objects/SaladBowl.xml")
   root.addObject('include', href="Objects/TorusRigid.xml", scale="0.05", rx="30", ry="15", dz="1")