Pull out the main computation into a function that can be called twice.
Pull out the main computation into a function that can be called twice.

Also fixed an issue with the final alpha value.

hodbauer/cesium,YonatanKra/cesium,AnimatedRNG/cesium,denverpierce/cesium,geoscan/cesium,kiselev-dv/cesium,jason-crow/cesium,ggetz/cesium,soceur/cesium,kaktus40/cesium,hodbauer/cesium,ggetz/cesium,jason-crow/cesium,aelatgt/cesium,CesiumGS/cesium,likangning93/cesium,josh-bernstein/cesium,wallw-bits/cesium,aelatgt/cesium,oterral/cesium,YonatanKra/cesium,progsung/cesium,likangning93/cesium,esraerik/cesium,likangning93/cesium,CesiumGS/cesium,soceur/cesium,wallw-bits/cesium,aelatgt/cesium,kiselev-dv/cesium,aelatgt/cesium,omh1280/cesium,likangning93/cesium,jason-crow/cesium,geoscan/cesium,soceur/cesium,wallw-bits/cesium,AnimatedRNG/cesium,YonatanKra/cesium,ggetz/cesium,hodbauer/cesium,denverpierce/cesium,likangning93/cesium,NaderCHASER/cesium,emackey/cesium,omh1280/cesium,CesiumGS/cesium,emackey/cesium,CesiumGS/cesium,CesiumGS/cesium,oterral/cesium,emackey/cesium,denverpierce/cesium,jasonbeverage/cesium,kiselev-dv/cesium,NaderCHASER/cesium,omh1280/cesium,jason-crow/cesium,emackey/cesium,oterral/cesium,AnalyticalGraphicsInc/cesium,esraerik/cesium,YonatanKra/cesium,ggetz/cesium,omh1280/cesium,NaderCHASER/cesium,kaktus40/cesium,AnalyticalGraphicsInc/cesium,esraerik/cesium,esraerik/cesium,denverpierce/cesium,kiselev-dv/cesium,AnimatedRNG/cesium,jasonbeverage/cesium,wallw-bits/cesium,josh-bernstein/cesium,AnimatedRNG/cesium,progsung/cesium