/// <summary>
 /// Write the specified value using the writer.
 /// </summary>
 /// <param name="value">Value.</param>
 /// <param name="writer">Writer.</param>
 public override void Write(object value, ISaveGameWriter writer)
 {
     UnityEngine.LightProbes lightProbes = (UnityEngine.LightProbes)value;
     writer.WriteProperty("bakedProbes", lightProbes.bakedProbes);
     writer.WriteProperty("name", lightProbes.name);
     writer.WriteProperty("hideFlags", lightProbes.hideFlags);
 }
 static public int constructor(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.LightProbes o;
         o = new UnityEngine.LightProbes();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
 static public int get_cellCount(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.LightProbes self = (UnityEngine.LightProbes)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.cellCount);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
 static void LightProbes_bakedProbes(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.LightProbes _this = (UnityEngine.LightProbes)vc.csObj;
         var result = _this.bakedProbes;
         var arrRet = result;
         for (int i = 0; arrRet != null && i < arrRet.Length; i++)
         {
             JSMgr.datax.setObject((int)JSApi.SetType.SaveAndTempTrace, arrRet[i]);
             JSApi.moveSaveID2Arr(i);
         }
         JSApi.setArrayS((int)JSApi.SetType.Rval, (arrRet != null ? arrRet.Length : 0), true);
     }
     else
     {
         UnityEngine.Rendering.SphericalHarmonicsL2[] arg0 = JSDataExchangeMgr.GetJSArg <UnityEngine.Rendering.SphericalHarmonicsL2[]>(() =>
         {
             int jsObjID = JSApi.getObject((int)JSApi.GetType.Arg);
             int length  = JSApi.getArrayLength(jsObjID);
             var ret     = new UnityEngine.Rendering.SphericalHarmonicsL2[length];
             for (var i = 0; i < length; i++)
             {
                 JSApi.getElement(jsObjID, i);
                 ret[i] = (UnityEngine.Rendering.SphericalHarmonicsL2)JSMgr.datax.getObject((int)JSApi.GetType.SaveAndRemove);
             }
             return(ret);
         });
         UnityEngine.LightProbes _this = (UnityEngine.LightProbes)vc.csObj;
         _this.bakedProbes = arg0;
     }
 }
示例#5
0
    static void LightProbes_cellCount(JSVCall vc)
    {
        UnityEngine.LightProbes _this = (UnityEngine.LightProbes)vc.csObj;
        var result = _this.cellCount;

        JSApi.setInt32((int)JSApi.SetType.Rval, (System.Int32)(result));
    }
示例#6
0
 static public int constructor(IntPtr l)
 {
     UnityEngine.LightProbes o;
     o = new UnityEngine.LightProbes();
     pushObject(l, o);
     return(1);
 }
示例#7
0
 static void LightProbes_coefficients(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.LightProbes _this = (UnityEngine.LightProbes)vc.csObj;
         var result = _this.coefficients;
         var arrRet = result;
         for (int i = 0; arrRet != null && i < arrRet.Length; i++)
         {
             JSApi.setSingle((int)JSApi.SetType.SaveAndTempTrace, arrRet[i]);
             JSApi.moveSaveID2Arr(i);
         }
         JSApi.setArrayS((int)JSApi.SetType.Rval, (arrRet != null ? arrRet.Length : 0), true);
     }
     else
     {
         System.Single[] arg0 = JSDataExchangeMgr.GetJSArg <System.Single[]>(() =>
         {
             int jsObjID = JSApi.getObject((int)JSApi.GetType.Arg);
             int length  = JSApi.getArrayLength(jsObjID);
             var ret     = new System.Single[length];
             for (var i = 0; i < length; i++)
             {
                 JSApi.getElement(jsObjID, i);
                 ret[i] = (System.Single)JSApi.getSingle((int)JSApi.GetType.SaveAndRemove);
             }
             return(ret);
         });
         UnityEngine.LightProbes _this = (UnityEngine.LightProbes)vc.csObj;
         _this.coefficients = arg0;
     }
 }
