Empeld
Empeld plugin documentation.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Pages
essentials.Environment.Sky.AtmosphereLayer Class Reference

Simple atmosphere layer that inspects orbitals and compares them to simulate atmospheric scattering More...

Inheritance diagram for essentials.Environment.Sky.AtmosphereLayer:
pluginbase.Objects.World.Environment.Sky.SkyLayerBase pluginbase.Objects.World.Environment.ISkyLayer pluginbase.Objects.World.Environment.IEnvironmentSimulatable

Public Member Functions

 AtmosphereLayer (IEnumerable< IOrbital > orbitals)
 
override Rgba DirectionalColor (float x, float y, float z)
 Get the color at a direction More...
 
override void Simulate (double time, double x, double y, double z)
 Simulate the environment with the time, and an x/y/z More...
 

Properties

override SkyLayerRenderMode RenderMode [get]
 
override int Layer [get]
 
virtual Rgba ZenithColor [get]
 
virtual Rgba HorizonColor [get]
 
virtual Rgba NadirColor [get]
 
- Properties inherited from pluginbase.Objects.World.Environment.Sky.SkyLayerBase
virtual SkyLayerRenderMode RenderMode [get]
 Gets the render mode. More...
 
virtual int Layer [get]
 Gets the layer the sky is drawn on More...
 
virtual Vector3 Direction [get]
 Gets the up-direction for the layer. This can be used to rotate a sky-sphere or position a shader value More...
 
virtual string Resource [get]
 Gets the resource. Either a texture, or shader. Only shaders support multiple resources More...
 
virtual Rgba Color [get]
 Overlay color More...
 
virtual float TextureScale [get]
 Gets the texture scale for render types that support it More...
 
virtual float CameraAdjustmentRatio [get]
 The amount the camera position adjusts the direction of the layer More...
 
virtual bool ReceivesLight [get]
 Gets a value indicating whether this pluginbase.Objects.World.Environment.Sky.SkyLayerBase receives light. More...
 
virtual bool CastsShadow [get]
 Gets a value indicating whether this instance can project on world. More...
 
virtual Rgba LightFilter [get]
 Gets a value to multiply incoming light by to simulate a layer filtering out sunlight More...
 
- Properties inherited from pluginbase.Objects.World.Environment.ISkyLayer
SkyLayerRenderMode RenderMode [get]
 Gets the render mode. More...
 
int Layer [get]
 Gets the layer the sky is drawn on More...
 
Vector3 Direction [get]
 Gets the up-direction for the layer. This can be used to rotate a sky-sphere or position a shader value More...
 
string Resource [get]
 Gets the resource. Either a texture, or shader. Only shaders support multiple resources More...
 
Rgba Color [get]
 Overlay color More...
 
float TextureScale [get]
 Gets the texture scale for render types that support it More...
 
float CameraAdjustmentRatio [get]
 The amount the camera position adjusts the direction of the layer More...
 
bool ReceivesLight [get]
 Gets a value indicating whether this pluginbase.Objects.World.Environment.ISkyLayer receives light. More...
 
bool CastsShadow [get]
 Gets a value indicating whether this instance can project on world. More...
 
Rgba LightFilter [get]
 Gets a value to multiply incoming light by to simulate a layer filtering out sunlight More...
 

Additional Inherited Members

- Protected Member Functions inherited from pluginbase.Objects.World.Environment.Sky.SkyLayerBase
 SkyLayerBase ()
 Initializes a new instance of the pluginbase.Objects.World.Environment.Sky.SkyLayerBase class. More...
 

Detailed Description

Simple atmosphere layer that inspects orbitals and compares them to simulate atmospheric scattering

Constructor & Destructor Documentation

◆ AtmosphereLayer()

essentials.Environment.Sky.AtmosphereLayer.AtmosphereLayer ( IEnumerable< IOrbital orbitals)
20  {
21  _orbitals = orbitals.ToArray();
22  _glowing = _orbitals.OfType<IOrbitalGlow>().ToArray();
23  }

Member Function Documentation

◆ DirectionalColor()

override Rgba essentials.Environment.Sky.AtmosphereLayer.DirectionalColor ( float  x,
float  y,
float  z 
)
virtual

Get the color at a direction

Returns
The color.
Parameters
xX.
yY.
zZ.

Attribute: i

;

Reimplemented from pluginbase.Objects.World.Environment.Sky.SkyLayerBase.

61  {
62  Rgba color;
63  if (z > 0.0)
64  {
65  color = (1f - z) * _horizon + _zenith * z;
66  }
67  else
68  {
69  color = (1f + z) * _horizon - _nadir * z;
70  }
71 
72  for (int i=0; i<_glowing.Length; ++i)
73  {
74  var orbital = _glowing[i];
75  Vector3 pt = orbital.Direction;
76  float dot = ((pt.X * x + pt.Y * y + pt.Z * z) - (1f - orbital.GlowRadius)) * (1f / orbital.GlowRadius);
77  if (dot > 0.0)
78  {
79  color += (orbital.GlowColor * dot * orbital.GlowStrength);
80  }
81  }
82  color.Clamp();
83  return color;
84  }
Class the represents a floating-point color of red, green, blue, and alpha
Definition: Rgba.cs:11
Vector3 Direction
Gets the direction that the object is rendered in Needs to be normalized
Definition: IOrbital.cs:127
void Clamp(float min, float max)
Clamp each component of Rgba to between min and max
Definition: Rgba.cs:266

◆ Simulate()

override void essentials.Environment.Sky.AtmosphereLayer.Simulate ( double  time,
double  x,
double  y,
double  z 
)
virtual

Simulate the environment with the time, and an x/y/z

Parameters
timeTime.
xX.
yY.
zZ.

Attribute: i

;

Reimplemented from pluginbase.Objects.World.Environment.Sky.SkyLayerBase.

87  {
88  Rgba totalEmit = Rgba.Zero;
89  for (int i=0; i<_orbitals.Length; ++i)
90  {
91  var orbital = _orbitals[i];
92  if (orbital.Direction.Z > 0f)
93  {
94  totalEmit += orbital.EmittanceDiffuse * Math.Min(1f, orbital.Direction.Z * 2f);
95  }
96  }
97 
98  _zenith = new Rgba(ZenithColor, totalEmit.Luminosity);
99  _horizon = new Rgba(HorizonColor, totalEmit.Luminosity);
100  _nadir = NadirColor;
101  }
Class the represents a floating-point color of red, green, blue, and alpha
Definition: Rgba.cs:11
static readonly Rgba Zero
All-zeros (0,0,0,0)
Definition: Rgba.cs:441
float Luminosity
Get the average luminosity, multiplied by alpha
Definition: Rgba.cs:340
virtual Rgba ZenithColor
Definition: AtmosphereLayer.cs:46
virtual Rgba HorizonColor
Definition: AtmosphereLayer.cs:51
virtual Rgba NadirColor
Definition: AtmosphereLayer.cs:56

Property Documentation

◆ HorizonColor

virtual Rgba essentials.Environment.Sky.AtmosphereLayer.HorizonColor
getprotected

◆ Layer

override int essentials.Environment.Sky.AtmosphereLayer.Layer
get

◆ NadirColor

virtual Rgba essentials.Environment.Sky.AtmosphereLayer.NadirColor
getprotected

◆ RenderMode

override SkyLayerRenderMode essentials.Environment.Sky.AtmosphereLayer.RenderMode
get

◆ ZenithColor

virtual Rgba essentials.Environment.Sky.AtmosphereLayer.ZenithColor
getprotected

The documentation for this class was generated from the following file: