// Update is called once per frame void Update() { LightProbes.GetInterpolatedProbe(gameObject.transform.position, null, out var propProbe); Debug.Log(propProbe[0, 0]); Debug.Log(propProbe[0, 1]); Debug.Log(propProbe[0, 2]); Debug.Log(propProbe[0, 3]); Debug.Log(propProbe[0, 4]); Debug.Log(propProbe[0, 5]); Debug.Log(propProbe[0, 6]); Debug.Log(propProbe[0, 7]); Debug.Log(propProbe[0, 8]); Debug.Log("/////////////////////"); Debug.Log(propProbe[1, 0]); Debug.Log(propProbe[1, 1]); Debug.Log(propProbe[1, 2]); Debug.Log(propProbe[1, 3]); Debug.Log(propProbe[1, 4]); Debug.Log(propProbe[1, 5]); Debug.Log(propProbe[1, 6]); Debug.Log(propProbe[1, 7]); Debug.Log(propProbe[1, 8]); Debug.Log("/////////////////////"); Debug.Log(propProbe[2, 0]); Debug.Log(propProbe[2, 1]); Debug.Log(propProbe[2, 2]); Debug.Log(propProbe[2, 3]); Debug.Log(propProbe[2, 4]); Debug.Log(propProbe[2, 5]); Debug.Log(propProbe[2, 6]); Debug.Log(propProbe[2, 7]); Debug.Log(propProbe[2, 8]); }
// Token: 0x060034C9 RID: 13513 RVA: 0x000E6EE0 File Offset: 0x000E50E0 private void DrawDeferredDecals_Albedo(Camera cam) { if (this._deferredDecals.Count == 0) { return; } this._bufferDeferred.SetRenderTarget(this._albedoRenderTarget, BuiltinRenderTextureType.CameraTarget); foreach (KeyValuePair <Material, HashSet <Decal> > keyValuePair in this._deferredDecals) { Material key = keyValuePair.Key; Dictionary <Material, HashSet <Decal> > .Enumerator enumerator; keyValuePair = enumerator.Current; HashSet <Decal> value = keyValuePair.Value; int count = value.Count; int num = 0; foreach (Decal decal in value) { if (decal != null && decal.DrawAlbedo) { if (this.UseInstancing && !decal.UseLightProbes) { this._matrices[num] = decal.transform.localToWorldMatrix; this._fadeValues[num] = decal.Fade; this._limitToValues[num] = (decal.LimitTo ? ((float)decal.LimitTo.GetInstanceID()) : float.NaN); num++; if (num == 1023) { this._instancedBlock.Clear(); this._instancedBlock.SetFloatArray("_MaskMultiplier", this._fadeValues); this._instancedBlock.SetFloatArray("_LimitTo", this._limitToValues); DecaliciousRenderer.SetLightProbeOnBlock(RenderSettings.ambientProbe, this._instancedBlock); this._bufferDeferred.DrawMeshInstanced(DecaliciousRenderer._cubeMesh, 0, key, 0, this._matrices, num, this._instancedBlock); num = 0; } } else { this._directBlock.Clear(); this._directBlock.SetFloat("_MaskMultiplier", decal.Fade); this._directBlock.SetFloat("_LimitTo", decal.LimitTo ? ((float)decal.LimitTo.GetInstanceID()) : float.NaN); if (decal.UseLightProbes) { SphericalHarmonicsL2 probe; LightProbes.GetInterpolatedProbe(decal.transform.position, decal.GetComponent <MeshRenderer>(), out probe); DecaliciousRenderer.SetLightProbeOnBlock(probe, this._directBlock); } this._bufferDeferred.DrawMesh(DecaliciousRenderer._cubeMesh, decal.transform.localToWorldMatrix, key, 0, 0, this._directBlock); } } } if (this.UseInstancing && num > 0) { this._instancedBlock.Clear(); this._instancedBlock.SetFloatArray("_MaskMultiplier", this._fadeValues); this._instancedBlock.SetFloatArray("_LimitTo", this._limitToValues); DecaliciousRenderer.SetLightProbeOnBlock(RenderSettings.ambientProbe, this._instancedBlock); this._bufferDeferred.DrawMeshInstanced(DecaliciousRenderer._cubeMesh, 0, key, 0, this._matrices, num, this._instancedBlock); } } }
protected virtual IEnumerator CoActivateScene(string sceneName, bool disableCameras) { //Ensure that we are activating a loaded scene if (!_loadedScenes.ContainsKey(sceneName)) { LoadSceneAdditiveAsync(sceneName); } //Wait for the scene to be loaded, in case we are trying to activate a scene //that is not loaded yet. while (_loadedScenes[sceneName]._state == SceneState.Loading) { yield return(null); } SetSceneState(sceneName, SceneState.Loaded); //At this point, the scene is loaded. Activate it. Scene scene = SceneManager.GetSceneByName(sceneName); SceneManager.SetActiveScene(scene); LightProbes.Tetrahedralize(); if (disableCameras) { //Deactivate any present camera in the geometry scene foreach (Camera cam in Camera.allCameras) { if (cam.tag != "MainCamera") { cam.gameObject.SetActive(false); } } } }
/// <summary> /// 使用三色渐变模式生成球谐光数据 /// </summary> /// <param name="sky"></param> /// <param name="equator"></param> /// <param name="ground"></param> /// <returns></returns> public static SHData GenSHByTriLight(Color sky, Color equator, Color ground) { Color oSkyColor, oEquatorColor, oGroundColor; AmbientMode oMode = RenderSettings.ambientMode; RenderSettings.ambientMode = AmbientMode.Trilight; oSkyColor = RenderSettings.ambientSkyColor; oEquatorColor = RenderSettings.ambientEquatorColor; oGroundColor = RenderSettings.ambientGroundColor; RenderSettings.ambientSkyColor = sky; RenderSettings.ambientEquatorColor = equator; RenderSettings.ambientGroundColor = ground; DynamicGI.UpdateEnvironment(); SphericalHarmonicsL2 sh = new SphericalHarmonicsL2(); LightProbes.GetInterpolatedProbe(Vector3.zero, new Renderer(), out sh); SHData retData = CreateInstance <SHData>(); retData.Init(sh); RenderSettings.ambientMode = oMode; RenderSettings.ambientSkyColor = oSkyColor; RenderSettings.ambientEquatorColor = oEquatorColor; RenderSettings.ambientGroundColor = oGroundColor; DynamicGI.UpdateEnvironment(); return(retData); }
// Start is called before the first frame update void Start() { Debug.Log("123"); Object obj2 = new Object(); LightProbes obj = obj2 as LightProbes; LightProbeGroup lightProbeGroup = new LightProbeGroup(); }
void OnGUI() { #if !(UNITY_5_3_OR_NEWER || UNITY_5) if (GUI.Button(rect[0], "Switch to LightProbes Set 1")) { LightProbes xc = Instantiate(lp1) as LightProbes; LightmapSettings.lightProbes = xc; UpdateBaseCoefficients(); } if (GUI.Button(rect[1], "Switch to LightProbes Set 2")) { LightProbes xc = Instantiate(lp2) as LightProbes; LightmapSettings.lightProbes = xc; UpdateBaseCoefficients(); } if (GUI.Button(rect[2], "Switch to LightProbes Set 3")) { LightProbes xc = Instantiate(lp3) as LightProbes; LightmapSettings.lightProbes = xc; UpdateBaseCoefficients(); } GUI.Label(rect[3], "Current Light Probe Count:" + LightmapSettings.lightProbes.count); GUI.Label(rect[4], "Current Light Probe cellCount:" + LightmapSettings.lightProbes.cellCount); // for (int i = 0; i < rectL.Length; i++) { GUI.Label(rectL[i], labels[i]); } posx = GUI.HorizontalSlider(rectS[0], posx, -4.2f, 4.2f); factor1 = GUI.HorizontalSlider(rectS[1], factor1, 0f, 2f); factor2 = GUI.HorizontalSlider(rectS[2], factor2, 0f, 2f); factor3 = GUI.HorizontalSlider(rectS[3], factor3, 0f, 2f); UpdateCoeffients(); #endif }
/// <summary> /// 通过天空盒方式生成球谐光数据 /// </summary> /// <param name="cubeTex"></param> /// <param name="rotate"></param> /// <returns></returns> public static SHData GenSHBySkyBox(Texture cubeTex, float rotate) { AmbientMode oMode = RenderSettings.ambientMode; RenderSettings.ambientMode = AmbientMode.Skybox; Material mSky = new Material(Shader.Find("Skybox/Cubemap")); mSky.SetTexture("_Tex", cubeTex); mSky.SetFloat("_Rotation", rotate); Material oldSky = RenderSettings.skybox; RenderSettings.skybox = mSky; DynamicGI.UpdateEnvironment(); SphericalHarmonicsL2 sh = new SphericalHarmonicsL2(); LightProbes.GetInterpolatedProbe(Vector3.zero, new Renderer(), out sh); SHData retData = CreateInstance <SHData>(); retData.Init(sh); RenderSettings.skybox = oldSky; RenderSettings.ambientMode = oMode; DynamicGI.UpdateEnvironment(); DestroyImmediate(mSky); return(retData); }
// Set SH coefficients to MaterialPropertyBlock public static void SetSHCoefficients( Vector3 position, MaterialPropertyBlock properties ) { SphericalHarmonicsL2 sh; LightProbes.GetInterpolatedProbe(position, null, out sh); // Constant + Linear for (var i = 0; i < 3; i++) { properties.SetVector(_idSHA[i], new Vector4( sh[i, 3], sh[i, 1], sh[i, 2], sh[i, 0] - sh[i, 6] )); } // Quadratic polynomials for (var i = 0; i < 3; i++) { properties.SetVector(_idSHB[i], new Vector4( sh[i, 4], sh[i, 6], sh[i, 5] * 3, sh[i, 7] )); } // Final quadratic polynomial properties.SetVector(_idSHC, new Vector4( sh[0, 8], sh[2, 8], sh[1, 8], 1 )); }
void Update() { if (block == null) { block = new MaterialPropertyBlock(); block.SetVectorArray(baseColorId, baseColors); block.SetFloatArray(metallicId, metallic); block.SetFloatArray(smoothnessId, smoothness); if (!lightProbeVolume) { var positions = new Vector3[1023]; for (int i = 0; i < matrices.Length; i++) { positions[i] = matrices[i].GetColumn(3); } var lightProbes = new SphericalHarmonicsL2[1023]; var occlusionProbes = new Vector4[1023]; LightProbes.CalculateInterpolatedLightAndOcclusionProbes( positions, lightProbes, occlusionProbes ); block.CopySHCoefficientArraysFrom(lightProbes); block.CopyProbeOcclusionArrayFrom(occlusionProbes); } } Graphics.DrawMeshInstanced( mesh, 0, material, matrices, 1023, block, ShadowCastingMode.On, true, 0, null, lightProbeVolume ? LightProbeUsage.UseProxyVolume : LightProbeUsage.CustomProvided, lightProbeVolume ); }
void SwapLightmap(int index) { // Swap lightmap texture Texture2D lightmapTexture = versions[index].texture; LightmapData data = new LightmapData { lightmapColor = lightmapTexture }; LightmapSettings.lightmaps = new LightmapData[] { data }; // Swap LightProbes LightProbes lightProbes = versions[index].lightProbes; LightmapSettings.lightProbes = lightProbes; // Swap environment reflection Cubemap source = versions[index].skybox; RenderSettings.customReflection = source; RenderSettings.defaultReflectionMode = DefaultReflectionMode.Custom; // Swap Reflection probes Texture texture = versions[index].reflectionProbeTexture; reflectionProbe.bakedTexture = texture; // Swap Environment Light rotation Vector3 rotation = versions[index].environmentLightRotation; environmentLight.transform.eulerAngles = rotation; }
void LateUpdate() { HairWorksIntegration.hwStepSimulation(Time.deltaTime); SphericalHarmonicsL2 aSample; // SH sample consists of 27 floats LightProbes.GetInterpolatedProbe(this.transform.position, this.GetComponent <MeshRenderer>(), out aSample); for (int iC = 0; iC < 3; iC++) { avCoeff[iC] = new Vector4((float)aSample [iC, 3], aSample [iC, 1], aSample [iC, 2], aSample [iC, 0] - aSample [iC, 6]); } for (int iC = 0; iC < 3; iC++) { avCoeff [iC + 3].x = aSample [iC, 4]; avCoeff [iC + 3].y = aSample [iC, 5]; avCoeff [iC + 3].z = 3.0f * aSample [iC, 6]; avCoeff [iC + 3].w = aSample [iC, 7]; } avCoeff [6].x = aSample [0, 8]; avCoeff [6].y = aSample [1, 8]; avCoeff [6].y = aSample [2, 8]; avCoeff [6].w = 1.0f; if (oldColor != ambientLight) { aSample.AddAmbientLight(ambientLight); oldColor = ambientLight; } }
/// <summary> /// This function is called when all the scenes have been loaded /// </summary> private void SetActiveScene() { SceneManager.SetActiveScene(SceneManager.GetSceneByPath(_activeScene.scenePath)); // Will reconstruct LightProbe tetrahedrons to include the probes from the newly-loaded scene LightProbes.TetrahedralizeAsync(); //Raise the event to inform that the scene is loaded and set active _OnSceneReady.RaiseEvent(); }
/// <summary> /// SetActiveScene(AsyncOperation asyncOp) is called by AsyncOperation.complete event. /// </summary> /// <param name="asyncOp"></param> private void SetActiveScene(AsyncOperation asyncOp) { // TODO: As each event completes, decide if it needs to activate right away. SceneManager.SetActiveScene(SceneManager.GetSceneByPath(_activeScene.scenePath)); // Will reconstruct LightProbe tetrahedrons to include the probes from the newly-loaded scene LightProbes.TetrahedralizeAsync(); }
public void PlayGame() { Loading_Screen.gameObject.SetActive(true); scenesLoading.Add(SceneManager.UnloadSceneAsync((int)SceneIndexes.TITLE_SCREEN)); scenesLoading.Add(SceneManager.LoadSceneAsync((int)SceneIndexes.MAP, LoadSceneMode.Additive)); LightProbes.TetrahedralizeAsync(); StartCoroutine(GetScenesLoadProgress()); }
public void Distribute() { distribute = false; m_probeGroup ??= GetComponent <LightProbeGroup>(); var positions = Extensions.FibonacciPoints(m_probeCount); //m_probeGroup.probePositions = positions.ToArray(); LightProbes.Tetrahedralize(); }
void SetActiveScene() { Scene s = ((SceneInstance)_loadingOperationHandle.Result).Scene; SceneManager.SetActiveScene(s); LightProbes.TetrahedralizeAsync(); StartGameplay(); }
void SetLightmap(LightmapData[] lmds, LightProbes lp, Texture t) { string x = "LightMap/" + TimeData.clock.hour.ToString().PadLeft(2, '0') + "h" + TimeData.clock.min.ToString().PadLeft(2, '0') + "m/"; LightmapSettings.lightmaps = lmds; // LightmapSettings.lightProbes = Resources.Load(x+""); // probeComponent.customBakedTexture = t; }
public override void OnInspectorGUI() { GUILayout.BeginVertical(EditorStyles.helpBox, new GUILayoutOption[0]); LightProbes target = base.target as LightProbes; GUIStyle wordWrappedMiniLabel = EditorStyles.wordWrappedMiniLabel; GUILayout.Label("Light probe count: " + target.count, wordWrappedMiniLabel, new GUILayoutOption[0]); GUILayout.Label("Cell count: " + target.cellCount, wordWrappedMiniLabel, new GUILayoutOption[0]); GUILayout.EndVertical(); }
/* * Summary: * This function is called when all the scenes have been loaded. */ private void SetActiveScene() { //All the scenes have been loaded, so we assume the first in the array is ready to become the active scene Scene s = ((SceneInstance)_loadingOperationHandles[0].Result).Scene; SceneManager.SetActiveScene(s); LightProbes.TetrahedralizeAsync(); ///////////////////// _onSceneReady.RaiseEvent(); //Spawn System will spaw the Player? }
public void OnLightProbesSet1( ) { LightmapSettings.lightProbes = null; //LightmapData ld = null; //LightProbeGroup pg=null; LightProbes lp = null; SphericalHarmonicsL2[] sh = lp.bakedProbes; Vector3[] poss = lp.positions; }
private IEnumerator do_fade(int[] scene_index) { Scene[] current_scenes = SceneManager.GetAllScenes(); m_animator.SetTrigger("fade in"); yield return(null); yield return(new WaitForSecondsRealtime(m_animator.GetAnimatorTransitionInfo(0).duration)); AsyncOperation[] async_operation_loads = new AsyncOperation[scene_index.Length]; for (int i = 0; i < scene_index.Length; ++i) { async_operation_loads[i] = SceneManager.LoadSceneAsync(scene_index[i], LoadSceneMode.Additive); } float time = Time.unscaledTime; foreach (var async_operation_load in async_operation_loads) { while (!async_operation_load.isDone) { yield return(null); } } SceneManager.SetActiveScene(SceneManager.GetSceneByBuildIndex(scene_index[0])); AsyncOperation[] async_operation_unloads = new AsyncOperation[current_scenes.Length]; for (int i = 0; i < current_scenes.Length; ++i) { async_operation_unloads[i] = SceneManager.UnloadSceneAsync(current_scenes[i]); } foreach (var async_operation_unload in async_operation_unloads) { while (!async_operation_unload.isDone) { yield return(null); } } LightProbes.Tetrahedralize(); if ((time + 2) > Time.unscaledTime) { yield return(new WaitForSecondsRealtime((time + 2) - Time.unscaledTime)); } m_animator.SetTrigger("fade out"); GameEvent <LevelLoadedEvent> .Post(); yield return(new WaitForSecondsRealtime(m_animator.GetAnimatorTransitionInfo(0).duration)); Debug.Log("Load Complete!"); }
private void OnSceneLoadComplete() { LogicResouce lRes = ResourceManager.Instance.GetLogicRes(SceneRes); //LogicResourceBuilder builder = null; LightmapSettings.lightmapsMode = LightmapsMode.Single; LightmapSettings.lightmapsMode = LightmapsMode.Single; Dictionary <int, Texture2D> lightMapDic = new Dictionary <int, Texture2D>(); foreach (string s in lRes.phyResList) { if (s.Contains("LightmapFar")) { string[] strs = s.Split(new char[] { '-', '.' }); if (strs != null && strs.Length > 0) { int index = Int32.Parse(strs[strs.Length - 2]);//strs[Length - 1]; if (lightMapDic.ContainsKey(index)) { } else { lightMapDic.Add(index, ResourceManager.Instance.GetPhyRes(s).getTexture()); } } } if (s.Contains("LightProbe")) { PhyResouce probe = ResourceManager.Instance.GetPhyRes(s); if (probe != null) { LightProbes probes = (LightProbes)probe.assetBundle.mainAsset; LightmapSettings.lightProbes = probes; } } } LightmapData[] ldarr = new LightmapData[lightMapDic.Count]; foreach (KeyValuePair <int, Texture2D> kv in lightMapDic) { LightmapData ld = new LightmapData(); ld.lightmapFar = kv.Value; ldarr[kv.Key] = ld; } LightmapSettings.lightmaps = ldarr; PhyResouce res = ResourceManager.Instance.GetPhyRes(SceneRes); UnityEngine.Object obj = res.assetBundle.mainAsset; GameObject.Instantiate(obj); }
static int GetInterpolatedLightProbe(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 4); LightProbes obj = LuaScriptMgr.GetNetObject <LightProbes>(L, 1); Vector3 arg0 = LuaScriptMgr.GetNetObject <Vector3>(L, 2); Renderer arg1 = LuaScriptMgr.GetNetObject <Renderer>(L, 3); float[] objs2 = LuaScriptMgr.GetArrayNumber <float>(L, 4); obj.GetInterpolatedLightProbe(arg0, arg1, objs2); return(0); }
public void SaveRenderSetting() { fogEnable = RenderSettings.fog; fogColor = RenderSettings.fogColor; fogStart = RenderSettings.fogStartDistance; fogEnd = RenderSettings.fogEndDistance; fogDensity = RenderSettings.fogDensity; fogMode = (int)RenderSettings.fogMode; ambientColor = RenderSettings.ambientLight; skyMat = RenderSettings.skybox; lpData = LightmapSettings.lightProbes; }
bool CheckLightProbe() { LightProbes probes = LightmapSettings.lightProbes; if (probes == null) { CreateDefaultVolume(); return(false); } return(true); }
private void LateUpdate() { if (LightmapSettings.lightProbes.count > 0) { LightProbes.GetInterpolatedProbe(this.DummyRenderer.transform.position, this.DummyRenderer, out this.sampledProbe); if (this.injectLight) { this.sampledProbe.AddDirectionalLight(new Vector3(1f, 0f, 0f), Color.red, 0.25f); } RenderSettings.ambientProbe = this.sampledProbe; } }
byte[] SerializeLightProbes(LightProbes lightprobe) { if (this.lightProbes != null) { SphericalHarmonicsL2[] probeData = LightmapSettings.lightProbes.bakedProbes; Vector3[] probePositions = lightprobe.positions; float[] probeDataArray = new float[30 * probeData.Length]; int stride = 0; for (int i = 0; i < probeData.Length; i++) { Vector3 position = probePositions[i]; SphericalHarmonicsL2 probe = probeData[i]; probeDataArray[stride] = position.x; stride++; probeDataArray[stride] = position.y; stride++; probeDataArray[stride] = position.z; stride++; //Save all coefficients for this probe. for (int k = 0; k < 27; k++) { probeDataArray[stride + k] = probe[0, k]; } stride += 27; } byte[] serializedLightProbes = new byte[probeDataArray.Length * sizeof(float)]; int index = 0; for (int i = 0; i < probeDataArray.Length; i++) { byte[] serializedFloat = BitConverter.GetBytes(probeDataArray[i]); Buffer.BlockCopy(serializedFloat, 0, serializedLightProbes, index, serializedFloat.Length); index += 4; } return(serializedLightProbes); } //Do not return null, serializer will cry... return(new byte[10]); }
/// <summary> /// This function is called when all the scenes have been loaded /// </summary> private void SetActiveScene(SceneInstance sceneInstance) { Scene s = sceneInstance.Scene; SceneManager.SetActiveScene(s); LightProbes.TetrahedralizeAsync(); if (_onSceneReady != null) { _onSceneReady.RaiseEvent(); } }
// Set useMiniStyle to true to use smaller UI styles, // like in particle system modules UI. // // The code does branches right now on that instead of just // picking one or another style, since there are no UI // functions, like EditorGUILayout.ObjectField that would take // a style parameter :( internal void OnGUI(UnityEngine.Object[] selection, Renderer renderer, bool useMiniStyle) { int selectionCount = 1; bool isDeferredRenderingPath = SceneView.IsUsingDeferredRenderingPath(); bool isDeferredReflections = isDeferredRenderingPath && (UnityEngine.Rendering.GraphicsSettings.GetShaderMode(BuiltinShaderType.DeferredReflections) != BuiltinShaderMode.Disabled); bool areLightProbesAllowed = true; if (selection != null) { foreach (UnityEngine.Object obj in selection) { if (LightProbes.AreLightProbesAllowed((Renderer)obj) == false) { areLightProbesAllowed = false; break; } } selectionCount = selection.Length; } RenderLightProbeUsage(selectionCount, renderer, useMiniStyle, areLightProbesAllowed); RenderLightProbeProxyVolumeWarningNote(renderer, selectionCount); RenderReflectionProbeUsage(useMiniStyle, isDeferredRenderingPath, isDeferredReflections); // anchor field - light probes and reflection probes share the same anchor bool needsProbeAnchorField = RenderProbeAnchor(useMiniStyle); if (needsProbeAnchorField) { bool useReflectionProbes = !m_ReflectionProbeUsage.hasMultipleDifferentValues && (ReflectionProbeUsage)m_ReflectionProbeUsage.intValue != ReflectionProbeUsage.Off; if (useReflectionProbes) { if (!isDeferredReflections) { renderer.GetClosestReflectionProbes(m_BlendInfo); ShowClosestReflectionProbes(m_BlendInfo); } } } bool receivesShadow = !m_ReceiveShadows.hasMultipleDifferentValues && m_ReceiveShadows.boolValue; if ((isDeferredRenderingPath && receivesShadow) || (isDeferredReflections && needsProbeAnchorField)) { EditorGUILayout.HelpBox(m_DeferredNote.text, MessageType.Info); } }
public Color SampleLightProbesUp(Vector3 pos, float grayScaleFactor) { SphericalHarmonicsL2 sh; LightProbes.GetInterpolatedProbe(pos, null, out sh); var unity_SHAr = new Vector4(sh[0, 3], sh[0, 1], sh[0, 2], sh[0, 0] - sh[0, 6]); var unity_SHAg = new Vector4(sh[1, 3], sh[1, 1], sh[1, 2], sh[1, 0] - sh[1, 6]); var unity_SHAb = new Vector4(sh[2, 3], sh[2, 1], sh[2, 2], sh[2, 0] - sh[2, 6]); var unity_SHBr = new Vector4(sh[0, 4], sh[0, 6], sh[0, 5] * 3, sh[0, 7]); var unity_SHBg = new Vector4(sh[1, 4], sh[1, 6], sh[1, 5] * 3, sh[1, 7]); var unity_SHBb = new Vector4(sh[2, 4], sh[2, 6], sh[2, 5] * 3, sh[2, 7]); var unity_SHC = new Vector3(sh[0, 8], sh[2, 8], sh[1, 8]); var norm = new Vector4(0, 1, 0, 1); Color colorLinear = Color.black; colorLinear.r = Vector4.Dot(unity_SHAr, norm); colorLinear.g = Vector4.Dot(unity_SHAg, norm); colorLinear.b = Vector4.Dot(unity_SHAb, norm); // half4 vB = normal.xyzz * normal.yzzx; var normB = new Vector4(norm.x * norm.y, norm.y * norm.z, norm.z * norm.z, norm.z * norm.x); Color colorQuad = Color.black; colorQuad.r = Vector4.Dot(unity_SHBr, normB); colorQuad.g = Vector4.Dot(unity_SHBg, normB); colorQuad.b = Vector4.Dot(unity_SHBb, normB); float vC = norm.x * norm.x - norm.y * norm.y; var finalQuad = unity_SHC * vC; Color colorFinalQuad = new Color(finalQuad.x, finalQuad.y, finalQuad.z); Color finalColor = colorLinear + colorQuad + colorFinalQuad; var grayColor = finalColor.r * 0.33f + finalColor.g * 0.33f + finalColor.b * 0.33f; finalColor = Color.Lerp(finalColor, Color.white * grayColor, grayScaleFactor); if (QualitySettings.activeColorSpace == ColorSpace.Gamma) { return((colorLinear + colorQuad + colorFinalQuad).gamma); } else { return(finalColor); } }
private static void INTERNAL_CALL_GetInterpolatedLightProbe(LightProbes self, ref Vector3 position, Renderer renderer, Single[] coefficients){}