示例#8
0
        public static void CalculateInterpolatedLightAndOcclusionProbes(Vector3[] positions, SphericalHarmonicsL2[] lightProbes, Vector4[] occlusionProbes)
        {
            bool flag = positions == null;

            if (flag)
            {
                throw new ArgumentNullException("positions");
            }
            bool flag2 = lightProbes == null && occlusionProbes == null;

            if (flag2)
            {
                throw new ArgumentException("Argument lightProbes and occlusionProbes cannot both be null.");
            }
            bool flag3 = lightProbes != null && lightProbes.Length < positions.Length;

            if (flag3)
            {
                throw new ArgumentException("lightProbes", "Argument lightProbes has less elements than positions");
            }
            bool flag4 = occlusionProbes != null && occlusionProbes.Length < positions.Length;

            if (flag4)
            {
                throw new ArgumentException("occlusionProbes", "Argument occlusionProbes has less elements than positions");
            }
            LightProbes.CalculateInterpolatedLightAndOcclusionProbes_Internal(positions, positions.Length, lightProbes, occlusionProbes);
        }
示例#9
0
 public static void CalculateInterpolatedLightAndOcclusionProbes(List <Vector3> positions, List <SphericalHarmonicsL2> lightProbes, List <Vector4> occlusionProbes)
 {
     if (positions == null)
     {
         throw new ArgumentNullException("positions");
     }
     if (lightProbes == null && occlusionProbes == null)
     {
         throw new ArgumentException("Argument lightProbes and occlusionProbes cannot both be null.");
     }
     if (lightProbes != null)
     {
         if (lightProbes.Capacity < positions.Count)
         {
             lightProbes.Capacity = positions.Count;
         }
         if (lightProbes.Count < positions.Count)
         {
             NoAllocHelpers.ResizeList <SphericalHarmonicsL2>(lightProbes, positions.Count);
         }
     }
     if (occlusionProbes != null)
     {
         if (occlusionProbes.Capacity < positions.Count)
         {
             occlusionProbes.Capacity = positions.Count;
         }
         if (occlusionProbes.Count < positions.Count)
         {
             NoAllocHelpers.ResizeList <Vector4>(occlusionProbes, positions.Count);
         }
     }
     LightProbes.Internal_CalculateInterpolatedLightAndOcclusionProbes(NoAllocHelpers.ExtractArrayFromListT <Vector3>(positions), positions.Count, NoAllocHelpers.ExtractArrayFromListT <SphericalHarmonicsL2>(lightProbes), NoAllocHelpers.ExtractArrayFromListT <Vector4>(occlusionProbes));
 }
 static public int set_bakedProbes(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.LightProbes self = (UnityEngine.LightProbes)checkSelf(l);
         UnityEngine.Rendering.SphericalHarmonicsL2[] v;
         checkArray(l, 2, out v);
         self.bakedProbes = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
示例#11
0
 static public int set_coefficients(IntPtr l)
 {
     UnityEngine.LightProbes o = (UnityEngine.LightProbes)checkSelf(l);
     System.Single[]         v;
     checkType(l, 2, out v);
     o.coefficients = v;
     return(0);
 }
示例#12
0
 static public int get_cellCount(IntPtr l)
 {
     try {
         UnityEngine.LightProbes self = (UnityEngine.LightProbes)checkSelf(l);
         pushValue(l, self.cellCount);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_bakedProbes(IntPtr l)
 {
     try {
         UnityEngine.LightProbes self = (UnityEngine.LightProbes)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.bakedProbes);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#14
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.LightProbes o;
         o = new UnityEngine.LightProbes();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
	static public int constructor(IntPtr l) {
		try {
			UnityEngine.LightProbes o;
			o=new UnityEngine.LightProbes();
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
 static public int get_count(IntPtr l)
 {
     try {
         UnityEngine.LightProbes self = (UnityEngine.LightProbes)checkSelf(l);
         pushValue(l, self.count);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static public int constructor(IntPtr l)
 {
     LuaDLL.lua_remove(l, 1);
     UnityEngine.LightProbes o;
     if (matchType(l, 1))
     {
         o = new UnityEngine.LightProbes();
         pushObject(l, o);
         return(1);
     }
     LuaDLL.luaL_error(l, "New object failed.");
     return(0);
 }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.LightProbes o;
         o = new UnityEngine.LightProbes();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
示例#19
0
// fields

// properties
    static void LightProbes_positions(JSVCall vc)
    {
        UnityEngine.LightProbes _this = (UnityEngine.LightProbes)vc.csObj;
        var result = _this.positions;
        var arrRet = result;

        for (int i = 0; arrRet != null && i < arrRet.Length; i++)
        {
            JSApi.setVector3S((int)JSApi.SetType.SaveAndTempTrace, arrRet[i]);
            JSApi.moveSaveID2Arr(i);
        }
        JSApi.setArrayS((int)JSApi.SetType.Rval, (arrRet != null ? arrRet.Length : 0), true);
    }
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.LightProbes o;
         o=new UnityEngine.LightProbes();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
示例#21
0
 static void LightmapSettings_lightProbes(JSVCall vc)
 {
     if (vc.bGet)
     {
         var result = UnityEngine.LightmapSettings.lightProbes;
         JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.LightProbes arg0 = (UnityEngine.LightProbes)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
         UnityEngine.LightmapSettings.lightProbes = arg0;
     }
 }
示例#22
0
 static public int set_bakedProbes(IntPtr l)
 {
     try {
         UnityEngine.LightProbes self = (UnityEngine.LightProbes)checkSelf(l);
         UnityEngine.Rendering.SphericalHarmonicsL2[] v;
         checkType(l, 2, out v);
         self.bakedProbes = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#23
0
    void Update ()
    {
        // Do nothing if nothing was changed.
        if (mix == prevMix && intensity == prevIntensity && skyboxIntensity == prevSkyboxIntensity) return;

        if (probe == null)
        {
            // Clone the first probe and set it to the scene.
            probe = Instantiate(sourceProbes[0]) as LightProbes;
            LightmapSettings.lightProbes = probe;
        }

        if (updateSkybox && skybox == null)
        {
            // Make a empty skybox and set it to the scene.
            skybox = ProbePolisher.NewSkyboxMaterial(null);
            RenderSettings.skybox = skybox;
        }

        // Clamp the mixing position.
        mix = Mathf.Clamp(mix, 0.0f, 1.0f * (sourceProbes.Length - 1));

        // Choose two probes to mix.
        var mixIndex = Mathf.FloorToInt(mix);
        if (mixIndex == sourceProbes.Length - 1) mixIndex--;

        var source1 = ProbePolisher.NewVectorArrayFromCoeffs(sourceProbes[mixIndex + 0].coefficients, 27 * 2);
        var source2 = ProbePolisher.NewVectorArrayFromCoeffs(sourceProbes[mixIndex + 1].coefficients, 27 * 2);

        // Mix the two probes.
        var coeffs = new Vector3[9];
        var mixRate = mix - mixIndex;
        for (var i = 0; i < 9; i++)
            coeffs[i] = Vector3.Lerp(source1[i], source2[i], mixRate) * intensity;

        // Update the probe with the mixed coefficients.
        var temp = probe.coefficients;
        ProbePolisher.UpdateCoeffsWithVectorArray(temp, coeffs);
        probe.coefficients = temp;

        // Update the skybox if needed.
        if (updateSkybox && skybox != null)
        {
            ProbePolisher.UpdateSkyboxMaterial(skybox, coeffs);
            skybox.SetFloat("_Intensity", skyboxIntensity);
        }

        prevMix = mix;
        prevIntensity = intensity;
        prevSkyboxIntensity = skyboxIntensity;
    }
 static public int set_coefficients(IntPtr l)
 {
     try {
         UnityEngine.LightProbes self = (UnityEngine.LightProbes)checkSelf(l);
         System.Single[]         v;
         checkType(l, 2, out v);
         self.coefficients = v;
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
示例#25
0
 static public int set_coefficients(IntPtr l)
 {
     try {
         UnityEngine.LightProbes self = (UnityEngine.LightProbes)checkSelf(l);
         System.Single[]         v;
         checkType(l, 2, out v);
         self.coefficients = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#26
0
        public static void CalculateInterpolatedLightAndOcclusionProbes(List <Vector3> positions, List <SphericalHarmonicsL2> lightProbes, List <Vector4> occlusionProbes)
        {
            bool flag = positions == null;

            if (flag)
            {
                throw new ArgumentNullException("positions");
            }
            bool flag2 = lightProbes == null && occlusionProbes == null;

            if (flag2)
            {
                throw new ArgumentException("Argument lightProbes and occlusionProbes cannot both be null.");
            }
            bool flag3 = lightProbes != null;

            if (flag3)
            {
                bool flag4 = lightProbes.Capacity < positions.Count;
                if (flag4)
                {
                    lightProbes.Capacity = positions.Count;
                }
                bool flag5 = lightProbes.Count < positions.Count;
                if (flag5)
                {
                    NoAllocHelpers.ResizeList <SphericalHarmonicsL2>(lightProbes, positions.Count);
                }
            }
            bool flag6 = occlusionProbes != null;

            if (flag6)
            {
                bool flag7 = occlusionProbes.Capacity < positions.Count;
                if (flag7)
                {
                    occlusionProbes.Capacity = positions.Count;
                }
                bool flag8 = occlusionProbes.Count < positions.Count;
                if (flag8)
                {
                    NoAllocHelpers.ResizeList <Vector4>(occlusionProbes, positions.Count);
                }
            }
            LightProbes.CalculateInterpolatedLightAndOcclusionProbes_Internal(NoAllocHelpers.ExtractArrayFromListT <Vector3>(positions), positions.Count, NoAllocHelpers.ExtractArrayFromListT <SphericalHarmonicsL2>(lightProbes), NoAllocHelpers.ExtractArrayFromListT <Vector4>(occlusionProbes));
        }
示例#27
0
 static public int GetInterpolatedLightProbe(IntPtr l)
 {
     try {
         UnityEngine.LightProbes self = (UnityEngine.LightProbes)checkSelf(l);
         UnityEngine.Vector3     a1;
         checkType(l, 2, out a1);
         UnityEngine.Renderer a2;
         checkType(l, 3, out a2);
         System.Single[] a3;
         checkType(l, 4, out a3);
         self.GetInterpolatedLightProbe(a1, a2, a3);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#28
0
 // Reset the polishable probe (only when it's needed).
 public static void ResetPolisherIfNeeded(LightProbes probes)
 {
     var coeffs = probes.coefficients;
     if (coeffs[27] > -9.0f)
     {
         coeffs[27] = -10.0f;   // Initialization flag
         coeffs[28] = 1.0f;     // Base Intensity
         coeffs[29] = 0.0f;     // Sky Intensity
         coeffs[30] = 0.9f;     // Sky Color 1
         coeffs[31] = 1.0f;
         coeffs[32] = 1.0f;
         coeffs[33] = 1.0f;     // Sky Color 2
         coeffs[34] = 1.0f;
         coeffs[35] = 0.9f;
         coeffs[36] = 0.0f;     // Y-Axis Rotation
         probes.coefficients = coeffs;
     }
 }
示例#29
0
 static public int GetInterpolatedLightProbe(IntPtr l)
 {
     try{
         UnityEngine.LightProbes self = (UnityEngine.LightProbes)checkSelf(l);
         UnityEngine.Vector3     a1;
         checkType(l, 2, out a1);
         UnityEngine.Renderer a2;
         checkType(l, 3, out a2);
         System.Single[] a3;
         checkType(l, 4, out a3);
         self.GetInterpolatedLightProbe(a1, a2, a3);
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
示例#30
0
 public static void CalculateInterpolatedLightAndOcclusionProbes(Vector3[] positions, SphericalHarmonicsL2[] lightProbes, Vector4[] occlusionProbes)
 {
     if (positions == null)
     {
         throw new ArgumentNullException("positions");
     }
     if (lightProbes == null && occlusionProbes == null)
     {
         throw new ArgumentException("Argument lightProbes and occlusionProbes cannot both be null.");
     }
     if (lightProbes != null && lightProbes.Length < positions.Length)
     {
         throw new ArgumentException("lightProbes", "Argument lightProbes has less elements than positions");
     }
     if (occlusionProbes != null && occlusionProbes.Length < positions.Length)
     {
         throw new ArgumentException("occlusionProbes", "Argument occlusionProbes has less elements than positions");
     }
     LightProbes.Internal_CalculateInterpolatedLightAndOcclusionProbes(positions, positions.Length, lightProbes, occlusionProbes);
 }
        /// <summary>
        /// Read the data into the specified value.
        /// </summary>
        /// <param name="value">Value.</param>
        /// <param name="reader">Reader.</param>
        public override void ReadInto(object value, ISaveGameReader reader)
        {
            UnityEngine.LightProbes lightProbes = (UnityEngine.LightProbes)value;
            foreach (string property in reader.Properties)
            {
                switch (property)
                {
                case "bakedProbes":
                    lightProbes.bakedProbes = reader.ReadProperty <UnityEngine.Rendering.SphericalHarmonicsL2[]>();
                    break;

                case "name":
                    lightProbes.name = reader.ReadProperty <System.String>();
                    break;

                case "hideFlags":
                    lightProbes.hideFlags = reader.ReadProperty <UnityEngine.HideFlags>();
                    break;
                }
            }
        }
示例#32
0
    // Inspector GUI function for polishable probes.
    void ShowPolisherGUI(LightProbes probes)
    {
        ResetPolisherIfNeeded (probes);

        var coeffs = probes.coefficients;

        // Retrieve the optional information from the second probe.
        var baseIntensity = coeffs [28];
        var skyIntensity = coeffs [29];
        var skyColor1 = new Color (coeffs [30], coeffs [31], coeffs [32]);
        var skyColor2 = new Color (coeffs [33], coeffs [34], coeffs [35]);
        var yaw = coeffs [36];

        EditorGUI.BeginChangeCheck ();

        // Show the controls.
        baseIntensity = EditorGUILayout.Slider ("Base Intensity", baseIntensity, 0.0f, 10.0f);
        skyIntensity = EditorGUILayout.Slider ("Sky Intensity", skyIntensity, 0.0f, 10.0f);
        skyColor1 = EditorGUILayout.ColorField ("Sky Color Top", skyColor1);
        skyColor2 = EditorGUILayout.ColorField ("Sky Color Bottom", skyColor2);
        yaw = EditorGUILayout.Slider ("Rotation (Y-Axis)", yaw, -180.0f, 180.0f);

        if (EditorGUI.EndChangeCheck ())
        {
            // Update the optional information.
            coeffs [28] = baseIntensity;
            coeffs [29] = skyIntensity;
            coeffs [30] = skyColor1.r;
            coeffs [31] = skyColor1.g;
            coeffs [32] = skyColor1.b;
            coeffs [33] = skyColor2.r;
            coeffs [34] = skyColor2.g;
            coeffs [35] = skyColor2.b;
            coeffs [36] = yaw;

            // Retrieve the SH coefficients from the first probe.
            var sh = NewVectorArrayFromCoeffs (coeffs, 0);

            // Apply the intensity value.
            for (var i = 0; i < 9; i++)
                sh [i] *= baseIntensity;

            // Apply y-axis rotation.
            sh = RotateSHCoeffs (sh, yaw);

            // Add the skylight.
            var sky1 = ColorToVector3 (skyColor1) * skyIntensity;
            var sky2 = ColorToVector3 (skyColor2) * skyIntensity;
            sh [0] += (sky1 + sky2) * 0.5f;
            sh [1] += (sky2 - sky1) * 0.5f;

            // Copy the coefficients to the all probes.
            var newCoeffs = NewCoeffsFromVectorArray (sh);
            for (var i = 27 * 2; i < coeffs.Length; i += 27)
                System.Array.Copy (newCoeffs, 0, coeffs, i, 27);

            // Update the asset.
            probes.coefficients = coeffs;
        }

        EditorGUILayout.Space ();

        // Skybox generator button.
        if (GUILayout.Button ("Make/Update Skybox"))
            MakeSkybox (AssetDatabase.GetAssetPath (target), NewVectorArrayFromCoeffs (coeffs, 27 * 2));
    }
示例#33
0
 // Check if the light probes asset is polishable.
 bool CheckPolishable(LightProbes probes)
 {
     // Check if the probes are placed at strange positions. If true, that's a polishable probe.
     return (probes.count == 10) && (Vector3.Distance (probes.positions [0], Vector3.up * 20000.0f) < 0.1f);
 }
示例#34
0
    // Inspector GUI function for polishable probes.
    void ShowPolisherGUI(LightProbes probes)
    {
        ProbePolisher.ResetPolisherIfNeeded(probes);
        
        var coeffs = probes.coefficients;

        // Retrieve the optional information from the second probe.
        var baseIntensity = coeffs[28];
        var skyIntensity = coeffs[29];
        var skyColor1 = new Color(coeffs[30], coeffs[31], coeffs[32]);
        var skyColor2 = new Color(coeffs[33], coeffs[34], coeffs[35]);
        var yaw = coeffs[36];

        EditorGUI.BeginChangeCheck();

        // Show the controls.
        baseIntensity = EditorGUILayout.Slider("Base Intensity", baseIntensity, 0.0f, 10.0f);
        skyIntensity = EditorGUILayout.Slider("Sky Intensity", skyIntensity, 0.0f, 10.0f);
        skyColor1 = EditorGUILayout.ColorField("Sky Color Top", skyColor1);
        skyColor2 = EditorGUILayout.ColorField("Sky Color Bottom", skyColor2);
        yaw = EditorGUILayout.Slider("Rotation (Y-Axis)", yaw, -180.0f, 180.0f);

        if (EditorGUI.EndChangeCheck())
        {
            // Update the optional information.
            coeffs[28] = baseIntensity;
            coeffs[29] = skyIntensity;
            coeffs[30] = skyColor1.r;
            coeffs[31] = skyColor1.g;
            coeffs[32] = skyColor1.b;
            coeffs[33] = skyColor2.r;
            coeffs[34] = skyColor2.g;
            coeffs[35] = skyColor2.b;
            coeffs[36] = yaw;

            // Retrieve the SH coefficients from the first probe.
            var sh = ProbePolisher.NewVectorArrayFromCoeffs(coeffs, 0);

            // Apply the intensity value.
            for (var i = 0; i < 9; i++) sh[i] *= baseIntensity;

            // Apply y-axis rotation.
            sh = ProbePolisher.RotateSHCoeffs(sh, yaw);

            // Add the skylight.
            var sky1 = ProbePolisher.ColorToVector3(skyColor1) * skyIntensity;
            var sky2 = ProbePolisher.ColorToVector3(skyColor2) * skyIntensity;
            sh[0] += (sky1 + sky2) * 0.5f;
            sh[1] += (sky2 - sky1) * 0.5f;

            // Copy the coefficients to the all probes.
            ProbePolisher.UpdateCoeffsWithVectorArray(coeffs, sh);

            // Update the asset.
            probes.coefficients = coeffs;
        }

        EditorGUILayout.Space ();

        // Skybox generator button.
        if (GUILayout.Button ("Make/Update Skybox"))
        {
            // Look for the asset of the material.
            var probePath = AssetDatabase.GetAssetPath(target);
            var assetPath = probePath.Substring (0, probePath.Length - 6) + " skybox.mat";
            var material = AssetDatabase.LoadAssetAtPath (assetPath, typeof(Material)) as Material;

            // If there is no asset, make a new one.
            if (material == null)
            {
                material = new Material (Shader.Find ("ProbePolisher/SH Skybox"));
                AssetDatabase.CreateAsset (material, assetPath);
            }

            // Update the material.
            ProbePolisher.UpdateSkyboxMaterial(material, ProbePolisher.NewVectorArrayFromCoeffs(coeffs, 27 * 2));
        }
    }
示例#35
0
 static public int get_cellCount(IntPtr l)
 {
     UnityEngine.LightProbes o = (UnityEngine.LightProbes)checkSelf(l);
     pushValue(l, o.cellCount);
     return(1);
 }
示例#36
0
	//Nav mesh settings can't be accessed via script :(

	//Lightmapping is VERY version-specific. You may have to modify the settings that are compared
	public void CaptureSettings() {
#if UNITY_5
#else
		aoAmount = LightmapEditorSettings.aoAmount;
		aoContrast = LightmapEditorSettings.aoContrast;
		bounceBoost = LightmapEditorSettings.bounceBoost;	 
		bounceIntensity = LightmapEditorSettings.bounceIntensity;
		bounces = LightmapEditorSettings.bounces;
		
		quality = LightmapEditorSettings.quality;
		skyLightColor = LightmapEditorSettings.skyLightColor;
		skyLightIntensity = LightmapEditorSettings.skyLightIntensity;

		finalGatherContrastThreshold = LightmapEditorSettings.finalGatherContrastThreshold;
		finalGatherGradientThreshold = LightmapEditorSettings.finalGatherGradientThreshold;
		finalGatherInterpolationPoints = LightmapEditorSettings.finalGatherInterpolationPoints;
		finalGatherRays = LightmapEditorSettings.finalGatherRays;
		lastUsedResolution = LightmapEditorSettings.lastUsedResolution;
		lockAtlas = LightmapEditorSettings.lockAtlas;
#if !(UNITY_3_0 || UNITY_3_0_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5)
		bakedColorSpace = LightmapSettings.bakedColorSpace;
#endif
#endif
		ambientLight = RenderSettings.ambientLight;
#if UNITY_4_3 || UNITY_4_5 || UNITY_5 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3
		flareFadeSpeed = RenderSettings.flareFadeSpeed;
#endif
#if UNITY_3_0 || UNITY_3_0_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5
#else
		lightProbes = LightmapSettings.lightProbes;
		padding = LightmapEditorSettings.padding;
#endif
		flareStrength = RenderSettings.flareStrength;
		fog = RenderSettings.fog;
		fogColor = RenderSettings.fogColor;
		fogDensity = RenderSettings.fogDensity;
		fogEndDistance = RenderSettings.fogEndDistance;
		fogMode = RenderSettings.fogMode;
		fogStartDistance = RenderSettings.fogStartDistance;
		haloStrength = RenderSettings.haloStrength;
		skybox = RenderSettings.skybox;

		lightmaps = LightmapSettings.lightmaps;
		lightmapsMode = LightmapSettings.lightmapsMode;

		aoMaxDistance = LightmapEditorSettings.aoMaxDistance;
		maxAtlasHeight = LightmapEditorSettings.maxAtlasHeight;
		maxAtlasWidth = LightmapEditorSettings.maxAtlasWidth;
		resolution = LightmapEditorSettings.resolution;
		textureCompression = LightmapEditorSettings.textureCompression;
	}
示例#37
0
 public static void GetInterpolatedProbe(Vector3 position, Renderer renderer, out SphericalHarmonicsL2 probe)
 {
     LightProbes.INTERNAL_CALL_GetInterpolatedProbe(ref position, renderer, out probe);
 }
示例#38
0
    // Use this for initialization
    void Start()
    {
        float[] globalCoeffs = new float[27];
        for (int i = 0; i < globalCoeffs.Length; i++)
        {
            globalCoeffs[i] = 0;
        }
        Light[] lights = null;
        {
            if (SearchForLights)
            {
                GameObject[] temp = (GameObject[])FindObjectsOfType(typeof(GameObject));
                int lcount = 0;
                for (int i = 0; i < temp.Length; i++)
                {
                    if (temp[i].GetComponent<Light>() != null)
                    {
                        lcount++;
                    }
                }
                lights = new Light[lcount];
                GameObject[] tars = new GameObject[lcount];
                int pos = 0;
                for (int i = 0; i < temp.Length; i++)
                {
                    Light tl = temp[i].GetComponent<Light>();

                    if (tl != null)
                    {
                        lights[pos] = tl;
                        tars[pos] = temp[i];
                        pos++;
                    }
                }
                Lights = tars;
            }
            else
            {
                GameObject[] temp = Lights;
                int lcount = 0;
                for (int i = 0; i < temp.Length; i++)
                {
                    if (temp[i] != null && temp[i].GetComponent<Light>() != null)
                    {
                        lcount++;
                    }
                }
                lights = new Light[lcount];
                GameObject[] tars = new GameObject[lcount];
                int pos = 0;
                for (int i = 0; i < temp.Length; i++)
                {
                    if (temp[i] != null)
                    {
                        Light tl = temp[i].GetComponent<Light>();

                        if (tl != null)
                        {
                            lights[pos] = tl;
                            tars[pos] = temp[i];
                            pos++;
                        }
                    }
                }
                Lights = tars;
            }
        }
        Color ambient = Color.black;

        {
            float[] coefficients = null;
            int coefficientsPerProbe = 27;
            int probeCount = 0;
            Vector3[] probePositions = null;
            if (AddToBakedProbes)
            {
                try
                {
                    lightProbes = Instantiate(LightmapSettings.lightProbes) as LightProbes;
                    coefficients = lightProbes.coefficients;
                    coefficientsPerProbe = 27;
                    probeCount = lightProbes.count;
                    probePositions = lightProbes.positions;
                }
                catch
                {
                    lightProbes = null;

                    return;
                }
            }
            if (coefficients == null)
            {
                coefficients = new float[0];
                probeCount = 0;
                probePositions = new Vector3[0];
            }
            int i = 0;
            foreach (Light l in lights)
            {
                if (!OnlyUseActiveLights || (OnlyUseActiveLights && l.enabled && l.gameObject.active))
                {
                    if (l.type == LightType.Directional)
                    {
                        i = 0;
                        while (i < probeCount)
                        {
                            //Debug.Log("Added Directional Light");
                            if (AddToBakedProbes)
                            {
                                AddSHDirectionalLight(l.color, -l.transform.forward, l.intensity, coefficients, i * coefficientsPerProbe);
                            }
                            i++;
                        }
                        AddSHDirectionalLight(l.color, -l.transform.forward, l.intensity, globalCoeffs, 0);
                    }
                    else if(AddToBakedProbes)
                        if (l.type == LightType.Point)
                        {
                            i = 0;
                            while (i < probeCount)
                            {
                                //Debug.Log("Added Point Light");
                                AddSHPointLight(l.color, l.transform.position, l.range, l.intensity, coefficients, i * coefficientsPerProbe, probePositions[i]);
                                i++;
                            }
                        }
                }
                if (DeactivateLightsWhenFinished)
                {
                    l.enabled = false;
                }
            }
            if (AddToBakedProbes && lightProbes!= null)
            {
                lightProbes.coefficients = coefficients;
                LightmapSettings.lightProbes = lightProbes;
            }

            int pos = 0;
            float[] tcoffs = new float[27];
            for (int j = 0; j < 3; j++)
            {
                for(int k = 0; k<9;k++)
                {
                    tcoffs[pos] = globalCoeffs[k * 3 + j];
                    pos++;
                }
            }
            globalCoeffs = tcoffs;
            Norm(globalCoeffs);
            SetCoefficients(globalCoeffs);
        }
    }
示例#39
0
 public static void GetInterpolatedProbe(Vector3 position, Renderer renderer, out SphericalHarmonicsL2 probe)
 {
     LightProbes.GetInterpolatedProbe_Injected(ref position, renderer, out probe);
 }