Skip to content

Commit d651229

Browse files
committed
Add CB Render Texture input to preserve transparency
1 parent b585ede commit d651229

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

source/FrameRecorder/Inputs/CBRenderTexture/Editor/CBRenderTextureInputSettingsEditor.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class CBRenderTextureInputSettingsEditor : Editor
1414
SerializedProperty m_RenderSize;
1515
SerializedProperty m_RenderAspect;
1616
SerializedProperty m_FlipVertically;
17+
SerializedProperty m_Transparency;
1718

1819
protected void OnEnable()
1920
{
@@ -26,6 +27,7 @@ protected void OnEnable()
2627
m_RenderSize = pf.Find(w => w.m_RenderSize);
2728
m_RenderAspect = pf.Find(w => w.m_RenderAspect);
2829
m_FlipVertically = pf.Find(w => w.m_FlipVertical);
30+
m_Transparency = pf.Find(w => w.m_AllowTransparency);
2931
}
3032

3133
public override void OnInspectorGUI()
@@ -58,7 +60,8 @@ public override void OnInspectorGUI()
5860
}
5961
}
6062

61-
EditorGUILayout.PropertyField(m_FlipVertically, new GUIContent("Flip image vertically"));
63+
EditorGUILayout.PropertyField(m_Transparency, new GUIContent("Preserve transparency"));
64+
EditorGUILayout.PropertyField(m_FlipVertically, new GUIContent("Flip vertically"));
6265

6366
serializedObject.ApplyModifiedProperties();
6467

source/FrameRecorder/Inputs/CBRenderTexture/Engine/CBRenderTextureInput.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ public override void NewFrameStarting(RecordingSession session)
175175
if (m_Camera.targetTexture != null || cbSettings.m_FlipVertical )
176176
m_mat_copy.EnableKeyword("OFFSCREEN");
177177

178+
if( cbSettings.m_AllowTransparency )
179+
m_mat_copy.EnableKeyword("TRANSPARENCY_ON");
180+
178181
var tid = Shader.PropertyToID("_TmpFrameBuffer");
179182
m_cbCopyFB = new CommandBuffer { name = "Frame Recorder: copy frame buffer" };
180183
m_cbCopyFB.GetTemporaryRT(tid, -1, -1, 0, FilterMode.Bilinear);

source/FrameRecorder/Inputs/CBRenderTexture/Engine/CBRenderTextureInputSettings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public class CBRenderTextureInputSettings : InputSettings<CBRenderTextureInput>
88
public string m_CameraTag;
99
public bool m_FlipVertical = false;
1010
public bool m_PadSize = false;
11+
public bool m_AllowTransparency = false;
1112

1213
public override bool isValid {
1314
get { return source != EImageSource.TaggedCamera || !string.IsNullOrEmpty(m_CameraTag); }

source/FrameRecorder/Inputs/CBRenderTexture/Shaders/CopyFrameBuffer.shader

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ half4 copy_framebuffer(v2f I) : SV_Target
5050
t.y = 1.0 - t.y;
5151
#endif
5252
half4 O = tex2D(_TmpFrameBuffer, t);
53+
#if !defined(TRANSPARENCY_ON)
5354
O.a = 1.0;
55+
#endif
5456
return O;
5557
}
5658

0 commit comments

Comments
 (0)