#######
Effects
#######


HOOPS Communicator includes a variety of effects that can alter the appearance of your scene.


Ambient occlusion
=================

Ambient occlusion is a lighting effect that is included in HOOPS Communicator. Ambient occlusion uses the scene's ambient light to determine the brightness and color of points in the scene. Embedded areas of geometry are shaded by this effect.

In HOOPS Communicator, ambient occlusion is disabled by default. To enable or disable ambient occlusion, call the :ref:`setAmbientOcclusionEnabled() <api_ref/viewing/classes/Communicator.View:setambientocclusionenabled>` function with a Boolean:

.. code-block:: js

	// Enable Ambient Occlusion
	hwv.view.setAmbientOcclusionEnabled(true);
	// Disable Ambient Occlusion
	hwv.view.setAmbientOcclusionEnabled(false);

.. image:: images/ambientocclusion_off.png

*Ambient occlusion off*

.. image:: images/ambientocclusion_on.png

*Ambient occlusion on*

You can check the current ambient occlusion setting using the :ref:`getAmbientOcclusionEnabled() <api_ref/viewing/classes/Communicator.View:getambientocclusionenabled>` function which will return a boolean indicating if ambient occlusion is enabled or disabled.

.. code-block:: js

	hwv.view.getAmbientOcclusionEnabled();


Ambient occlusion radius
========================

Ambient occlusion radius is the maximum screen-proportional distance between two points such that one will cast a shadow on the other. Ambient occlusion radius can be updated by passing a number to the :ref:`setAmbientOcclusionRadius() <api_ref/viewing/classes/Communicator.View:setambientocclusionradius>` function.

.. code-block:: js

	hwv.view.setAmbientOcclusionRadius(0.15);

.. image:: images/AO_radius_0.065.png

*Ambient occlusion radius = 0.065*

.. image:: images/AO_radius_0.15.png

*Ambient occlusion radius = 0.15*

The current ambient occlusion value can also be retrieved with :ref:`getAmbientOcclusionRadius() <api_ref/viewing/classes/Communicator.View:getambientocclusionradius>`:

.. code-block:: js

	hwv.view.getAmbientOcclusionRadius();


Ambient light
=============

Ambient light is a nondirectional light which illuminates the scene. To change the ambient light color create a new instance of a :doc:`color </api_ref/viewing/classes/Communicator.Color>` object and pass it to the :ref:`setAmbientLightColor() <api_ref/viewing/classes/Communicator.View:setambientlightcolor>` function.

The constructor for the ``color`` object takes three parameters: red, green and blue. Each parameter in the constructor is a number from 0 to 255 which describes the intensity (with 0 being no intensity and 255 being max intensity) of red, green or blue in the newly created color.

.. code-block:: js

	var ambColor = new Communicator.Color(0, 60, 50);
	hwv.view.setAmbientLightColor(ambColor);

The following images have ambient occlusion enabled.

.. image:: images/amb_light_default.png

*Default ambient light color*

.. image:: images/amb_light_green.png

*Ambient light color (80, 0, 80)*

To retrieve the current ambient light color, call the :ref:`getAmbientLightColor() <api_ref/viewing/classes/Communicator.View:getambientlightcolor>` function. The default ambient light color in the scene is a white light with values red = 19.125, blue = 19.125 and green = 19.125.

.. code-block:: js

	hwv.view.getAmbientLightColor();


Bloom
=====

Bloom is an effect which simulates a bright light entering a camera. Bright areas in the scene, that exceed a specified :ref:`bloom luminance threshold <api_ref/viewing/classes/Communicator.View:setbloomthreshold>`, will glow casting their color on the surrounding surfaces. The bloom effect is achieved by applying a luminance filter to the source image, then progressively downsampling, blurring, and adding the results together. The result of each downsample/blur operation is fed into the next, which is executed at half the resolution of the previous. The number of stages and the behavior of each stage are controlled by the :ref:`setBloomLayers() <api_ref/viewing/classes/Communicator.View:setbloomlayers>` function.

In the images below, a directional light is hitting the models causing areas of their surfaces to exceed the bloom luminance threshold.

.. image:: images/bloom_disabled.png

*Bloom disabled*

.. image:: images/bloom_enabled.png

*Bloom enabled*

To enable and disable bloom pass a boolean to the :ref:`setBloomEnabled() <api_ref/viewing/classes/Communicator.View:setbloomenabled>` function:

.. code-block:: js

	// Enable Bloom
	hwv.view.setBloomEnabled(true);
	// Disable Bloom
	hwv.view.setBloomEnabled(false);

The viewer's current bloom state can be obtained using the :ref:`getBloomEnabled() <api_ref/viewing/classes/Communicator.View:getbloomenabled>` function.

.. code-block:: js

	hwv.view.getBloomEnabled();


Bloom threshold
===============

Bloom threshold is the minimum luminance value a pixel must have for it to contribute to bloom. The viewer's bloom threshold is set by passing a number in the range [0,1] (with values closer to 0 resulting in more bloom and values closer to 1 resulting in less bloom) to :ref:`setBloomThreshold() <api_ref/viewing/classes/Communicator.View:setbloomthreshold>`. The viewer's current view threshold can be acquired using :ref:`getBloomThreshold() <api_ref/viewing/classes/Communicator.View:getbloomthreshold>`. The default bloom threshold value is 0.65.

.. code-block:: js

	// Get the current Bloom Threshold
	hwv.view.getBloomThreshold();

	// Update Bloom Threshold
	hwv.view.setBloomThreshold(0.5);

.. image:: images/bloom_threshold_0.5.png

*Bloom threshold 0.5*

.. image:: images/bloom_threshold_0.65.png

*Bloom threshold 0.65 (default)*


Bloom threshold ramp width
==========================

Determines how much greater the pixel luminance value must be when compared to the threshold set by the :ref:`setBloomThreshold() <api_ref/viewing/classes/Communicator.View:setbloomthreshold>` method before it contributes fully to the bloom effect. If the pixel's luminance value does not exceed the threshold by at least the amount set by this function, the pixel's contribution will be diminished based on how close its luminance value is to the threshold.

Set the viewer's bloom threshold ramp width using :ref:`setBloomThresholdRampWidth() <api_ref/viewing/classes/Communicator.View:setbloomthresholdrampwidth>`. The viewer's existing bloom threshold ramp width value can be obtained with :ref:`getBloomThresholdRampWidth() <api_ref/viewing/classes/Communicator.View:getbloomthresholdrampwidth>`. The default value of the bloom threshold ramp width is 0.1.

.. code-block:: js

	// Get the current Bloom Threshold Ramp Width value
	hwv.view.getBloomThresholdRampWidth();

	// Set the Bloom Threshold Ramp Width value
	hwv.view.setBloomThresholdRampWidth(0.2);

.. image:: images/bloom_rampwith_0.1.png

*Bloom threshold ramp width 0.1 (default)*

.. image:: images/bloom_rampwith_0.2.png

*Bloom threshold ramp width 0.2*


Bloom intensity scale
=====================

The intensity of a bloom layer can be controlled by passing a number to :ref:`setBloomIntensityScale  <api_ref/viewing/classes/Communicator.View:setbloomintensityscale>`. The viewer's current bloom intensity can be retrieved with :ref:`getBloomIntensityScale()  <api_ref/viewing/classes/Communicator.View:getbloomintensityscale>`. The default bloom intensity scale is 1.

.. code-block:: js

	// Retrieve the current bloom intensity scale
	hwv.view.getBloomIntensityScale();
	// Update the bloom intensity scale
	hwv.view.setBloomIntensityScale(0.25);

.. image:: images/bloom_intensity_1.png

*Bloom intensity scale 1*

.. image:: images/bloom_intensity_0.25.png

*Bloom intensity scale 0.25*


Multi-layer bloom
=================

The bloom effect is achieved by applying a luminance filter to the source image, then progressively downsampling, blurring, and adding the results together. The result of each downsample/blur operation is fed into the next, which is executed at half the resolution of the previous. The number of stages and the behavior of each stage are controlled by the :ref:`setBloomLayers() <api_ref/viewing/classes/Communicator.View:setbloomlayers>` function.


BloomLayerInfo
==============

:doc:`Communicator.BloomLayerInfo </api_ref/viewing/interfaces/Communicator.BloomLayerInfo>` describes a single layer in the bloom effect. Each bloom layer contains ``blurInterval``, ``blurSamples`` and ``intensity`` properties.

