StarSphere: Parameterized skybox material and planet shader for space environments in Unreal Engine 4.

Available at UE4 Marketplace
Video
Video (planet shader)
Support thread

Current version: 1.2.1
Supported UE4 versions: 4.12 - 4.16

Change log

Version 1.2.1 (06/01/17)
Supported engine versions: 4.16
Version 1.2.0 (02/23/17)
Supported engine versions: 4.15
Version 1.1.0 (07/28/16)
Supported engine versions: 4.12 - 4.14

Documentation

Overview

StarSphere is a collection of assets for creating beautiful space skybox backdrops within Unreal Engine 4. It consists of 2 blueprints, 2 parameterized master materials and accompanying instance materials, 3 master textures and 4 sample decal textures. Also provided are materials and textures optimized for mobile applications as well as three additional bonus features: planet shader, physics based 6 DoF camera actor and space dust effect blueprint.

Provided blueprints let you setup your StarSphere in two ways: either using constant material instance, or using dynamic material instance. With first approach you control all material parameters and have an option to add up to 4 decals. Second approach provides same material parameters control but allows only up to 2 decals. Advantage of the first method is performance: master material uses static switches for decals which when not used are compiled out. Second method uses dynamic material instance which has slower performance, but it provides sphere randomizer on begin play which allows you to have completely different StarSphere each time you hit Play.

Two example levels are provided in the StarSphere project that show each of the outlined setups.


Constant StarSphere

To add a StarSphere with constant material instance to your level, locate blueprint BP_StarSphere in the content browser and drag it into your level viewport.

  

MI_StarSphere material instance is the material already assigned by default in the blueprint. All layers that build up the StarSphere are controlled through this material instance parameters.

Important note

Before you proceed setting up MI_StarSphere it is advised to set up a Post Process Volume and adjust Auto Exposure (eye adaptation) settings. As can be seen on the second screenshot above, default UE4 settings for auto exposure are not suitable for star dome backdrops. Stars and nebula gradually become too bright if there are no other lit objects in the scene. With such a wide possible swing of nebula brightness it is pretty hard to get colors right. Adjusting only Min Brightness parameter is enough to achieve desired effect. Value of 0.4 is a good starting point. Also make the volume Unbound.

While in Post Process Volume you might want to tweak two other settings depending on your preference. You can switch off Motion Blur and change AA Method to FXAA. TemporalAA with blur dims the stars during camera rotate while FXAA with blur brightens them. FXAA alone dims (blurs) the whole picture due to its nature but does not have brightening effect during camera rotate when blur is off. It is up to you to decide what setup you like best.

With UE 4.15 release Epic has changed default bloom settings. For consistency with documentation and screenshots, please change bloom settings to previous defaults. Those settings can be now found under Lens - Bloom rollout in Post Process Volume.



MI_StarSphere parameters

To setup StarSphere material parameters, locate MI_StarSphere material instance in the content browser and double-click it. If you don't use multiple monitors a good approach here is to undock main editor viewport window and align it alongside material instance editor window. This way any changes you will make to material instance parameters will be reflected in real time in the viewport.

  

1. Point Stars group
This group controls three point stars layers.

Dense Layer Color-sets the color of the point stars in dense layer (75K stars)
Medium Layer Color-sets the color of the point stars in medium density layer (30K stars)
Sparse Layer Color-sets the color of the point stars in sparse layer (10K stars)
Tiling-controls tiling of the point stars layers. Increase tiling to get finer star points

2. Big Stars group
This group controls three big (billboard) stars groups.

Dense Group Color-sets the color tint of the big stars in dense group (10 stars)
Medium Group Color-sets the color tint of the big stars in medium density group (5 stars)
Sparse Group Color-sets the color tint of the big stars in sparse group (2 stars)
Stars Offset 1-controls UV offset of dense and medium groups.
R,G - dense group U,V offset. B,A - medium density group U,V offset
Stars Offset 2-controls UV offset of sparse group.
R,G - sparse group U,V offset. B,A - unused

