This commit is contained in:
Jan Racek
2026-03-27 18:31:35 +01:00
parent 1c48b8b425
commit 24d0c1fa07
27 changed files with 779 additions and 609 deletions

View File

@@ -20,8 +20,8 @@ namespace SplashEdit.RuntimeCode
/// At export time, the AudioClip is converted to SPU ADPCM and packed
/// into the splashpack binary. Use Audio.Play(clipIndex) from Lua.
/// </summary>
[AddComponentMenu("PSX/Audio Source")]
public class PSXAudioSource : MonoBehaviour
[AddComponentMenu("PSX/Audio Clip")]
public class PSXAudioClip : MonoBehaviour
{
[Tooltip("Name used to identify this clip in Lua (Audio.Play(\"name\"))." )]
public string ClipName = "";

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 0da2803235be654438e86fe9d9a954d4

View File

@@ -13,7 +13,7 @@ namespace SplashEdit.RuntimeCode
[Tooltip("Frame at which to trigger this audio clip.")]
public int Frame;
[Tooltip("Name of the audio clip (must match a PSXAudioSource ClipName in the scene).")]
[Tooltip("Name of the audio clip (must match a PSXAudioClip ClipName in the scene).")]
public string ClipName = "";
[Tooltip("Playback volume (0 = silent, 128 = max).")]

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 3c4c3feb30e8c264baddc3a5e774473b

View File

@@ -45,7 +45,7 @@ namespace SplashEdit.RuntimeCode
BinaryWriter writer,
PSXCutsceneClip[] cutscenes,
PSXObjectExporter[] exporters,
PSXAudioSource[] audioSources,
PSXAudioClip[] audioSources,
float gteScaling,
out long cutsceneTableStart,
Action<string, LogType> log = null)

View File

@@ -12,7 +12,8 @@ namespace SplashEdit.RuntimeCode
Dynamic = 2
}
[RequireComponent(typeof(Renderer))]
[RequireComponent(typeof(MeshFilter))]
[RequireComponent(typeof(MeshRenderer))]
public class PSXObjectExporter : MonoBehaviour, IPSXExportable
{
public LuaFile LuaFile => luaFile;

View File

@@ -26,8 +26,11 @@ namespace SplashEdit.RuntimeCode
void OnDrawGizmos()
{
var exporter = FindFirstObjectByType<PSXSceneExporter>();
if (exporter != null && !exporter.PreviewRoomsPortals) return;
Gizmos.color = new Color(1f, 0.5f, 0f, 0.3f);
Gizmos.matrix = transform.localToWorldMatrix;
Gizmos.matrix = transform.localToWorldMatrix;
Gizmos.DrawCube(Vector3.zero, new Vector3(PortalSize.x, PortalSize.y, 0.05f));
Gizmos.color = new Color(1f, 0.5f, 0f, 0.8f);
Gizmos.DrawWireCube(Vector3.zero, new Vector3(PortalSize.x, PortalSize.y, 0.05f));

View File

@@ -56,6 +56,9 @@ namespace SplashEdit.RuntimeCode
void OnDrawGizmos()
{
var exporter = FindFirstObjectByType<PSXSceneExporter>();
if (exporter != null && !exporter.PreviewRoomsPortals) return;
Gizmos.color = new Color(0.2f, 0.8f, 0.4f, 0.15f);
Gizmos.matrix = transform.localToWorldMatrix;
Gizmos.DrawCube(VolumeOffset, VolumeSize);
@@ -66,7 +69,7 @@ namespace SplashEdit.RuntimeCode
#if UNITY_EDITOR
if (!string.IsNullOrEmpty(RoomName))
{
UnityEditor.Handles.Label(transform.TransformPoint(VolumeOffset),
UnityEditor.Handles.Label(transform.TransformPoint(VolumeOffset),
RoomName, new GUIStyle { normal = { textColor = Color.green } });
}
#endif

View File

@@ -57,7 +57,7 @@ namespace SplashEdit.RuntimeCode
// Component arrays
private PSXInteractable[] _interactables;
private PSXAudioSource[] _audioSources;
private PSXAudioClip[] _audioSources;
private PSXTriggerBox[] _triggerBoxes;
// Phase 3+4: World collision and nav regions
@@ -90,6 +90,8 @@ namespace SplashEdit.RuntimeCode
private BVH _bvh;
public bool PreviewBVH = true;
public bool PreviewRoomsPortals = true;
public int BVHPreviewDepth = 9999;
/// <summary>
@@ -120,7 +122,7 @@ namespace SplashEdit.RuntimeCode
// Collect components
_interactables = FindObjectsByType<PSXInteractable>(FindObjectsSortMode.None);
_audioSources = FindObjectsByType<PSXAudioSource>(FindObjectsSortMode.None);
_audioSources = FindObjectsByType<PSXAudioClip>(FindObjectsSortMode.None);
_triggerBoxes = FindObjectsByType<PSXTriggerBox>(FindObjectsSortMode.None);
// Collect UI image textures for VRAM packing alongside 3D textures

View File

@@ -31,7 +31,7 @@ namespace SplashEdit.RuntimeCode
// Cutscene data (v12)
public PSXCutsceneClip[] cutscenes;
public PSXAudioSource[] audioSources;
public PSXAudioClip[] audioSources;
// UI canvases (v13)
public PSXCanvasData[] canvases;

View File

@@ -154,6 +154,18 @@ namespace SplashEdit.RuntimeCode
G = (ushort)(pixel.g * 31),
B = (ushort)(pixel.b * 31)
};
// PS1: color 0x0000 is transparent. If the source pixel is opaque
// but quantized to pure black, bump to near-black (1,1,1) with bit15
// set so the hardware doesn't treat it as see-through.
if (vramPixel.Pack() == 0x0000 && pixel.a > 0f)
{
vramPixel.R = 1;
vramPixel.G = 1;
vramPixel.B = 1;
vramPixel.SemiTransparent = true;
}
psxTex.ImageData[x, y] = vramPixel;
}
}
@@ -169,6 +181,18 @@ namespace SplashEdit.RuntimeCode
{
Color pixel = new Color(color.x, color.y, color.z);
VRAMPixel vramPixel = new VRAMPixel { R = (ushort)(pixel.r * 31), G = (ushort)(pixel.g * 31), B = (ushort)(pixel.b * 31) };
// PS1: palette entry 0x0000 is transparent. Any non-transparent palette
// color that quantizes to pure black must be bumped to near-black (1,1,1)
// with bit15 set to avoid the hardware treating it as see-through.
if (vramPixel.Pack() == 0x0000)
{
vramPixel.R = 1;
vramPixel.G = 1;
vramPixel.B = 1;
vramPixel.SemiTransparent = true;
}
psxTex.ColorPalette.Add(vramPixel);
}