Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Web API (`/api/v1`) - This allows you to make your own apps, pages and overlays on the same JRTI feeds as the default proposed interface, with an optional control key for other devices if need be. Pages from other websites can no longer change anything, as a security measure. See the API page of the docs for more information
- Your own pages and styles (`PluginData/Apps/`, `PluginData/Web/`) - you can now make your own pages and styles, kept across updates
- Save recordings to this device (Settings, Finished recordings) - the web UI downloads each recording when it stops, so recordings land on the computer watching the feeds as well as the KSP one. On by default on every device except the KSP computer

### Fixed

- Firefly re-entry (Visual Mod Integrations) - with Deferred installed, re-entry plasma no longer turns huge and drops the game below 1 FPS when feeds are open on parts with built-in cameras, like SEP's onboards. This is a workaround until Firefly merges my proper fix (https://github.com/M1rageDev/Firefly/pull/58), see Troubleshooting
- Planet from orbit (Scatterer, Deferred) - camera feeds keep the atmosphere over the planet after loading a save in orbit, instead of showing improperly drawn atmosphere
- Hull lighting in orbit (Scatterer) - shiny hulls on camera feeds are no longer lit from where the main camera is looking

## v3.3.0.2 - 2026-11-27

### Fixed

- Fix the timing at which the JRTI cameras copy depth buffer to avoid lighting artifacts.


## v3.3.0.1 - 2026-11-26

### Added

- Web API (`/api/v1`) - This allows you to make your own apps, pages and overlays on the same JRTI feeds as the default proposed interface, with an optional control key for other devices if need be. Pages from other websites can no longer change anything, as a security measure. See the API page of the docs for more information
- Your own pages and styles (`PluginData/Apps/`, `PluginData/Web/`) - you can now make your own pages and styles, kept across updates

### Fixed

- Atmosphere seen from orbit (Scatterer) - feeds no longer cut the atmosphere off along a line that follows where the main view looks, at least from what my testing has shown... Answers issue [#39](https://github.com/RELMYMathieu/JustReadTheInstructions/issues/39)


## v3.3.0 - 2026-11-11

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"NAME": "Just Read The Instructions",
"VERSION": "3.3.0.0",
"VERSION": "3.3.0.2",
"URL": "https://raw.githubusercontent.com/RELMYMathieu/JustReadTheInstructions/main/GameData/JustReadTheInstructions/JustReadTheInstructions.version",
"DOWNLOAD": "https://github.com/RELMYMathieu/JustReadTheInstructions/releases/latest",
"KSP_VERSION": "1.12.5",
Expand Down
26 changes: 26 additions & 0 deletions GameData/JustReadTheInstructions/changelog.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,32 @@ KERBALCHANGELOG
license = MIT
author = Mathieu Relmy

VERSION
{
version = 3.3.0.2
CHANGE
{
change = Fixed
subchange = Fix the timing at which the JRTI cameras copy depth buffer to avoid lighting artifacts.
}
}

VERSION
{
version = 3.3.0.1
CHANGE
{
change = Added
subchange = Web API (/api/v1) - This allows you to make your own apps, pages and overlays on the same JRTI feeds as the default proposed interface, with an optional control key for other devices if need be. Pages from other websites can no longer change anything, as a security measure. See the API page of the docs for more information
subchange = Your own pages and styles (PluginData/Apps/, PluginData/Web/) - you can now make your own pages and styles, kept across updates
}
CHANGE
{
change = Fixed
subchange = Atmosphere seen from orbit (Scatterer) - feeds no longer cut the atmosphere off along a line that follows where the main view looks, at least from what my testing has shown... Answers issue #39
}
}

VERSION
{
version = 3.3.0
Expand Down
28 changes: 27 additions & 1 deletion Source/DeferredIntegration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ namespace JustReadTheInstructions
{
public static class DeferredIntegration
{
private const int LocalCameraQueue = 15;

private static bool? _isAvailable;
private static Type _forwardRenderingCompatibilityType;
private static Type _pqsFadeType;
private static MethodInfo _initMethod;
private static FieldInfo _dummyObjectField;

Expand All @@ -33,6 +36,7 @@ public static bool IsAvailable
}

_forwardRenderingCompatibilityType = deferredAssembly.GetType("Deferred.ForwardRenderingCompatibility");
_pqsFadeType = deferredAssembly.GetType("Deferred.DeferredPQSFade");

if (_forwardRenderingCompatibilityType == null)
{
Expand Down Expand Up @@ -67,7 +71,7 @@ public static bool IsAvailable
}
}

public static void ApplyToCamera(Camera camera, int renderQueue = 15)
public static void ApplyToCamera(Camera camera, int renderQueue = LocalCameraQueue)
{
if (!IsAvailable || camera == null)
return;
Expand All @@ -76,6 +80,9 @@ public static void ApplyToCamera(Camera camera, int renderQueue = 15)
{
camera.renderingPath = RenderingPath.DeferredShading;

if (renderQueue == LocalCameraQueue)
AddPQSFade(camera);

var existingComponent = camera.gameObject.GetComponent(_forwardRenderingCompatibilityType);
if (existingComponent != null)
{
Expand Down Expand Up @@ -107,6 +114,15 @@ public static void ApplyToCamera(Camera camera, int renderQueue = 15)
}
}

private static void AddPQSFade(Camera camera)
{
if (_pqsFadeType == null || camera.gameObject.GetComponent(_pqsFadeType) != null)
return;

camera.gameObject.AddComponent(_pqsFadeType);
Debug.Log($"[JRTI-Deferred]: Added PQS fade to {camera.name}");
}

// TEMP: until Firefly merges https://github.com/M1rageDev/Firefly/pull/58
private static void DetachDummyObject(Component component, Camera camera)
{
Expand All @@ -126,6 +142,13 @@ public static void RemoveFromCamera(Camera camera)
{
camera.renderingPath = RenderingPath.Forward;

if (_pqsFadeType != null)
{
var fade = camera.gameObject.GetComponent(_pqsFadeType);
if (fade != null)
UnityEngine.Object.Destroy(fade);
}

if (_forwardRenderingCompatibilityType != null)
{
var component = camera.gameObject.GetComponent(_forwardRenderingCompatibilityType);
Expand Down Expand Up @@ -158,6 +181,9 @@ public static string GetDiagnosticInfo(Camera camera)
: "- ForwardRenderingCompatibility: Missing\n";
}

if (_pqsFadeType != null)
info += $"- DeferredPQSFade: {(camera.GetComponent(_pqsFadeType) != null ? "Present" : "Missing")}\n";

return info;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/JustReadTheInstructions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<Version>3.3.0.0</Version>
<Version>3.3.0.2</Version>
<Description>KSP Mod, inspired by OCISLY, as a spiritual successor.</Description>
<Copyright>MIT</Copyright>
<KSPBT_ModRoot>$(MSBuildThisFileDirectory)../GameData/JustReadTheInstructions</KSPBT_ModRoot>
Expand Down
18 changes: 18 additions & 0 deletions Source/ScattererAtmosphereBinding.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using UnityEngine;

namespace JustReadTheInstructions
{
public class ScattererAtmosphereBinding : MonoBehaviour
{
private Camera _camera;

void Awake()
{
_camera = GetComponent<Camera>();
}

void OnPreRender() => ScattererScaledAtmosphere.Bind(_camera);

void OnPostRender() => ScattererScaledAtmosphere.RestoreMain();
}
}
137 changes: 137 additions & 0 deletions Source/ScattererScaledAtmosphere.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
using System;
using System.Reflection;
using UnityEngine;

namespace JustReadTheInstructions
{
internal static class ScattererScaledAtmosphere
{
private const string ReflectionProbeScaledCameraName = "ScattererReflectionProbeScaledSpaceCamera";
private const float ReflectionProbeSearchInterval = 1f;

private static bool _resolved;
private static Type _skyNodeType;
private static FieldInfo _materialField;
private static FieldInfo _containerField;
private static FieldInfo _parentScaledTransformField;
private static FieldInfo _rtField;
private static MethodInfo _updateScreenBoundsMethod;
private static MethodInfo _enableScreenCopyMethod;
private static readonly object[] ScreenCopyArgs = new object[1];

private static GameObject _reflectionProbeScaledCamera;
private static float _nextReflectionProbeSearch;

private static readonly int CameraToWorldId = Shader.PropertyToID("CameraToWorld");
private static readonly int CurrentVpId = Shader.PropertyToID("currentVP"); private static readonly object[] BoundsArgs = new object[5];

public static void Bind(Camera viewer)
{
var mainScaledCamera = ScattererScaledCameraSwap.MainScaledCamera;
if (viewer == null || mainScaledCamera == null || !Resolve())
return;

try
{
foreach (var skyNode in mainScaledCamera.GetComponents(_skyNodeType))
BindSkyNode(skyNode, viewer);
}
catch (Exception ex)
{
Debug.LogError($"[JRTI-ScaledSwap]: Scaled atmosphere bind failed, disabled: {ex.Message}");
_skyNodeType = null;
}
}

public static void RestoreMain() => Bind(ScattererScaledCameraSwap.MainScaledCamera);

public static void EnableScreenCopy(Camera camera)
{
if (camera == null || !Resolve() || _enableScreenCopyMethod == null)
return;

try
{
ScreenCopyArgs[0] = camera;
_enableScreenCopyMethod.Invoke(null, ScreenCopyArgs);
}
catch (Exception ex)
{
Debug.LogError($"[JRTI-ScaledSwap]: Screen copy failed, disabled: {ex.Message}");
_enableScreenCopyMethod = null;
}
}

public static void AttachToReflectionProbe()
{
if (_reflectionProbeScaledCamera != null || Time.unscaledTime < _nextReflectionProbeSearch)
return;

_nextReflectionProbeSearch = Time.unscaledTime + ReflectionProbeSearchInterval;
_reflectionProbeScaledCamera = GameObject.Find(ReflectionProbeScaledCameraName);
if (_reflectionProbeScaledCamera == null || _reflectionProbeScaledCamera.GetComponent<ScattererAtmosphereBinding>() != null)
return;

_reflectionProbeScaledCamera.AddComponent<ScattererAtmosphereBinding>();
Debug.Log("[JRTI-ScaledSwap]: Scaled atmosphere follows the reflection probe camera");
}

private static void BindSkyNode(Component skyNode, Camera camera)
{
var material = _materialField.GetValue(skyNode) as Material;
var container = _containerField.GetValue(skyNode);
var parent = _parentScaledTransformField.GetValue(skyNode) as Transform;
if (material == null || container == null || parent == null)
return;

var projection = camera.nonJitteredProjectionMatrix;
var view = camera.worldToCameraMatrix;

var cameraToWorld = view.inverse;
cameraToWorld.SetColumn(2, -cameraToWorld.GetColumn(2));
material.SetMatrix(CameraToWorldId, cameraToWorld);
material.SetMatrix(CurrentVpId, GL.GetGPUProjectionMatrix(projection, false) * view);

BoundsArgs[0] = camera;
BoundsArgs[1] = projection;
BoundsArgs[2] = view;
BoundsArgs[3] = parent.position;
BoundsArgs[4] = (float)_rtField.GetValue(skyNode) / ScaledSpace.ScaleFactor;
_updateScreenBoundsMethod.Invoke(container, BoundsArgs);
}

private static bool Resolve()
{
if (_resolved)
return _skyNodeType != null;

var scatterer = ScattererScaledCameraSwap.ScattererAssembly;
if (scatterer == null)
return false;

_resolved = true;
var skyNodeType = scatterer.GetType("Scatterer.SkyNode");
if (skyNodeType == null)
return false;

const BindingFlags flags = BindingFlags.Public | BindingFlags.Instance;
_materialField = skyNodeType.GetField("scaledDepthBufferScatteringMaterial", flags);
_containerField = skyNodeType.GetField("scaledDepthBufferScatteringContainer", flags);
_parentScaledTransformField = skyNodeType.GetField("parentScaledTransform", flags);
_rtField = skyNodeType.GetField("Rt", flags);
_updateScreenBoundsMethod = _containerField?.FieldType.GetMethod("UpdateScreenBounds", flags);
_enableScreenCopyMethod = scatterer.GetType("Scatterer.ScreenCopyCommandBuffer")
?.GetMethod("EnableScreenCopyForFrame", BindingFlags.Public | BindingFlags.Static, null, new[] { typeof(Camera) }, null);

if (_materialField == null || _parentScaledTransformField == null || _rtField == null || _updateScreenBoundsMethod == null)
{
Debug.Log("[JRTI-ScaledSwap]: Scatterer has no scaled depth-buffer atmosphere - nothing to bind");
return false;
}

_skyNodeType = skyNodeType;
Debug.Log("[JRTI-ScaledSwap]: Scaled atmosphere follows feed cameras");
return true;
}
}
}
8 changes: 8 additions & 0 deletions Source/ScattererScaledCameraSwap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class ScattererScaledCameraSwap : MonoBehaviour
private static object _scattererInstance;
private static FieldInfo _scaledCameraField;
private static Camera _mainScaledCamera;
private static Assembly _scattererAssembly;

private static readonly string[] _candidateFieldNames =
{
Expand All @@ -22,9 +23,13 @@ public class ScattererScaledCameraSwap : MonoBehaviour
"mainScaledCamera",
};

internal static Camera MainScaledCamera => _initialized ? _mainScaledCamera : null;
internal static Assembly ScattererAssembly => _scattererAssembly;

void Awake()
{
_camera = GetComponent<Camera>();
gameObject.AddComponent<ScattererAtmosphereBinding>();
}

void OnEnable()
Expand All @@ -51,6 +56,7 @@ private static bool Initialize(Camera scaledCamera)
if (assembly == null)
return false;

_scattererAssembly = assembly;
var scattererType = assembly.GetType("Scatterer.Scatterer");
if (scattererType == null)
{
Expand Down Expand Up @@ -121,6 +127,8 @@ void OnPreCull()
return;

_scaledCameraField.SetValue(_scattererInstance, _camera);
ScattererScaledAtmosphere.EnableScreenCopy(_camera);
ScattererScaledAtmosphere.AttachToReflectionProbe();
}

void OnPostRender()
Expand Down
Loading