Skip to content

Commit

Permalink
Add env cube setting to light settings
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackYps committed Jan 30, 2025
1 parent af90916 commit b268b88
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 47 deletions.
69 changes: 65 additions & 4 deletions Assets/MapEditor.unity
Original file line number Diff line number Diff line change
Expand Up @@ -21071,7 +21071,7 @@ PrefabInstance:
- target: {fileID: 114659475374214984, guid: b68527975f2edce489c9336fa9650c39,
type: 3}
propertyPath: onValueChanged.m_PersistentCalls.m_Calls.Array.data[0].m_Mode
value: 6
value: 1
objectReference: {fileID: 0}
- target: {fileID: 114659475374214984, guid: b68527975f2edce489c9336fa9650c39,
type: 3}
Expand All @@ -21091,7 +21091,7 @@ PrefabInstance:
- target: {fileID: 114659475374214984, guid: b68527975f2edce489c9336fa9650c39,
type: 3}
propertyPath: onValueChanged.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
value: WaterSettingsChanged
value: ClickLightSettingsToggle
objectReference: {fileID: 0}
- target: {fileID: 114659475374214984, guid: b68527975f2edce489c9336fa9650c39,
type: 3}
Expand Down Expand Up @@ -59817,6 +59817,62 @@ RectTransform:
type: 3}
m_PrefabInstance: {fileID: 2138712282956750934}
m_PrefabAsset: {fileID: 0}
--- !u!1 &681728541 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1541227934717128, guid: e6265867d457e8545b0b9e582f674244,
type: 3}
m_PrefabInstance: {fileID: 857264157}
m_PrefabAsset: {fileID: 0}
--- !u!224 &681728542 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 224682333546820604, guid: e6265867d457e8545b0b9e582f674244,
type: 3}
m_PrefabInstance: {fileID: 857264157}
m_PrefabAsset: {fileID: 0}
--- !u!114 &681728544
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 681728541}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0b148fe25e99eb48b9724523833bab1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Delegates:
- eventID: 6
callback:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 1040494783}
m_TargetAssemblyTypeName: EditMap.LightingInfo, Assembly-CSharp
m_MethodName: selectSkyCube
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
--- !u!114 &681728547
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 681728541}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: aa1a2693f2ccf724ead028a0f6f4299e, type: 3}
m_Name:
m_EditorClassIdentifier:
text: The environment texture does not have a direct effect on the terrain lighting,
but it drives the reflections on units. So you should choose a texture that resembles
the colors of your terrain and sky.
--- !u!1001 &681871945
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -64912,6 +64968,10 @@ PrefabInstance:
type: 3}
insertIndex: -1
addedObject: {fileID: 1585518668}
- targetCorrespondingSourceObject: {fileID: 7116784941686974531, guid: 19f207330ece4db409fb300e477c9218,
type: 3}
insertIndex: -1
addedObject: {fileID: 681728542}
- targetCorrespondingSourceObject: {fileID: 3926609239394685170, guid: 19f207330ece4db409fb300e477c9218,
type: 3}
insertIndex: -1
Expand Down Expand Up @@ -93747,6 +93807,7 @@ MonoBehaviour:
LightColor: {fileID: 2051153278}
AmbienceColor: {fileID: 107577170}
ShadowColor: {fileID: 1585518669}
EnvCube: {fileID: 857264158}
Glow: {fileID: 0}
Bloom: {fileID: 539195835}
Specular: {fileID: 321185191}
Expand Down Expand Up @@ -128998,12 +129059,12 @@ PrefabInstance:
m_Modifications:
- target: {fileID: 1541227934717128, guid: e6265867d457e8545b0b9e582f674244, type: 3}
propertyPath: m_Name
value: SkyCube
value: EnvCube
objectReference: {fileID: 0}
- target: {fileID: 114300400988709808, guid: e6265867d457e8545b0b9e582f674244,
type: 3}
propertyPath: m_Text
value: Cubemap texture path
value: EnvCube Texture Path
objectReference: {fileID: 0}
- target: {fileID: 114549324857000576, guid: e6265867d457e8545b0b9e582f674244,
type: 3}
Expand Down
40 changes: 10 additions & 30 deletions Assets/Scripts/HazardX SCMAP Code/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,11 @@ public Map(int _Width, int _Height, int InitialHeight, bool _Water, int WaterLev
HeightScale = 0.0078125f;

TexPathBackground = "/textures/environment/blackbackground.dds";
TexPathSkyCubemap = "/textures/environment/skycube_evergreen01a.dds";
EnvCubemapsName = new string[3];
EnvCubemapsFile = new string[3];
EnvCubemapsName[0] = "<aeon>";
EnvCubemapsName[1] = "<default>";
EnvCubemapsName[2] = "<seraphim>";
EnvCubemapsFile[0] = "/textures/environment/envcube_aeon_evergreen.dds";
EnvCubemapsFile[1] = "/textures/environment/envcube_evergreen01a.dds";
EnvCubemapsFile[2] = "/textures/environment/envcube_seraphim_evergreen.dds";
TexPathSkyCubemap = "/textures/environment/defaultenvcube.dds";
EnvCubemapsName = new string[1];
EnvCubemapsFile = new string[1];
EnvCubemapsName[0] = "<default>";
EnvCubemapsFile[0] = "/textures/environment/defaultenvcube.dds";

Bloom = 0.03f;// 0.145f;

Expand Down Expand Up @@ -547,7 +543,6 @@ public bool Load(string Filename)
if (VersionMinor >= 56)
{
Count = _with1.ReadInt32();
//always 1?
EnvCubemapsName = new string[Count];
EnvCubemapsFile = new string[Count];
for (int i = 0; i <= Count - 1; i++)
Expand All @@ -556,16 +551,12 @@ public bool Load(string Filename)
EnvCubemapsFile[i] = _with1.ReadStringNull();
}
}
else
else // Original SupCom campaign maps, and the first 6 multiplayer maps (i.e. until SCMP_006) are v53
{
EnvCubemapsName = new string[3];
EnvCubemapsFile = new string[3];
EnvCubemapsName[0] = "<aeon>";
EnvCubemapsName[1] = "<default>";
EnvCubemapsName[2] = "<seraphim>";
EnvCubemapsFile[0] = "/textures/environment/envcube_aeon_evergreen.dds";
EnvCubemapsFile[1] = _with1.ReadStringNull();
EnvCubemapsFile[2] = "/textures/environment/envcube_seraphim_evergreen.dds";
EnvCubemapsName = new string[1];
EnvCubemapsFile = new string[1];
EnvCubemapsName[0] = "<default>";
EnvCubemapsFile[0] = _with1.ReadStringNull();
}