* :ref:`blurInterval <api_ref/viewing/interfaces/Communicator.BloomLayerInfo:blurinterval>` is the distance between samples taken during the Gaussian blur operation executed when rendering this layer. ``blurInterval`` is defined as ``[number, BlurIntervalUnit]`` where number is distance between samples the and ``BlurIntervalUnit`` describes the unit used to measure intervals between samples. If unspecified, the value will default to ``[1, Pixels]``. Information regarding ``BlurIntervalUnit.Pixels`` and othe the other ``BlurInteralUnits`` can be found at this :ref:`page <api_ref/viewing/enums/Communicator.BlurIntervalUnit>`.

* :ref:`blurSamples <api_ref/viewing/interfaces/Communicator.BloomLayerInfo:blursamples>` are the number of samples taken in each of the two passes of the Gaussian blur operation executed when rendering this layer. If unspecified, the value will default to 9.

* :ref:`Intensity <api_ref/viewing/interfaces/Communicator.BloomLayerInfo:intensity>` is the number used to scale the contribution of the layer to the image. If unspecified, the value will default to 1. Set the intensity using :ref:`setBloomIntensityScale()  <api_ref/viewing/classes/Communicator.View:setbloomintensityscale>`.


Adding and removing bloom layers
================================

To add a new bloom layer create a javascript object with the properties listed on the :doc:`Communicator.BloomLayerInfo </api_ref/viewing/interfaces/Communicator.BloomLayerInfo>` page.

.. code-block:: js

	var bInterval = 1.0;
	var bStyle = Communicator.BlurIntervalUnit.Pixels;
	var bSample = 9.0;
	var layerIntensity = 1.0;
	var newLayer = {intensity: layerIntensity, blurSamples: bSample, blurInterval: [bInterval, bStyle]};

With the layer object created you can add it to the existing bloom layer array, which you can get with :ref:`getBloomLayers() <api_ref/viewing/classes/Communicator.View:getbloomlayers>`, and then set the bloom layers with the updated array using :ref:`setBloomLayers()  <api_ref/viewing/classes/Communicator.View:setbloomlayers>`.

.. code-block:: js

	// Get the current Bloom Layer Array
	var bloomLayers = hwv.view.getBloomLayers();

	// Add the new bloom layer
	bloomLayers.push(newLayer);

	// Set the Bloom Layer Array
	hwv.view.setBloomLayers(bloomLayers);

If you want to discard all existing elements of the bloom layer array simply create a new array.

.. code-block:: js

	// Discard all exisiting bloom layers and use a new array with your layer
	var newArray = [newLayer];
	hwv.view.setBloomLayers(newArray);

.. image:: images/bloom_layers_1.png

*1 bloom layer (using the settings from above)*

.. image:: images/bloom_layers_4.png

*4 bloom layers (Using the settings from above)*

Elements of the bloom layer array can be removed like any javascript array. After removing layers from the array you must use :ref:`setBloomLayers()  <api_ref/viewing/classes/Communicator.View:setbloomlayers>` to update the viewer's bloom layer array.

.. code-block:: js

	// Get the current bloom layer array
	var bloomLayers = hwv.view.getBloomLayers();
	// Remove the last element from the array
	bloomLayers.pop();
	// Remove an element at the given index (here we are removing the first element)
	bloomLayers.splice(0, 1);
	// Update the viewer's bloom layers
	hmv.view.setBloomLayers(bloomLayers);


Simple shadows
==============

Simple shadows are full-scene shadow projected onto an invisible ground plane. By default simple shadows are disabled. They can be enabled by passing a true boolean to the :ref:`setSimpleShadowEnabled()  <api_ref/viewing/classes/Communicator.View:setsimpleshadowenabled>` function. To get the viewer's simple shadow setting use :ref:`getSimpleShadowEnabled()  <api_ref/viewing/classes/Communicator.View:getsimpleshadowenabled>`.

.. code-block:: js

	// Enable simple shadows
	hwv.view.setSimpleShadowEnabled(true);
	// Disable simple shadows
	hwv.view.setSimpleShadowEnabled(false);
	// Get the viewer's simple shadow setting
	hwv.view.getSimpleShadowEnabled();

.. image:: images/floor-shadow-off.png

*Simple shadow disabled*

