Skip to content

Commit bb92be2

Browse files
authored
Merge pull request #39 from Unity-Technologies/fixes-for-osx-and-movie-recorder
Fixed the Sampling input so it works on OSX and with MovieRecorder.
2 parents 1c35ecd + dff1463 commit bb92be2

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

source/FrameRecorder/Inputs/RenderTextureSampler/Editor/RenderTextureSamplerEditor.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class RenderTextureSamplerEditor : InputEditor
1515
SerializedProperty m_AspectRatio;
1616
SerializedProperty m_SuperSampling;
1717
SerializedProperty m_CameraTag;
18+
SerializedProperty m_FlipFinalOutput;
1819

1920
protected void OnEnable()
2021
{
@@ -28,6 +29,7 @@ protected void OnEnable()
2829
m_SuperSampling = pf.Find(w => w.m_SuperSampling);
2930
m_FinalSize = pf.Find(w => w.m_FinalSize);
3031
m_CameraTag = pf.Find(w => w.m_CameraTag);
32+
m_FlipFinalOutput = pf.Find( w => w.m_FlipFinalOutput );
3133
}
3234

3335

@@ -80,7 +82,7 @@ public override void OnInspectorGUI()
8082
using (new EditorGUI.DisabledScope(true))
8183
{
8284
EditorGUILayout.TextField("Color Space", (target as RenderTextureSamplerSettings).m_ColorSpace.ToString());
83-
EditorGUILayout.Toggle("Flip output", (target as RenderTextureSamplerSettings).m_FlipFinalOutput);
85+
EditorGUILayout.PropertyField(m_FlipFinalOutput, new GUIContent("Flip output"));
8486
}
8587
}
8688

source/FrameRecorder/Inputs/RenderTextureSampler/Engine/RenderTextureSampler.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class RenderTextureSampler : BaseRenderTextureInput
1414

1515
RenderTexture m_renderRT;
1616
RenderTexture[] m_accumulateRTs = new RenderTexture[2];
17-
int m_renderWidth, m_renderHeight, m_outputWidth, m_outputHeight;
17+
int m_renderWidth, m_renderHeight;
1818

1919
Material m_superMaterial;
2020
Material m_accumulateMaterial;
@@ -115,12 +115,12 @@ public override void BeginRecording(RecordingSession session)
115115
var aspect = AspectRatioHelper.GetRealAR(rtsSettings.m_AspectRatio);
116116
m_renderHeight = (int)rtsSettings.m_RenderSize;
117117
m_renderWidth = Mathf.Min(16 * 1024, Mathf.RoundToInt(m_renderHeight * aspect));
118-
m_outputHeight = (int)rtsSettings.m_FinalSize;
119-
m_outputWidth = Mathf.Min(16 * 1024, Mathf.RoundToInt(m_outputHeight * aspect));
118+
outputHeight = (int)rtsSettings.m_FinalSize;
119+
outputWidth = Mathf.Min(16 * 1024, Mathf.RoundToInt(outputHeight * aspect));
120120
if (rtsSettings.m_ForceEvenSize)
121121
{
122-
m_outputWidth = (m_outputWidth + 1) & ~1;
123-
m_outputHeight = (m_outputHeight + 1) & ~1;
122+
outputWidth = (outputWidth + 1) & ~1;
123+
outputHeight = (outputHeight + 1) & ~1;
124124
}
125125

126126
m_superMaterial = new Material(superShader);
@@ -140,7 +140,7 @@ public override void BeginRecording(RecordingSession session)
140140
m_accumulateRTs[i].wrapMode = TextureWrapMode.Clamp;
141141
m_accumulateRTs[i].Create();
142142
}
143-
var rt = new RenderTexture(m_outputWidth, m_outputHeight, 0, RenderTextureFormat.DefaultHDR, RenderTextureReadWrite.Linear);
143+
var rt = new RenderTexture(outputWidth, outputHeight, 0, RenderTextureFormat.DefaultHDR, RenderTextureReadWrite.Linear);
144144
rt.Create();
145145
outputRT = rt;
146146
m_samples = new Vector2[(int)rtsSettings.m_SuperSampling];
@@ -312,7 +312,7 @@ public override void NewFrameReady(RecordingSession session)
312312
else
313313
{
314314
// Ideally we would use a separable filter here, but we're massively bound by readback and disk anyway for hi-res.
315-
m_superMaterial.SetVector("_Target_TexelSize", new Vector4(1f / m_outputWidth, 1f / m_outputHeight, m_outputWidth, m_outputHeight));
315+
m_superMaterial.SetVector("_Target_TexelSize", new Vector4(1f / outputWidth, 1f / outputHeight, outputWidth, outputHeight));
316316
m_superMaterial.SetFloat("_KernelCosPower", rtsSettings.m_SuperKernelPower);
317317
m_superMaterial.SetFloat("_KernelScale", rtsSettings.m_SuperKernelScale);
318318
m_superMaterial.SetFloat("_NormalizationFactor", 1.0f / (float)rtsSettings.m_SuperSampling);
@@ -415,4 +415,4 @@ void SaveRT(RenderTexture input)
415415
File.WriteAllBytes("Recorder/DebugDump.png", bytes);
416416
}
417417
}
418-
}
418+
}

source/FrameRecorder/Inputs/RenderTextureSampler/Shaders/BS4Accumulate.shader

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ Properties {
1313

1414
CGINCLUDE
1515

16-
#pragma only_renderers d3d11 ps4 opengl
16+
// FIXME: Had to comment out to make it work on OSX. Needs to be revised.
17+
// #pragma only_renderers d3d11 ps4 opengl
1718

1819
#include "UnityCG.cginc"
1920

source/FrameRecorder/Inputs/RenderTextureSampler/Shaders/BS4SuperShader.shader

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ Properties {
77

88
CGINCLUDE
99

10-
#pragma only_renderers d3d11 ps4 opengl
10+
// FIXME: Had to comment out to make it work on OSX. Needs to be revised.
11+
// #pragma only_renderers d3d11 ps4 opengl
1112

1213
#include "UnityCG.cginc"
1314

0 commit comments

Comments
 (0)