/// <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); }
//------------------------------------------------------------------------------------------------------------------ private void SetWeatherType_1() { this.m_ambientEquatorColor = new Color(1.0f, 1.0f, 1.0f); this.m_ambientGroundColor = new Color(1.0f, 1.0f, 1.0f); this.m_ambientIntensity = 1.0f; this.m_ambientLight = new Color(1.0f, 1.0f, 1.0f); this.m_ambientMode = AmbientMode.Skybox; //this.m_ambientProbe = SphericalHarmonicsL2; this.m_ambientSkyColor = new Color(1.0f, 1.0f, 1.0f); this.m_customReflection = null; this.m_defaultReflectionMode = DefaultReflectionMode.Skybox; this.m_defaultReflectionResolution = 128; this.m_flareFadeSpeed = 3.0f; this.m_flareStrength = 1.0f; this.m_fog = true; this.m_fogColor = new Color(0.5f, 0.5f, 0.5f); this.m_fogDensity = 0.01f; this.m_fogEndDistance = 300.0f; this.m_fogMode = FogMode.Linear; this.m_fogStartDistance = 0; this.m_haloStrength = 0.5f; this.m_reflectionBounces = 1; this.m_reflectionIntensity = 1.0f; Material skyboxMaterial = null; this.m_skybox = skyboxMaterial; }
/// <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); }
void Reset() { lastResetTime = System.DateTime.Now.ToString (); ambientEquatorColor = RenderSettings.ambientEquatorColor; ambientGroundColor = RenderSettings.ambientGroundColor; ambientIntensity = RenderSettings.ambientIntensity; ambientLight = RenderSettings.ambientLight; ambientMode = RenderSettings.ambientMode; ambientProbe = RenderSettings.ambientProbe; ambientSkyColor = RenderSettings.ambientSkyColor; customReflection = RenderSettings.customReflection; defaultReflectionMode = RenderSettings.defaultReflectionMode; defaultReflectionResolution = RenderSettings.defaultReflectionResolution; flareFadeSpeed = RenderSettings.flareFadeSpeed; flareStrength = RenderSettings.flareStrength; fog = RenderSettings.fog; fogColor = RenderSettings.fogColor; fogDensity = RenderSettings.fogDensity; fogEndDistance = RenderSettings.fogEndDistance; fogMode = RenderSettings.fogMode; fogStartDistance = RenderSettings.fogStartDistance; haloStrength = RenderSettings.haloStrength; reflectionBounces = RenderSettings.reflectionBounces; reflectionIntensity = RenderSettings.reflectionIntensity; skybox = RenderSettings.skybox; }
/// <summary> /// Set Ambient Mode /// </summary> /// <param name="target">Target device</param> /// <param name="mode"><see cref="AmbientMode" />Type of Ambient Mode to set</param> /// <returns></returns> public async Task <DreamScreenResponse> SetAmbientMode(DreamDevice target, AmbientMode mode) { var flag = Equals(target.DeviceGroup == 0) ? MessageFlag.WriteIndividual : MessageFlag.WriteGroup; var msg = new Message(target.IpAddress, MessageType.AmbientModeType, flag, target.DeviceGroup) { Payload = new Payload(new object[] { (byte)mode }) }; var response = await BroadcastMessageForResponse(msg); return(response); }
void UpdateUsingSunSceneRenderSettingsValues() { if (!m_UseSceneSun) { return; } m_SceneSun = RenderSettings.sun; m_SceneAmbientProbe = RenderSettings.ambientProbe; m_SceneAmbientMode = RenderSettings.ambientMode; }
private void Start() { StartTime = time; domeMaterial = Instantiate(skyDomeRenderer.material); skyDomeRenderer.material = domeMaterial; oldSun = RenderSettings.sun; oldMode = RenderSettings.ambientMode; oldAmbientColor = RenderSettings.ambientLight; RenderSettings.sun = sun; RenderSettings.ambientMode = AmbientMode.Flat; }
private static int set_ambientMode(IntPtr L) { int result; try { AmbientMode ambientMode = (AmbientMode)((int)ToLua.CheckObject(L, 2, typeof(AmbientMode))); RenderSettings.ambientMode = ambientMode; result = 0; } catch (Exception e) { result = LuaDLL.toluaL_exception(L, e, null); } return(result); }
public void SetHierarchyEnviroments(BattleCameraObject cameraObject) { RenderSettings.skybox = this.skybox; Light sunLight = cameraObject.sunLight; sunLight.intensity = this.sunLightIntensity; LightColorChanger sunLightColorChanger = cameraObject.sunLightColorChanger; sunLight.bounceIntensity = this.sunLightBounceLight; sunLightColorChanger.SetColors(this._sunLightColor); sunLightColorChanger.speed = this._sunLightColorTransitionSpeed; sunLightColorChanger.ResetColor(); sunLightColorChanger.transform.rotation = Quaternion.Euler(this.sunLightEulerAngle); sunLightColorChanger.isEnable = true; Camera camera3D = cameraObject.camera3D; if (this.skybox != null) { camera3D.clearFlags = CameraClearFlags.Skybox; } else { camera3D.clearFlags = CameraClearFlags.Color; camera3D.backgroundColor = this.skyColor; } RenderSettings.ambientMode = this.ambientMode; AmbientMode ambientMode = RenderSettings.ambientMode; if (ambientMode != AmbientMode.Skybox) { if (ambientMode != AmbientMode.Trilight) { RenderSettings.ambientLight = this.ambientLight; } else { RenderSettings.ambientSkyColor = this.ambientLight; RenderSettings.ambientEquatorColor = this.ambientEquatorColor; RenderSettings.ambientGroundColor = this.ambientGroundColor; } } else { RenderSettings.ambientLight = this.ambientLight; } RenderSettings.ambientIntensity = this.ambientIntensity; }
public static void SetupLighting() { //Setup faux albedo lighting Light[] lights = FindObjectsOfType <Light>(); dirLights = new List <Light>(); foreach (Light light in lights) { if (light.type == LightType.Directional) { dirLights.Add(light); light.enabled = false; } } ambientMode = RenderSettings.ambientMode; ambientColor = RenderSettings.ambientLight; RenderSettings.ambientMode = AmbientMode.Flat; RenderSettings.ambientLight = Color.white; }
private void OnPreRender() { this.originAmbientMode = RenderSettings.ambientMode; this.originAmbientIntensity = RenderSettings.ambientIntensity; this.originAmbientLight = RenderSettings.ambientLight; this.originAmbientSkyColor = RenderSettings.ambientSkyColor; this.originAmbientEquatorColor = RenderSettings.ambientEquatorColor; this.originAmbientGroundColorr = RenderSettings.ambientGroundColor; this.originCustomReflection = RenderSettings.customReflection; this.originFog = RenderSettings.fog; RenderSettings.ambientMode = this.ambientMode2; RenderSettings.ambientIntensity = this.ambientIntensity; RenderSettings.ambientLight = this.ambientLight; RenderSettings.ambientSkyColor = this.ambientSkyColor; RenderSettings.ambientEquatorColor = this.ambientEquatorColor; RenderSettings.ambientGroundColor = this.ambientGroundColor; RenderSettings.customReflection = this.customReflection; RenderSettings.fog = this.fog; }
private void OnPreRender() { if (this.overrideAmbientLight) { this.old_ambientLight = RenderSettings.ambientLight; this.old_ambientIntensity = RenderSettings.ambientIntensity; this.old_ambientMode = RenderSettings.ambientMode; this.old_ambientGroundColor = RenderSettings.ambientGroundColor; this.old_ambientEquatorColor = RenderSettings.ambientEquatorColor; this.old_ambientGroundColor = RenderSettings.ambientGroundColor; RenderSettings.ambientMode = this.ambientMode; RenderSettings.ambientLight = this.ambientLight; RenderSettings.ambientIntensity = this.ambientIntensity; RenderSettings.ambientGroundColor = this.ambientLight; RenderSettings.ambientEquatorColor = this.ambientEquatorColor; RenderSettings.ambientGroundColor = this.ambientGroundColor; } if (this.aspect > 0f) { base.GetComponent <UnityEngine.Camera>().aspect = this.aspect; } }
/// <summary> /// Saves the last clear color, culling mask, and ambient light mode, then prepares the /// camera to render the special "faded out" view, which allows TransparentFX objects to /// still be visible, so we can have simple UI elements still visible while the view is faded /// out. If Unity's audio subsystem is available, switches the audio source to use the /// fade-in sound for the next transition. Also, executes and queued actions that are waiting /// for the fade transition to complete. /// </summary> protected override void OnEntered() { base.OnEntered(); lastColor = DisplayManager.BackgroundColor; lastCameraCullingMask = DisplayManager.CullingMask; lastControllerLayer = input.ControllerLayer; lastAmbientMode = RenderSettings.ambientMode; Find.Any(out JuniperSystem sys); if (sys.m_ARMode == AugmentedRealityTypes.None) { DisplayManager.ClearFlags = CameraClearFlags.Color; DisplayManager.BackgroundColor = fadeOutColor; } input.ControllerLayer = LayerMask.NameToLayer("TransparentFX"); DisplayManager.CullingMask = LayerMask.GetMask("TransparentFX"); RenderSettings.ambientMode = AmbientMode.Flat; foreach (var action in actions) { try { action(); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception exp) { Debug.LogError(exp); } #pragma warning restore CA1031 // Do not catch general exception types } actions.Clear(); }
internal bool Setup(SndInfoParser parser) { // Read index if (!parser.ReadSignedInt(ref index)) { // Not numeric! parser.ReportError("Expected $ambient <index> value"); return(false); } // Check index //INFO: Up to 64 ambient sounds can be used in the Doom map format and 256 in Hexen format. UDMF maps have no limit. //TODO: can index be zero/negative in UDMF? if (General.Map.DOOM && (index < 1 || index > 64)) { parser.ReportError("$ambient <index> must be in [1..64] range"); return(false); } if (General.Map.HEXEN && (index < 1 || index > 256)) { parser.ReportError("$ambient <index> must be in [1..256] range"); return(false); } // Read name if (!parser.SkipWhitespace(true)) { return(false); } soundname = parser.StripTokenQuotes(parser.ReadToken(false)); if (string.IsNullOrEmpty(soundname)) { parser.ReportError("Expected $ambient <logicalsound> value"); return(false); } // Next token can be either [type] or <mode>... if (!parser.SkipWhitespace(true)) { return(false); } string token = parser.ReadToken(false).ToLowerInvariant(); // Can be [type] if (token == "point" || token == "surround" || token == "world") { // Next token may be attenuation... if (token == "point") { if (!parser.SkipWhitespace(false)) { return(false); } string next = parser.ReadToken(false); if (!parser.ReadSignedFloat(next, ref attenuation) || attenuation < 0f) { // Rewind so this structure can be read again parser.DataStream.Seek(-next.Length - 1, SeekOrigin.Current); } } // Store type switch (token) { case "point": type = AmbientType.POINT; break; case "surround": type = AmbientType.SURROUND; break; case "world": type = AmbientType.WORLD; break; } // Read next token if (!parser.SkipWhitespace(false)) { return(false); } token = parser.ReadToken(false).ToLowerInvariant(); } // Sould be <mode> if (token == "continuous" || token == "random" || token == "periodic") { // Next 2 tokens must be minsecs and maxsecs if (token == "random") { if (!parser.SkipWhitespace(false)) { return(false); } if (!parser.ReadSignedFloat(ref minsecs) || minsecs < 0f) { parser.ReportError("Expected $ambient <minsecs> value"); return(false); } if (!parser.SkipWhitespace(false)) { return(false); } if (!parser.ReadSignedFloat(ref maxsecs) || maxsecs < 0f) { parser.ReportError("Expected $ambient <maxsecs> value"); return(false); } } // Next token must be secs else if (token == "periodic") { if (!parser.SkipWhitespace(false)) { return(false); } if (!parser.ReadSignedFloat(ref secs) || secs < 0f) { parser.ReportError("Expected $ambient <secs> value"); return(false); } } // Store mode switch (token) { case "continuous": mode = AmbientMode.CONTINUOUS; break; case "random": mode = AmbientMode.RANDOM; break; case "periodic": mode = AmbientMode.PERIODIC; break; } } else { parser.ReportError("Expected ambient sound <mode> or [type]"); return(false); } // Read volume if (!parser.SkipWhitespace(false)) { return(false); } if (!parser.ReadSignedFloat(ref volume) || volume < 0f) { parser.ReportError("Expected ambient sound <volume> value"); return(false); } // There can be multiple different ambient sounds with the same sound name, so build a description containing the index // and the name to differentiate them. See https://github.com/jewalky/UltimateDoomBuilder/issues/390 sounddescription = index.ToString() + ": " + soundname + " (" + type.ToString().ToLowerInvariant(); if (type == AmbientType.POINT) { sounddescription += ", attenuation: " + attenuation; } if (mode == AmbientMode.CONTINUOUS) { sounddescription += ", " + mode.ToString().ToLowerInvariant(); } else if (mode == AmbientMode.RANDOM) { sounddescription += ", every " + minsecs + " to " + maxsecs + " seconds"; } else if (mode == AmbientMode.PERIODIC) { sounddescription += ", every " + secs + " seconds"; } sounddescription += ", " + volume * 100 + "% volume)"; return(true); }
private void DrawGUI() { Material material = this.m_SkyboxMaterial.objectReferenceValue as Material; this.m_bShowEnvironment = EditorGUILayout.FoldoutTitlebar(this.m_bShowEnvironment, LightingEditor.Styles.env_top, true); if (this.m_bShowEnvironment) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(this.m_SkyboxMaterial, LightingEditor.Styles.env_skybox_mat, new GUILayoutOption[0]); if (material && !EditorMaterialUtility.IsBackgroundMaterial(material)) { EditorGUILayout.HelpBox(LightingEditor.Styles.skyboxWarning.text, MessageType.Warning); } EditorGUILayout.PropertyField(this.m_Sun, LightingEditor.Styles.env_skybox_sun, new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUILayout.LabelField(LightingEditor.Styles.env_amb_top, new GUILayoutOption[0]); EditorGUI.indentLevel++; EditorGUILayout.IntPopup(this.m_AmbientSource, LightingEditor.Styles.kFullAmbientSource, LightingEditor.Styles.kFullAmbientSourceValues, LightingEditor.Styles.env_amb_src, new GUILayoutOption[0]); AmbientMode intValue = (AmbientMode)this.m_AmbientSource.intValue; if (intValue != AmbientMode.Trilight) { if (intValue != AmbientMode.Flat) { if (intValue == AmbientMode.Skybox) { if (material == null) { EditorGUI.BeginChangeCheck(); Color colorValue = EditorGUILayout.ColorField(LightingEditor.Styles.ambient, this.m_AmbientSkyColor.colorValue, true, false, true, ColorPicker.defaultHDRConfig, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { this.m_AmbientSkyColor.colorValue = colorValue; } } else { EditorGUILayout.Slider(this.m_AmbientIntensity, 0f, 8f, LightingEditor.Styles.env_amb_int, new GUILayoutOption[0]); } } } else { EditorGUI.BeginChangeCheck(); Color colorValue2 = EditorGUILayout.ColorField(LightingEditor.Styles.ambient, this.m_AmbientSkyColor.colorValue, true, false, true, ColorPicker.defaultHDRConfig, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { this.m_AmbientSkyColor.colorValue = colorValue2; } } } else { EditorGUI.BeginChangeCheck(); Color colorValue3 = EditorGUILayout.ColorField(LightingEditor.Styles.ambientUp, this.m_AmbientSkyColor.colorValue, true, false, true, ColorPicker.defaultHDRConfig, new GUILayoutOption[0]); Color colorValue4 = EditorGUILayout.ColorField(LightingEditor.Styles.ambientMid, this.m_AmbientEquatorColor.colorValue, true, false, true, ColorPicker.defaultHDRConfig, new GUILayoutOption[0]); Color colorValue5 = EditorGUILayout.ColorField(LightingEditor.Styles.ambientDown, this.m_AmbientGroundColor.colorValue, true, false, true, ColorPicker.defaultHDRConfig, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { this.m_AmbientSkyColor.colorValue = colorValue3; this.m_AmbientEquatorColor.colorValue = colorValue4; this.m_AmbientGroundColor.colorValue = colorValue5; } } if (LightModeUtil.Get().IsAnyGIEnabled()) { int selectedValue; bool ambientLightingMode = LightModeUtil.Get().GetAmbientLightingMode(out selectedValue); using (new EditorGUI.DisabledScope(!ambientLightingMode)) { int[] optionValues = new int[] { 0, 1 }; if (ambientLightingMode) { this.m_AmbientLightingMode.intValue = EditorGUILayout.IntPopup(LightingEditor.Styles.AmbientLightingMode, this.m_AmbientLightingMode.intValue, LightingEditor.Styles.AmbientLightingModes, optionValues, new GUILayoutOption[0]); } else { EditorGUILayout.IntPopup(LightingEditor.Styles.AmbientLightingMode, selectedValue, LightingEditor.Styles.AmbientLightingModes, optionValues, new GUILayoutOption[0]); } } } EditorGUI.indentLevel--; EditorGUILayout.Space(); EditorGUILayout.LabelField(LightingEditor.Styles.env_refl_top, new GUILayoutOption[0]); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(this.m_DefaultReflectionMode, LightingEditor.Styles.env_refl_src, new GUILayoutOption[0]); DefaultReflectionMode intValue2 = (DefaultReflectionMode)this.m_DefaultReflectionMode.intValue; if (intValue2 != DefaultReflectionMode.FromSkybox) { if (intValue2 == DefaultReflectionMode.Custom) { EditorGUILayout.PropertyField(this.m_CustomReflection, LightingEditor.Styles.customReflection, new GUILayoutOption[0]); } } else { EditorGUILayout.IntPopup(this.m_DefaultReflectionResolution, LightingEditor.Styles.defaultReflectionSizes, LightingEditor.Styles.defaultReflectionSizesValues, LightingEditor.Styles.env_refl_res, new GUILayoutOption[] { GUILayout.MinWidth(40f) }); } EditorGUILayout.PropertyField(this.m_ReflectionCompression, LightingEditor.Styles.env_refl_cmp, new GUILayoutOption[0]); EditorGUILayout.Slider(this.m_ReflectionIntensity, 0f, 1f, LightingEditor.Styles.env_refl_int, new GUILayoutOption[0]); EditorGUILayout.IntSlider(this.m_ReflectionBounces, 1, 5, LightingEditor.Styles.env_refl_bnc, new GUILayoutOption[0]); EditorGUI.indentLevel--; EditorGUI.indentLevel--; EditorGUILayout.Space(); } }
public static void mapify() { RenderTexture temporary = RenderTexture.GetTemporary((int)Level.size, (int)Level.size, 32); temporary.name = "Texture"; Level.mapper.GetComponent<Camera>().targetTexture = temporary; bool fog = RenderSettings.fog; AmbientMode ambientMode = RenderSettings.ambientMode; Color ambientSkyColor = RenderSettings.ambientSkyColor; Color ambientEquatorColor = RenderSettings.ambientEquatorColor; Color ambientGroundColor = RenderSettings.ambientGroundColor; float heightmapPixelError = 0f; float heightmapPixelError2 = 0f; float basemapDistance = 0f; float basemapDistance2 = 0f; if (LevelGround.terrain != null) { heightmapPixelError = LevelGround.terrain.heightmapPixelError; heightmapPixelError2 = LevelGround.terrain2.heightmapPixelError; basemapDistance = LevelGround.terrain.basemapDistance; basemapDistance2 = LevelGround.terrain2.basemapDistance; } float lodBias = QualitySettings.lodBias; float @float = LevelLighting.sea.GetFloat("_Shininess"); Color color = LevelLighting.sea.GetColor("_SpecularColor"); ERenderMode renderMode = GraphicsSettings.renderMode; GraphicsSettings.renderMode = ERenderMode.FORWARD; GraphicsSettings.apply(); RenderSettings.fog = false; RenderSettings.ambientMode = 1; RenderSettings.ambientSkyColor = Palette.AMBIENT; RenderSettings.ambientEquatorColor = Palette.AMBIENT; RenderSettings.ambientGroundColor = Palette.AMBIENT; if (LevelGround.terrain != null) { LevelGround.terrain.heightmapPixelError = 1f; LevelGround.terrain2.heightmapPixelError = 1f; LevelGround.terrain.basemapDistance = 8192f; LevelGround.terrain2.basemapDistance = 8192f; } LevelLighting.sea.SetFloat("_Shininess", 500f); LevelLighting.sea.SetColor("_SpecularColor", Color.black); QualitySettings.lodBias = float.MaxValue; for (byte b = 0; b < Regions.WORLD_SIZE; b += 1) { for (byte b2 = 0; b2 < Regions.WORLD_SIZE; b2 += 1) { if (!LevelObjects.regions[(int)b, (int)b2]) { List<LevelObject> list = LevelObjects.objects[(int)b, (int)b2]; for (int i = 0; i < list.Count; i++) { list[i].enableCollision(); list[i].enableVisual(); list[i].disableSkybox(); } } if (!LevelGround.regions[(int)b, (int)b2]) { List<ResourceSpawnpoint> list2 = LevelGround.trees[(int)b, (int)b2]; for (int j = 0; j < list2.Count; j++) { list2[j].enable(); } } } } Level.mapper.GetComponent<Camera>().Render(); for (byte b3 = 0; b3 < Regions.WORLD_SIZE; b3 += 1) { for (byte b4 = 0; b4 < Regions.WORLD_SIZE; b4 += 1) { if (!LevelObjects.regions[(int)b3, (int)b4]) { List<LevelObject> list3 = LevelObjects.objects[(int)b3, (int)b4]; for (int k = 0; k < list3.Count; k++) { list3[k].disableCollision(); list3[k].disableVisual(); if (list3[k].isLandmarkQualityMet) { list3[k].enableSkybox(); } } } if (!LevelGround.regions[(int)b3, (int)b4]) { List<ResourceSpawnpoint> list4 = LevelGround.trees[(int)b3, (int)b4]; for (int l = 0; l < list4.Count; l++) { list4[l].disable(); } } } } GraphicsSettings.renderMode = renderMode; GraphicsSettings.apply(); RenderSettings.fog = fog; RenderSettings.ambientMode = ambientMode; RenderSettings.ambientSkyColor = ambientSkyColor; RenderSettings.ambientEquatorColor = ambientEquatorColor; RenderSettings.ambientGroundColor = ambientGroundColor; if (LevelGround.terrain != null) { LevelGround.terrain.heightmapPixelError = heightmapPixelError; LevelGround.terrain2.heightmapPixelError = heightmapPixelError2; LevelGround.terrain.basemapDistance = basemapDistance; LevelGround.terrain2.basemapDistance = basemapDistance2; } LevelLighting.sea.SetFloat("_Shininess", @float); LevelLighting.sea.SetColor("_SpecularColor", color); QualitySettings.lodBias = lodBias; RenderTexture.active = temporary; Texture2D texture2D = new Texture2D(temporary.width, temporary.height); texture2D.name = "Mapify"; texture2D.hideFlags = 61; texture2D.filterMode = 2; texture2D.ReadPixels(new Rect(0f, 0f, (float)temporary.width, (float)temporary.height), 0, 0); for (int m = 0; m < texture2D.width; m++) { for (int n = 0; n < texture2D.height; n++) { Color pixel = texture2D.GetPixel(m, n); if (pixel.a < 1f) { pixel.a = 1f; texture2D.SetPixel(m, n, pixel); } } } texture2D.Apply(); byte[] bytes = texture2D.EncodeToPNG(); ReadWrite.writeBytes(Level.info.path + "/Map.png", false, false, bytes); Object.DestroyImmediate(texture2D); }
public override void OnInspectorGUI() { base.serializedObject.Update(); this.m_lightmapSettings.Update(); EditorGUILayout.Space(); this.m_ShowEditor = EditorGUILayout.FoldoutTitlebar(this.m_ShowEditor, LightingEditor.Styles.environmentHeader); if (this.m_ShowEditor) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(this.m_SkyboxMaterial, LightingEditor.Styles.skyboxLabel, new GUILayoutOption[0]); Material material = this.m_SkyboxMaterial.objectReferenceValue as Material; if (material && !EditorMaterialUtility.IsBackgroundMaterial(material)) { EditorGUILayout.HelpBox(LightingEditor.Styles.skyboxWarning.text, MessageType.Warning); } EditorGUILayout.PropertyField(this.m_Sun, LightingEditor.Styles.sunLabel, new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUILayout.IntPopup(this.m_AmbientMode, LightingEditor.Styles.kFullAmbientModes, LightingEditor.Styles.kFullAmbientModeValues, LightingEditor.Styles.ambientModeLabel, new GUILayoutOption[0]); EditorGUI.indentLevel++; AmbientMode intValue = (AmbientMode)this.m_AmbientMode.intValue; if (intValue != AmbientMode.Trilight) { if (intValue != AmbientMode.Flat) { if (intValue == AmbientMode.Skybox) { if (material == null) { EditorGUI.BeginChangeCheck(); Color colorValue = EditorGUILayout.ColorField(LightingEditor.Styles.ambient, this.m_AmbientSkyColor.colorValue, true, false, true, ColorPicker.defaultHDRConfig, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { this.m_AmbientSkyColor.colorValue = colorValue; } } else { EditorGUILayout.Slider(this.m_AmbientIntensity, 0f, 8f, LightingEditor.Styles.ambientIntensity, new GUILayoutOption[0]); } } } else { EditorGUI.BeginChangeCheck(); Color colorValue2 = EditorGUILayout.ColorField(LightingEditor.Styles.ambient, this.m_AmbientSkyColor.colorValue, true, false, true, ColorPicker.defaultHDRConfig, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { this.m_AmbientSkyColor.colorValue = colorValue2; } } } else { EditorGUI.BeginChangeCheck(); Color colorValue3 = EditorGUILayout.ColorField(LightingEditor.Styles.ambientUp, this.m_AmbientSkyColor.colorValue, true, false, true, ColorPicker.defaultHDRConfig, new GUILayoutOption[0]); Color colorValue4 = EditorGUILayout.ColorField(LightingEditor.Styles.ambientMid, this.m_AmbientEquatorColor.colorValue, true, false, true, ColorPicker.defaultHDRConfig, new GUILayoutOption[0]); Color colorValue5 = EditorGUILayout.ColorField(LightingEditor.Styles.ambientDown, this.m_AmbientGroundColor.colorValue, true, false, true, ColorPicker.defaultHDRConfig, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { this.m_AmbientSkyColor.colorValue = colorValue3; this.m_AmbientEquatorColor.colorValue = colorValue4; this.m_AmbientGroundColor.colorValue = colorValue5; } } EditorGUI.indentLevel--; this.m_ShowAmbientBakeMode.target = LightingEditor.ShowAmbientField(); if (EditorGUILayout.BeginFadeGroup(this.m_ShowAmbientBakeMode.faded)) { bool flag = Lightmapping.realtimeGI && Lightmapping.bakedGI; using (new EditorGUI.DisabledScope(!flag)) { if (flag) { EditorGUILayout.PropertyField(this.m_EnvironmentLightingMode, LightingEditor.Styles.SkyLightBaked, new GUILayoutOption[0]); } else { int num = (!Lightmapping.bakedGI) ? 0 : 1; EditorGUILayout.LabelField(LightingEditor.Styles.SkyLightBaked, GUIContent.Temp(this.m_EnvironmentLightingMode.enumNames[num]), EditorStyles.popup, new GUILayoutOption[0]); } } } EditorGUILayout.EndFadeGroup(); EditorGUILayout.Space(); EditorGUILayout.PropertyField(this.m_DefaultReflectionMode, LightingEditor.Styles.reflectionModeLabel, new GUILayoutOption[0]); EditorGUI.indentLevel++; Cubemap exists = this.m_CustomReflection.objectReferenceValue as Cubemap; DefaultReflectionMode intValue2 = (DefaultReflectionMode)this.m_DefaultReflectionMode.intValue; if ((!material && intValue2 == DefaultReflectionMode.FromSkybox) || (!exists && intValue2 == DefaultReflectionMode.Custom)) { EditorGUILayout.HelpBox(LightingEditor.Styles.defReflectionWarning.text, MessageType.Warning); } if (intValue2 != DefaultReflectionMode.FromSkybox) { if (intValue2 == DefaultReflectionMode.Custom) { EditorGUILayout.PropertyField(this.m_CustomReflection, LightingEditor.Styles.customReflection, new GUILayoutOption[0]); } } else { EditorGUILayout.IntPopup(this.m_DefaultReflectionResolution, LightingEditor.Styles.defaultReflectionSizes, LightingEditor.Styles.defaultReflectionSizesValues, LightingEditor.Styles.defaultReflectionResolution, new GUILayoutOption[] { GUILayout.MinWidth(40f) }); } EditorGUILayout.PropertyField(this.m_ReflectionCompression, LightingEditor.Styles.ReflectionCompression, new GUILayoutOption[0]); EditorGUI.indentLevel--; EditorGUILayout.Slider(this.m_ReflectionIntensity, 0f, 1f, LightingEditor.Styles.reflectionIntensity, new GUILayoutOption[0]); EditorGUILayout.IntSlider(this.m_ReflectionBounces, 1, 5, LightingEditor.Styles.reflectionBounces, new GUILayoutOption[0]); EditorGUI.indentLevel--; base.serializedObject.ApplyModifiedProperties(); this.m_lightmapSettings.ApplyModifiedProperties(); } }
public void Save() { if (_ambientEquatorColor != RenderSettings.ambientEquatorColor) { _ambientEquatorColor = RenderSettings.ambientEquatorColor; } if (_ambientGroundColor != RenderSettings.ambientGroundColor) { _ambientGroundColor = RenderSettings.ambientGroundColor; } if (_ambientIntensity != RenderSettings.ambientIntensity) { _ambientIntensity = RenderSettings.ambientIntensity; } if (_subtractiveShadowColor != RenderSettings.subtractiveShadowColor) { _subtractiveShadowColor = RenderSettings.subtractiveShadowColor; } if (_ambientProbe != RenderSettings.ambientProbe) { _ambientProbe = RenderSettings.ambientProbe; } if (_ambientMode != RenderSettings.ambientMode) { _ambientMode = RenderSettings.ambientMode; } if (_ambientSkyColor != RenderSettings.ambientSkyColor) { _ambientSkyColor = RenderSettings.ambientSkyColor; } if (_defaultReflectionMode != RenderSettings.defaultReflectionMode) { _defaultReflectionMode = RenderSettings.defaultReflectionMode; } if (_defaultReflectionResolution != RenderSettings.defaultReflectionResolution) { _defaultReflectionResolution = RenderSettings.defaultReflectionResolution; } if (_reflectionBounces != RenderSettings.reflectionBounces) { _reflectionBounces = RenderSettings.reflectionBounces; } if (_reflectionIntensity != RenderSettings.reflectionIntensity) { _reflectionIntensity = RenderSettings.reflectionIntensity; } if (_aoExponentDirect != LightmapEditorSettings.aoExponentDirect) { _aoExponentDirect = LightmapEditorSettings.aoExponentDirect; } if (_aoExponentIndirect != LightmapEditorSettings.aoExponentIndirect) { _aoExponentIndirect = LightmapEditorSettings.aoExponentIndirect; } if (_aoMaxDistance != LightmapEditorSettings.aoMaxDistance) { _aoMaxDistance = LightmapEditorSettings.aoMaxDistance; } if (_bakeResolution != LightmapEditorSettings.bakeResolution) { _bakeResolution = LightmapEditorSettings.bakeResolution; } if (_enableAmbientOcclusion != LightmapEditorSettings.enableAmbientOcclusion) { _enableAmbientOcclusion = LightmapEditorSettings.enableAmbientOcclusion; } if (_maxAtlasSize != LightmapEditorSettings.maxAtlasSize) { _maxAtlasSize = LightmapEditorSettings.maxAtlasSize; } if (_padding != LightmapEditorSettings.padding) { _padding = LightmapEditorSettings.padding; } if (_realtimeResolution != LightmapEditorSettings.realtimeResolution) { _realtimeResolution = LightmapEditorSettings.realtimeResolution; } if (_reflectionCubemapCompression != LightmapEditorSettings.reflectionCubemapCompression) { _reflectionCubemapCompression = LightmapEditorSettings.reflectionCubemapCompression; } if (_textureCompression != LightmapEditorSettings.textureCompression) { _textureCompression = LightmapEditorSettings.textureCompression; } if (_bakedGI != Lightmapping.bakedGI) { _bakedGI = Lightmapping.bakedGI; } if (_bounceBoost != Lightmapping.bounceBoost) { _bounceBoost = Lightmapping.bounceBoost; } if (_giWorkflowMode != Lightmapping.giWorkflowMode) { _giWorkflowMode = Lightmapping.giWorkflowMode; } if (_indirectOutputScale != Lightmapping.indirectOutputScale) { _indirectOutputScale = Lightmapping.indirectOutputScale; } if (_realtimeGI != Lightmapping.realtimeGI) { _realtimeGI = Lightmapping.realtimeGI; } if (_lightmapsMode != LightmapSettings.lightmapsMode) { _lightmapsMode = LightmapSettings.lightmapsMode; } }
private void DrawGUI() { Material material = this.m_SkyboxMaterial.objectReferenceValue as Material; this.m_bShowEnvironment = EditorGUILayout.FoldoutTitlebar(this.m_bShowEnvironment, LightingEditor.Styles.env_top, true); if (this.m_bShowEnvironment) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(this.m_SkyboxMaterial, LightingEditor.Styles.env_skybox_mat, new GUILayoutOption[0]); if (material && !EditorMaterialUtility.IsBackgroundMaterial(material)) { EditorGUILayout.HelpBox(LightingEditor.Styles.skyboxWarning.text, MessageType.Warning); } EditorGUILayout.PropertyField(this.m_Sun, LightingEditor.Styles.env_skybox_sun, new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUILayout.LabelField(LightingEditor.Styles.env_amb_top, new GUILayoutOption[0]); EditorGUI.indentLevel++; EditorGUILayout.IntPopup(this.m_AmbientSource, LightingEditor.Styles.kFullAmbientSource, LightingEditor.Styles.kFullAmbientSourceValues, LightingEditor.Styles.env_amb_src, new GUILayoutOption[0]); AmbientMode intValue = (AmbientMode)this.m_AmbientSource.intValue; if (intValue != AmbientMode.Trilight) { if (intValue != AmbientMode.Flat) { if (intValue == AmbientMode.Skybox) { if (material == null) { EditorGUI.BeginChangeCheck(); Color colorValue = EditorGUILayout.ColorField(LightingEditor.Styles.ambient, this.m_AmbientSkyColor.colorValue, true, false, true, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { this.m_AmbientSkyColor.colorValue = colorValue; } } else { EditorGUILayout.Slider(this.m_AmbientIntensity, 0f, 8f, LightingEditor.Styles.env_amb_int, new GUILayoutOption[0]); } } } else { EditorGUI.BeginChangeCheck(); Color colorValue2 = EditorGUILayout.ColorField(LightingEditor.Styles.ambient, this.m_AmbientSkyColor.colorValue, true, false, true, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { this.m_AmbientSkyColor.colorValue = colorValue2; } } } else { EditorGUI.BeginChangeCheck(); Color colorValue3 = EditorGUILayout.ColorField(LightingEditor.Styles.ambientUp, this.m_AmbientSkyColor.colorValue, true, false, true, new GUILayoutOption[0]); Color colorValue4 = EditorGUILayout.ColorField(LightingEditor.Styles.ambientMid, this.m_AmbientEquatorColor.colorValue, true, false, true, new GUILayoutOption[0]); Color colorValue5 = EditorGUILayout.ColorField(LightingEditor.Styles.ambientDown, this.m_AmbientGroundColor.colorValue, true, false, true, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { this.m_AmbientSkyColor.colorValue = colorValue3; this.m_AmbientEquatorColor.colorValue = colorValue4; this.m_AmbientGroundColor.colorValue = colorValue5; } } bool flag = SupportedRenderingFeatures.IsLightmapBakeTypeSupported(LightmapBakeType.Realtime); bool flag2 = SupportedRenderingFeatures.IsLightmapBakeTypeSupported(LightmapBakeType.Baked); if ((this.m_EnabledBakedGI.boolValue || this.m_EnabledRealtimeGI.boolValue) && (flag2 || flag)) { int[] optionValues = new int[] { 0, 1 }; if (this.m_EnabledBakedGI.boolValue && this.m_EnabledRealtimeGI.boolValue) { using (new EditorGUI.DisabledScope((this.m_AmbientLightingMode.intValue == 0 && flag && !flag2) || (this.m_AmbientLightingMode.intValue == 1 && flag2 && !flag))) { EditorGUILayout.IntPopup(this.m_AmbientLightingMode, LightingEditor.Styles.AmbientLightingModes, optionValues, LightingEditor.Styles.AmbientLightingMode, new GUILayoutOption[0]); } if ((this.m_AmbientLightingMode.intValue == 0 && !flag) || (this.m_AmbientLightingMode.intValue == 1 && !flag2)) { EditorGUILayout.HelpBox("The following mode is not supported and will fallback on " + ((this.m_AmbientLightingMode.intValue != 0 || flag) ? "Realtime" : "Baked"), MessageType.Warning); } } else if ((this.m_EnabledBakedGI.boolValue && flag2) || (this.m_EnabledRealtimeGI.boolValue && flag)) { using (new EditorGUI.DisabledScope(true)) { EditorGUILayout.IntPopup(LightingEditor.Styles.AmbientLightingMode, (!this.m_EnabledBakedGI.boolValue) ? 0 : 1, LightingEditor.Styles.AmbientLightingModes, optionValues, new GUILayoutOption[0]); } } } EditorGUI.indentLevel--; EditorGUILayout.Space(); EditorGUILayout.LabelField(LightingEditor.Styles.env_refl_top, new GUILayoutOption[0]); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(this.m_DefaultReflectionMode, LightingEditor.Styles.env_refl_src, new GUILayoutOption[0]); DefaultReflectionMode intValue2 = (DefaultReflectionMode)this.m_DefaultReflectionMode.intValue; if (intValue2 != DefaultReflectionMode.FromSkybox) { if (intValue2 == DefaultReflectionMode.Custom) { EditorGUILayout.PropertyField(this.m_CustomReflection, LightingEditor.Styles.customReflection, new GUILayoutOption[0]); } } else { int[] optionValues2 = null; GUIContent[] displayedOptions = null; ReflectionProbeEditor.GetResolutionArray(ref optionValues2, ref displayedOptions); EditorGUILayout.IntPopup(this.m_DefaultReflectionResolution, displayedOptions, optionValues2, LightingEditor.Styles.env_refl_res, new GUILayoutOption[] { GUILayout.MinWidth(40f) }); } EditorGUILayout.PropertyField(this.m_ReflectionCompression, LightingEditor.Styles.env_refl_cmp, new GUILayoutOption[0]); EditorGUILayout.Slider(this.m_ReflectionIntensity, 0f, 1f, LightingEditor.Styles.env_refl_int, new GUILayoutOption[0]); EditorGUILayout.IntSlider(this.m_ReflectionBounces, 1, 5, LightingEditor.Styles.env_refl_bnc, new GUILayoutOption[0]); EditorGUI.indentLevel--; EditorGUI.indentLevel--; EditorGUILayout.Space(); } }
// Token: 0x0600342A RID: 13354 RVA: 0x00154300 File Offset: 0x00152700 public static Texture2D captureIcon(ushort id, ushort skin, Transform model, Transform icon, int width, int height, float orthoSize) { ItemTool.tool.transform.position = icon.position; ItemTool.tool.transform.rotation = icon.rotation; RenderTexture temporary = RenderTexture.GetTemporary(width, height, 16, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB); temporary.name = string.Concat(new object[] { "Render_", id, "_", skin }); RenderTexture.active = temporary; ItemTool.tool.GetComponent <Camera>().targetTexture = temporary; ItemTool.tool.GetComponent <Camera>().orthographicSize = orthoSize; bool fog = RenderSettings.fog; AmbientMode ambientMode = RenderSettings.ambientMode; Color ambientSkyColor = RenderSettings.ambientSkyColor; Color ambientEquatorColor = RenderSettings.ambientEquatorColor; Color ambientGroundColor = RenderSettings.ambientGroundColor; RenderSettings.fog = false; RenderSettings.ambientMode = AmbientMode.Trilight; RenderSettings.ambientSkyColor = Color.white; RenderSettings.ambientEquatorColor = Color.white; RenderSettings.ambientGroundColor = Color.white; if (Provider.isConnected) { LevelLighting.setEnabled(false); } ItemTool.tool.GetComponent <Light>().enabled = true; ItemTool.tool.GetComponent <Camera>().cullingMask = (RayMasks.ITEM | RayMasks.VEHICLE | RayMasks.MEDIUM | RayMasks.SMALL); ItemTool.tool.GetComponent <Camera>().farClipPlane = 16f; ItemTool.tool.GetComponent <Camera>().Render(); ItemTool.tool.GetComponent <Light>().enabled = false; if (Provider.isConnected) { LevelLighting.setEnabled(true); } RenderSettings.fog = fog; RenderSettings.ambientMode = ambientMode; RenderSettings.ambientSkyColor = ambientSkyColor; RenderSettings.ambientEquatorColor = ambientEquatorColor; RenderSettings.ambientGroundColor = ambientGroundColor; model.position = new Vector3(0f, -256f, -256f); UnityEngine.Object.Destroy(model.gameObject); Texture2D texture2D = new Texture2D(width, height, TextureFormat.ARGB32, false, true); texture2D.name = string.Concat(new object[] { "Icon_", id, "_", skin }); texture2D.filterMode = FilterMode.Point; texture2D.ReadPixels(new Rect(0f, 0f, (float)width, (float)height), 0, 0); texture2D.Apply(); RenderTexture.ReleaseTemporary(temporary); return(texture2D); }
public static IEnumerator ChangeLightSettings(Light pLight, Color pLightColor, float fadeTime, float pLightIntensity = 1, AmbientMode pAmbientMode = AmbientMode.Flat) { //RenderSettings.reflectionIntensity = pLightIntensity; //RenderSettings.ambientMode = pAmbientMode; //Color light = pLight == null ? RenderSettings.ambientLight : pLight; Color lightCurrentColor = pLight == null ? RenderSettings.ambientLight : pLight.color; float progress = 0f; while (lightCurrentColor != pLightColor) { lightCurrentColor = Color.Lerp(lightCurrentColor, pLightColor, progress); progress += Time.deltaTime / fadeTime; if (pLight != null) { pLight.color = lightCurrentColor; } else { RenderSettings.ambientLight = lightCurrentColor; } yield return(null); } //RenderSettings.ambientSkyColor = pLightColor; lightCurrentColor = pLightColor; }
public void CopyCurrentSettings() { sun = RenderSettings.sun; switch (RenderSettings.ambientMode) { case UnityEngine.Rendering.AmbientMode.Skybox: ambientMode = AmbientMode.Skybox; //makes sure the skybox gets set correctly if (skyboxes.Contains(RenderSettings.skybox)) { for (int i = 0; i < skyboxes.Count; i++) { if (skyboxes[i].Equals(RenderSettings.skybox)) { currentSkybox = i; break; } } RenderSettings.skybox = skyboxes[currentSkybox]; } else { skyboxes.Add(RenderSettings.skybox); currentSkybox = skyboxes.Count - 1; } skyBoxColor = RenderSettings.skybox.GetColor("_Tint"); skyboxIntensityMultiplier = RenderSettings.ambientIntensity; break; case UnityEngine.Rendering.AmbientMode.Flat: RenderSettings.skybox = null; ambientMode = AmbientMode.Color; ambientColor = RenderSettings.ambientSkyColor; break; case UnityEngine.Rendering.AmbientMode.Trilight: RenderSettings.skybox = null; ambientMode = AmbientMode.Gradient; skyColor = RenderSettings.ambientSkyColor; equatorColor = RenderSettings.ambientEquatorColor; groundColor = RenderSettings.ambientGroundColor; break; } switch (RenderSettings.defaultReflectionMode) { case DefaultReflectionMode.Skybox: reflectionMode = ReflectionMode.Skybox; reflectionResolution = (ReflectionResolution)RenderSettings.defaultReflectionResolution; reflectionIntensity = RenderSettings.reflectionIntensity; reflectionBounces = RenderSettings.reflectionBounces; break; case DefaultReflectionMode.Custom: reflectionMode = ReflectionMode.Custom; reflectionCubeMap = RenderSettings.customReflection; reflectionIntensity = RenderSettings.reflectionIntensity; reflectionBounces = RenderSettings.reflectionBounces; break; } cameraBackground = mainCamera.backgroundColor; }
public static Texture2D getCard(Transform item, Transform hook_0, Transform hook_1, int width, int height, float size, float range) { if (item == null) { return(null); } item.position = new Vector3(-256f, -256f, 0f); RenderTexture temporary = RenderTexture.GetTemporary(width, height, 16, 0, 2); temporary.name = "Card_Render"; RenderTexture.active = temporary; ItemTool.tool.GetComponent <Camera>().targetTexture = temporary; ItemTool.tool.GetComponent <Camera>().orthographicSize = size; Texture2D texture2D = new Texture2D(width * 2, height, 5, false, false); texture2D.name = "Card_Atlas"; texture2D.filterMode = 0; texture2D.wrapMode = 1; bool fog = RenderSettings.fog; AmbientMode ambientMode = RenderSettings.ambientMode; Color ambientSkyColor = RenderSettings.ambientSkyColor; Color ambientEquatorColor = RenderSettings.ambientEquatorColor; Color ambientGroundColor = RenderSettings.ambientGroundColor; RenderSettings.fog = false; RenderSettings.ambientMode = 1; RenderSettings.ambientSkyColor = Color.white; RenderSettings.ambientEquatorColor = Color.white; RenderSettings.ambientGroundColor = Color.white; if (Provider.isConnected) { LevelLighting.setEnabled(false); } ItemTool.tool.GetComponent <Camera>().cullingMask = RayMasks.RESOURCE; ItemTool.tool.GetComponent <Camera>().farClipPlane = range; ItemTool.tool.transform.position = hook_0.position; ItemTool.tool.transform.rotation = hook_0.rotation; ItemTool.tool.GetComponent <Camera>().Render(); texture2D.ReadPixels(new Rect(0f, 0f, (float)width, (float)height), 0, 0); ItemTool.tool.transform.position = hook_1.position; ItemTool.tool.transform.rotation = hook_1.rotation; ItemTool.tool.GetComponent <Camera>().Render(); texture2D.ReadPixels(new Rect(0f, 0f, (float)width, (float)height), width, 0); if (Provider.isConnected) { LevelLighting.setEnabled(true); } RenderSettings.fog = fog; RenderSettings.ambientMode = ambientMode; RenderSettings.ambientSkyColor = ambientSkyColor; RenderSettings.ambientEquatorColor = ambientEquatorColor; RenderSettings.ambientGroundColor = ambientGroundColor; item.position = new Vector3(0f, -256f, -256f); Object.Destroy(item.gameObject); for (int i = 0; i < texture2D.width; i++) { for (int j = 0; j < texture2D.height; j++) { Color32 color = texture2D.GetPixel(i, j); if (color.r == 255 && color.g == 255 && color.b == 255) { color.a = 0; } else { color.a = byte.MaxValue; } texture2D.SetPixel(i, j, color); } } texture2D.Apply(); RenderTexture.ReleaseTemporary(temporary); return(texture2D); }
private void Update() { if (ItemTool.icons == null || ItemTool.icons.Count == 0) { return; } ItemIconInfo itemIconInfo = ItemTool.icons.Dequeue(); if (itemIconInfo == null) { return; } if (itemIconInfo.itemAsset == null) { return; } Transform item = ItemTool.getItem(itemIconInfo.id, itemIconInfo.skin, itemIconInfo.quality, itemIconInfo.state, false, itemIconInfo.itemAsset, itemIconInfo.skinAsset); item.position = new Vector3(-256f, -256f, 0f); Transform transform; if (itemIconInfo.scale && itemIconInfo.skin != 0) { if (itemIconInfo.itemAsset.size2_z == 0f) { item.position = new Vector3(0f, -256f, -256f); Object.Destroy(item.gameObject); Assets.errors.Add("Failed to create a skin icon of size 0 for " + itemIconInfo.id + "."); return; } transform = item.FindChild("Icon2"); if (transform == null) { item.position = new Vector3(0f, -256f, -256f); Object.Destroy(item.gameObject); Assets.errors.Add("Failed to find a skin icon hook on " + itemIconInfo.id + "."); return; } } else { if (itemIconInfo.itemAsset.size_z == 0f) { item.position = new Vector3(0f, -256f, -256f); Object.Destroy(item.gameObject); Assets.errors.Add("Failed to create an item icon of size 0 for " + itemIconInfo.id + "."); return; } transform = item.FindChild("Icon"); if (transform == null) { item.position = new Vector3(0f, -256f, -256f); Object.Destroy(item.gameObject); Assets.errors.Add("Failed to find an item icon hook on " + itemIconInfo.id + "."); return; } } ItemTool.tool.transform.position = transform.position; ItemTool.tool.transform.rotation = transform.rotation; RenderTexture temporary = RenderTexture.GetTemporary(itemIconInfo.x, itemIconInfo.y, 16, 0, 2); temporary.name = string.Concat(new object[] { "Item_Render_", itemIconInfo.id, "_", itemIconInfo.skin }); RenderTexture.active = temporary; ItemTool.tool.GetComponent <Camera>().targetTexture = temporary; ItemTool.tool.GetComponent <Camera>().orthographicSize = itemIconInfo.itemAsset.size_z; if (itemIconInfo.scale) { if (itemIconInfo.skin != 0) { ItemTool.tool.GetComponent <Camera>().orthographicSize = itemIconInfo.itemAsset.size2_z; } else { float num = (float)itemIconInfo.itemAsset.size_x / (float)itemIconInfo.itemAsset.size_y; ItemTool.tool.GetComponent <Camera>().orthographicSize *= num; } } bool fog = RenderSettings.fog; AmbientMode ambientMode = RenderSettings.ambientMode; Color ambientSkyColor = RenderSettings.ambientSkyColor; Color ambientEquatorColor = RenderSettings.ambientEquatorColor; Color ambientGroundColor = RenderSettings.ambientGroundColor; RenderSettings.fog = false; RenderSettings.ambientMode = 1; RenderSettings.ambientSkyColor = Color.white; RenderSettings.ambientEquatorColor = Color.white; RenderSettings.ambientGroundColor = Color.white; if (Provider.isConnected) { LevelLighting.setEnabled(false); } ItemTool.tool.GetComponent <Light>().enabled = true; ItemTool.tool.GetComponent <Camera>().cullingMask = RayMasks.ITEM; ItemTool.tool.GetComponent <Camera>().farClipPlane = 16f; ItemTool.tool.GetComponent <Camera>().Render(); ItemTool.tool.GetComponent <Light>().enabled = false; if (Provider.isConnected) { LevelLighting.setEnabled(true); } RenderSettings.fog = fog; RenderSettings.ambientMode = ambientMode; RenderSettings.ambientSkyColor = ambientSkyColor; RenderSettings.ambientEquatorColor = ambientEquatorColor; RenderSettings.ambientGroundColor = ambientGroundColor; item.position = new Vector3(0f, -256f, -256f); Object.Destroy(item.gameObject); Texture2D texture2D = new Texture2D(itemIconInfo.x, itemIconInfo.y, 5, false, true); texture2D.name = string.Concat(new object[] { "Item_Icon_", itemIconInfo.id, "_", itemIconInfo.skin }); texture2D.filterMode = 0; texture2D.ReadPixels(new Rect(0f, 0f, (float)itemIconInfo.x, (float)itemIconInfo.y), 0, 0); texture2D.Apply(); RenderTexture.ReleaseTemporary(temporary); if (itemIconInfo.callback != null) { itemIconInfo.callback(texture2D); } if (itemIconInfo.state.Length == 0 && itemIconInfo.skin == 0 && itemIconInfo.x == (int)(itemIconInfo.itemAsset.size_x * 50) && itemIconInfo.y == (int)(itemIconInfo.itemAsset.size_y * 50) && !ItemTool.cache.ContainsKey(itemIconInfo.id)) { ItemTool.cache.Add(itemIconInfo.id, texture2D); } }