.. image:: images/floor-shadow-on.png

*Simple shadow enabled*


Simple shadow opacity
=====================

The opacity of the simple shadows can be set by passing a number (with higher value numbers being more opaque) to :ref:`setSimpleShadowOpacity()  <api_ref/viewing/classes/Communicator.View:setsimpleshadowopacity>`. To retrieve the viewer's current simple shadow opacity use :ref:`getSimpleShadowOpacity()  <api_ref/viewing/classes/Communicator.View:getsimpleshadowopacity>`. The default shadow opacity is 0.65.

.. code-block:: js
	
	// Set the simple shadow opacity
	hwv.view.setSimpleShadowOpacity(0.2);
	// Get the simple shadow opacity
	hwv.view.getSimpleShadowOpacity();

.. image:: images/floor-shadow-0.2.png

*Simple shadow opacity 0.2*

.. image:: images/floor-shadow-0.65.png

*Simple shadow opacity 0.65 (default)*


Simple shadow color
===================

The color of the simple shadow can also be changed by calling the :ref:`setSimpleShadowColor()  <api_ref/viewing/classes/Communicator.View:setsimpleshadowcolor>` function with a :doc:`Communicator.Color </api_ref/viewing/classes/Communicator.Color>` object. Get the current simple shadow color by using :ref:`getSimpleShadowColor()  <api_ref/viewing/classes/Communicator.View:getsimpleshadowcolor>`. The default shadow color is black (0, 0, 0).

.. code-block:: js

	// Create a red color object
	var redShadow = new Communicator.Color(180, 30, 30);
	// Set the simple shadow color
	hwv.view.setSimpleShadowColor(redShadow);
	// Get the current shadow color
	hwv.view.getSimpleShadowColor();

.. image:: images/floor-shadow-red.png

*Red simple shadow*


Simple shadow resolution
========================

Sets the width and height in pixels of the texture image into which simple shadows are drawn. Set the resolution by passing a number to :ref:`setSimpleShadowResolution()  <api_ref/viewing/classes/Communicator.View:setsimpleshadowresolution>`. Retrieve the viewer's simple shadow resolution with :ref:`getSimpleShadowResolution()  <api_ref/viewing/classes/Communicator.View:getsimpleshadowresolution>`. The default simple shadow resolution is 512.

.. code-block:: js

	// Set Simple Shadow Resolution
	hwv.view.setSimpleShadowResolution(1024);
	// Get Simple Shadow Resolution
	hwv.view.getSimpleShadowResolution();

.. image:: images/floor-shadow-res-256.png

*Simple shadow resolution = 256*

.. image:: images/floor-shadow-res-2048.png

*Simple shadow resolution = 2048*


Simple shadow blurSamples
=========================

Sets the diameter of the blur filter used for simple shadows. Setting the value to 0 will disable blurring. Set the ``blurSamples`` value by passing a number to the :ref:`setSimpleShadowBlurSamples()  <api_ref/viewing/classes/Communicator.View:setsimpleshadowblursamples>` function. Get the viewer's blurSamples value by using :ref:`getSimpleShadowBlurSamples()  <api_ref/viewing/classes/Communicator.View:getsimpleshadowblursamples>`.

The default ``blurSamples`` value is 5.

.. code-block:: js

	// Set simple shadows blurSamples
	hwv.view.setSimpleShadowBlurSamples(10);
	// Get simple shadows blurSamples
	hwv.view.getSimpleShadowBlurSamples();

.. image:: images/floor-shadow-sample-1.png

*Simple shadow blurSamples = 1*

.. image:: images/floor-shadow-sample-10.png

*Simple shadow blurSamples = 10*


Simple shadow blurInterval
==========================

Sets the distance in pixels between samples taken by the blur filter used for simple shadows. Set the ``blurInterval`` value by passing a number to :ref:`setSimpleShadowBlurInterval()  <api_ref/viewing/classes/Communicator.View:setsimpleshadowblurinterval>`. Get the viewer's current simple shadow blurInterval value by calling :ref:`getSimpleShadowBlurInterval()  <api_ref/viewing/classes/Communicator.View:getsimpleshadowblurinterval>`.

The default value for simple shadow blurInterval is 1.