Note about Stars Offset parameters: use this for fine tuning star positions (e.g. move slightly to better blend with nebula). Big stars layers are not additionally masked, so after moving, some stars may land on UV seam and will appear chopped. After adjustment, please examine your StarSphere and correct star positions if you will notice such occurrences.

3. Nebula group
This group controls two layers that build up nebula.

Base Layer Color-sets the color of the base layer of the nebula
Layers Offset-controls UV offset of base and overlay layers of the nebula.
R,G – base layer U,V offset. B,A – overlay layer U,V offset.
Adjustment of these offsets moves perlin noise masks which adds variations to your nebula. Note that unlike Big Stars offset parameters, nebula masks are additionally masked, so no seams will be seen no matter what offsets are set.
Overlay Layer Brightness-sets brightness multiplier for the highlight layer of the nebula
Overlay Layer Color-sets the color of the highlight layer of the nebula

4. Decals group
This group controls decal placement. You can place up to 4 decals on the sphere using 6 predefined positions. Setting groups are the same for each of the 4 decals.

Decal X Active-activates decal
Decal X Brightness-sets brightness multiplier for the decal
Decal X Position-sets the position index of the decal. Value must be in [1,6] integer range. See the screenshot below for the corresponding position indices location on the sphere.
Decal X Size-sets size of the decal. Value must be in [0,1] floating point range.
Decal X Texture-specifies decal texture

  

When creating your own decal textures, consider the size setting you will use. Decal of size 1 occupies roughly the whole screen with the FOV setting of 70. For this kind of decal you will need 2K texture. For smaller sizes you can use textures with lower resolution. Decal textures must be square.

Performance considerations: Decal activation switches in MI_StarSphere are static switches, so their branches are compiled out when switch is not active. Material without any active decals uses 61 instructions. Each of the activated decals adds 15 instructions. Material with 4 active decals uses 121 instructions and adds 4 more texture samplers.

BP_StarSphere parameters

Constant StarSphere blueprint parameters are provided under Star Sphere group. Select BP_StarSphere blueprint in the World Outliner and locate Star Sphere parameter group in the Details window.

  

Sphere Diameter-sets sphere diameter in kilometers. This overrides Scale parameter setting in Transform group. Integer range.
Material Instance-set material instance to use with this StarSphere. If you are setting different star spheres in different levels, duplicate MI_StarSphere and set here. There is no need to duplicate BP_StarSphere blueprint.
Lock Translation To Actor-set actor to lock sphere translation to. This is useful for cases when your actor can travel huge distances on Unreal Engine grid and get close to or outside of StarSphere boundary. This feature is complementary and provided for extreme scenarios when your game actor could potentially traverse the whole available grid space in the engine. It is preferred to just increase sphere diameter. You can key in maximum integer in the Sphere Diameter parameter (2 billion kilometers) and Unreal Engine still handles it just fine.
Align To Light Source-set directional light source to align sphere. This will align StarSphere rotation to match selected decal position index to the selected light source. Modifies Rotation parameter setting in Transform group.
Decal Index-set decal index to be used for sphere alignment
Update-use this to force StarSphere update in editor window (e.g. re-align after directional light source angle was changed)


Dynamic StarSphere

To add a StarSphere with dynamic material instance to your level, locate blueprint BP_StarSphereDynamic in the content browser and drag it into your level viewport.

  

MI_StarSphereDynamic material instance is the material already assigned by default in the blueprint. This material instance provides control over the same material parameters as MI_StarSphere material instance except that only 2 decals are allowed. Please refer to MI_StarSphere parameters section above for parameter descriptions.

BP_StarSphereDynamic parameters

Like BP_StarSphere, BP_StarSphereDynamic provides Sphere Diameter, Material Instance and Lock Translation To Actor parameters in Star Sphere group. Light source alignment is not available with dynamic StarSphere. Main feature of the BP_StarSphereDynamic is the sphere randomizer, which controls are provided under Star Sphere Randomizer parameter group.