LightingMultiplier = _with1.ReadSingle();
Expand Down Expand Up @@ -962,18 +953,7 @@ public void SaveMapInformation(string Filename, int randomSeed)

public void ConvertToV56()
{
EnvCubemapsName = new string[3];
EnvCubemapsFile = new string[3];
EnvCubemapsName[0] = "<aeon>";
EnvCubemapsName[1] = "<default>";
EnvCubemapsName[2] = "<seraphim>";
EnvCubemapsFile[0] = "/textures/environment/envcube_aeon_evergreen.dds";
EnvCubemapsFile[1] = "/textures/environment/envcube_evergreen01a.dds";
EnvCubemapsFile[2] = "/textures/environment/envcube_seraphim_evergreen.dds";


Unknown15 = 0;

VersionMinor = 56;
}

Expand Down
31 changes: 29 additions & 2 deletions Assets/Scripts/UI/Tools/Lighting/LightingInfo.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.IO;
using Ozone.UI;
using System.Runtime.InteropServices;
using FAF.MapEditor;
using SFB;

namespace EditMap
Expand All @@ -24,6 +23,7 @@ public class LightingInfo : MonoBehaviour
public UiColor AmbienceColor;
public UiColor ShadowColor;

public InputField EnvCube;

public UiTextField Glow;
public UiTextField Bloom;
Expand Down Expand Up @@ -71,6 +71,13 @@ public void LoadValues()
AmbienceColor.SetColorField(Scmap.map.SunAmbience.x, Scmap.map.SunAmbience.y, Scmap.map.SunAmbience.z); // UpdateColors
ShadowColor.SetColorField(Scmap.map.ShadowFillColor.x, Scmap.map.ShadowFillColor.y, Scmap.map.ShadowFillColor.z); // UpdateColors