.. code-block:: js

	// Set the simple shadow blurInterval
	hwv.view.setSimpleShadowBlurInterval(5);
	// Get the current simple shadow blurInterval
	hwv.view.getSimpleShadowBlurInterval();

.. image:: images/floor-shadow-interval-1.png

*Simple shadow blurInterval = 1*

.. image:: images/floor-shadow-interval-5.png

*Simple shadow blurInterval = 5*


Simple reflections
==================

Simple reflections projected onto an invisible ground plane. Enable or disable by passing a boolean to the :ref:`setSimpleReflectionEnabled()  <api_ref/viewing/classes/Communicator.View:setsimplereflectionenabled>`.

Get the viewer's simple reflection state with the :ref:`getSimpleReflectionEnabled() <api_ref/viewing/classes/Communicator.View:getsimplereflectionenabled>` function. Simple reflections are disabled by default.

.. code-block:: js

	// Disable Simple Reflections
	hwv.view.setSimpleReflectionEnabled(false);
	// Enable Simple Reflections
	hwv.view.setSimpleReflectionEnabled(true);
	// Get the viewer's simple reflection value
	hwv.view.getSimpleReflectionEnabled();

.. image:: images/simple-reflections-off.png

*Simple reflection disabled*

.. image:: images/simple-reflections-on.png

*Simple reflection enabled*


Simple reflection blurInterval
==============================

Sets the distance in pixels between samples taken by the blur filter used for simple reflections. Set the reflection ``blurInterval`` by passing a number and a :doc:`BlurIntervalUnit  </api_ref/viewing/enums/Communicator.blurintervalunit>` to :ref:`setSimpleReflectionBlurInterval()  <api_ref/viewing/classes/Communicator.View:setsimplereflectionblurinterval>`. Get the current simple reflection blurInterval with :ref:`getSimpleReflectionBlurInterval()  <api_ref/viewing/classes/Communicator.View:getsimplereflectionblurinterval>`.

The default simple reflection ``blurInterval`` value is [1, Pixels].

.. code-block:: js

	// Set the viewer's reflection blurInterval
	hwv.view.setSimpleReflectionBlurInterval(3, Communicator.BlurIntervalUnit.Pixels);
	// Get the reflection blurInterval
	hwv.view.getSimpleReflectionBlurInterval();

.. image:: images/simple-reflection-interval-1.png

*Simple reflection blurInterval (1, Pixels)*

.. image:: images/simple-reflection-interval-3.png

* Simple reflection blurInterval (3, Pixels)*


Simple reflection blurSamples
=============================

Sets the diameter of the blur filter used for simple reflections. Setting the value less than or equal to 1 will disable blurring. Set the samples value by passing a number to :ref:`setSimpleReflectionBlurSamples()  <api_ref/viewing/classes/Communicator.View:setsimplereflectionblursamples>`. Get the current ``blurSamples`` value using :ref:`getSimpleReflectionBlurSamples()  <api_ref/viewing/classes/Communicator.View:getsimplereflectionblursamples>`.

The default value is 9.

.. code-block:: js

	// Set simple reflection blurSamples
	hwv.view.setSimpleReflectionBlurSamples(10);
	// Get the simple reflection blurSamples value
	hwv.view.getSimpleReflectionBlurSamples();

.. image:: images/simple-reflection-samples-0.png

*Simple reflection blurSamples = 0*

.. image:: images/simple-reflection-samples-10.png

*Simple reflection blurSamples = 10*


Simple reflection fade angle
============================

Sets the angle, in degrees, between the view vector and the ground plane at which simple reflections begin to fade. Settings the value to 0 will disable the fading effect. Regardless of the value, simple reflections will not be drawn if the camera is below the ground plane. Set the fade angle value by passing a number, representing degrees, to :ref:`setSimpleReflectionFadeAngle()  <api_ref/viewing/classes/Communicator.View:setsimplereflectionfadeangle>`. Get the current simple reflection fade angle using ``getSimpleReflectionFadeAngle()``.

The default angle is 10 degrees.

.. code-block:: js

	// Set the fade angle
	hwv.view.setSimpleReflectionFadeAngle(45);
	// Get the fade angle
	hwv.view.getSimpleReflectionBlurSamples();

.. image:: images/simple-reflection-angle-0.png

*Simple reflection fade angle = 0*

