A quick way to toggle light visibility in SAMSON using NSL

In molecular modeling, especially when rendering complex scenes or setting up simulations, it can become cumbersome to manually manage all the elements in your scene—particularly light sources. Lights play a critical role in how molecular structures are visualized, but as your scene grows, so does the need for a fast and reliable way to organize and control those lights.

This post shows how light attributes in the Node Specification Language (NSL) can be used to quickly control the visibility of light nodes in SAMSON. Whether you’re preparing a publication-ready rendering or debugging a visibility issue, understanding how to use these NSL constructs can save you time and make your workflow more efficient.

Why visibility matters

Light nodes in SAMSON can significantly affect how your scene looks. A single active light can alter shadows, highlights, and overall perception of molecular geometry. When lights are not behaving as expected, often the issue lies with their visibility or flags. Being able to script and query these parameters is essential in complex projects.

Different ways to manage light visibility

Light visibility in NSL can be controlled using a few different attributes:

  • li.v for visible (true or false)
  • li.vf for visibilityFlag
  • li.h for hidden

The li prefix ensures the selection or action is limited to light nodes.

Examples of use

Here are a few ways you can filter or control lights:

  • li.v – Selects all visible light nodes
  • not li.v – Selects all invisible light nodes
  • li.vf false – Selects all light nodes with a false visibilityFlag
  • li.h – Selects all hidden light nodes

Using these queries, you could for example quickly isolate all hidden or disabled lights, and either make them visible again or inspect why they were producing unexpected lighting effects.

When to use which attribute?

  • li.v: This indicates whether the node is currently visible in the scene—very useful for toggling display settings.
  • li.vf: This flag can be used for more advanced logic, such as preparing a dynamic scene where certain conditions toggle visibility automatically.
  • li.h: This is complementary to visibility and sometimes used internally in more advanced selection filters. It’s helpful for consistency checks.

Putting it into practice

Imagine you’re working on a large protein-ligand complex with a few custom lighting setups for different visualizations. Before presenting or exporting visuals, you want to ensure only the relevant lights are shown. A simple query such as:

will select all light nodes that are not visible, and allow you to inspect or enable them if needed.

Or you could bulk hide all lights with:

This makes managing complex scenes something that can be done in seconds instead of manually searching and checking node properties one by one.

This can be especially helpful when collaborating or sharing a project with others who may have different visualization preferences. Having precise control over which lights are active keeps everything clear and easy to manage.

To learn more about light attributes and how to use NSL efficiently in SAMSON, check the original documentation at https://documentation.samson-connect.net/users/latest/nsl/light/.

SAMSON and all SAMSON Extensions are free for non-commercial use. You can get SAMSON at https://www.samson-connect.net.

Comments are closed.