-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System.Linq; | ||
using UnityEditor.Recorder; | ||
using UnityEngine; | ||
|
||
namespace UnityEditor.BigImageRecorder | ||
{ | ||
/// <summary> | ||
/// Input that divides a tagged camera's projection matrix and renders the tiles to individual render textures. | ||
/// </summary> | ||
class BigCameraInput : RecorderInput | ||
{ | ||
BigCameraInputSettings InputSettings => settings as BigCameraInputSettings; | ||
|
||
protected override void BeginRecording(RecordingSession session) | ||
{ | ||
base.BeginRecording(session); | ||
// TODO: create render textures | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
base.Dispose(disposing); | ||
// TODO: throw out render textures | ||
} | ||
|
||
protected override void NewFrameReady(RecordingSession session) | ||
{ | ||
base.NewFrameReady(session); | ||
var camera = GetTargetCamera(InputSettings.CameraTag); | ||
|
||
// TODO: | ||
// save current projection matrix | ||
// save current render target | ||
// change projection matrix | ||
// change render target | ||
// render camera | ||
// reset render target | ||
// reset projection matrix | ||
} | ||
|
||
static Camera GetTargetCamera(string cameraTag) | ||
{ | ||
try | ||
{ | ||
var cameras = GameObject | ||
.FindGameObjectsWithTag(cameraTag) | ||
.Select(gameObject => gameObject.GetComponent<Camera>()) | ||
.Where(camera => camera != null) | ||
.ToList(); | ||
|
||
if (cameras.Count > 1) | ||
{ | ||
Debug.LogWarning($"Found more than one camera with tag '{cameraTag}'."); | ||
} | ||
|
||
return cameras.FirstOrDefault(); | ||
} | ||
catch (UnityException) | ||
{ | ||
Debug.LogWarning($"Tag '{cameraTag}' does not exist."); | ||
return null; | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using UnityEditor.Recorder.Input; | ||
using UnityEngine; | ||
|
||
namespace UnityEditor.BigImageRecorder | ||
{ | ||
[Serializable] | ||
class BigCameraInputSettings : ImageInputSettings | ||
{ | ||
protected override Type InputType => typeof(BigCameraInput); | ||
|
||
public string CameraTag | ||
{ | ||
get => cameraTag; | ||
set => cameraTag = value; | ||
} | ||
|
||
[SerializeField] string cameraTag = "MainCamera"; | ||
|
||
public override int OutputHeight | ||
{ | ||
get => outputHeight; | ||
set => outputHeight = value; | ||
} | ||
|
||
[SerializeField] int outputHeight = 8096; | ||
|
||
public override int OutputWidth | ||
{ | ||
get => outputWidth; | ||
set => outputWidth = value; | ||
} | ||
|
||
[SerializeField] int outputWidth = 8096; | ||
|
||
protected override bool ValidityCheck(List<string> errors) | ||
{ | ||
var ok = true; | ||
|
||
if (OutputWidth <= 0 || OutputHeight <= 0) | ||
{ | ||
errors.Add($"Invalid output resolution: {OutputWidth}x{OutputHeight}"); | ||
ok = false; | ||
} | ||
|
||
return ok; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using UnityEngine; | ||
|
||
namespace UnityEditor.BigImageRecorder | ||
{ | ||
[CustomPropertyDrawer(typeof(BigCameraInputSettings))] | ||
class BigCameraInputSettingsPropertyDrawer : PropertyDrawer | ||
{ | ||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) | ||
{ | ||
// Removes gap above controls. | ||
return 0; | ||
} | ||
|
||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) | ||
{ | ||
var cameraTag = property.FindPropertyRelative("cameraTag"); | ||
var outputHeight = property.FindPropertyRelative("outputHeight"); | ||
var outputWidth = property.FindPropertyRelative("outputWidth"); | ||
|
||
using (new EditorGUI.IndentLevelScope(-1)) | ||
{ | ||
EditorGUILayout.PropertyField(cameraTag); | ||
EditorGUILayout.PropertyField(outputWidth); | ||
EditorGUILayout.PropertyField(outputHeight); | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
using UnityEditor.Recorder; | ||
using UnityEngine; | ||
|
||
namespace UnityEditor.BigImageRecorder | ||
{ | ||
/// <summary> | ||
/// Input settings specialization with a camera input as the only option. | ||
/// </summary> | ||
[Serializable] | ||
class BigImageInputSelector : InputSettingsSelector | ||
{ | ||
[SerializeField] BigCameraInputSettings cameraInputSettings = new BigCameraInputSettings(); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "BigImageRecorder.Editor", | ||
"rootNamespace": "", | ||
"references": [ | ||
"Unity.Recorder.Editor" | ||
], | ||
"includePlatforms": [ | ||
"Editor" | ||
], | ||
"excludePlatforms": [], | ||
"allowUnsafeCode": false, | ||
"overrideReferences": false, | ||
"precompiledReferences": [], | ||
"autoReferenced": true, | ||
"defineConstraints": [], | ||
"versionDefines": [], | ||
"noEngineReferences": false | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using UnityEditor.Recorder; | ||
|
||
namespace UnityEditor.BigImageRecorder | ||
{ | ||
/// <summary> | ||
/// Recorder to capture image sequences that exceed Unity's maximum texture size. | ||
/// </summary> | ||
class BigImageRecorder : GenericRecorder<BigImageRecorderSettings> | ||
{ | ||
protected override void RecordFrame(RecordingSession session) | ||
{ | ||
var path = Settings.FileNameGenerator.BuildAbsolutePath(session); | ||
var input = m_Inputs[0] as BigCameraInput; | ||
// TODO: save images | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using UnityEditor.Recorder; | ||
using UnityEngine; | ||
|
||
namespace UnityEditor.BigImageRecorder | ||
{ | ||
[CustomEditor(typeof(BigImageRecorderSettings))] | ||
class BigImageRecorderEditor : RecorderEditor | ||
{ | ||
protected override void FileTypeAndFormatGUI() | ||
{ | ||
base.FileTypeAndFormatGUI(); | ||
GUILayout.Label("PNG is the only supported image format."); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.Collections.Generic; | ||
using UnityEditor.Recorder; | ||
using UnityEngine; | ||
|
||
namespace UnityEditor.BigImageRecorder | ||
{ | ||
[RecorderSettings(typeof(BigImageRecorder), "Big Image Sequence", "imagesequence_16")] | ||
class BigImageRecorderSettings : RecorderSettings | ||
{ | ||
[SerializeField] BigImageInputSelector imageInputSelector = new BigImageInputSelector(); | ||
|
||
protected override string Extension => "png"; | ||
|
||
public override IEnumerable<RecorderInputSettings> InputsSettings | ||
{ | ||
get { yield return imageInputSelector.Selected; } | ||
} | ||
|
||
public BigImageRecorderSettings() | ||
{ | ||
FileNameGenerator.FileName = $"image_{DefaultWildcard.Frame}"; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "com.matthewminer.bigimagerecorder", | ||
"displayName": "Big Image Recorder", | ||
"version": "0.0.1", | ||
"unity": "2020.3", | ||
"description": "Recorder to capture image sequences that exceed Unity's maximum texture size.", | ||
"dependencies": { | ||
"com.unity.recorder": "2.5.0" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.