Random Sphere Rotation-override and randomize sphere rotation transform
Random Point Stars Dense-override material setting and randomize color of the point stars in the dense layer
Point Stars Dense Min-minimum value for each of the color channels
Point Stars Dense Max-maximum value for each of the color channels
Random Point Stars Medium-override material setting and randomize color of the point stars in the medium density layer
Point Stars Medium Min-minimum value for each of the color channels
Point Stars Medium Max-maximum value for each of the color channels
Random Point Stars Sparse-override material setting and randomize color of the point stars in the sparse layer
Point Stars Sparse Min-minimum value for each of the color channels
Point Stars Sparse Max-maximum value for each of the color channels
Random Big Stars Dense-override material setting and randomize color tint of the big stars in the dense group
Big Stars Dense Min-minimum value for each of the color channels
Big Stars Dense Max-maximum value for each of the color channels
Random Big Stars Medium-override material setting and randomize color tint of the big stars in the medium density group
Big Stars Medium Min-minimum value for each of the color channels
Big Stars Medium Max-maximum value for each of the color channels
Random Big Stars Sparse-override material setting and randomize color tint of the big stars in the sparse group
Big Stars Sparse Min-minimum value for each of the color channels
Big Stars Sparse Max-maximum value for each of the color channels
Random Nebula Base-override material setting and randomize color of the nebula base layer
Nebula Base Min-minimum value for each of the color channels
Nebula Base Max-maximum value for each of the color channels
Random Nebula Overlay-override material settings and randomize nebula overlay layer
Nebula Overlay Min-minimum value for each of the color channels
Nebula Overlay Max-maximum value for each of the color channels
Nebula Overlay Brightness Min-minimum value for brightness multiplier
Nebula Overlay Brightness Max-maximum value for brightness multiplier
Random Nebula Offset-override material settings and randomize offsets of the base and overlay nebula layers
Update-use this to force StarSphere update in editor window

Decal randomization is not available and will use material instance settings. As it is, dynamic StarSphere might not be game-ready for your project. It is provided as a base which you can expand upon. For example, you can create a blueprint that places random directional light in the scene, assigns sun decal and aligns the sphere accordingly. You can also setup an array holding your decal textures and assign them randomly. Just duplicate BP_StarSphereDynamic, MI_StarSphereDynamic and experiment. All blueprints are documented and pretty simple so should be easy to understand.


Mobile Application

For mobile applications use the same blueprints as described above, but change material instance to either MI_StarSphere_Mobile for constant StarSphere or to MI_StarSphereDynamic_Mobile for dynamic StarSphere.

  

Mobile material instances are located in Materials/Mobile folder and have the same parameter controls as regular material instances with the following exception: only 2 decals are allowed for both constant and dynamic material instances. Moreover, decals are set by using 2 texture parameters: diffuse texture and separate alpha texture. Mobile decal textures are provided in Textures/Mobile folder. Diffuse textures use _Mobile_D suffix, alpha textures use _Mobile_A suffix. Such separation is recommended for mobile applications since textures with alpha channel have limited compression support and on some platforms are forced to be uncompressed (e.g. Android ETC1).


Bonus Features

Planet Shader

Planet shader uses a blueprint with 2 meshes and material instances to define planet surface and atmosphere. Planet surface uses 3 texture levels for surface, clouds and night lights. Atmosphere level fakes Rayleigh scattering effect and also provides eclipse effect.

To add a planet to your level first locate BP_Planet blueprint and drag it into your scene. Then you need to create a copy of MI_PlanetSurface and MI_PlanetAtmosphere material instances and assign them to corresponding parameters in planet blueprint. Directional light source must be also set for Light Source parameter for blueprint to get updated in the viewport.

  

Planet blueprint parameters can be found under Planet parameter group rollout.

