Created
January 15, 2018 11:38
-
-
Save atteneder/d4fe33368afaf176413ec09d14ef41db to your computer and use it in GitHub Desktop.
Unity Editor Tool that prints the spherical harmonics values of the current scene to the console. Useful to retrieve the values for use in other engines.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
using System.Collections; | |
using System.Text; | |
using UnityEngine.Rendering; | |
public class AmbientLightingHelper : MonoBehaviour { | |
[MenuItem("Tools/Print Ambient Probe Values")] | |
public static void GetLighting() { | |
if( RenderSettings.ambientMode == AmbientMode.Trilight) { | |
StringBuilder sb = new StringBuilder(); | |
sb.AppendFormat("ambientEquatorColor: {0}\n", RenderSettings.ambientEquatorColor); | |
sb.AppendFormat("ambientGroundColor: {0}\n", RenderSettings.ambientGroundColor); | |
sb.AppendFormat("ambientLight: {0}\n", RenderSettings.ambientLight); | |
sb.AppendFormat("ambientIntensity: {0}\n", RenderSettings.ambientIntensity); | |
Debug.Log(sb.ToString()); | |
} else { | |
PrintProbe(RenderSettings.ambientProbe); | |
} | |
} | |
public static void PrintProbe( UnityEngine.Rendering.SphericalHarmonicsL2 probe ) { | |
StringBuilder sb = new StringBuilder(); | |
sb.Append("var shLight = new THREE.SphericalHarmonicsLight(\n\t[\n"); | |
for(int y=0; y<9; y++) { | |
sb.AppendFormat("\t\tnew THREE.Color({0},{1},{2})", probe[0,y],probe[1,y],probe[2,y]); | |
if (y < 8) { | |
sb.Append (','); | |
} | |
sb.Append ('\n'); | |
} | |
sb.Append("\t]);\n"); | |
Debug.Log(sb.ToString()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment