Skip to content

Commit

Permalink
fix dumb stupid shit again
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeroluna committed Nov 8, 2024
1 parent d0a4b1f commit 4d836d8
Show file tree
Hide file tree
Showing 4 changed files with 220 additions and 216 deletions.
8 changes: 8 additions & 0 deletions Vivify/HarmonyPatches/AddComponentsToCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ private void AddComponents(MainEffectController __instance)
SafeAddComponent<CameraPropertyController>(gameObject);
}

[AffinityPrefix]
[AffinityPatch(typeof(ImageEffectController), nameof(ImageEffectController.OnRenderImage))]
private bool StopRenderImage(RenderTexture src, RenderTexture dest)
{
Graphics.Blit(src, dest);
return false;
}

private void SafeAddComponent<T>(GameObject gameObject)
where T : Component
{
Expand Down
66 changes: 12 additions & 54 deletions Vivify/HarmonyPatches/CameraEffectApplier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,66 +70,24 @@ private void Reset()

[AffinityPrefix]
[AffinityPatch(typeof(MainEffectController), nameof(MainEffectController.ImageEffectControllerCallback))]
private bool ApplyVivifyEffect(MainEffectController __instance, RenderTexture src, RenderTexture dest)
private void ApplyVivifyEffect(MainEffectController __instance, RenderTexture src, RenderTexture dest)
{
if (!_postProcessingControllers.TryGetValue(__instance, out PostProcessingController? postProcessingController))
if (_postProcessingControllers.TryGetValue(__instance, out PostProcessingController? postProcessingController))
{
postProcessingController = __instance.GetComponent<PostProcessingController?>();
if (postProcessingController == null)
{
return true;
}

_postProcessingControllers[__instance] = postProcessingController;
postProcessingController.CameraDatas = CameraDatas;
postProcessingController.DeclaredTextureDatas = DeclaredTextureDatas;
postProcessingController.PrewarmCameras(_prewarmCount);
return;
}

RenderTextureDescriptor descriptor = src.descriptor;
postProcessingController.CreateDeclaredTextures(descriptor);
RenderTexture main = src;
if (PreEffects.Count > 0)
postProcessingController = __instance.GetComponent<PostProcessingController?>();
if (postProcessingController == null)
{
main = postProcessingController.RenderImage(main, PreEffects);
return;
}

MainEffectSO mainEffect = __instance._mainEffectContainer.mainEffect;

if (PostEffects.Count > 0)
{
RenderTexture temp = RenderTexture.GetTemporary(descriptor);
mainEffect.Render(main, temp, __instance._fadeValue);
if (main != src)
{
RenderTexture.ReleaseTemporary(main);
}

if (postProcessingController.MainEffect)
{
main = postProcessingController.RenderImage(temp, PostEffects);
if (temp != main)
{
RenderTexture.ReleaseTemporary(temp);
}
}
else
{
main = temp;
}

Graphics.Blit(main, dest);
RenderTexture.ReleaseTemporary(main);
}
else
{
mainEffect.Render(main, dest, __instance._fadeValue);
if (main != src)
{
RenderTexture.ReleaseTemporary(main);
}
}

return false;
_postProcessingControllers[__instance] = postProcessingController;
postProcessingController.CameraDatas = CameraDatas;
postProcessingController.DeclaredTextureDatas = DeclaredTextureDatas;
postProcessingController.PreEffects = PreEffects;
postProcessingController.PostEffects = PostEffects;
postProcessingController.PrewarmCameras(_prewarmCount);
}
}
4 changes: 4 additions & 0 deletions Vivify/PostProcessing/CullingTextureController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ protected override void OnPreCull()
transform1.localPosition = Vector3.zero;
transform1.localRotation = Quaternion.identity;
camera.cullingMatrix = other.projectionMatrix * other.worldToCameraMatrix;
camera.projectionMatrix = other.projectionMatrix;
camera.nonJitteredProjectionMatrix = other.nonJitteredProjectionMatrix;
camera.worldToCameraMatrix = other.worldToCameraMatrix;
}

// very simple comparison
Expand Down Expand Up @@ -100,6 +103,7 @@ private void RefreshCamera()
// copyfrom lags for some reason
////Camera.CopyFrom(_postProcessingController.Camera);
Camera other = _postProcessingController.Camera;
Camera.stereoTargetEye = other.stereoTargetEye;
Camera.fieldOfView = other.fieldOfView;
Camera.aspect = other.aspect;
Camera.depth = other.depth - 1;
Expand Down
Loading

0 comments on commit 4d836d8

Please sign in to comment.