Planet Diameter-sets planet diameter in kilometers
Atmosphere Thickness-sets planet atmosphere thickness in percentage of planet radius. Set this to 0 to disable atmosphere.
Compute Falloff Params-autocompute atmosphere scattering falloff parameters based on thickness. Disable this if you wish to manually set falloff parameters in atmosphere material instance. When enabled, fitted functions are used to compute InnerFalloff, OuterFalloff and OuterFalloffMultiplier coefficients of the atmosphere material instance.
Surface Material-planet surface material instance
Atmosphere Material-planet atmosphere material instance
Light Source-directional light source to use for lighting computation. This parameter must be set.

To define surface of the planet open planet surface material instance you assigned to Surface Material parameter.

  

1. Light group

LightDirection-light direction vector. This parameter gets overridden by BP_Planet blueprint.

2. Surface group

DarkSideMultiplier-multiplier for the dark (night) side of the planet
SurfaceColorMultiplier-surface texture color multiplier
SurfaceRotationSpeed-surface texture panning speed. Use negative values for counterclockwise rotation and positive values for clockwise rotation effect.
SurfaceTexture-planet surface texture

3. Clouds group

CloudsActive-activates clouds layer
CloudsRotationSpeed-clouds texture panning speed. For better visual effect set it to slightly lower value than SurfaceRotationSpeed.
CloudsTint-clouds tint color. Use alpha channel as multiplier.

4. NightLights group

NightLightsActive-activates dark side night city lights layer
NightLightsTexture-planet night city lights texture
NightLightsTint-night lights tint color. Use alpha channel as multiplier.

To define atmosphere of the planet open planet atmosphere material instance you assigned to Atmosphere Material parameter in BP_Planet blueprint.

1. Light group

LightDirection-light direction vector. This parameter gets overridden by BP_Planet blueprint.

2. Colors group

EclipseTint-color of the eclipse effect. Use alpha channel as multiplier.
RayleighFadeTint-secondary color of Rayleigh scattering effect. Use alpha channel as multiplier.
RayleighMainTint-primary color of Rayleigh scattering effect. Use alpha channel as multiplier.

3. Coefficients group

EclipsePower-controls size of the eclipse effect. Lower values increase effect size.
InnerFalloff-controls size of the inner falloff for the Rayleigh scattering effect. This parameter gets overridden by BP_Planet blueprint if Compute Falloff Params parameter is checked.
OuterFalloff-controls size of the outer falloff for the Rayleigh scattering effect. This parameter gets overridden by BP_Planet blueprint if Compute Falloff Params parameter is checked.
OuterFalloffMultiplier-controls brightness of the outer falloff for the Rayleigh scattering effect. This parameter gets overridden by BP_Planet blueprint if Compute Falloff Params parameter is checked.

For examples on planet shader setup please check three levels provided with the StarSphere package: PlanetEarth, PlanetMars and PlanetVenus.


6 Degree of Freedom Camera Actor

Default player start camera in Unreal Engine suffers from the gimbal lock and is not really useful if you wish to test your space environment from the flying spaceship perspective. For such purposes StarSphere provides physics based 6 DoF camera actor blueprint. To set it up simply locate BP_6DoFCamera blueprint and drag it into your scene. Set Auto Possess Player to Player 0 in Pawn parameter group and you are set.

Add Force and Add Torque are used for actor movement. The following blueprint parameters are exposed in the Default parameter group:

Max Linear Velocity-maximum linear velocity camera will achieve, set in m/s
Linear Acceleration-controls how fast camera will accelerate to the max speed or decelerate to a complete stop. This is a unit-less coefficient that sets relation between linear force and linear damping. Higher values will make camera accelerate/decelerate faster. Minimum value is 0.1
Max Angular Velocity-maximum angular velocity camera will achieve, set in deg/s
Angular Acceleration-controls angular movement acceleration/deceleration rate. Unit-less coefficient that sets relation between angular torque and angular damping. Higher values will make camera angular acceleration/deceleration faster. Minimum value is 0.1
Invert Y-Axis-when checked this will invert pitch axis, causing camera to pitch up if the mouse goes down and pitch down when mouse goes up

Camera uses the following controls:

W/S-move forward/backward
A/D-move left/right
Z/X-move up/down
Q/E-roll
Mouse-pitch/yaw

