Progress Update #18

 Solar Niagara Effects & Asset Cleanup in UE4


    I had two goals for this week: to make the stars more interesting in their material and added particle effects, and to get assets to be automatically cleaned up (deleted) when not in use.


Solar Effects:

    Looking at pictures of the sun, it is clear that the surface is much more than a smooth plane. There are bright spots, dark spots, swirls of fire, and ribbon-like structures that dance on and away from the surface.


    I only made very minor changes to the material to mimic these effects. These were changes to the noise and to the color to make more bright spots appear and less black. The rest of the changes, like the solar flares, had to be made as particle effects.

    The solar flare effect can be broken down into 3 main parts: spawning, adding initial force, and adding noise force.


    The flare emitter loops infinitely but each loop, it chooses a new location and burst strength. CMELocation is a float2 that corresponds to the UV position on the sphere used in the SphereLocation module of the particle spawn. 
    The initial force is governed by BurstStrength, the other variable set each loop. It is used by LinearForce which does the math to make the arc shape of the flares. 
    In the particle's update it is given a curl noise which gives the fire look to the arc.

    The other emitter which I called SolarSurfaceEmitter is meant to emulate all the smaller features of the surface (see the bottom of the first picture above). All it does is spawn particles uniformly around the sphere and adds a curl force to them.


    Both of these emitters together make up the SolarNiagaraSystem. The particles also respond in real time to changes in the star (e.g. color and radius). In the future there will be more granular control over intensity of the effects, but at this point I had to start working on the asset cleanup.



Asset Cleanup:

    Before trying to do this all myself, I did some googling to see if anyone had found an easy way to delete unused assets. I'm very glad I did this because I came across a plugin by ashe23 called Project Cleaner that does exactly that. It doesn't have much if any documentation though because it wasn't designed to be used through C++, only in the editor.
    After a bit of trial and error, digging through the source code, and adding the plugin API to some of the source files to fix unresolved externals, I made a class with static methods that would clean up whenever was needed:

AssetCleaner.h

AssetCleaner.cpp

    
    A quick summary of this class is that there are three functions that clean different amounts of assets.
CleanAll() will clean meshes, textures, and data assets, CleanDirectory(Directory) will clean the given directory only, and CleanDirectories(Directories[]) will clean multiple. 
The private Clean() does the actual deleting, saving beforehand to update asset dependencies, and fixing redirectors after.
    Now that I am looking back at this code though, I am realizing that the conversion from string array to directory path array could be done in Clean() to make it simpler :/ oops...

Comments

Popular posts from this blog

Polishing the Foundation

Progress Update #13

A New Chapter