diff --git a/CHANGELOG.md b/CHANGELOG.md index 64cc566..f23a095 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ All notable changes to com.unity.renderstreaming package will be documented in t The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [3.0.1] - 2021-03-04 + +### Fixed + +- Fixed a script error when importing the package sample + +### Changed + +- `Camerastreamer` uses a `TargetTexture` on the `Camera` component if the `RenderTexture` is attached on the `Camera`. + ## [3.0.0] - 2021-03-02 Version 3.0.0 has a big change in the package design. This mainly addresses moving scripts from the sample folder to Package Manager. diff --git a/Documentation~/components.md b/Documentation~/components.md index 1a80aa1..6dbd246 100644 --- a/Documentation~/components.md +++ b/Documentation~/components.md @@ -30,6 +30,10 @@ This component streams the `Camera` component's camera rendering results. Uses `Target Texture` to store the rendering results. +> [!NOTE] +> You can attach the `Target Texture` to the `Camera` component. +> If `Target Texture` is attached on Camera, use that `Render Texture` setting first. + ![Camera Streamer inspector](images/camerastreamer_inspector.png) ### Properties @@ -37,6 +41,8 @@ This component streams the `Camera` component's camera rendering results. Uses | Parameter | Description | Default | | ---------------------------- | ------------------------------------------------------------------- | ------------------------------- | | **Streaming Size** | Size of the frame buffer used for streaming | 1280, 720 | +| **Anti-aliasing** | The antialiasing level for the RenderTexture | None | +| **Depth Buffer** | The precision of the render texture's depth buffer in bits | No depth buffer | ## `WebCamStreamer` diff --git a/Documentation~/images/camerastreamer_inspector.png b/Documentation~/images/camerastreamer_inspector.png index 2560abd..566ab24 100644 Binary files a/Documentation~/images/camerastreamer_inspector.png and b/Documentation~/images/camerastreamer_inspector.png differ diff --git a/Documentation~/tutorial.md b/Documentation~/tutorial.md index 4054020..1a62602 100644 --- a/Documentation~/tutorial.md +++ b/Documentation~/tutorial.md @@ -40,7 +40,7 @@ Check Package Manager window, Click `+` button and select `Add package from git Input the string below to the input field. ``` -com.unity.renderstreaming@3.0.0-preview.1 +com.unity.renderstreaming@3.0.1-preview ``` The list of version string is [here](https://github.com/Unity-Technologies/com.unity.renderstreaming/tags). In most cases, the latest version is recommended to use. diff --git a/Editor/CameraStreamerEditor.cs b/Editor/CameraStreamerEditor.cs new file mode 100644 index 0000000..aef4e87 --- /dev/null +++ b/Editor/CameraStreamerEditor.cs @@ -0,0 +1,49 @@ +using System.Linq; +using UnityEditor; +using UnityEngine; + +namespace Unity.RenderStreaming.Editor +{ + [CustomEditor(typeof(CameraStreamer))] + public class CameraStreamerEditor : UnityEditor.Editor + { + readonly GUIContent[] renderTextureAntiAliasing = new GUIContent[4] + { + EditorGUIUtility.TrTextContent("None"), + EditorGUIUtility.TrTextContent("2 samples"), + EditorGUIUtility.TrTextContent("4 samples"), + EditorGUIUtility.TrTextContent("8 samples") + }; + + readonly int[] renderTextureAntiAliasingValues = new int[4] {1, 2, 4, 8}; + + readonly GUIContent antiAliasing = + EditorGUIUtility.TrTextContent("Anti-aliasing", "Number of anti-aliasing samples."); + + readonly GUIContent[] renderTextureDepthBuffer = new GUIContent[3] + { + EditorGUIUtility.TrTextContent("No depth buffer"), + EditorGUIUtility.TrTextContent("At least 16 bits depth (no stencil)"), + EditorGUIUtility.TrTextContent("At least 24 bits depth (with stencil)") + }; + + readonly int[] renderTextureDepthBufferValues = new int[3] {0, 16, 24}; + + readonly GUIContent depthBuffer = EditorGUIUtility.TrTextContent("Depth Buffer", "Format of the depth buffer."); + + public override void OnInspectorGUI() + { + serializedObject.Update(); + + EditorGUILayout.PropertyField(serializedObject.FindProperty("streamingSize")); + var antiAliasingProperty = serializedObject.FindProperty("antiAliasing"); + EditorGUILayout.IntPopup(antiAliasingProperty, renderTextureAntiAliasing, renderTextureAntiAliasingValues, antiAliasing); + var depthBufferProperty = serializedObject.FindProperty("depth"); + EditorGUILayout.IntPopup(depthBufferProperty, renderTextureDepthBuffer, renderTextureDepthBufferValues, depthBuffer); + + serializedObject.ApplyModifiedProperties(); + + EditorGUILayout.HelpBox("If TargetTexture is attached on Camera, use that RenderTexture setting first.", MessageType.Info); + } + } +} diff --git a/Editor/CameraStreamerEditor.cs.meta b/Editor/CameraStreamerEditor.cs.meta new file mode 100644 index 0000000..f1e1ada --- /dev/null +++ b/Editor/CameraStreamerEditor.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2d01da8f1ad4418bae842b1dc3ecd65a +timeCreated: 1614647816 \ No newline at end of file diff --git a/Editor/WebAppDownloader.cs b/Editor/WebAppDownloader.cs index 61e4004..33399e9 100644 --- a/Editor/WebAppDownloader.cs +++ b/Editor/WebAppDownloader.cs @@ -7,7 +7,7 @@ namespace Unity.RenderStreaming.Editor public static class WebAppDownloader { const string URLRoot = "https://github.com/Unity-Technologies/UnityRenderStreaming"; - const string LatestKnownVersion = "3.0.0-preview.1"; + const string LatestKnownVersion = "3.0.1-preview"; // TODO::fix release process of webserver runtime. const string FileNameWebAppForMac = "webserver_mac"; diff --git a/Runtime/Scripts/CameraStreamer.cs b/Runtime/Scripts/CameraStreamer.cs index f0f974d..529b298 100644 --- a/Runtime/Scripts/CameraStreamer.cs +++ b/Runtime/Scripts/CameraStreamer.cs @@ -1,17 +1,17 @@ using Unity.WebRTC; using UnityEngine; +using UnityEngine.Experimental.Rendering; namespace Unity.RenderStreaming { [RequireComponent(typeof(Camera))] public class CameraStreamer : VideoStreamBase { - [SerializeField] private RenderTextureDepth depth; - [SerializeField, Tooltip("This property is needed to choose from 1,2,4 or 8")] - private int antiAliasing = 1; //ToDO(kannan):using enum + [SerializeField] private int depth = 0; + [SerializeField] private int antiAliasing = 1; - protected Camera m_camera; + private Camera m_camera; public override Texture SendTexture => m_camera.targetTexture; protected virtual void Awake() @@ -21,14 +21,37 @@ protected virtual void Awake() protected override MediaStreamTrack CreateTrack() { - int depthValue = (int)depth; - var format = WebRTC.WebRTC.GetSupportedRenderTextureFormat(SystemInfo.graphicsDeviceType); - var rt = new RenderTexture(streamingSize.x, streamingSize.y, depthValue, format) + RenderTexture rt; + if (m_camera.targetTexture != null) { - antiAliasing = antiAliasing - }; - rt.Create(); - m_camera.targetTexture = rt; + rt = m_camera.targetTexture; + RenderTextureFormat supportFormat = WebRTC.WebRTC.GetSupportedRenderTextureFormat(SystemInfo.graphicsDeviceType); + GraphicsFormat graphicsFormat = GraphicsFormatUtility.GetGraphicsFormat(supportFormat, RenderTextureReadWrite.Default); + GraphicsFormat compatibleFormat = SystemInfo.GetCompatibleFormat(graphicsFormat, FormatUsage.Render); + GraphicsFormat format = graphicsFormat == compatibleFormat ? graphicsFormat : compatibleFormat; + + if (rt.graphicsFormat != format) + { + Debug.LogWarning( + $"This color format:{rt.graphicsFormat} not support in unity.webrtc. Change to supported color format:{format}."); + rt.Release(); + rt.graphicsFormat = format; + rt.Create(); + } + + m_camera.targetTexture = rt; + } + else + { + RenderTextureFormat format = WebRTC.WebRTC.GetSupportedRenderTextureFormat(SystemInfo.graphicsDeviceType); + rt = new RenderTexture(streamingSize.x, streamingSize.y, depth, format) + { + antiAliasing = antiAliasing + }; + rt.Create(); + m_camera.targetTexture = rt; + } + return new VideoStreamTrack(m_camera.name, rt); } } diff --git a/Samples~/Example/Gyro/Unity.RenderStreaming.GyroSample.asmdef b/Samples~/Example/Gyro/Unity.RenderStreaming.GyroSample.asmdef new file mode 100644 index 0000000..2e33f68 --- /dev/null +++ b/Samples~/Example/Gyro/Unity.RenderStreaming.GyroSample.asmdef @@ -0,0 +1,16 @@ +{ + "name": "Unity.RenderStreaming.GyroSample", + "references": [ + "Unity.InputSystem", + "Unity.RenderStreaming.Runtime" + ], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Samples~/Example/Gyro/Unity.RenderStreaming.GyroSample.asmdef.meta b/Samples~/Example/Gyro/Unity.RenderStreaming.GyroSample.asmdef.meta new file mode 100644 index 0000000..2d4f5d0 --- /dev/null +++ b/Samples~/Example/Gyro/Unity.RenderStreaming.GyroSample.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: d2a0563a601204045910d3dc8d88ea99 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/package.json b/package.json index 20593b1..9a84f37 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.unity.renderstreaming", "displayName": "Unity Render Streaming", - "version": "3.0.0-preview.1", + "version": "3.0.1-preview", "unity": "2019.4", "description": "This is a package for using Unity Render Streaming technology. It contains two samples to use the technology.", "dependencies": { @@ -16,11 +16,11 @@ } ], "upmCi": { - "footprint": "c1560b9c1ca0d95fc643968a60c260b3ceae7b4a" + "footprint": "cbe62f773b614ee573138d157bab396293a30dd7" }, "repository": { "url": "https://github.com/Unity-Technologies/UnityRenderStreaming.git", "type": "git", - "revision": "6e3492661dfc150a316e0c43e65019353d11793a" + "revision": "ec92d7059723d64dc86c6bf77d22be7d2b8c1411" } }