Note: Since only "Add to Project" action is available for StarSphere on marketplace, you need to setup the following input bindings in your project settings:

If you don't have any input bindings already setup, you can also download DefaultInput.ini file and copy it over into your project Config folder.


Space Dust Effect

Space dust effect blueprint (BP_SpaceDust) can be used to add a sense of movement to your pawn actor. It repositions particle emitter sphere in the path of the actor it is attached to and spawns space dust particles. To setup BP_SpaceDust blueprint, drag it into your scene and set parameters in the Space Dust parameter group.

Actor-set actor to which space dust effect is attached
Update Rate-set rate in seconds at which emitter sphere is repositioned and new particles are spawned
Min Actor Velocity-minimum actor velocity threshold to activate update, set in m/s. If actor velocity is less than given value, new particles are not spawned
Emitter Position Offset-actor velocity vector is multiplied by this value to determine emitter position offset. Given value basically means how many seconds it will take actor to reach emitter sphere center if actor direction/velocity does not change.

BP_SpaceDust uses PS_SpaceDust particle system that defines emitter sphere and particles. Provided setup uses single emitter sphere of 50m radius, particle burst of 10 particles, particle size of 20cm and 6-10s lifetime. Particles use M_SpaceDust material.

This setup is very basic and can be used as a foundation for space dust effect that will suit best your project. You can change update rate, increase emitter sphere offset and emitter sphere size. Increase particle burst to add more particles. Tune Color Over Life, add particle rotation, and so on. Try adding additional emitters, for example with subtle smoke puffs that will add more pronounced sense of motion to your effect.

Note: BP_SpaceDust blueprint checks Actor validity and will disable the effect if Actor got destroyed. Also provided are Pause Update and Resume Update custom events which you can invoke in order to pause/resume effect update (e.g. if switching to another camera view and when space dust effect is not desired).



Technical Details

SM_StarSphere static mesh
Triangles: 768
Vertices: 776
UV Channels: 4
Base Diameter: 10000

M_StarSphere master material
No decals: 62 instructions, 30 vertex shader instructions, 3/16 texture samplers
1 decal: 77 instructions, 32 vertex shader instructions, 4/16 texture samplers
2 decals: 92 instructions, 32 vertex shader instructions, 5/16 texture samplers
3 decals: 107 instructions, 32 vertex shader instructions, 6/16 texture samplers
4 decals: 122 instructions, 32 vertex shader instructions, 7/16 texture samplers
Point stars: 4096x4096 texture
Big stars: 4096x4096 texture
Nebula: 1024x1024 texture, UserInterface2D (no compression)
1 Material Function

M_StarSphereDynamic master material
95 instructions, 32 vertex shader instructions, 5/16 texture samplers

M_StarSphere_Mobile master material
No decals: (HDR) 84 instructions, 56 vertex shader instructions, 3/8 texture samplers
1 decal: (HDR) 110 instructions, 56 vertex shader instructions, 5/8 texture samplers
2 decals: (HDR) 136 instructions, 56 vertex shader instructions, 7/8 texture samplers
Point stars: 1024x1024 texture
Big stars: 2048x2048 texture
Nebula: 512x512 texture, UserInterface2D (no compression)
1 Material Function

M_StarSphereDynamic_Mobile master material
(HDR) 140 instructions, 56 vertex shader instructions, 7/8 texture samplers

Note about Nebula texture: UserInterface2D (no compression) is required because any other compression method is not kind to gradients and nebula base layer appears blocky. For mobile applications with very tight texture size budget, you can reduce texture size down to 256x256 – nebula will still look better than 512x512 texture with compression enabled.


Public Domain Content

3 images from the public domain were used to create sample decals that are provided with StarSphere
Earth (NASA public domain)
Saturn (NASA public domain)
Black Hole (Original image by: ESA/Hubble & NASA and S. Smartt (Queen's University Belfast))

Original textures for Earth, Mars and Venus used by Planet Shader: Solar System Scope