.. image:: images/simple-reflection-angle-45.png

*Simple reflection fade angle = 45*


Simple reflection opacity
=========================

Set the opacity of simple reflections by passing a number (in the range 0 to 1, with values closer to 1 being more opaque) to :ref:`setSimpleReflectionOpacity()  <api_ref/viewing/classes/Communicator.View:setsimplereflectionopacity>`. Get the existing simple reflection opacity with :ref:`getSimpleReflectionOpacity()  <api_ref/viewing/classes/Communicator.View:getsimplereflectionopacity>`.

The default simple reflection opacity is 0.65.

.. code-block:: js 

	// Set the simple reflection opacity
	hwv.view.setSimpleReflectionOpacity(0.2);
	// Get the simple reflection opacity
	hwv.view.getSimpleReflectionOpacity();


.. image:: images/simple-reflection-opacity-0.65.png

*Simple Reflection Opacity = 0.65 (Default)*

.. image:: images/simple-reflection-opacity-0.2.png

*Simple reflection opacity = 0.2*


Simple reflection attenuation
=============================

The :ref:`setSimpleReflectionAttenuation()  <api_ref/viewing/classes/Communicator.View:setsimplereflectionattenuation>` function controls how objects are drawn in simple reflections fade as they move further from the ground plane.

Attenuation begins at ``nearDistance``, the first argument to the function, and increases linearly such that the model is not visible in the reflection beyond ``farDistance``. Attenuation is disabled if ``farDistance``, the second argument to the function, is less than or equal to ``nearDistance``.

There is a third optional argument to :ref:`setSimpleReflectionAttenuation()  <api_ref/viewing/classes/Communicator.View:setsimplereflectionattenuation>` which is :doc:` </api_ref/viewing/enum/Communicator.SimpleReflectionAttenuationUnit>`. ``SimpleReflectionAttenuationUnit`` specifies the unit which attenuation distances are specified for simple reflections. With the :ref:`ProportionOfBoundingHeight  <api_ref/viewing/enums/Communicator.SimpleReflectionAttenuationUnit:proportionofboundingheight>` unit distances will be multiplied by the distance from the ground plane to the furthest point on the scene bounding.

The other unit, :ref:`World <api_ref/viewing/enums/Communicator.SimpleReflectionAttenuationUnit:world>`, uses world-space units.

Get the view's current simple reflection attenuation with :ref:`getSimpleReflectionAttenuation()  <api_ref/viewing/classes/Communicator.View:getsimplereflectionattenuation>`. The default simple reflection value is ``{nearDistance: 0, farDistance: 1``, unit:

``Communicator.SimpleReflectionAttenuationUnit.ProportionOfBoundingHeight}``

.. code-block:: js

	// Set the simple reflection attenuation
	hwv.view.setSimpleReflectionAttenuation(0, 5, Communicator.SimpleReflectionAttenuationUnit.ProportionOfBoundingHeight);
	// Get the simple reflection attenuation
	hwv.view.getSimpleReflectionAttenuation();

The captions below list the images simple reflection attenuation settings.

.. image:: images/simple-reflection-atten-0-1-height.png

*{near: 0, far: 1, unit: ProportionOfBoundingHeight}*

.. image:: images/simple-reflection-atten-0-5-height.png

*{near: 0, far: 5, unit: ProportionOfBoundingHeight}*

.. image:: images/simple-reflection-atten-0-20-world.png

*{near: 0, far: 20, unit: World}*

.. image:: images/simple-reflection-atten-0-50-world.png

*{near: 0, far: 50, unit: World}*


Silhouette edges
================

The silhouette edges effect draws lines around geometrical edges. To enable or disable silhouette edges pass a Boolean to :ref:`setSilhouetteEnabled()  <api_ref/viewing/classes/Communicator.View:setsilhouetteenabled>`. To get the viewer's current silhouette edges status call :ref:`getSilhouetteEnabled()  <api_ref/viewing/classes/Communicator.View:getsilhouetteenabled>`. Silhouette edges are disabled by default. Silhouette edges are always enabled in hidden line mode.


.. code-block:: js

	// Disable Silhouette Edges
	hwv.view.setSilhouetteEnabled(false);
	// Enable Silhouette Edges
	hwv.view.setSilhouetteEnabled(true);
	// Get the Silhouette Edges status
	hwv.view.getSilhouetteEnabled();


.. image:: images/silhouette-disabled.png

*Silhouette edges disabled*

.. image:: images/silhouette-enabled.png

*Silhouette edges enabled*


Silhouette color
================

The color of silhouette edges can be set by passing a :doc:`Communicator.Color  </api_ref/viewing/classes/Communicator.Color>` to :ref:`setSilhouetteColor()  <api_ref/viewing/classes/Communicator.View:setsilhouettecolor>`. Get the current silhouette color by calling :ref:`getSilhouetteColor()  <api_ref/viewing/classes/Communicator.View:getsilhouettecolor>`. The default silhouette color is black (0, 0, 0).

.. code-block:: js

	// Set the Silhouette Edge Color to red
	var redColor = new Communicator.Color(200, 50, 50);
	hwv.view.setSilhouetteColor(redColor);
	// Get the Silhouette Edge Color
	hwv.view.getSilhouetteColor();

.. image:: images/silhouette-red.png

*Red silhouette color*


Silhouette opacity
==================

Set the opacity of silhouette edges by calling :ref:`setSilhouetteOpacity()  <api_ref/viewing/classes/Communicator.View:setsilhouetteopacity>` with a number (in the range 0 to 1 with values close to 1 being more opaque). The current silhouette edge opacity can be obtained with :ref:`getSilhouetteOpacity()  <api_ref/viewing/classes/Communicator.View:getsilhouetteopacity>`. The default silhouette edge opacity is 1.

.. code-block:: js

	// Set the silhouette edge opacity
	hwv.view.setSilhouetteOpacity(0.5);
	// Get the silhouette edge opacity
	hwv.view.getSilhouetteOpacity();

.. image:: images/silhouette-opacity_1.png

*Silhouette Opacity = 1 (Default)*

.. image:: images/silhouette-opacity_0.5.png

*Silhouette Opacity = 0.5*


Silhouette threshold
====================

Set the distance threshold for silhouette edges by passing a number to :ref:`setSilhouetteThreshold()  <api_ref/viewing/classes/Communicator.View:setsilhouettethreshold>`. This value affects the minimum z-distance required between two pixels for an edge to be drawn. A smaller value will result in more edges being drawn on finer details. The value is a proportion of the canvas size and not a world-space distance. Get the current silhouette threshold with :ref:`getSilhouetteThreshold()  <api_ref/viewing/classes/Communicator.View:getsilhouettethreshold>`. The default threshold is 0.05.

.. code-block:: js

	// Set the silhouette threshold
	hwv.view.setSilhouetteThreshold(0.2);
	// Get the silhouette threshold
	hwv.view.getSilhouetteThreshold();


.. image:: images/silhouette-threshold-0.05.png

*Silhouette Threshold = 0.05 (default)*

.. image:: images/silhouette-threshold-0.2.png

*Silhouette Threshold = 0.2*


Silhouette threshold ramp width
===============================

Control how quickly edges fade as z-distance between pixels decreases by passing a number to :ref:`setSilhouetteThresholdRampWidth()  <api_ref/viewing/classes/Communicator.View:setsilhouettethresholdrampwidth>`. This value is added to the one set by :ref:`setSilhouetteThreshold() <api_ref/viewing/classes/Communicator.View:setsilhouettethreshold>` to create a secondary threshold. Distances greater than the secondary threshold will result in edges with full opacity, and distances between the two thresholds will result in edges with reduced opacity. Setting this value to 0 will cause all edges to be drawn at full opacity.

Get the current silhouette threshold ramp width by calling :ref:`getSilhouetteThresholdRampWidth()  <api_ref/viewing/classes/Communicator.View:getsilhouettethresholdrampwidth>`.

The default value is 0.025.

.. code-block:: js

	// Set the silhouette threshold ramp width
	hwv.view.setSilhouetteThresholdRampWidth(0.2);
	// Get the silhouette threshold ramp width
	hwv.view.getSilhouetteThresholdRampWidth();


.. image:: images/silhouette-threshold-ramp-0.025.png

*Silhouette Threshold Ramp Width = 0.025 (Default)*

.. image:: images/silhouette-threshold-ramp-0.2.png

*Silhouette Threshold Ramp Width = 0.2*