EnvCube.text = Scmap.map.EnvCubemapsFile[0]; // This is our fallback
for (int i = 0; i < Scmap.map.EnvCubemapsFile.Length; i++)
{
if (Scmap.map.EnvCubemapsName[i] == "<default>")
EnvCube.text = Scmap.map.EnvCubemapsFile[i];
}

FogColor.SetColorField(Scmap.map.FogColor.x, Scmap.map.FogColor.y, Scmap.map.FogColor.z);
FogStart.SetValue(Scmap.map.FogStart);
FogEnd.SetValue(Scmap.map.FogEnd);
Expand Down Expand Up @@ -188,6 +195,11 @@ void UpdateLightingData()
Scmap.map.SunColor = LightColor.GetVectorValue();
Scmap.map.SunAmbience = AmbienceColor.GetVectorValue();
Scmap.map.ShadowFillColor = ShadowColor.GetVectorValue();

for (int i = 0; i < Scmap.map.EnvCubemapsFile.Length; i++)
{
Scmap.map.EnvCubemapsFile[i] = EnvCube.text;
}

Scmap.map.SpecularColor = Specular.GetVector4Value();
if (SpecularRed.gameObject.activeSelf)
Expand Down Expand Up @@ -241,6 +253,21 @@ public void RecalculateLightSettings(float NewLightMultiplier)

LoadValues();
}

public void selectSkyCube()
{
if(ResourceBrowser.DragedObject == null || ResourceBrowser.DragedObject.ContentType != ResourceObject.ContentTypes.Texture)
return;
if (!ResourceBrowser.Current.gameObject.activeSelf)
return;
EnvCube.text = ResourceBrowser.Current.LoadedPaths[ResourceBrowser.DragedObject.InstanceId];
ResourceBrowser.ClearDrag();
}

public void ClickSkyCubeButton()
{
ResourceBrowser.Current.LoadSkyCube(EnvCube.text);
}

public void ResetLight()
{
Expand Down
27 changes: 16 additions & 11 deletions Assets/Scripts/UI/Tools/Terrain/WaterInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,17 +219,6 @@ public void WaterSettingsChanged(bool Slider)
if (Loading)
return;

if (UseLightingSettings.isOn)
{
Map map = ScmapEditor.Current.map;
SunColor.SetColorField(map.SunColor.x * (map.LightingMultiplier - map.ShadowFillColor.x),
map.SunColor.y * (map.LightingMultiplier - map.ShadowFillColor.y),
map.SunColor.z * (map.LightingMultiplier - map.ShadowFillColor.z));
SunDirection = map.SunDirection;
} else {
SunDirection = new Vector3(0.09954818f, -0.9626309f, 0.2518569f);
}

if (!AnyChanged())
return;

Expand Down Expand Up @@ -345,6 +334,22 @@ public void ClickWave3Button()
{
ResourceBrowser.Current.LoadWaveTexture(Waves3.TexPath.text);
}

public void ClickLightSettingsToggle()
{
if (UseLightingSettings.isOn)
{
Map map = ScmapEditor.Current.map;
SunColor.SetColorField(map.SunColor.x * (map.LightingMultiplier - map.ShadowFillColor.x),
map.SunColor.y * (map.LightingMultiplier - map.ShadowFillColor.y),
map.SunColor.z * (map.LightingMultiplier - map.ShadowFillColor.z));
SunDirection = map.SunDirection;
Cubemap.text = MapLuaParser.Current.EditMenu.LightingMenu.EnvCube.text;
} else {
SunDirection = new Vector3(0.09954818f, -0.9626309f, 0.2518569f);
}
WaterSettingsChanged(false);
}

#region Import/Export
const string ExportPathKey = "WaterExport";
Expand Down

0 comments on commit b268b88

Please sign in to comment.