Add Depthkit packages and changed manifest file
parent
b7bf08930d
commit
39d7353464
|
@ -0,0 +1,31 @@
|
||||||
|
## Changelog
|
||||||
|
|
||||||
|
### 0.6.1
|
||||||
|
* Update SDK license agreement
|
||||||
|
|
||||||
|
### 0.6.0
|
||||||
|
* Updated to Unity 2022.3
|
||||||
|
|
||||||
|
### 0.5.2
|
||||||
|
* Updated assembly definitions.
|
||||||
|
|
||||||
|
### 0.5.1
|
||||||
|
* Updated com.unity.shadergraph dependency
|
||||||
|
|
||||||
|
### 0.5.0
|
||||||
|
* Updated to Unity 2020.3
|
||||||
|
* Updated surface buffer capacity to be set as a percentage of the maximum triangles needed to render the lattice mesh at the set mesh density.
|
||||||
|
|
||||||
|
### 0.4.0
|
||||||
|
* compatibility with 0.11.0
|
||||||
|
|
||||||
|
### 0.3.0
|
||||||
|
* Added support for material property blocks
|
||||||
|
* Moved common code to ShaderGraphLook base class
|
||||||
|
* Bug fixes
|
||||||
|
|
||||||
|
### 0.2.2
|
||||||
|
* Added depthkit icon to all depthkit components
|
||||||
|
|
||||||
|
### 0.2.1
|
||||||
|
* Bug fixes
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5b7ffb1510a7211428df971944eda351
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f9c6355c33d5da541a1eb187dfcdaa30
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,40 @@
|
||||||
|
/************************************************************************************
|
||||||
|
|
||||||
|
Depthkit Unity SDK License v1
|
||||||
|
Copyright 2016-2024 Simile Inc dba Scatter. All Rights reserved.
|
||||||
|
|
||||||
|
Licensed under the the Simile Inc dba Scatter ("Scatter")
|
||||||
|
Software Development Kit License Agreement (the "License");
|
||||||
|
you may not use this SDK except in compliance with the License,
|
||||||
|
which is provided at the time of installation or download,
|
||||||
|
or which otherwise accompanies this software in either electronic or hard copy form.
|
||||||
|
|
||||||
|
You may obtain a copy of the License at http://www.depthkit.tv/license-agreement-v1
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
the SDK distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Depthkit
|
||||||
|
{
|
||||||
|
public class CoreShaderGraphLookGizmosDrawer
|
||||||
|
{
|
||||||
|
[DrawGizmo(GizmoType.Selected | GizmoType.Active)]
|
||||||
|
static void DrawGizmosFor(Depthkit.CoreShaderGraphLook look, GizmoType gizmoType)
|
||||||
|
{
|
||||||
|
if (look.showCameraFrustums)
|
||||||
|
{
|
||||||
|
Depthkit.Util.RenderMetadataGizmos(look.depthkitClip.metadata, look.transform);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d27449979fb9b6246b129fb82af75c05
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,44 @@
|
||||||
|
/************************************************************************************
|
||||||
|
|
||||||
|
Depthkit Unity SDK License v1
|
||||||
|
Copyright 2016-2024 Simile Inc dba Scatter. All Rights reserved.
|
||||||
|
|
||||||
|
Licensed under the the Simile Inc dba Scatter ("Scatter")
|
||||||
|
Software Development Kit License Agreement (the "License");
|
||||||
|
you may not use this SDK except in compliance with the License,
|
||||||
|
which is provided at the time of installation or download,
|
||||||
|
or which otherwise accompanies this software in either electronic or hard copy form.
|
||||||
|
|
||||||
|
You may obtain a copy of the License at http://www.depthkit.tv/license-agreement-v1
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
the SDK distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace Depthkit {
|
||||||
|
public class CoreShaderGraphMenu
|
||||||
|
{
|
||||||
|
[MenuItem ("Assets/Create/Shader/Depthkit/Core Look - Shader Graph")]
|
||||||
|
static void CreateDepthkitCoreSRPLookShaderGraph(MenuCommand menuCommand)
|
||||||
|
{
|
||||||
|
string filename;
|
||||||
|
if(Selection.assetGUIDs.Length > 0)
|
||||||
|
{
|
||||||
|
string clickedAssetGuid = Selection.assetGUIDs[0];
|
||||||
|
string clickedPath = AssetDatabase.GUIDToAssetPath(clickedAssetGuid);
|
||||||
|
filename = Depthkit.Util.GetNextFileName(clickedPath + "/MyCoreLook", ".shadergraph");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
filename = Depthkit.Util.GetNextFileName("Assets/MyCoreLook", ".shadergraph");
|
||||||
|
}
|
||||||
|
AssetDatabase.CopyAsset("Packages/nyc.scatter.depthkit.core.shadergraph/Runtime/Resources/Shaders/Depthkit Core Photo Look Unlit.shadergraph", filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9efa5fe257de17f4b84e8be369eb5ef4
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"name": "Depthkit.Core.ShaderGraph.Editor",
|
||||||
|
"references": [
|
||||||
|
"GUID:d757665d4a59fe94bab8bd5391e60e3d",
|
||||||
|
"GUID:3fcfa8946fa8f2b4bae0b88785a14d3e"
|
||||||
|
],
|
||||||
|
"includePlatforms": [
|
||||||
|
"Editor"
|
||||||
|
],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": false,
|
||||||
|
"overrideReferences": false,
|
||||||
|
"precompiledReferences": [],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": [],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5272d745ea42c5743b70cb2d0f0ffbd2
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,138 @@
|
||||||
|
SOFTWARE DEVELOPMENT KIT LICENSE AGREEMENT
|
||||||
|
|
||||||
|
The text of this license (this “License”) may be found at: www.depthkit.tv/license-agreement-v1
|
||||||
|
|
||||||
|
Thank you for your interest in using the Simile Inc dba Scatter ("Scatter") Software Development Kit (the "SDK").
|
||||||
|
In order to obtain and use the SDK, you must first agree to the terms of this License. If you do not agree to the
|
||||||
|
terms of this License, then you may not use the SDK.
|
||||||
|
|
||||||
|
SDK LICENSE
|
||||||
|
1. Subject to the terms and conditions of this License, Scatter hereby
|
||||||
|
grants to you a worldwide, non-exclusive, royalty-free, sublicenseable license to use, reproduce, modify,
|
||||||
|
embed and redistribute (subject to restrictions below) the software contained in the SDK, including, but
|
||||||
|
not limited to, the samples, headers, documentation and source code. This License is subject to the
|
||||||
|
following terms and conditions:
|
||||||
|
1.1 This license grants you the non-exclusive license and right to use the SDK to develop
|
||||||
|
methods to play back content produced in the software suite known as Depth Kit (such content referred
|
||||||
|
to as your “Content”) in the Unity game engine, as well as other features that may be added from time to
|
||||||
|
time by Scatter. You may not use the SDK to connect Depth Kit to any software platform or game engine
|
||||||
|
other than Unity.
|
||||||
|
1.2 For avoidance of doubt, when you use the SDK in or with your Content, you retain all
|
||||||
|
rights to your Content, and you have no obligations to share or license your Content (including your
|
||||||
|
source and object code) to Scatter or any third parties; provided, however, Scatter retains all rights to the
|
||||||
|
SDK and the headers, libraries and APIs of Depth Kit and other tools made available by Scatter, including
|
||||||
|
those that may be incorporated into your Content by virtue of your producing it through Depth Kit.
|
||||||
|
1.3 You agree not to commit any act intended to (a) interfere with the normal operation of
|
||||||
|
Depth Kit or the SDK, (b) provide software to Depth Kit users or developers that would induce breach of
|
||||||
|
any Scatter agreements, or (c) provide software to Scatter or Depth Kit users that contains malware,
|
||||||
|
viruses, hacks, bots, Trojan horses, or other malicious code.
|
||||||
|
1.4 You may not use the SDK for any purpose not expressly permitted by this License. You
|
||||||
|
may not:
|
||||||
|
|
||||||
|
a. decompile;
|
||||||
|
b. reverse engineer;
|
||||||
|
c. disassemble; or
|
||||||
|
d. attempt to derive the source code of any part of the SDK where source code is
|
||||||
|
not directly provided to you, or any other software or firmware provided to you by Scatter in binary
|
||||||
|
form (except as and only to the extent any foregoing restriction is prohibited by applicable law).
|
||||||
|
|
||||||
|
REDISTRIBUTION
|
||||||
|
2. Subject to the terms and conditions of this License, your license to redistribute and sublicense the SDK
|
||||||
|
is also expressly made subject to the following conditions:
|
||||||
|
2.1 You may sublicense and redistribute the binary or object code form of the SDK in whole
|
||||||
|
for no charge or as part of a for-charge piece of Content; provided, however, you may only license,
|
||||||
|
sublicense or redistribute the binary or object code of the SDK (and not the SDK’s source code) in its
|
||||||
|
entirety. The SDK, including its associated libraries, and your Content that includes any portion of the
|
||||||
|
SDK, may only be used with Depth Kit and may not be used, licensed, or sublicensed to interface with
|
||||||
|
software that is not authorized and approved by Scatter;
|
||||||
|
2.2 You must include with all such redistributed or sublicensed SDK code the following copyright
|
||||||
|
notice: “Copyright 2016-2024 Simile Inc dba Scatter. All rights reserved.”;
|
||||||
|
2.3 You must give any other recipients of the SDK a copy of this License as such recipients,
|
||||||
|
licensees or sublicensees may only use the SDK subject to the terms of this License and such recipient's,
|
||||||
|
licensee's or sublicensee's agreement to and acceptance of this License with Scatter; and
|
||||||
|
2.4 The SDK includes a “LICENSE” text file (the “License Notice”), and any SDK distribution that
|
||||||
|
you distribute must include a copy of this License with the License Notice.
|
||||||
|
|
||||||
|
GENERAL PROVISIONS
|
||||||
|
3. Additional Materials
|
||||||
|
3.1 Scatter may include in this SDK additional content (e.g., samples) for demonstration,
|
||||||
|
references or other specific purposes. Such content will be clearly marked in the SDK and is subject to
|
||||||
|
any included terms and conditions.
|
||||||
|
3.2 Your use of third-party materials included in the SDK, or which the SDK may be dependent
|
||||||
|
upon (including without limitation Unity), may be subject to other terms and conditions typically found in
|
||||||
|
separate third-party license agreements or "READ ME" files included with such third-party materials. To
|
||||||
|
the extent such other terms and conditions conflict with the terms and conditions of this License, the
|
||||||
|
former will control with respect to the applicable third-party materials. The terms of licensing the Unity
|
||||||
|
game engine can be found here: https://unity3d.com/legal/terms-of-service/software.
|
||||||
|
4. THE SDK AND ANY COMPONENT THEREOF ARE PROVIDED “AS IS” AND ANY EXPRESS OR
|
||||||
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||||
|
EVENT SHALL Scatter AS THE COPYRIGHT OWNER OR ITS CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SDK, EVEN IF
|
||||||
|
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOME JURISDICTIONS DO NOT PERMIT THE
|
||||||
|
EXCLUSION OR LIMITATION OF IMPLIED WARRANTIES, SO YOU MAY HAVE ADDITIONAL
|
||||||
|
RIGHTS.
|
||||||
|
5. This License does not grant permission to use the trade names, trademarks, service marks, or product
|
||||||
|
names of Scatter, including without limitation “Depth Kit,” except as required for reasonable and customary
|
||||||
|
use in describing the origin of the SDK, and reproducing the content of the License Notice file. Scatter
|
||||||
|
reserves all rights not expressly granted to you under this License. Neither Scatter’s name nor the names
|
||||||
|
of Scatter’s contributors, licensors, employees, or contractors, may be used to endorse or promote
|
||||||
|
products developed using the SDK without specific prior written permission of Scatter.
|
||||||
|
6. You are responsible for ensuring that your use of the SDK and your Content complies with all
|
||||||
|
applicable laws (including privacy laws) wherever your Content is made available. You acknowledge and
|
||||||
|
agree that you are solely responsible for any health and safety issues arising from your Content.
|
||||||
|
7. Your acceptance of the terms and conditions of this License in and of itself and for all of your Content
|
||||||
|
may be evidenced by your usage of the SDK or acceptance of this License. As this License is updated for
|
||||||
|
future releases of the SDK, you agree to abide by and meet all requirements of future updates of this
|
||||||
|
License for those future SDK releases, with acceptance evidenced by usage of the SDK or any element
|
||||||
|
thereof and the future updates of this License will apply for your Content that may be developed for or
|
||||||
|
with that future SDK or any element thereof (i.e., you cannot sidestep out of the requirements of future
|
||||||
|
updates of the License by developing against an older release of the SDK or License). You acknowledge
|
||||||
|
that future versions of the SDK may be provided for a fee or otherwise under substantially different terms
|
||||||
|
from those provided hereunder.
|
||||||
|
8. Scatter reserves the right to terminate this License and all your rights hereunder immediately in the
|
||||||
|
event you materially breach this License.
|
||||||
|
9. Furthermore, Scatter also reserves the right to cancel or terminate this License for any of the following
|
||||||
|
reasons:
|
||||||
|
a. Intellectual property infringement by you for your Content that is used with or by
|
||||||
|
the SDK;
|
||||||
|
b. Content that violates applicable law;
|
||||||
|
c. Health and safety issues associated with your Content;
|
||||||
|
d. Use of the SDK with a commercial product other than Depth Kit and Unity; and
|
||||||
|
e. Failure to provide required notices as set forth above.
|
||||||
|
10. You agree to fully indemnify Scatter from any and all losses, costs, damages and expenses (including
|
||||||
|
reasonable attorney's fees) arising out of your Content or any breach of this License.
|
||||||
|
11. Scatter may discontinue or change functionality of Depth Kit or the SDK at any time, and your
|
||||||
|
continued use of Depth Kit or the SDK or use of any modified or additional services in connection
|
||||||
|
therewith is conditioned upon your adherence to the terms of this License, as modified by Scatter from
|
||||||
|
time to time, as well as any additional license agreements necessitated by additional features.
|
||||||
|
12. In the event any provision of this License is determined to be invalid, prohibited or unenforceable by a
|
||||||
|
court or other body of competent jurisdiction, this License shall be construed as if such invalid, prohibited
|
||||||
|
or unenforceable provision has been more narrowly drawn so as not to be invalid, prohibited or
|
||||||
|
unenforceable.
|
||||||
|
13. You may not assign any rights or obligations under this License without the advance written consent
|
||||||
|
of Scatter, which may be withheld in its sole discretion. Scatter may assign its rights or obligations under
|
||||||
|
this License in its sole discretion.
|
||||||
|
14. Failure of either party at any time to enforce any of the provisions of this License will not be construed
|
||||||
|
as a waiver of such provisions or in any way affect the validity of this License or parts thereof.
|
||||||
|
15. Your remedies under this License shall be limited to the right to collect money damages, if any, and
|
||||||
|
you hereby waive your right to injunctive or other equitable relief.
|
||||||
|
16. You will comply with all applicable export control laws of the United States and any other applicable
|
||||||
|
governmental authority, including without limitation, the U.S. Export Administration Regulations. You
|
||||||
|
agree that this License and the SDK and accompanying documentation are Scatter's confidential
|
||||||
|
information (and is not publicly available), and you will not use it, disclose it or make it available to others
|
||||||
|
except in accordance with the terms of this License.
|
||||||
|
17. This License shall be governed by the laws of the State of New York, without giving effect to choice of
|
||||||
|
law principles. All disputes relating to this License shall be resolved by binding non-appearance-based
|
||||||
|
arbitration before a single arbitrator in New York County, New York. The arbitration shall be conducted in
|
||||||
|
accordance with the rules and procedures of JAMS then in effect, and the judgment of the arbitrator shall
|
||||||
|
be final and capable of entry in any court of competent jurisdiction. You and Scatter agree to submit to the
|
||||||
|
personal jurisdiction of the courts located within New York County, New York in connection with any
|
||||||
|
entrance of an arbitrator’s judgment or decision or any dispute with respect to the arbitration process or
|
||||||
|
procedure or Scatter’s exercise of its equitable rights or remedies.
|
||||||
|
|
||||||
|
Effective as of October 7, 2016
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e30fdbafb6a3b4444852d807234af082
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,2 @@
|
||||||
|
# Depthkit Core Shader Graph
|
||||||
|
Copyright 2021 Scatter All Rights reserved.
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0d6f9fa8d2b16354b95d28638bd44eb9
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: fbcbe8f39d8261c42b5d86fece785f5d
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"name": "Depthkit.Core.ShaderGraph",
|
||||||
|
"rootNamespace": "",
|
||||||
|
"references": [
|
||||||
|
"GUID:d757665d4a59fe94bab8bd5391e60e3d"
|
||||||
|
],
|
||||||
|
"includePlatforms": [],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": false,
|
||||||
|
"overrideReferences": false,
|
||||||
|
"precompiledReferences": [],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": [],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3fcfa8946fa8f2b4bae0b88785a14d3e
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 57fff10957385e04e8bfae0c20b2c47d
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,63 @@
|
||||||
|
/************************************************************************************
|
||||||
|
|
||||||
|
Depthkit Unity SDK License v1
|
||||||
|
Copyright 2016-2024 Simile Inc dba Scatter. All Rights reserved.
|
||||||
|
|
||||||
|
Licensed under the the Simile Inc dba Scatter ("Scatter")
|
||||||
|
Software Development Kit License Agreement (the "License");
|
||||||
|
you may not use this SDK except in compliance with the License,
|
||||||
|
which is provided at the time of installation or download,
|
||||||
|
or which otherwise accompanies this software in either electronic or hard copy form.
|
||||||
|
|
||||||
|
You may obtain a copy of the License at http://www.depthkit.tv/license-agreement-v1
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
the SDK distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Depthkit
|
||||||
|
{
|
||||||
|
[ExecuteInEditMode]
|
||||||
|
[AddComponentMenu("Depthkit/Core/Shader Graph/Depthkit Core Shader Graph Look")]
|
||||||
|
public class CoreShaderGraphLook : ShaderGraphLook
|
||||||
|
{
|
||||||
|
protected static Shader s_defaultUnlitPhotoLookShader = null;
|
||||||
|
protected static Material s_defaultUnlitPhotoLookMaterial = null;
|
||||||
|
|
||||||
|
protected static Material GetDefaultMaterial()
|
||||||
|
{
|
||||||
|
if (s_defaultUnlitPhotoLookShader == null)
|
||||||
|
{
|
||||||
|
s_defaultUnlitPhotoLookShader = Shader.Find("Shader Graphs/Depthkit Core Photo Look Unlit");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s_defaultUnlitPhotoLookMaterial == null)
|
||||||
|
{
|
||||||
|
s_defaultUnlitPhotoLookMaterial = new Material(s_defaultUnlitPhotoLookShader);
|
||||||
|
}
|
||||||
|
return s_defaultUnlitPhotoLookMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Material GetDefaultShaderGraph()
|
||||||
|
{
|
||||||
|
return GetDefaultMaterial();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string GetLookName(){ return "Depthkit Core Shader Graph Look"; }
|
||||||
|
|
||||||
|
protected override void SetDataSources()
|
||||||
|
{
|
||||||
|
if(meshSource == null)
|
||||||
|
{
|
||||||
|
meshSource = depthkitClip.GetDataSource<Depthkit.CoreMeshSource>();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!meshSource.useTriangleMesh) meshSource.useTriangleMesh = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 49f9b3a47303df142865cad5acebdb4d
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {fileID: 2800000, guid: 42c51ff9981f3e24b83cd7ad3c56e235, type: 3}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6f54e2f05488f994b9935950d3a5d1f9
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2e3afc07320a9f3489644400c10ca721
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,10 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c87a04016ad3ac64fb8dabf413e1d1e3
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,10 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d8f155b222bf9234fab7df9371f4cff5
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3}
|
|
@ -0,0 +1,55 @@
|
||||||
|
{
|
||||||
|
"m_SerializedProperties": [],
|
||||||
|
"m_SerializedKeywords": [],
|
||||||
|
"m_SerializableNodes": [
|
||||||
|
{
|
||||||
|
"typeInfo": {
|
||||||
|
"fullName": "UnityEditor.ShaderGraph.SubGraphOutputNode"
|
||||||
|
},
|
||||||
|
"JSONnodeData": "{\n \"m_GuidSerialized\": \"db251ffe-9a41-44bb-9a24-2c4e2335d61c\",\n \"m_GroupGuidSerialized\": \"00000000-0000-0000-0000-000000000000\",\n \"m_Name\": \"Output\",\n \"m_NodeVersion\": 0,\n \"m_DrawState\": {\n \"m_Expanded\": true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n \"x\": 344.0,\n \"y\": -72.0,\n \"width\": 160.0,\n \"height\": 149.0\n }\n },\n \"m_SerializableSlots\": [\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEditor.ShaderGraph.Vector3MaterialSlot\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 1,\\n \\\"m_DisplayName\\\": \\\"Object Position\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ShaderOutputName\\\": \\\"ObjectPosition\\\",\\n \\\"m_StageCapability\\\": 3,\\n \\\"m_Value\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0\\n },\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0\\n },\\n \\\"m_Labels\\\": [\\n \\\"X\\\",\\n \\\"Y\\\",\\n \\\"Z\\\"\\n ]\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEditor.ShaderGraph.Vector3MaterialSlot\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 2,\\n \\\"m_DisplayName\\\": \\\"Object Normal\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ShaderOutputName\\\": \\\"ObjectNormal\\\",\\n \\\"m_StageCapability\\\": 3,\\n \\\"m_Value\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0\\n },\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0\\n },\\n \\\"m_Labels\\\": [\\n \\\"X\\\",\\n \\\"Y\\\",\\n \\\"Z\\\"\\n ]\\n}\"\n }\n ],\n \"m_Precision\": 0,\n \"m_PreviewExpanded\": true,\n \"m_CustomColors\": {\n \"m_SerializableColors\": []\n }\n}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"typeInfo": {
|
||||||
|
"fullName": "UnityEditor.ShaderGraph.CustomFunctionNode"
|
||||||
|
},
|
||||||
|
"JSONnodeData": "{\n \"m_GuidSerialized\": \"9ab40ef9-5889-4e0c-9278-1f65e72b4622\",\n \"m_GroupGuidSerialized\": \"00000000-0000-0000-0000-000000000000\",\n \"m_Name\": \"Custom Function\",\n \"m_NodeVersion\": 0,\n \"m_DrawState\": {\n \"m_Expanded\": true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n \"x\": 40.0,\n \"y\": -80.0,\n \"width\": 234.0,\n \"height\": 166.0\n }\n },\n \"m_SerializableSlots\": [\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEditor.ShaderGraph.Vector2MaterialSlot\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 0,\\n \\\"m_DisplayName\\\": \\\"triangle uv\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ShaderOutputName\\\": \\\"triangleuv\\\",\\n \\\"m_StageCapability\\\": 3,\\n \\\"m_Value\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0\\n },\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0\\n },\\n \\\"m_Labels\\\": [\\n \\\"X\\\",\\n \\\"Y\\\"\\n ]\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEditor.ShaderGraph.Vector2MaterialSlot\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 1,\\n \\\"m_DisplayName\\\": \\\"perspective uv\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ShaderOutputName\\\": \\\"perspectiveuv\\\",\\n \\\"m_StageCapability\\\": 3,\\n \\\"m_Value\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0\\n },\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0\\n },\\n \\\"m_Labels\\\": [\\n \\\"X\\\",\\n \\\"Y\\\"\\n ]\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEditor.ShaderGraph.Vector3MaterialSlot\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 2,\\n \\\"m_DisplayName\\\": \\\"position\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ShaderOutputName\\\": \\\"position\\\",\\n \\\"m_StageCapability\\\": 3,\\n \\\"m_Value\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0\\n },\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0\\n },\\n \\\"m_Labels\\\": [\\n \\\"X\\\",\\n \\\"Y\\\",\\n \\\"Z\\\"\\n ]\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEditor.ShaderGraph.Vector3MaterialSlot\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 3,\\n \\\"m_DisplayName\\\": \\\"normal\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ShaderOutputName\\\": \\\"normal\\\",\\n \\\"m_StageCapability\\\": 3,\\n \\\"m_Value\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0\\n },\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0\\n },\\n \\\"m_Labels\\\": [\\n \\\"X\\\",\\n \\\"Y\\\",\\n \\\"Z\\\"\\n ]\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEditor.ShaderGraph.Vector1MaterialSlot\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 4,\\n \\\"m_DisplayName\\\": \\\"perspective\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ShaderOutputName\\\": \\\"perspective\\\",\\n \\\"m_StageCapability\\\": 3,\\n \\\"m_Value\\\": 0.0,\\n \\\"m_DefaultValue\\\": 0.0,\\n \\\"m_Labels\\\": [\\n \\\"X\\\"\\n ]\\n}\"\n }\n ],\n \"m_Precision\": 0,\n \"m_PreviewExpanded\": false,\n \"m_CustomColors\": {\n \"m_SerializableColors\": []\n },\n \"m_SourceType\": 0,\n \"m_FunctionName\": \"DepthkitCoreSampleTriangleBuffer\",\n \"m_FunctionSource\": \"9425010fadc863c47b5f8775a2f32428\",\n \"m_FunctionBody\": \"Enter function body here...\"\n}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"typeInfo": {
|
||||||
|
"fullName": "UnityEditor.ShaderGraph.UVNode"
|
||||||
|
},
|
||||||
|
"JSONnodeData": "{\n \"m_GuidSerialized\": \"c46bd900-8f26-4aa2-ab4c-3f9d4aeb0f40\",\n \"m_GroupGuidSerialized\": \"00000000-0000-0000-0000-000000000000\",\n \"m_Name\": \"UV\",\n \"m_NodeVersion\": 0,\n \"m_DrawState\": {\n \"m_Expanded\": true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n \"x\": -173.75,\n \"y\": -70.50000762939453,\n \"width\": 144.99998474121095,\n \"height\": 128.0\n }\n },\n \"m_SerializableSlots\": [\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEditor.ShaderGraph.Vector4MaterialSlot\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 0,\\n \\\"m_DisplayName\\\": \\\"Out\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ShaderOutputName\\\": \\\"Out\\\",\\n \\\"m_StageCapability\\\": 3,\\n \\\"m_Value\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n }\\n}\"\n }\n ],\n \"m_Precision\": 0,\n \"m_PreviewExpanded\": false,\n \"m_CustomColors\": {\n \"m_SerializableColors\": []\n },\n \"m_OutputChannel\": 0\n}"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"m_Groups": [],
|
||||||
|
"m_StickyNotes": [],
|
||||||
|
"m_SerializableEdges": [
|
||||||
|
{
|
||||||
|
"typeInfo": {
|
||||||
|
"fullName": "UnityEditor.Graphing.Edge"
|
||||||
|
},
|
||||||
|
"JSONnodeData": "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 0,\n \"m_NodeGUIDSerialized\": \"c46bd900-8f26-4aa2-ab4c-3f9d4aeb0f40\"\n },\n \"m_InputSlot\": {\n \"m_SlotId\": 0,\n \"m_NodeGUIDSerialized\": \"9ab40ef9-5889-4e0c-9278-1f65e72b4622\"\n }\n}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"typeInfo": {
|
||||||
|
"fullName": "UnityEditor.Graphing.Edge"
|
||||||
|
},
|
||||||
|
"JSONnodeData": "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 2,\n \"m_NodeGUIDSerialized\": \"9ab40ef9-5889-4e0c-9278-1f65e72b4622\"\n },\n \"m_InputSlot\": {\n \"m_SlotId\": 1,\n \"m_NodeGUIDSerialized\": \"db251ffe-9a41-44bb-9a24-2c4e2335d61c\"\n }\n}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"typeInfo": {
|
||||||
|
"fullName": "UnityEditor.Graphing.Edge"
|
||||||
|
},
|
||||||
|
"JSONnodeData": "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 3,\n \"m_NodeGUIDSerialized\": \"9ab40ef9-5889-4e0c-9278-1f65e72b4622\"\n },\n \"m_InputSlot\": {\n \"m_SlotId\": 2,\n \"m_NodeGUIDSerialized\": \"db251ffe-9a41-44bb-9a24-2c4e2335d61c\"\n }\n}"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"m_PreviewData": {
|
||||||
|
"serializedMesh": {
|
||||||
|
"m_SerializedMesh": "{\"mesh\":{\"instanceID\":0}}",
|
||||||
|
"m_Guid": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"m_Path": "Sub Graphs",
|
||||||
|
"m_ConcretePrecision": 0,
|
||||||
|
"m_ActiveOutputNodeGuidSerialized": ""
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4be5c3a372dc98742b91488a7f372740
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3}
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: df8e8c109175b7b42a3e4d94c1d9e9aa
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,15 @@
|
||||||
|
#ifndef DEPTHKIT_SAMPLETRIANGLEBUFFER_HLSL_INCLUDE
|
||||||
|
#define DEPTHKIT_SAMPLETRIANGLEBUFFER_HLSL_INCLUDE
|
||||||
|
|
||||||
|
#include "Packages/nyc.scatter.depthkit.core/Runtime/Resources/Shaders/Includes/SampleCoreTriangles.cginc"
|
||||||
|
|
||||||
|
void DepthkitCoreSampleTriangleBuffer_float(in float2 triangleUV, out float2 perspectiveUV, out float3 position, out float3 normal, out uint perspective)
|
||||||
|
{
|
||||||
|
Vertex vert = dkSampleTriangleBuffer((uint)triangleUV.x, (uint)triangleUV.y);
|
||||||
|
perspective = vert.perspectiveIndex;
|
||||||
|
position = vert.position;
|
||||||
|
normal = vert.normal;
|
||||||
|
perspectiveUV = vert.uv.xy;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9425010fadc863c47b5f8775a2f32428
|
||||||
|
ShaderImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
defaultTextures: []
|
||||||
|
nonModifiableTextures: []
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,53 @@
|
||||||
|
|
||||||
|
#ifndef DEPTHKIT_FRAGMENT_HLSL_INCLUDED
|
||||||
|
#define DEPTHKIT_FRAGMENT_HLSL_INCLUDED
|
||||||
|
|
||||||
|
#include "Packages/nyc.scatter.depthkit.core/Runtime/Resources/Shaders/Includes/Depthkit.cginc"
|
||||||
|
#include "Packages/nyc.scatter.depthkit.core/Runtime/Resources/Shaders/Includes/SampleEdgeMask.cginc"
|
||||||
|
|
||||||
|
DK_EDGEMASK_UNIFORMS
|
||||||
|
|
||||||
|
void DepthkitCoreFragment_float(in float3 screenSpacePosition, in float3 objectPosition, out float3 color, out float alpha, out float2 uv, out float alphaclip)
|
||||||
|
{
|
||||||
|
float2 colorUV;
|
||||||
|
float2 depthUV;
|
||||||
|
float3 viewspace;
|
||||||
|
dkWorldToPerspectiveUV(0, objectPosition, uv, depthUV, colorUV, viewspace);
|
||||||
|
float depth = dkSampleDepth(depthUV, 0, uv);
|
||||||
|
bool valid = dkValidateNormalizedDepth(0, depth);
|
||||||
|
|
||||||
|
#ifdef DK_USE_DEBUG_COLOR
|
||||||
|
color = dkGetDebugCameraColor(0);
|
||||||
|
#else
|
||||||
|
color = dkSampleColor(colorUV);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
alpha = lerp(-1.f, DK_SAMPLE_EDGEMASK(uv, 0, screenSpacePosition), valid);
|
||||||
|
alphaclip = DK_CLIP_THRESHOLD(0);
|
||||||
|
|
||||||
|
#ifdef DK_DEBUG_EDGEMASK
|
||||||
|
color = float3(alpha * dkGetDebugCameraColor(0));
|
||||||
|
#ifdef DK_USE_EDGEMASK
|
||||||
|
float2 minMaxMask = DK_SAMPLE_DOWNSAMPLED_EDGEMASK(uv, 0);
|
||||||
|
if (alpha < 0.0)
|
||||||
|
{
|
||||||
|
color = float3(0.3, 0.3, 0.3);
|
||||||
|
}
|
||||||
|
if (alpha == 0.0) //completely invalid
|
||||||
|
{
|
||||||
|
color = float3(0.05, 0.05, 0.05);
|
||||||
|
}
|
||||||
|
// dim if is edge
|
||||||
|
if ((1.0f - minMaxMask.y) < DK_CLIP_THRESHOLD(0))
|
||||||
|
{
|
||||||
|
color *= .5;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (alpha < DK_ALPHA_CLIP_THRESHOLD) { color = float3(0.3f, 0.3f, 0.3f); }
|
||||||
|
#endif
|
||||||
|
alpha = 1.0f;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 54392f0b351a5bc418d0e506882a5db2
|
||||||
|
ShaderImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
defaultTextures: []
|
||||||
|
nonModifiableTextures: []
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,74 @@
|
||||||
|
/************************************************************************************
|
||||||
|
|
||||||
|
Depthkit Unity SDK License v1
|
||||||
|
Copyright 2016-2024 Simile Inc dba Scatter. All Rights reserved.
|
||||||
|
|
||||||
|
Licensed under the the Simile Inc dba Scatter ("Scatter")
|
||||||
|
Software Development Kit License Agreement (the "License");
|
||||||
|
you may not use this SDK except in compliance with the License,
|
||||||
|
which is provided at the time of installation or download,
|
||||||
|
or which otherwise accompanies this software in either electronic or hard copy form.
|
||||||
|
|
||||||
|
You may obtain a copy of the License at http://www.depthkit.tv/license-agreement-v1
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
the SDK distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
using System.Collections;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Depthkit
|
||||||
|
{
|
||||||
|
[RequireComponent(typeof(MeshFilter))]
|
||||||
|
[RequireComponent(typeof(MeshRenderer))]
|
||||||
|
public abstract class ShaderGraphLook : Look
|
||||||
|
{
|
||||||
|
protected MeshRenderer m_meshRenderer = null;
|
||||||
|
protected MeshFilter m_meshFilter = null;
|
||||||
|
|
||||||
|
protected abstract Material GetDefaultShaderGraph();
|
||||||
|
|
||||||
|
protected override void SetDefaults()
|
||||||
|
{
|
||||||
|
m_meshFilter = GetComponent<MeshFilter>();
|
||||||
|
m_meshFilter.hideFlags = HideFlags.NotEditable;
|
||||||
|
m_meshRenderer = GetComponent<MeshRenderer>();
|
||||||
|
|
||||||
|
if (m_meshRenderer.sharedMaterial == null)
|
||||||
|
{
|
||||||
|
m_meshRenderer.material = GetDefaultShaderGraph();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_meshRenderer.SetPropertyBlock(materialPropertyBlock);
|
||||||
|
|
||||||
|
base.SetDefaults();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool UsesMaterial() { return true; }
|
||||||
|
protected override Material GetMaterial()
|
||||||
|
{
|
||||||
|
return m_meshRenderer.sharedMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnUpdate()
|
||||||
|
{
|
||||||
|
if (!meshSource.useTriangleMesh) meshSource.useTriangleMesh = true;
|
||||||
|
if(meshSource.triangleMesh != null && meshSource.triangleMesh.mesh != m_meshFilter.sharedMesh)
|
||||||
|
m_meshFilter.sharedMesh = meshSource.triangleMesh.mesh;
|
||||||
|
m_meshRenderer.SetPropertyBlock(GetMaterialPropertyBlock());
|
||||||
|
base.OnUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDestroy()
|
||||||
|
{
|
||||||
|
if (m_meshFilter != null)
|
||||||
|
{
|
||||||
|
m_meshFilter.hideFlags = HideFlags.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c3101e111365f0e45a87bfedbd25d76d
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,28 @@
|
||||||
|
{
|
||||||
|
"name": "nyc.scatter.depthkit.core.shadergraph",
|
||||||
|
"version": "0.6.1",
|
||||||
|
"displayName": "Depthkit Core Shader Graph",
|
||||||
|
"description": "Use the Depthkit Core Shader Graph Package to render Depthkit captures from Depthkit Core and Depthkit Cinema in Unity’s Scriptable Render Pipeline including High Definition RP and Universal RP. This includes the components to visualize and customize Depthkit captures using Unity’s Shader Graph system.\n\nNote you can only render single-perspective captures with the Depthkit Core packages. For multi-perspective captures, use Depthkit Studio package suite.",
|
||||||
|
"unity": "2022.3",
|
||||||
|
"dependencies": {
|
||||||
|
"nyc.scatter.depthkit.core": "0.14.2",
|
||||||
|
"com.unity.shadergraph": "14.0.9"
|
||||||
|
},
|
||||||
|
"samples": [
|
||||||
|
{
|
||||||
|
"displayName": "Prefabs - Depthkit Core Shader Graph",
|
||||||
|
"description": "Prefabs for the Scriptable Render Pipelines",
|
||||||
|
"path": "Samples~/Depthkit Core Shader Graph Prefabs"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"keywords": [
|
||||||
|
"Depthkit",
|
||||||
|
"Volumetric",
|
||||||
|
"Scatter"
|
||||||
|
],
|
||||||
|
"author": {
|
||||||
|
"name": "Scatter",
|
||||||
|
"email": "support@depthkit.tv",
|
||||||
|
"url": "https://www.depthkit.tv"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 46adddac66588c1428ec4cef359c7a03
|
||||||
|
PackageManifestImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,77 @@
|
||||||
|
## Changelog
|
||||||
|
|
||||||
|
### 0.14.3
|
||||||
|
* Fix bug where certain fields were not serializing after GUI changes
|
||||||
|
|
||||||
|
### 0.14.2
|
||||||
|
* Update SDK license agreement
|
||||||
|
|
||||||
|
### 0.14.1
|
||||||
|
* Fixed an issue where Built-in RP Looks were not rendering in Unity 2022.3.19
|
||||||
|
|
||||||
|
### 0.14.0
|
||||||
|
* Updated to Unity 2022.3
|
||||||
|
* Better handling of clip reconstruction settings when setting a new metadata asset
|
||||||
|
|
||||||
|
### 0.13.4
|
||||||
|
* Updated assembly definitions.
|
||||||
|
|
||||||
|
### 0.13.3
|
||||||
|
* Fixes a runtime error when disabling and re-enabling a component that uses a Mask Generator
|
||||||
|
* Fixes an issue on Quest 2 where certain compute shaders would fail to link
|
||||||
|
|
||||||
|
### 0.13.2
|
||||||
|
* Bug fixes
|
||||||
|
|
||||||
|
### 0.13.1
|
||||||
|
* Bug fixes
|
||||||
|
|
||||||
|
### 0.13.0
|
||||||
|
* Support new 0.5.0 metadata version with preconfigured texture blending and depth bias compensation settings
|
||||||
|
|
||||||
|
### 0.12.2
|
||||||
|
* Bug fixes
|
||||||
|
|
||||||
|
### 0.12.1
|
||||||
|
* Minor UI updates
|
||||||
|
|
||||||
|
### 0.12.0
|
||||||
|
* Updated to Unity 2020.3
|
||||||
|
* Improved edge masking usability and performance.
|
||||||
|
* Added edge dithering to soften clipped edges.
|
||||||
|
|
||||||
|
### 0.11.1
|
||||||
|
* Updated BiRP Photo Look shader to use light probes by default.
|
||||||
|
* Exposed Disable Main Directional Shadows toggle in BiRP Photo Look shader.
|
||||||
|
|
||||||
|
### 0.11.0
|
||||||
|
* Apply depth bias to depth everywhere depth is sampled.
|
||||||
|
|
||||||
|
### 0.10.2
|
||||||
|
* Allow BiRP looks to use shadows from all light types.
|
||||||
|
|
||||||
|
### 0.10.1
|
||||||
|
* If OpenVR is detected, force single pass instanced stereo rendering mode. A hack to work around OpenVR not reporting to XRSettings.
|
||||||
|
|
||||||
|
### 0.10.0
|
||||||
|
* Allow BiRP light probes
|
||||||
|
* Pause video or data generation on invisible
|
||||||
|
* AVPro 2
|
||||||
|
* Sync collider and triangle mesh to clip bounds
|
||||||
|
|
||||||
|
### 0.9.0
|
||||||
|
* Lifecycle fixes
|
||||||
|
* Allow changing video player from API
|
||||||
|
|
||||||
|
### 0.8.0
|
||||||
|
* Improved GPU resource management and execution order
|
||||||
|
* Added support for material property blocks
|
||||||
|
* Bug fixes
|
||||||
|
|
||||||
|
### 0.6.0
|
||||||
|
* Removed depthkit info from depthkit clip and added depthkit icon to all depthkit components
|
||||||
|
* Added Edge Smoothing Scale to **Core Mesh Source** Component
|
||||||
|
* Reorganized utils files into Utils folder
|
||||||
|
|
||||||
|
### 0.5.1
|
||||||
|
* removed Unity Video Player's component menu
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 11fb57a5eed95f2439c5743f2a1e4ceb
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6ccbc805dc3c70a46a5b7db6bfa86237
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,184 @@
|
||||||
|
/************************************************************************************
|
||||||
|
|
||||||
|
Depthkit Unity SDK License v1
|
||||||
|
Copyright 2016-2024 Simile Inc dba Scatter. All Rights reserved.
|
||||||
|
|
||||||
|
Licensed under the the Simile Inc dba Scatter ("Scatter")
|
||||||
|
Software Development Kit License Agreement (the "License");
|
||||||
|
you may not use this SDK except in compliance with the License,
|
||||||
|
which is provided at the time of installation or download,
|
||||||
|
or which otherwise accompanies this software in either electronic or hard copy form.
|
||||||
|
|
||||||
|
You may obtain a copy of the License at http://www.depthkit.tv/license-agreement-v1
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
the SDK distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Depthkit
|
||||||
|
{
|
||||||
|
[CustomEditor(typeof(Depthkit.Clip))]
|
||||||
|
public class ClipEditor : Editor
|
||||||
|
{
|
||||||
|
bool m_showAdvanced = false;
|
||||||
|
bool m_platformValid = true;
|
||||||
|
List<string> m_invalidReasons = new List<string>();
|
||||||
|
|
||||||
|
void OnEnable()
|
||||||
|
{
|
||||||
|
if(AvailablePlayers.Empty())
|
||||||
|
{
|
||||||
|
AvailablePlayers.UpdatePlayers();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_platformValid = Info.IsPlatformValid(ref m_invalidReasons);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnInspectorGUI()
|
||||||
|
{
|
||||||
|
//update the object with the object variables
|
||||||
|
serializedObject.Update();
|
||||||
|
|
||||||
|
//set the clip var as the target of this inspector
|
||||||
|
Depthkit.Clip clip = (Depthkit.Clip)target;
|
||||||
|
|
||||||
|
if (!m_platformValid)
|
||||||
|
{
|
||||||
|
EditorGUILayout.BeginVertical();
|
||||||
|
GUI.backgroundColor = Color.red;
|
||||||
|
EditorGUILayout.HelpBox("Depthkit Unity Plugin is incompatible with this platform", MessageType.Error);
|
||||||
|
foreach (string reason in m_invalidReasons)
|
||||||
|
{
|
||||||
|
EditorGUILayout.HelpBox(reason, MessageType.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorGUILayout.EndVertical();
|
||||||
|
GUI.backgroundColor = Color.white;
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorGUILayout.BeginVertical("Box");
|
||||||
|
{
|
||||||
|
// PLAYER INFO
|
||||||
|
SetupPlayerGUI(clip);
|
||||||
|
SetupMetadataGUI(clip);
|
||||||
|
SetupPosterGUI(clip);
|
||||||
|
EditorGUILayout.Space();
|
||||||
|
CheckClipSetup(clip);
|
||||||
|
}
|
||||||
|
EditorGUILayout.EndVertical();
|
||||||
|
m_showAdvanced = EditorGUILayout.Foldout(m_showAdvanced, "Advanced Settings");
|
||||||
|
if(m_showAdvanced)
|
||||||
|
{
|
||||||
|
EditorGUILayout.BeginHorizontal();
|
||||||
|
EditorGUILayout.LabelField(new GUIContent("Disable Poster", "Disabling the poster will cause the clip not to show anything unless playing. Disable the poster to control the video player via a Timeline Playable."), GUILayout.Width(EditorGUIUtility.labelWidth));
|
||||||
|
bool disable = clip.disablePoster;
|
||||||
|
bool newDisable = EditorGUILayout.Toggle(disable);
|
||||||
|
if(disable != newDisable)
|
||||||
|
{
|
||||||
|
Undo.RecordObject(clip, "Set Disable Poster");
|
||||||
|
clip.disablePoster = newDisable;
|
||||||
|
EditorUtility.SetDirty(clip);
|
||||||
|
}
|
||||||
|
EditorGUILayout.EndHorizontal();
|
||||||
|
}
|
||||||
|
EditorGUILayout.Space();
|
||||||
|
// APPLY PROPERTY MODIFICATIONS
|
||||||
|
serializedObject.ApplyModifiedProperties();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CheckClipSetup(Depthkit.Clip clip)
|
||||||
|
{
|
||||||
|
if (clip.isSetup)
|
||||||
|
{
|
||||||
|
GUI.backgroundColor = Color.green;
|
||||||
|
EditorGUILayout.BeginVertical();
|
||||||
|
|
||||||
|
EditorGUILayout.HelpBox("Depthkit clip is setup and ready for playback",
|
||||||
|
MessageType.Info);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GUI.backgroundColor = Color.red;
|
||||||
|
EditorGUILayout.BeginVertical();
|
||||||
|
|
||||||
|
EditorGUILayout.HelpBox("Depthkit clip is not setup. \n"
|
||||||
|
+ string.Format("Player Setup: {0} | Metadata Setup: {1}",
|
||||||
|
clip.playerSetup, clip.hasMetadata),
|
||||||
|
MessageType.Error);
|
||||||
|
}
|
||||||
|
EditorGUILayout.EndVertical();
|
||||||
|
GUI.backgroundColor = Color.white;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetupPlayerGUI(Depthkit.Clip clip)
|
||||||
|
{
|
||||||
|
EditorGUILayout.LabelField("Settings", EditorStyles.boldLabel);
|
||||||
|
int choiceIndex = -1;
|
||||||
|
ClipPlayer player = clip.player;
|
||||||
|
|
||||||
|
if(player != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < AvailablePlayers.Types.Count; ++i)
|
||||||
|
{
|
||||||
|
if (AvailablePlayers.Types[i] == player.GetPlayerTypeName())
|
||||||
|
{
|
||||||
|
choiceIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
choiceIndex = AvailablePlayers.DefaultPlayerIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
int finalChoiceIndex = EditorGUILayout.Popup("Player", choiceIndex, AvailablePlayers.PrettyNames.ToArray());
|
||||||
|
|
||||||
|
if (finalChoiceIndex < 0 || finalChoiceIndex >= AvailablePlayers.PrettyNames.Count)
|
||||||
|
finalChoiceIndex = AvailablePlayers.DefaultPlayerIndex;
|
||||||
|
|
||||||
|
if (finalChoiceIndex != choiceIndex)
|
||||||
|
{
|
||||||
|
clip.SetPlayer(Type.GetType(AvailablePlayers.AssemblyNames[finalChoiceIndex]));
|
||||||
|
EditorUtility.SetDirty(clip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetupMetadataGUI(Depthkit.Clip clip)
|
||||||
|
{
|
||||||
|
//TODO other metadata asset types
|
||||||
|
EditorGUI.BeginChangeCheck();
|
||||||
|
TextAsset metadataFile = EditorGUILayout.ObjectField("Metadata", clip.metadataFile, typeof(TextAsset), false) as TextAsset;
|
||||||
|
if(EditorGUI.EndChangeCheck())
|
||||||
|
{
|
||||||
|
Undo.RecordObject(clip, "Set Metadata File");
|
||||||
|
clip.metadataFile = metadataFile;
|
||||||
|
EditorUtility.SetDirty(clip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetupPosterGUI(Depthkit.Clip clip)
|
||||||
|
{
|
||||||
|
Texture2D poster = clip.poster;
|
||||||
|
EditorGUILayout.BeginHorizontal();
|
||||||
|
EditorGUILayout.PrefixLabel("Poster");
|
||||||
|
Texture2D newPoster = EditorGUILayout.ObjectField(poster, typeof(Texture2D), false) as Texture2D;
|
||||||
|
if (poster != newPoster)
|
||||||
|
{
|
||||||
|
Undo.RecordObject(clip, "Set Poster");
|
||||||
|
clip.poster = newPoster;
|
||||||
|
EditorUtility.SetDirty(clip);
|
||||||
|
}
|
||||||
|
EditorGUILayout.EndHorizontal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 09f4cd57574ad9a4b9292f36adba66bd
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"name": "Depthkit.Core.Editor",
|
||||||
|
"references": [
|
||||||
|
"GUID:d757665d4a59fe94bab8bd5391e60e3d"
|
||||||
|
],
|
||||||
|
"includePlatforms": [
|
||||||
|
"Editor"
|
||||||
|
],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": false,
|
||||||
|
"overrideReferences": false,
|
||||||
|
"precompiledReferences": [],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": [],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7ec71480072be074c8f90dd646706fad
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,44 @@
|
||||||
|
/************************************************************************************
|
||||||
|
|
||||||
|
Depthkit Unity SDK License v1
|
||||||
|
Copyright 2016-2024 Simile Inc dba Scatter. All Rights reserved.
|
||||||
|
|
||||||
|
Licensed under the the Simile Inc dba Scatter ("Scatter")
|
||||||
|
Software Development Kit License Agreement (the "License");
|
||||||
|
you may not use this SDK except in compliance with the License,
|
||||||
|
which is provided at the time of installation or download,
|
||||||
|
or which otherwise accompanies this software in either electronic or hard copy form.
|
||||||
|
|
||||||
|
You may obtain a copy of the License at http://www.depthkit.tv/license-agreement-v1
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
the SDK distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace Depthkit {
|
||||||
|
public static class EditorUtil
|
||||||
|
{
|
||||||
|
public static void ShowEditorComponentLink<T>(T target) where T : MonoBehaviour
|
||||||
|
{
|
||||||
|
GUI.enabled = false;
|
||||||
|
EditorGUILayout.ObjectField("Script", MonoScript.FromMonoBehaviour(target), typeof(T), false);
|
||||||
|
GUI.enabled = true;
|
||||||
|
}
|
||||||
|
public static void DrawUILine(Color color, int thickness = 2, int padding = 10)
|
||||||
|
{
|
||||||
|
Rect r = EditorGUILayout.GetControlRect(GUILayout.Height(padding + thickness));
|
||||||
|
r.height = thickness;
|
||||||
|
r.y += padding / 2;
|
||||||
|
r.x -= 2;
|
||||||
|
r.width += 6;
|
||||||
|
EditorGUI.DrawRect(r, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a1d2cd4e73ea57e4ca92a5d8e18c6a2c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6b28c48544776e74f9c13a6d2eda471e
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,40 @@
|
||||||
|
/************************************************************************************
|
||||||
|
|
||||||
|
Depthkit Unity SDK License v1
|
||||||
|
Copyright 2016-2024 Simile Inc dba Scatter. All Rights reserved.
|
||||||
|
|
||||||
|
Licensed under the the Simile Inc dba Scatter ("Scatter")
|
||||||
|
Software Development Kit License Agreement (the "License");
|
||||||
|
you may not use this SDK except in compliance with the License,
|
||||||
|
which is provided at the time of installation or download,
|
||||||
|
or which otherwise accompanies this software in either electronic or hard copy form.
|
||||||
|
|
||||||
|
You may obtain a copy of the License at http://www.depthkit.tv/license-agreement-v1
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
the SDK distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Depthkit
|
||||||
|
{
|
||||||
|
public class CoreLookGizmosDrawer
|
||||||
|
{
|
||||||
|
[DrawGizmo(GizmoType.Selected | GizmoType.Active)]
|
||||||
|
static void DrawGizmosFor(CoreLook look, GizmoType gizmoType)
|
||||||
|
{
|
||||||
|
if (look.showCameraFrustums)
|
||||||
|
{
|
||||||
|
Depthkit.Util.RenderMetadataGizmos(look.depthkitClip.metadata, look.transform);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 82bf8826e90df0641aef0db261581664
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,87 @@
|
||||||
|
/************************************************************************************
|
||||||
|
|
||||||
|
Depthkit Unity SDK License v1
|
||||||
|
Copyright 2016-2024 Simile Inc dba Scatter. All Rights reserved.
|
||||||
|
|
||||||
|
Licensed under the the Simile Inc dba Scatter ("Scatter")
|
||||||
|
Software Development Kit License Agreement (the "License");
|
||||||
|
you may not use this SDK except in compliance with the License,
|
||||||
|
which is provided at the time of installation or download,
|
||||||
|
or which otherwise accompanies this software in either electronic or hard copy form.
|
||||||
|
|
||||||
|
You may obtain a copy of the License at http://www.depthkit.tv/license-agreement-v1
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
the SDK distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Depthkit
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
public static class AvailablePlayers
|
||||||
|
{
|
||||||
|
static AvailablePlayers()
|
||||||
|
{
|
||||||
|
Types = new List<string>();
|
||||||
|
AssemblyNames = new List<string>();
|
||||||
|
PrettyNames = new List<string>();
|
||||||
|
}
|
||||||
|
public static List<string> Types;
|
||||||
|
public static List<string> PrettyNames;
|
||||||
|
public static List<string> AssemblyNames;
|
||||||
|
public static int DefaultPlayerIndex;
|
||||||
|
|
||||||
|
public static bool Empty(){ return AvailablePlayers.Types.Count == 0; }
|
||||||
|
|
||||||
|
public static void UpdatePlayers()
|
||||||
|
{
|
||||||
|
AvailablePlayers.Types.Clear();
|
||||||
|
AvailablePlayers.PrettyNames.Clear();
|
||||||
|
AvailablePlayers.AssemblyNames.Clear();
|
||||||
|
var players = Reflector.GetDerivedTypeSet<Depthkit.ClipPlayer>();
|
||||||
|
int index = 0;
|
||||||
|
foreach(KeyValuePair<string, string> player in players)
|
||||||
|
{
|
||||||
|
if(player.Key == typeof(Depthkit.UnityVideoPlayer).Name)
|
||||||
|
{
|
||||||
|
AvailablePlayers.DefaultPlayerIndex = index;
|
||||||
|
}
|
||||||
|
Type t = Type.GetType(player.Value);
|
||||||
|
AvailablePlayers.PrettyNames.Add(t.GetMethod("GetPlayerPrettyName").Invoke(null, null) as string);
|
||||||
|
AvailablePlayers.Types.Add(player.Key);
|
||||||
|
AvailablePlayers.AssemblyNames.Add(player.Value);
|
||||||
|
++index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Depthkit_PlayerProcessor : UnityEditor.AssetModificationProcessor
|
||||||
|
{
|
||||||
|
public static string[] OnWillSaveAssets(string[] paths)
|
||||||
|
{
|
||||||
|
AvailablePlayers.UpdatePlayers();
|
||||||
|
return paths;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void OnWillCreateAsset(string name)
|
||||||
|
{
|
||||||
|
AvailablePlayers.UpdatePlayers();
|
||||||
|
}
|
||||||
|
|
||||||
|
static AssetDeleteResult OnWillDeleteAsset(string name, RemoveAssetOptions options)
|
||||||
|
{
|
||||||
|
AvailablePlayers.UpdatePlayers();
|
||||||
|
return AssetDeleteResult.DidNotDelete;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 689c86c2b7116384fb4aa20757e5e5e5
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: aba3d1fb25ad3d74fa223dc39e209f56
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,233 @@
|
||||||
|
/************************************************************************************
|
||||||
|
|
||||||
|
Depthkit Unity SDK License v1
|
||||||
|
Copyright 2016-2024 Simile Inc dba Scatter. All Rights reserved.
|
||||||
|
|
||||||
|
Licensed under the the Simile Inc dba Scatter ("Scatter")
|
||||||
|
Software Development Kit License Agreement (the "License");
|
||||||
|
you may not use this SDK except in compliance with the License,
|
||||||
|
which is provided at the time of installation or download,
|
||||||
|
or which otherwise accompanies this software in either electronic or hard copy form.
|
||||||
|
|
||||||
|
You may obtain a copy of the License at http://www.depthkit.tv/license-agreement-v1
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
the SDK distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace Depthkit
|
||||||
|
{
|
||||||
|
[CustomEditor(typeof(Depthkit.CoreMeshSource))]
|
||||||
|
public class CoreMeshSourceEditor : Editor
|
||||||
|
{
|
||||||
|
private bool m_showAdvanced = false;
|
||||||
|
private bool m_showRelighting = false;
|
||||||
|
private static MeshDensity s_maskScale;
|
||||||
|
|
||||||
|
SerializedProperty adjustableNormalSlope;
|
||||||
|
SerializedProperty normalGenerationTechnique;
|
||||||
|
SerializedProperty pauseDataGenerationWhenInvisible;
|
||||||
|
SerializedProperty pausePlayerWhenInvisible;
|
||||||
|
SerializedProperty radialBias;
|
||||||
|
|
||||||
|
public static readonly GUIContent s_meshDensityLabel = new GUIContent("Mesh Density", "Adjust the density of the Depthkit mesh. Higher values capture more detail and have cleaner edges at the cost of performance.");
|
||||||
|
public static readonly GUIContent s_maxSurfaceTrianglesLabel = new GUIContent("Surface Buffer Capacity", "This value determines the maximum number of triangles that can be displayed for each frame of this Clip. Each frame will have a variable size mesh based on the shape of its contents. A higher number ensures that no part of the surface is every excluded and allocates a larger memory footprint.");
|
||||||
|
public static readonly GUIContent s_normalGenTechniqueLabel = new GUIContent("Normal Generation Technique", "This is the algorithm used to generate normals. Flat is the fastest.");
|
||||||
|
public static readonly GUIContent s_normalSlopeLabel = new GUIContent("Normal Slope", "Adjust the slope of the normal to artificially flatten or sharpen surface normals.");
|
||||||
|
public static readonly GUIContent s_setSurfaceBufferCapLabel = new GUIContent("Set Surface Buffer Capacity", "Use this button to sample the current frame to set a reasonable Surface Buffer Capacity tailored to your content.");
|
||||||
|
public static readonly GUIContent s_setSurfaceBufferCapSliderLabel = new GUIContent("Surface Buffer Capacity (% of max)", "Use this slider to adjust Surface Buffer Capacity as a percentage of the maximum triangles needed for your content.");
|
||||||
|
public static readonly GUIContent s_radialBiasLabel = new GUIContent("Depth Bias Compensation", "Time of Flight cameras measure surfaces farther away than they are in reality. The amount of bias depends greatly on the material of the surface being measured. Skin in particular has a large bias. The Depth Bias Compensation is a correction for this error by pulling the surface back towards their true depth. It most useful for recovering high quality faces and hands on otherwise well-calibrated captures. The larger the value, the larger the compensation. 0 means no depth bias compensation is applied.");
|
||||||
|
|
||||||
|
public static readonly GUIContent s_ditherEdgeLabel = new GUIContent("Dither Edge", "");
|
||||||
|
|
||||||
|
MaskGeneratorGUI m_maskGeneratorGui;
|
||||||
|
|
||||||
|
void OnEnable()
|
||||||
|
{
|
||||||
|
pauseDataGenerationWhenInvisible = serializedObject.FindProperty("pauseDataGenerationWhenInvisible");
|
||||||
|
pausePlayerWhenInvisible = serializedObject.FindProperty("pausePlayerWhenInvisible");
|
||||||
|
radialBias = serializedObject.FindProperty("radialBias");
|
||||||
|
normalGenerationTechnique = serializedObject.FindProperty("normalGenerationTechnique");
|
||||||
|
adjustableNormalSlope = serializedObject.FindProperty("adjustableNormalSlope");
|
||||||
|
|
||||||
|
if(m_maskGeneratorGui == null)
|
||||||
|
{
|
||||||
|
m_maskGeneratorGui = new MaskGeneratorGUI();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDisable()
|
||||||
|
{
|
||||||
|
m_maskGeneratorGui?.Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Check(CoreMeshSource source)
|
||||||
|
{
|
||||||
|
if (GUI.changed)
|
||||||
|
{
|
||||||
|
EditorUtility.SetDirty(source);
|
||||||
|
GUI.changed = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Check(CoreMeshSource source, ref bool resize)
|
||||||
|
{
|
||||||
|
if (Check(source))
|
||||||
|
{
|
||||||
|
resize = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Check(CoreMeshSource source, ref bool resize, ref bool generate)
|
||||||
|
{
|
||||||
|
if (Check(source, ref resize))
|
||||||
|
{
|
||||||
|
generate = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool ValidateMeshDensity(System.Enum md)
|
||||||
|
{
|
||||||
|
return s_maskScale <= (MeshDensity)md;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void MeshSettingsGUI(ref CoreMeshSource meshSource, ref bool doResize, ref bool doGenerate)
|
||||||
|
{
|
||||||
|
// save mask scale to static so it can be used in the validator function wrt downscale
|
||||||
|
s_maskScale = (MeshDensity)meshSource.maskGenerator.scale;
|
||||||
|
meshSource.meshDensity = (MeshDensity)EditorGUILayout.EnumPopup(s_meshDensityLabel, meshSource.meshDensity, ValidateMeshDensity, false);
|
||||||
|
Check(meshSource, ref doResize, ref doGenerate);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ResizeTriangleMeshGUI(ref CoreMeshSource meshSource, uint submeshIndex, ref bool doResize, ref bool doGenerate)
|
||||||
|
{
|
||||||
|
if (meshSource.useTriangleMesh)
|
||||||
|
{
|
||||||
|
if (GUILayout.Button(s_setSurfaceBufferCapLabel))
|
||||||
|
{
|
||||||
|
meshSource.recalculateCurrentSurfaceTriangleCount = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
GUI.enabled = !meshSource.recalculateCurrentSurfaceTriangleCount;
|
||||||
|
uint originalIndex = meshSource.currentSubmeshIndex;
|
||||||
|
meshSource.currentSubmeshIndex = submeshIndex;
|
||||||
|
float percent = (float)EditorGUILayout.Slider(s_setSurfaceBufferCapSliderLabel, meshSource.surfaceTriangleCountPercent*100, 0.0f, 100.0f)/100.0f;
|
||||||
|
if( percent != meshSource.surfaceTriangleCountPercent)
|
||||||
|
{
|
||||||
|
meshSource.maxSurfaceTriangles = (uint)( percent * (float)meshSource.latticeMaxTriangles);
|
||||||
|
meshSource.surfaceTriangleCountPercent = percent;
|
||||||
|
}
|
||||||
|
GUI.enabled = false;
|
||||||
|
EditorGUILayout.IntField(s_maxSurfaceTrianglesLabel, (int)meshSource.maxSurfaceTriangles);
|
||||||
|
GUI.enabled = true;
|
||||||
|
Check(meshSource, ref doResize, ref doGenerate);
|
||||||
|
meshSource.currentSubmeshIndex = originalIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RelightingGUI(ref bool show, ref SerializedProperty technique, ref SerializedProperty slope, ref bool doResize, ref bool doGenerate)
|
||||||
|
{
|
||||||
|
show = EditorGUILayout.Foldout(show, "Normal Generation Settings");
|
||||||
|
if (show)
|
||||||
|
{
|
||||||
|
EditorGUILayout.PropertyField(technique, s_normalGenTechniqueLabel);
|
||||||
|
if (GUI.changed)
|
||||||
|
{
|
||||||
|
doResize = true;
|
||||||
|
doGenerate = true;
|
||||||
|
GUI.changed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
NormalGenerationTechnique normalTechnique = (NormalGenerationTechnique)technique.enumValueIndex;
|
||||||
|
|
||||||
|
if (normalTechnique == NormalGenerationTechnique.Adjustable ||
|
||||||
|
normalTechnique == NormalGenerationTechnique.AdjustableSmoother)
|
||||||
|
{
|
||||||
|
EditorGUILayout.PropertyField(slope, s_normalSlopeLabel);
|
||||||
|
if (GUI.changed)
|
||||||
|
{
|
||||||
|
doGenerate = true;
|
||||||
|
GUI.changed = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnInspectorGUI()
|
||||||
|
{
|
||||||
|
Depthkit.CoreMeshSource meshSource = target as Depthkit.CoreMeshSource;
|
||||||
|
bool doGenerate = false;
|
||||||
|
bool doResize = false;
|
||||||
|
|
||||||
|
serializedObject.Update();
|
||||||
|
MeshSettingsGUI(ref meshSource, ref doResize, ref doGenerate);
|
||||||
|
ResizeTriangleMeshGUI(ref meshSource, 0, ref doResize, ref doGenerate);
|
||||||
|
RelightingGUI(ref m_showRelighting, ref normalGenerationTechnique, ref adjustableNormalSlope, ref doResize, ref doGenerate);
|
||||||
|
|
||||||
|
EditorGUI.BeginChangeCheck();
|
||||||
|
|
||||||
|
meshSource.clipThreshold = EditorGUILayout.Slider("Clipping Threshold", meshSource.clipThreshold, 0.0f, 1.0f);
|
||||||
|
|
||||||
|
bool ditherEdge = meshSource.ditherEdge;
|
||||||
|
ditherEdge = EditorGUILayout.Toggle(s_ditherEdgeLabel, ditherEdge);
|
||||||
|
|
||||||
|
if (ditherEdge != meshSource.ditherEdge)
|
||||||
|
{
|
||||||
|
meshSource.ditherEdge = ditherEdge;
|
||||||
|
}
|
||||||
|
if (meshSource.ditherEdge)
|
||||||
|
{
|
||||||
|
meshSource.ditherWidth = EditorGUILayout.Slider("Dithering Width", meshSource.ditherWidth, 0.0f, 0.2f);
|
||||||
|
}
|
||||||
|
if (EditorGUI.EndChangeCheck())
|
||||||
|
{
|
||||||
|
doGenerate = true;
|
||||||
|
EditorUtility.SetDirty(meshSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_maskGeneratorGui.MaskGui(ref meshSource.maskGenerator, meshSource.meshDensity, ref doGenerate);
|
||||||
|
Check(meshSource);
|
||||||
|
|
||||||
|
m_showAdvanced = EditorGUILayout.Foldout(m_showAdvanced, "Advanced Settings");
|
||||||
|
if (m_showAdvanced)
|
||||||
|
{
|
||||||
|
EditorGUI.BeginChangeCheck();
|
||||||
|
|
||||||
|
EditorGUILayout.PropertyField(radialBias, s_radialBiasLabel);
|
||||||
|
meshSource.edgeCompressionNoiseThreshold = EditorGUILayout.Slider("Edge Compression Noise Threshold", meshSource.edgeCompressionNoiseThreshold, 0.0f, 1.0f);
|
||||||
|
EditorGUILayout.PropertyField(pausePlayerWhenInvisible);
|
||||||
|
EditorGUILayout.PropertyField(pauseDataGenerationWhenInvisible);
|
||||||
|
|
||||||
|
if (EditorGUI.EndChangeCheck())
|
||||||
|
{
|
||||||
|
doGenerate = true;
|
||||||
|
EditorUtility.SetDirty(meshSource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
serializedObject.ApplyModifiedProperties();
|
||||||
|
|
||||||
|
if (doResize)
|
||||||
|
{
|
||||||
|
meshSource.Resize();
|
||||||
|
}
|
||||||
|
if (doGenerate)
|
||||||
|
{
|
||||||
|
m_maskGeneratorGui.MarkDirty();
|
||||||
|
meshSource.Generate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c22cb842fc788774cb0ce85d7280d961
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,214 @@
|
||||||
|
/************************************************************************************
|
||||||
|
|
||||||
|
Depthkit Unity SDK License v1
|
||||||
|
Copyright 2016-2024 Simile Inc dba Scatter. All Rights reserved.
|
||||||
|
|
||||||
|
Licensed under the the Simile Inc dba Scatter ("Scatter")
|
||||||
|
Software Development Kit License Agreement (the "License");
|
||||||
|
you may not use this SDK except in compliance with the License,
|
||||||
|
which is provided at the time of installation or download,
|
||||||
|
or which otherwise accompanies this software in either electronic or hard copy form.
|
||||||
|
|
||||||
|
You may obtain a copy of the License at http://www.depthkit.tv/license-agreement-v1
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
the SDK distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Depthkit
|
||||||
|
{
|
||||||
|
public class MaskGeneratorGUI
|
||||||
|
{
|
||||||
|
RenderTexture[] m_arrayTextures = null;
|
||||||
|
RenderTexture[] m_arrayDownscaledTextures = null;
|
||||||
|
bool m_filled = false;
|
||||||
|
float m_scale = 0.5f;
|
||||||
|
private static MeshDensity s_meshDensity;
|
||||||
|
|
||||||
|
private bool m_showTextures = false;
|
||||||
|
|
||||||
|
public static readonly GUIContent s_maskScaleLabel = new GUIContent("Down Scale", "Adjust the scale of the mask. Higher values capture more detail and have cleaner edges at the cost of performance.");
|
||||||
|
public static readonly GUIContent s_edgeMaskSobelStrengthLabel = new GUIContent("Intensity", "Corrects texture spill between surfaces, such as fragments of hands appearing on clothing.");
|
||||||
|
public static readonly GUIContent s_edgeMaskBlurRadiusLabel = new GUIContent("Feather", "Softens texture spill correction. Needs to be adjusted visually and varies based on the Texture Spill Correction Intensity applied above.");
|
||||||
|
public static readonly GUIContent s_previewMaskOnGeoLabel = new GUIContent("Debug Edge Mask", "Debug view of the mask generated per perspective for precise edge masking adjustments.");
|
||||||
|
|
||||||
|
public static bool ValidateMeshDensity(System.Enum md)
|
||||||
|
{
|
||||||
|
return s_meshDensity >= (MeshDensity)md;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MaskGui(ref MaskGenerator maskGenerator, MeshDensity meshDensity, ref bool doGenerate, bool drawBox=false)
|
||||||
|
{
|
||||||
|
if (drawBox)
|
||||||
|
{
|
||||||
|
EditorGUILayout.BeginVertical("Box");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EditorGUILayout.Space();
|
||||||
|
EditorUtil.DrawUILine(Color.gray, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorGUI.BeginChangeCheck();
|
||||||
|
|
||||||
|
bool previewMaskOnGeo = maskGenerator.enableMaskDebug;
|
||||||
|
previewMaskOnGeo = EditorGUILayout.Toggle(s_previewMaskOnGeoLabel, previewMaskOnGeo);
|
||||||
|
if (previewMaskOnGeo != maskGenerator.enableMaskDebug)
|
||||||
|
{
|
||||||
|
maskGenerator.enableMaskDebug = previewMaskOnGeo;
|
||||||
|
}
|
||||||
|
|
||||||
|
s_meshDensity = meshDensity;
|
||||||
|
MeshDensity d = (MeshDensity)EditorGUILayout.EnumPopup(s_maskScaleLabel, (MeshDensity)maskGenerator.scale, ValidateMeshDensity, false);
|
||||||
|
if (maskGenerator.scale != (int)d)
|
||||||
|
{
|
||||||
|
maskGenerator.scale = (int)d;
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorGUILayout.LabelField("Texture Spill Correction", EditorStyles.boldLabel);
|
||||||
|
EditorGUILayout.BeginVertical("Box");
|
||||||
|
maskGenerator.sobelMultiplier = EditorGUILayout.Slider(s_edgeMaskSobelStrengthLabel, maskGenerator.sobelMultiplier, 0.0f, 100.0f);
|
||||||
|
maskGenerator.blurRadius = EditorGUILayout.Slider(s_edgeMaskBlurRadiusLabel, maskGenerator.blurRadius, 0.0f, 0.1f);
|
||||||
|
EditorGUILayout.EndVertical();
|
||||||
|
|
||||||
|
if (EditorGUI.EndChangeCheck())
|
||||||
|
{
|
||||||
|
doGenerate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
PreviewGUI(ref m_showTextures, ref maskGenerator, false);
|
||||||
|
|
||||||
|
if (drawBox)
|
||||||
|
{
|
||||||
|
EditorGUILayout.EndVertical();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EditorUtil.DrawUILine(Color.gray, 1);
|
||||||
|
EditorGUILayout.Space();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MarkDirty()
|
||||||
|
{
|
||||||
|
m_filled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReleaseTexture(ref RenderTexture[] textures)
|
||||||
|
{
|
||||||
|
if (textures != null)
|
||||||
|
{
|
||||||
|
foreach (var tex in textures)
|
||||||
|
{
|
||||||
|
if (tex == null) continue;
|
||||||
|
tex.Release();
|
||||||
|
Object.DestroyImmediate(tex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
textures = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Release()
|
||||||
|
{
|
||||||
|
ReleaseTexture(ref m_arrayTextures);
|
||||||
|
ReleaseTexture(ref m_arrayDownscaledTextures);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PreviewGUI(ref bool show, ref MaskGenerator maskGenerator, bool showDownscaled)
|
||||||
|
{
|
||||||
|
show = EditorGUILayout.Foldout(show, "Edge Mask Preview");
|
||||||
|
if (show)
|
||||||
|
{
|
||||||
|
if (maskGenerator.maskTexture != null)
|
||||||
|
{
|
||||||
|
m_scale = EditorGUILayout.Slider("Preview Scale", m_scale, 0.0001f, 1.0f);
|
||||||
|
GUI.enabled = false;
|
||||||
|
EditorGUILayout.Vector2Field("Mask Dimensions", new Vector2(maskGenerator.maskTexture.width, maskGenerator.maskTexture.height));
|
||||||
|
GUI.enabled = true;
|
||||||
|
switch (maskGenerator.maskTexture.dimension)
|
||||||
|
{
|
||||||
|
case UnityEngine.Rendering.TextureDimension.Tex2D:
|
||||||
|
GUILayout.Label(maskGenerator.maskTexture, GUILayout.Height(maskGenerator.maskTexture.height * m_scale));
|
||||||
|
break;
|
||||||
|
case UnityEngine.Rendering.TextureDimension.Tex2DArray:
|
||||||
|
{
|
||||||
|
if (!m_filled)
|
||||||
|
{
|
||||||
|
// Mask
|
||||||
|
if (m_arrayTextures == null || m_arrayTextures.Length != maskGenerator.maskTexture.volumeDepth)
|
||||||
|
{
|
||||||
|
if (m_arrayTextures != null)
|
||||||
|
{
|
||||||
|
foreach (var tex in m_arrayTextures)
|
||||||
|
{
|
||||||
|
tex.Release();
|
||||||
|
Object.DestroyImmediate(tex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_arrayTextures = new RenderTexture[maskGenerator.maskTexture.volumeDepth];
|
||||||
|
}
|
||||||
|
for (int i = 0; i < maskGenerator.maskTexture.volumeDepth; ++i)
|
||||||
|
{
|
||||||
|
RenderTexture tempTexture = new RenderTexture(maskGenerator.maskTexture.width, maskGenerator.maskTexture.height, 0, maskGenerator.maskTexture.format, 0);
|
||||||
|
tempTexture.Create();
|
||||||
|
Graphics.CopyTexture(maskGenerator.maskTexture, i, tempTexture, 0);
|
||||||
|
if (m_arrayTextures[i] != null)
|
||||||
|
{
|
||||||
|
m_arrayTextures[i].Release();
|
||||||
|
}
|
||||||
|
m_arrayTextures[i] = tempTexture;
|
||||||
|
}
|
||||||
|
if (showDownscaled)
|
||||||
|
{
|
||||||
|
// Downscaled Mask
|
||||||
|
if (m_arrayDownscaledTextures == null || m_arrayDownscaledTextures.Length != maskGenerator.downScaledMaskTexture.volumeDepth)
|
||||||
|
{
|
||||||
|
if (m_arrayDownscaledTextures != null)
|
||||||
|
{
|
||||||
|
foreach (var tex in m_arrayDownscaledTextures)
|
||||||
|
{
|
||||||
|
tex.Release();
|
||||||
|
Object.DestroyImmediate(tex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_arrayDownscaledTextures = new RenderTexture[maskGenerator.downScaledMaskTexture.volumeDepth];
|
||||||
|
}
|
||||||
|
for (int i = 0; i < maskGenerator.downScaledMaskTexture.volumeDepth; ++i)
|
||||||
|
{
|
||||||
|
RenderTexture tempTexture = new RenderTexture(maskGenerator.downScaledMaskTexture.width, maskGenerator.downScaledMaskTexture.height, 0, maskGenerator.downScaledMaskTexture.format, 0);
|
||||||
|
tempTexture.Create();
|
||||||
|
Graphics.CopyTexture(maskGenerator.downScaledMaskTexture, i, tempTexture, 0);
|
||||||
|
if (m_arrayDownscaledTextures[i] != null)
|
||||||
|
{
|
||||||
|
m_arrayDownscaledTextures[i].Release();
|
||||||
|
}
|
||||||
|
m_arrayDownscaledTextures[i] = tempTexture;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_filled = true;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < m_arrayTextures.Length; ++i)
|
||||||
|
{
|
||||||
|
GUILayout.Label(m_arrayTextures[i], GUILayout.Height(maskGenerator.maskTexture.height * m_scale));
|
||||||
|
if (showDownscaled) GUILayout.Label(m_arrayDownscaledTextures[i], GUILayout.Height(maskGenerator.downScaledMaskTexture.height * m_scale));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_filled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 211f4bdd9821d554cb67ae02e926e266
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
|
@ -0,0 +1,92 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 42c51ff9981f3e24b83cd7ad3c56e235
|
||||||
|
TextureImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 11
|
||||||
|
mipmaps:
|
||||||
|
mipMapMode: 0
|
||||||
|
enableMipMap: 1
|
||||||
|
sRGBTexture: 1
|
||||||
|
linearTexture: 0
|
||||||
|
fadeOut: 0
|
||||||
|
borderMipMap: 0
|
||||||
|
mipMapsPreserveCoverage: 0
|
||||||
|
alphaTestReferenceValue: 0.5
|
||||||
|
mipMapFadeDistanceStart: 1
|
||||||
|
mipMapFadeDistanceEnd: 3
|
||||||
|
bumpmap:
|
||||||
|
convertToNormalMap: 0
|
||||||
|
externalNormalMap: 0
|
||||||
|
heightScale: 0.25
|
||||||
|
normalMapFilter: 0
|
||||||
|
isReadable: 0
|
||||||
|
streamingMipmaps: 0
|
||||||
|
streamingMipmapsPriority: 0
|
||||||
|
grayScaleToAlpha: 0
|
||||||
|
generateCubemap: 6
|
||||||
|
cubemapConvolution: 0
|
||||||
|
seamlessCubemap: 0
|
||||||
|
textureFormat: 1
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
filterMode: -1
|
||||||
|
aniso: -1
|
||||||
|
mipBias: -100
|
||||||
|
wrapU: -1
|
||||||
|
wrapV: -1
|
||||||
|
wrapW: -1
|
||||||
|
nPOTScale: 1
|
||||||
|
lightmap: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
spriteMode: 0
|
||||||
|
spriteExtrude: 1
|
||||||
|
spriteMeshType: 1
|
||||||
|
alignment: 0
|
||||||
|
spritePivot: {x: 0.5, y: 0.5}
|
||||||
|
spritePixelsToUnits: 100
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
spriteGenerateFallbackPhysicsShape: 1
|
||||||
|
alphaUsage: 1
|
||||||
|
alphaIsTransparency: 0
|
||||||
|
spriteTessellationDetail: -1
|
||||||
|
textureType: 0
|
||||||
|
textureShape: 1
|
||||||
|
singleChannelComponent: 0
|
||||||
|
maxTextureSizeSet: 0
|
||||||
|
compressionQualitySet: 0
|
||||||
|
textureFormatSet: 0
|
||||||
|
applyGammaDecoding: 0
|
||||||
|
platformSettings:
|
||||||
|
- serializedVersion: 3
|
||||||
|
buildTarget: DefaultTexturePlatform
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
spriteSheet:
|
||||||
|
serializedVersion: 2
|
||||||
|
sprites: []
|
||||||
|
outline: []
|
||||||
|
physicsShape: []
|
||||||
|
bones: []
|
||||||
|
spriteID:
|
||||||
|
internalID: 0
|
||||||
|
vertices: []
|
||||||
|
indices:
|
||||||
|
edges: []
|
||||||
|
weights: []
|
||||||
|
secondaryTextures: []
|
||||||
|
spritePackingTag:
|
||||||
|
pSDRemoveMatte: 0
|
||||||
|
pSDShowRemoveMatteOption: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,138 @@
|
||||||
|
SOFTWARE DEVELOPMENT KIT LICENSE AGREEMENT
|
||||||
|
|
||||||
|
The text of this license (this “License”) may be found at: www.depthkit.tv/license-agreement-v1
|
||||||
|
|
||||||
|
Thank you for your interest in using the Simile Inc dba Scatter ("Scatter") Software Development Kit (the "SDK").
|
||||||
|
In order to obtain and use the SDK, you must first agree to the terms of this License. If you do not agree to the
|
||||||
|
terms of this License, then you may not use the SDK.
|
||||||
|
|
||||||
|
SDK LICENSE
|
||||||
|
1. Subject to the terms and conditions of this License, Scatter hereby
|
||||||
|
grants to you a worldwide, non-exclusive, royalty-free, sublicenseable license to use, reproduce, modify,
|
||||||
|
embed and redistribute (subject to restrictions below) the software contained in the SDK, including, but
|
||||||
|
not limited to, the samples, headers, documentation and source code. This License is subject to the
|
||||||
|
following terms and conditions:
|
||||||
|
1.1 This license grants you the non-exclusive license and right to use the SDK to develop
|
||||||
|
methods to play back content produced in the software suite known as Depth Kit (such content referred
|
||||||
|
to as your “Content”) in the Unity game engine, as well as other features that may be added from time to
|
||||||
|
time by Scatter. You may not use the SDK to connect Depth Kit to any software platform or game engine
|
||||||
|
other than Unity.
|
||||||
|
1.2 For avoidance of doubt, when you use the SDK in or with your Content, you retain all
|
||||||
|
rights to your Content, and you have no obligations to share or license your Content (including your
|
||||||
|
source and object code) to Scatter or any third parties; provided, however, Scatter retains all rights to the
|
||||||
|
SDK and the headers, libraries and APIs of Depth Kit and other tools made available by Scatter, including
|
||||||
|
those that may be incorporated into your Content by virtue of your producing it through Depth Kit.
|
||||||
|
1.3 You agree not to commit any act intended to (a) interfere with the normal operation of
|
||||||
|
Depth Kit or the SDK, (b) provide software to Depth Kit users or developers that would induce breach of
|
||||||
|
any Scatter agreements, or (c) provide software to Scatter or Depth Kit users that contains malware,
|
||||||
|
viruses, hacks, bots, Trojan horses, or other malicious code.
|
||||||
|
1.4 You may not use the SDK for any purpose not expressly permitted by this License. You
|
||||||
|
may not:
|
||||||
|
|
||||||
|
a. decompile;
|
||||||
|
b. reverse engineer;
|
||||||
|
c. disassemble; or
|
||||||
|
d. attempt to derive the source code of any part of the SDK where source code is
|
||||||
|
not directly provided to you, or any other software or firmware provided to you by Scatter in binary
|
||||||
|
form (except as and only to the extent any foregoing restriction is prohibited by applicable law).
|
||||||
|
|
||||||
|
REDISTRIBUTION
|
||||||
|
2. Subject to the terms and conditions of this License, your license to redistribute and sublicense the SDK
|
||||||
|
is also expressly made subject to the following conditions:
|
||||||
|
2.1 You may sublicense and redistribute the binary or object code form of the SDK in whole
|
||||||
|
for no charge or as part of a for-charge piece of Content; provided, however, you may only license,
|
||||||
|
sublicense or redistribute the binary or object code of the SDK (and not the SDK’s source code) in its
|
||||||
|
entirety. The SDK, including its associated libraries, and your Content that includes any portion of the
|
||||||
|
SDK, may only be used with Depth Kit and may not be used, licensed, or sublicensed to interface with
|
||||||
|
software that is not authorized and approved by Scatter;
|
||||||
|
2.2 You must include with all such redistributed or sublicensed SDK code the following copyright
|
||||||
|
notice: “Copyright 2016-2024 Simile Inc dba Scatter. All rights reserved.”;
|
||||||
|
2.3 You must give any other recipients of the SDK a copy of this License as such recipients,
|
||||||
|
licensees or sublicensees may only use the SDK subject to the terms of this License and such recipient's,
|
||||||
|
licensee's or sublicensee's agreement to and acceptance of this License with Scatter; and
|
||||||
|
2.4 The SDK includes a “LICENSE” text file (the “License Notice”), and any SDK distribution that
|
||||||
|
you distribute must include a copy of this License with the License Notice.
|
||||||
|
|
||||||
|
GENERAL PROVISIONS
|
||||||
|
3. Additional Materials
|
||||||
|
3.1 Scatter may include in this SDK additional content (e.g., samples) for demonstration,
|
||||||
|
references or other specific purposes. Such content will be clearly marked in the SDK and is subject to
|
||||||
|
any included terms and conditions.
|
||||||
|
3.2 Your use of third-party materials included in the SDK, or which the SDK may be dependent
|
||||||
|
upon (including without limitation Unity), may be subject to other terms and conditions typically found in
|
||||||
|
separate third-party license agreements or "READ ME" files included with such third-party materials. To
|
||||||
|
the extent such other terms and conditions conflict with the terms and conditions of this License, the
|
||||||
|
former will control with respect to the applicable third-party materials. The terms of licensing the Unity
|
||||||
|
game engine can be found here: https://unity3d.com/legal/terms-of-service/software.
|
||||||
|
4. THE SDK AND ANY COMPONENT THEREOF ARE PROVIDED “AS IS” AND ANY EXPRESS OR
|
||||||
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||||
|
EVENT SHALL Scatter AS THE COPYRIGHT OWNER OR ITS CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SDK, EVEN IF
|
||||||
|
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOME JURISDICTIONS DO NOT PERMIT THE
|
||||||
|
EXCLUSION OR LIMITATION OF IMPLIED WARRANTIES, SO YOU MAY HAVE ADDITIONAL
|
||||||
|
RIGHTS.
|
||||||
|
5. This License does not grant permission to use the trade names, trademarks, service marks, or product
|
||||||
|
names of Scatter, including without limitation “Depth Kit,” except as required for reasonable and customary
|
||||||
|
use in describing the origin of the SDK, and reproducing the content of the License Notice file. Scatter
|
||||||
|
reserves all rights not expressly granted to you under this License. Neither Scatter’s name nor the names
|
||||||
|
of Scatter’s contributors, licensors, employees, or contractors, may be used to endorse or promote
|
||||||
|
products developed using the SDK without specific prior written permission of Scatter.
|
||||||
|
6. You are responsible for ensuring that your use of the SDK and your Content complies with all
|
||||||
|
applicable laws (including privacy laws) wherever your Content is made available. You acknowledge and
|
||||||
|
agree that you are solely responsible for any health and safety issues arising from your Content.
|
||||||
|
7. Your acceptance of the terms and conditions of this License in and of itself and for all of your Content
|
||||||
|
may be evidenced by your usage of the SDK or acceptance of this License. As this License is updated for
|
||||||
|
future releases of the SDK, you agree to abide by and meet all requirements of future updates of this
|
||||||
|
License for those future SDK releases, with acceptance evidenced by usage of the SDK or any element
|
||||||
|
thereof and the future updates of this License will apply for your Content that may be developed for or
|
||||||
|
with that future SDK or any element thereof (i.e., you cannot sidestep out of the requirements of future
|
||||||
|
updates of the License by developing against an older release of the SDK or License). You acknowledge
|
||||||
|
that future versions of the SDK may be provided for a fee or otherwise under substantially different terms
|
||||||
|
from those provided hereunder.
|
||||||
|
8. Scatter reserves the right to terminate this License and all your rights hereunder immediately in the
|
||||||
|
event you materially breach this License.
|
||||||
|
9. Furthermore, Scatter also reserves the right to cancel or terminate this License for any of the following
|
||||||
|
reasons:
|
||||||
|
a. Intellectual property infringement by you for your Content that is used with or by
|
||||||
|
the SDK;
|
||||||
|
b. Content that violates applicable law;
|
||||||
|
c. Health and safety issues associated with your Content;
|
||||||
|
d. Use of the SDK with a commercial product other than Depth Kit and Unity; and
|
||||||
|
e. Failure to provide required notices as set forth above.
|
||||||
|
10. You agree to fully indemnify Scatter from any and all losses, costs, damages and expenses (including
|
||||||
|
reasonable attorney's fees) arising out of your Content or any breach of this License.
|
||||||
|
11. Scatter may discontinue or change functionality of Depth Kit or the SDK at any time, and your
|
||||||
|
continued use of Depth Kit or the SDK or use of any modified or additional services in connection
|
||||||
|
therewith is conditioned upon your adherence to the terms of this License, as modified by Scatter from
|
||||||
|
time to time, as well as any additional license agreements necessitated by additional features.
|
||||||
|
12. In the event any provision of this License is determined to be invalid, prohibited or unenforceable by a
|
||||||
|
court or other body of competent jurisdiction, this License shall be construed as if such invalid, prohibited
|
||||||
|
or unenforceable provision has been more narrowly drawn so as not to be invalid, prohibited or
|
||||||
|
unenforceable.
|
||||||
|
13. You may not assign any rights or obligations under this License without the advance written consent
|
||||||
|
of Scatter, which may be withheld in its sole discretion. Scatter may assign its rights or obligations under
|
||||||
|
this License in its sole discretion.
|
||||||
|
14. Failure of either party at any time to enforce any of the provisions of this License will not be construed
|
||||||
|
as a waiver of such provisions or in any way affect the validity of this License or parts thereof.
|
||||||
|
15. Your remedies under this License shall be limited to the right to collect money damages, if any, and
|
||||||
|
you hereby waive your right to injunctive or other equitable relief.
|
||||||
|
16. You will comply with all applicable export control laws of the United States and any other applicable
|
||||||
|
governmental authority, including without limitation, the U.S. Export Administration Regulations. You
|
||||||
|
agree that this License and the SDK and accompanying documentation are Scatter's confidential
|
||||||
|
information (and is not publicly available), and you will not use it, disclose it or make it available to others
|
||||||
|
except in accordance with the terms of this License.
|
||||||
|
17. This License shall be governed by the laws of the State of New York, without giving effect to choice of
|
||||||
|
law principles. All disputes relating to this License shall be resolved by binding non-appearance-based
|
||||||
|
arbitration before a single arbitrator in New York County, New York. The arbitration shall be conducted in
|
||||||
|
accordance with the rules and procedures of JAMS then in effect, and the judgment of the arbitrator shall
|
||||||
|
be final and capable of entry in any court of competent jurisdiction. You and Scatter agree to submit to the
|
||||||
|
personal jurisdiction of the courts located within New York County, New York in connection with any
|
||||||
|
entrance of an arbitrator’s judgment or decision or any dispute with respect to the arbitration process or
|
||||||
|
procedure or Scatter’s exercise of its equitable rights or remedies.
|
||||||
|
|
||||||
|
Effective as of October 7, 2016
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 72a16cade0b6ec746abaaf5084eca140
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,2 @@
|
||||||
|
# Depthkit Core
|
||||||
|
Copyright 2021 Scatter All Rights reserved.
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9454e32cc81dce24abdd4429805c2e9b
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9df3aea1edf1acc44bf8fdb17a8ee6b4
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,761 @@
|
||||||
|
/************************************************************************************
|
||||||
|
|
||||||
|
Depthkit Unity SDK License v1
|
||||||
|
Copyright 2016-2024 Simile Inc dba Scatter. All Rights reserved.
|
||||||
|
|
||||||
|
Licensed under the the Simile Inc dba Scatter ("Scatter")
|
||||||
|
Software Development Kit License Agreement (the "License");
|
||||||
|
you may not use this SDK except in compliance with the License,
|
||||||
|
which is provided at the time of installation or download,
|
||||||
|
or which otherwise accompanies this software in either electronic or hard copy form.
|
||||||
|
|
||||||
|
You may obtain a copy of the License at http://www.depthkit.tv/license-agreement-v1
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
the SDK distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace Depthkit
|
||||||
|
{
|
||||||
|
public delegate void ClipEventHandler();
|
||||||
|
|
||||||
|
[ExecuteInEditMode]
|
||||||
|
[DefaultExecutionOrder(-20)]
|
||||||
|
[AddComponentMenu("Depthkit/Depthkit Clip")]
|
||||||
|
public class Clip : MonoBehaviour, IPropertyTransfer
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
internal class PerspectiveDataBuffer : SyncedStructuredBuffer<Depthkit.Metadata.StructuredPerspectiveData>
|
||||||
|
{
|
||||||
|
public PerspectiveDataBuffer(Metadata metadata) :
|
||||||
|
base("Depthkit Perspective Data Buffer", 0, Depthkit.Metadata.FillPersistentMetadataFromPerspectives(metadata.perspectives))
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Events
|
||||||
|
|
||||||
|
//clip specific events
|
||||||
|
public event ClipPlayerEventHandler newFrame;
|
||||||
|
public event ClipPlayerEventHandler newPoster;
|
||||||
|
|
||||||
|
private event DataSourceEventHandler m_newMetadata;
|
||||||
|
public event DataSourceEventHandler newMetadata
|
||||||
|
{
|
||||||
|
add
|
||||||
|
{
|
||||||
|
if (m_newMetadata != null)
|
||||||
|
{
|
||||||
|
foreach (DataSourceEventHandler existingHandler in m_newMetadata.GetInvocationList())
|
||||||
|
{
|
||||||
|
if (existingHandler == value)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_newMetadata += value;
|
||||||
|
}
|
||||||
|
remove
|
||||||
|
{
|
||||||
|
if (m_newMetadata != null)
|
||||||
|
{
|
||||||
|
foreach (DataSourceEventHandler existingHandler in m_newMetadata.GetInvocationList())
|
||||||
|
{
|
||||||
|
if (existingHandler == value)
|
||||||
|
{
|
||||||
|
m_newMetadata -= value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnNewFrame()
|
||||||
|
{
|
||||||
|
if (newFrame != null) { newFrame(); }
|
||||||
|
}
|
||||||
|
protected virtual void OnNewMetadata()
|
||||||
|
{
|
||||||
|
if (m_newMetadata != null) { m_newMetadata(); }
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
UnityEditor.EditorApplication.QueuePlayerLoopUpdate();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
protected virtual void OnNewPoster()
|
||||||
|
{
|
||||||
|
if (newPoster != null) { newPoster(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Depthkit.PlayerEvents playerEvents
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
return player.events;
|
||||||
|
}
|
||||||
|
Debug.LogError("Unable to access events as player is currently null");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Metadata
|
||||||
|
|
||||||
|
public enum MetadataSourceType
|
||||||
|
{
|
||||||
|
TextAsset,
|
||||||
|
FilePath,
|
||||||
|
StreamingAssetPath,
|
||||||
|
JSONString
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The metadata path. Can be relative to StreamingAssets.</summary>
|
||||||
|
[Tooltip("The path to your metadata file. Can be relative to StreamingAssets.")]
|
||||||
|
[SerializeField]
|
||||||
|
private string m_metadataFilePath;
|
||||||
|
public string metadataFilePath
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_metadataFilePath;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
string metaDataJson;
|
||||||
|
string path;
|
||||||
|
MetadataSourceType type;
|
||||||
|
|
||||||
|
if (File.Exists(value))
|
||||||
|
{
|
||||||
|
metaDataJson = System.IO.File.ReadAllText(value);
|
||||||
|
type = MetadataSourceType.FilePath;
|
||||||
|
path = value;
|
||||||
|
}
|
||||||
|
else if (File.Exists(Path.Combine(Application.streamingAssetsPath, value)))
|
||||||
|
{
|
||||||
|
string relPath = Path.Combine(Application.streamingAssetsPath, value);
|
||||||
|
metaDataJson = System.IO.File.ReadAllText(relPath);
|
||||||
|
type = MetadataSourceType.StreamingAssetPath;
|
||||||
|
path = relPath;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogError("Metadata filepath does not exist: " + value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LoadMetadata(metaDataJson))
|
||||||
|
{
|
||||||
|
m_metadataSourceType = type;
|
||||||
|
m_metadataFilePath = path;
|
||||||
|
OnNewMetadata();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The metadata file text asset that corresponds to a given clip. Setting this asset null will clear the current metadata</summary>
|
||||||
|
[Tooltip("Your metadata TextAsset file, generated when you bring your metadata file anywhere into Unity's Assets/ folder")]
|
||||||
|
[SerializeField]
|
||||||
|
private TextAsset m_metadataFile;
|
||||||
|
public TextAsset metadataFile
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_metadataFile;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value != null)
|
||||||
|
{
|
||||||
|
string metaDataJson = value.text;
|
||||||
|
if (LoadMetadata(metaDataJson))
|
||||||
|
{
|
||||||
|
m_metadataFile = value;
|
||||||
|
m_metadataSourceType = MetadataSourceType.TextAsset;
|
||||||
|
OnNewMetadata();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//setting this asset null, will clear the current metadata
|
||||||
|
m_metadataFile = null;
|
||||||
|
m_metadata = new Metadata();
|
||||||
|
m_perspectiveDataBuffer.Release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The Type of Metadata file you're provided to the Depthkit renderer</summary>
|
||||||
|
[Tooltip("The type of Metadata file you're providing for this clip.")]
|
||||||
|
[SerializeField]
|
||||||
|
private MetadataSourceType m_metadataSourceType = MetadataSourceType.TextAsset;
|
||||||
|
public MetadataSourceType metadataSourceType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return metadataSourceType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
private Depthkit.Metadata m_metadata = null;
|
||||||
|
public Depthkit.Metadata metadata
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_metadata;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool hasMetadata
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_metadata.Valid();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public bool LoadMetadata(string metaDataJson)
|
||||||
|
{
|
||||||
|
if (metaDataJson == "")
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
m_metadata = Depthkit.Metadata.CreateFromJSON(metaDataJson);
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError("Invalid Depthkit Metadata Format. Make sure you are using the proper metadata export from Depthkit.");
|
||||||
|
Debug.LogError(e.Message);
|
||||||
|
m_metadata = new Metadata();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO have the player's subscribe to the clip's event.
|
||||||
|
if (m_player != null)
|
||||||
|
{
|
||||||
|
m_player.OnMetadataUpdated(m_metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_doResizeData = true;
|
||||||
|
m_doGenerateData = true;
|
||||||
|
|
||||||
|
EnsurePerspectiveDataBuffer();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
[SerializeField, HideInInspector]
|
||||||
|
private PerspectiveDataBuffer m_perspectiveDataBuffer;
|
||||||
|
|
||||||
|
private void EnsurePerspectiveDataBuffer()
|
||||||
|
{
|
||||||
|
if (hasMetadata) m_perspectiveDataBuffer = new PerspectiveDataBuffer(m_metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ComputeBuffer perspectiveDataBuffer
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_perspectiveDataBuffer?.buffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Player
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
private Depthkit.ClipPlayer m_player;
|
||||||
|
public Depthkit.ClipPlayer player
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_player;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void CreatePlayer(Type type)
|
||||||
|
{
|
||||||
|
//destroy the components that player references
|
||||||
|
//use a for loop to get around the component potentially shifting in the event of an undo
|
||||||
|
Depthkit.ClipPlayer[] attachedPlayers = GetComponents<Depthkit.ClipPlayer>();
|
||||||
|
for (int i = 0; i < attachedPlayers.Length; i++)
|
||||||
|
{
|
||||||
|
attachedPlayers[i].RemoveComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_player = null;
|
||||||
|
|
||||||
|
m_player = gameObject.AddComponent(type) as Depthkit.ClipPlayer;
|
||||||
|
|
||||||
|
player.CreatePlayer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetPlayer<T>() where T : ClipPlayer
|
||||||
|
{
|
||||||
|
m_lastFrame = -1;
|
||||||
|
|
||||||
|
m_player = gameObject.GetComponent<T>();
|
||||||
|
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CreatePlayer(typeof(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetPlayer(Type type)
|
||||||
|
{
|
||||||
|
m_lastFrame = -1;
|
||||||
|
|
||||||
|
m_player = gameObject.GetComponent(type) as ClipPlayer;
|
||||||
|
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CreatePlayer(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool playerSetup
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_player != null && m_player.IsPlayerSetup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int m_lastFrame = -1;
|
||||||
|
public bool playerIsActive
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (Application.isPlaying || player.IsPlaying()) && isSetup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public uint width
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return playerSetup ? player.GetVideoWidth() : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public uint height
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return playerSetup ? player.GetVideoHeight() : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public GammaCorrection gammaCorrectDepth
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (playerIsActive || disablePoster)
|
||||||
|
{
|
||||||
|
return player.GammaCorrectDepth();
|
||||||
|
}
|
||||||
|
|
||||||
|
return QualitySettings.activeColorSpace == ColorSpace.Linear ? GammaCorrection.LinearToGammaSpace : GammaCorrection.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public GammaCorrection gammaCorrectColor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (playerIsActive || disablePoster) ? player.GammaCorrectColor() : GammaCorrection.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Texture m_currentCPPTexture;
|
||||||
|
public Texture cppTexture
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (!playerIsActive && !disablePoster && player.SupportsPosterFrame())
|
||||||
|
{
|
||||||
|
return poster;
|
||||||
|
}
|
||||||
|
return m_currentCPPTexture;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool textureIsFlipped
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (playerIsActive || disablePoster) ? player.IsTextureFlipped() : false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Poster
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
private Texture2D m_poster;
|
||||||
|
|
||||||
|
public Texture2D poster
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_poster;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_poster = value;
|
||||||
|
if (m_poster != null)
|
||||||
|
{
|
||||||
|
m_doGenerateData = true;
|
||||||
|
OnNewPoster();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
private bool m_disablePoster = false;
|
||||||
|
public bool disablePoster
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_disablePoster;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value != m_disablePoster)
|
||||||
|
{
|
||||||
|
m_disablePoster = value;
|
||||||
|
m_doGenerateData = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region DataSource
|
||||||
|
|
||||||
|
private List<WeakReference> m_dataSourceRoots;
|
||||||
|
|
||||||
|
private bool m_doResizeData = false;
|
||||||
|
private bool m_doGenerateData = false;
|
||||||
|
|
||||||
|
//if the clip doesn't have the generator it will add it
|
||||||
|
public T GetDataSource<T>(bool create = true) where T : Depthkit.DataSource
|
||||||
|
{
|
||||||
|
if (m_dataSourceRoots == null)
|
||||||
|
{
|
||||||
|
ResetDataSources();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_dataSourceRoots.RemoveAll(x => x.Target == null);
|
||||||
|
}
|
||||||
|
|
||||||
|
//check if we already had it cached
|
||||||
|
foreach (var dataSource in m_dataSourceRoots)
|
||||||
|
{
|
||||||
|
var g = dataSource.Target as Depthkit.DataSource;
|
||||||
|
if (g != null)
|
||||||
|
{
|
||||||
|
if (dataSource.Target.GetType().Equals(typeof(T)))
|
||||||
|
{
|
||||||
|
return dataSource.Target as T;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!create) return null;
|
||||||
|
//check if its just not cached yet
|
||||||
|
T gen = gameObject.GetComponent<T>();
|
||||||
|
if (gen == null)
|
||||||
|
{
|
||||||
|
//add it
|
||||||
|
gen = gameObject.AddComponent<T>();
|
||||||
|
gen.ScheduleGenerate();
|
||||||
|
}
|
||||||
|
//cache it
|
||||||
|
m_dataSourceRoots.Add(new WeakReference(gen));
|
||||||
|
return gen;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal bool DoResize()
|
||||||
|
{
|
||||||
|
if (!hasMetadata || cppTexture == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
foreach (var root in m_dataSourceRoots)
|
||||||
|
{
|
||||||
|
var gen = root.Target as Depthkit.DataSource;
|
||||||
|
if (gen != null) gen.Resize();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal bool DoGenerate()
|
||||||
|
{
|
||||||
|
if (!hasMetadata || cppTexture == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var root in m_dataSourceRoots)
|
||||||
|
{
|
||||||
|
var gen = root.Target as Depthkit.DataSource;
|
||||||
|
if (gen != null)
|
||||||
|
{
|
||||||
|
gen.Generate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_dataSourceRoots.RemoveAll(x => x.Target == null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void ResetDataSources()
|
||||||
|
{
|
||||||
|
m_dataSourceRoots = new List<WeakReference>();
|
||||||
|
var datasources = GetComponents<Depthkit.DataSource>();
|
||||||
|
foreach (var gen in datasources)
|
||||||
|
{
|
||||||
|
if (gen.dataSourceParent == "root")
|
||||||
|
{
|
||||||
|
m_dataSourceRoots.Add(new WeakReference(gen));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ShaderProps
|
||||||
|
|
||||||
|
private static readonly float s_edgeChoke = 0.25f;
|
||||||
|
|
||||||
|
internal static class ShaderIds
|
||||||
|
{
|
||||||
|
internal static readonly int
|
||||||
|
_CPPTexture = Shader.PropertyToID("_CPPTexture"),
|
||||||
|
_CPPTexture_TexelSize = Shader.PropertyToID("_CPPTexture_TexelSize"),
|
||||||
|
_EdgeChoke = Shader.PropertyToID("_EdgeChoke"),
|
||||||
|
_TextureFlipped = Shader.PropertyToID("_TextureFlipped"),
|
||||||
|
_ColorSpaceCorrectionDepth = Shader.PropertyToID("_ColorSpaceCorrectionDepth"),
|
||||||
|
_ColorSpaceCorrectionColor = Shader.PropertyToID("_ColorSpaceCorrectionColor"),
|
||||||
|
_PerspectivesCount = Shader.PropertyToID("_PerspectivesCount"),
|
||||||
|
_PerspectivesInX = Shader.PropertyToID("_PerspectivesInX"),
|
||||||
|
_PerspectivesInY = Shader.PropertyToID("_PerspectivesInY"),
|
||||||
|
_PerspectiveDataStructuredBuffer = Shader.PropertyToID("_PerspectiveDataStructuredBuffer");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetProperties(ref ComputeShader compute, int kernel)
|
||||||
|
{
|
||||||
|
if (cppTexture == null) return;
|
||||||
|
compute.SetTexture(kernel, ShaderIds._CPPTexture, cppTexture);
|
||||||
|
compute.SetInt(ShaderIds._TextureFlipped, textureIsFlipped ? 1 : 0);
|
||||||
|
compute.SetInt(ShaderIds._ColorSpaceCorrectionDepth, (int)gammaCorrectDepth);
|
||||||
|
compute.SetInt(ShaderIds._ColorSpaceCorrectionColor, (int)gammaCorrectColor);
|
||||||
|
compute.SetInt(ShaderIds._PerspectivesCount, metadata.perspectivesCount);
|
||||||
|
compute.SetInt(ShaderIds._PerspectivesInX, metadata.numColumns);
|
||||||
|
compute.SetInt(ShaderIds._PerspectivesInY, metadata.numRows);
|
||||||
|
compute.SetFloat(ShaderIds._EdgeChoke, s_edgeChoke);
|
||||||
|
if (perspectiveDataBuffer != null)
|
||||||
|
compute.SetBuffer(kernel, ShaderIds._PerspectiveDataStructuredBuffer, perspectiveDataBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetProperties(ref Material material)
|
||||||
|
{
|
||||||
|
if (cppTexture == null) return;
|
||||||
|
material.SetTexture(ShaderIds._CPPTexture, cppTexture);
|
||||||
|
material.SetInt(ShaderIds._TextureFlipped, textureIsFlipped ? 1 : 0);
|
||||||
|
material.SetInt(ShaderIds._ColorSpaceCorrectionDepth, (int)gammaCorrectDepth);
|
||||||
|
material.SetInt(ShaderIds._ColorSpaceCorrectionColor, (int)gammaCorrectColor);
|
||||||
|
material.SetInt(ShaderIds._PerspectivesCount, metadata.perspectivesCount);
|
||||||
|
material.SetInt(ShaderIds._PerspectivesInX, metadata.numColumns);
|
||||||
|
material.SetInt(ShaderIds._PerspectivesInY, metadata.numRows);
|
||||||
|
material.SetFloat(ShaderIds._EdgeChoke, s_edgeChoke);
|
||||||
|
if (perspectiveDataBuffer != null)
|
||||||
|
material.SetBuffer(ShaderIds._PerspectiveDataStructuredBuffer, perspectiveDataBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetProperties(ref Material material, ref MaterialPropertyBlock block)
|
||||||
|
{
|
||||||
|
if (cppTexture == null) return;
|
||||||
|
block.SetTexture(ShaderIds._CPPTexture, cppTexture);
|
||||||
|
block.SetInt(ShaderIds._TextureFlipped, textureIsFlipped ? 1 : 0);
|
||||||
|
block.SetInt(ShaderIds._ColorSpaceCorrectionDepth, (int)gammaCorrectDepth);
|
||||||
|
block.SetInt(ShaderIds._ColorSpaceCorrectionColor, (int)gammaCorrectColor);
|
||||||
|
block.SetInt(ShaderIds._PerspectivesCount, metadata.perspectivesCount);
|
||||||
|
block.SetInt(ShaderIds._PerspectivesInX, metadata.numColumns);
|
||||||
|
block.SetInt(ShaderIds._PerspectivesInY, metadata.numRows);
|
||||||
|
block.SetFloat(ShaderIds._EdgeChoke, s_edgeChoke);
|
||||||
|
if (perspectiveDataBuffer != null)
|
||||||
|
block.SetBuffer(ShaderIds._PerspectiveDataStructuredBuffer, perspectiveDataBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public bool isSetup
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return playerSetup && hasMetadata;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
void OnAssemblyReload()
|
||||||
|
{
|
||||||
|
EnsurePerspectiveDataBuffer();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void OnEnable()
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
AssemblyReloadEvents.afterAssemblyReload += OnAssemblyReload;
|
||||||
|
EditorApplication.update += Update;
|
||||||
|
#endif
|
||||||
|
if (m_dataSourceRoots == null)
|
||||||
|
{
|
||||||
|
ResetDataSources();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_dataSourceRoots.RemoveAll(x => x.Target == null);
|
||||||
|
}
|
||||||
|
foreach (var root in m_dataSourceRoots)
|
||||||
|
{
|
||||||
|
var gen = root.Target as Depthkit.DataSource;
|
||||||
|
if (gen != null)
|
||||||
|
{
|
||||||
|
gen.hideFlags = HideFlags.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_doGenerateData = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDisable()
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
AssemblyReloadEvents.afterAssemblyReload -= OnAssemblyReload;
|
||||||
|
EditorApplication.update -= Update;
|
||||||
|
#endif
|
||||||
|
m_perspectiveDataBuffer?.Release();
|
||||||
|
if (m_dataSourceRoots == null) return;
|
||||||
|
foreach (var root in m_dataSourceRoots)
|
||||||
|
{
|
||||||
|
var gen = root.Target as Depthkit.DataSource;
|
||||||
|
if (gen != null)
|
||||||
|
{
|
||||||
|
gen.hideFlags = HideFlags.NotEditable;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
if (m_player == null)
|
||||||
|
{
|
||||||
|
SetPlayer<UnityVideoPlayer>();
|
||||||
|
}
|
||||||
|
ResetDataSources();
|
||||||
|
m_doResizeData = true;
|
||||||
|
m_doGenerateData = true;
|
||||||
|
EnsurePerspectiveDataBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
bool hasNewFrame = false;
|
||||||
|
|
||||||
|
if (isSetup)
|
||||||
|
{
|
||||||
|
int frame = player.GetCurrentFrame();
|
||||||
|
if (frame != -1 && m_lastFrame != frame)
|
||||||
|
{
|
||||||
|
m_currentCPPTexture = player.GetTexture();
|
||||||
|
m_lastFrame = frame;
|
||||||
|
m_doGenerateData = true;
|
||||||
|
hasNewFrame = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasNewFrame)
|
||||||
|
{
|
||||||
|
OnNewFrame();
|
||||||
|
}
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
if (isSetup && !Application.isPlaying && player.IsPlaying())
|
||||||
|
{
|
||||||
|
// Ensure continuous Update calls.
|
||||||
|
UnityEditor.EditorApplication.QueuePlayerLoopUpdate();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void LateUpdate()
|
||||||
|
{
|
||||||
|
if (isSetup)
|
||||||
|
{
|
||||||
|
m_perspectiveDataBuffer.Sync();
|
||||||
|
|
||||||
|
if (m_doResizeData)
|
||||||
|
{
|
||||||
|
m_doResizeData = !DoResize();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_doGenerateData)
|
||||||
|
{
|
||||||
|
m_doGenerateData = !DoGenerate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDestroy()
|
||||||
|
{
|
||||||
|
if (m_dataSourceRoots == null) return;
|
||||||
|
foreach (var root in m_dataSourceRoots)
|
||||||
|
{
|
||||||
|
var gen = root.Target as Depthkit.DataSource;
|
||||||
|
if (gen != null)
|
||||||
|
{
|
||||||
|
gen.Cleanup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnApplicationQuit()
|
||||||
|
{
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
player.Stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b4fa781ea55830e408ba83c0f9d07c4b
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {fileID: 2800000, guid: 42c51ff9981f3e24b83cd7ad3c56e235, type: 3}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8d0be35cbb3985b49ba00a3f74d3b68a
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,495 @@
|
||||||
|
/************************************************************************************
|
||||||
|
|
||||||
|
Depthkit Unity SDK License v1
|
||||||
|
Copyright 2016-2024 Simile Inc dba Scatter. All Rights reserved.
|
||||||
|
|
||||||
|
Licensed under the the Simile Inc dba Scatter ("Scatter")
|
||||||
|
Software Development Kit License Agreement (the "License");
|
||||||
|
you may not use this SDK except in compliance with the License,
|
||||||
|
which is provided at the time of installation or download,
|
||||||
|
or which otherwise accompanies this software in either electronic or hard copy form.
|
||||||
|
|
||||||
|
You may obtain a copy of the License at http://www.depthkit.tv/license-agreement-v1
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
the SDK distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Depthkit
|
||||||
|
{
|
||||||
|
public enum MeshDensity
|
||||||
|
{
|
||||||
|
Low = 8,
|
||||||
|
Medium = 4,
|
||||||
|
High = 2,
|
||||||
|
Full = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum NormalGenerationTechnique
|
||||||
|
{
|
||||||
|
Smooth,
|
||||||
|
Adjustable,
|
||||||
|
AdjustableSmoother,
|
||||||
|
None,
|
||||||
|
DepthCamera
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
public struct Vertex
|
||||||
|
{
|
||||||
|
public Vector4 uv;
|
||||||
|
public Vector3 position;
|
||||||
|
public Vector3 normal;
|
||||||
|
public uint perspectiveIndex;
|
||||||
|
public uint valid;
|
||||||
|
|
||||||
|
public string Print()
|
||||||
|
{
|
||||||
|
return "uv: " + uv.ToString("F4") + " position: " + position.ToString("F4") + " normal: " + normal.ToString("F4");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct PackedTriangle
|
||||||
|
{
|
||||||
|
public Vertex vertex0;
|
||||||
|
public Vertex vertex1;
|
||||||
|
public Vertex vertex2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct IndexedTriangle
|
||||||
|
{
|
||||||
|
public uint perspective;
|
||||||
|
public uint vertex0;
|
||||||
|
public uint vertex1;
|
||||||
|
public uint vertex2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class PackedCoreTriangleSubMesh : SubMesh<Core.PackedTriangle>{}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class IndexedCoreTriangleSubMesh : SubMesh<Core.IndexedTriangle>{}
|
||||||
|
|
||||||
|
[ExecuteInEditMode]
|
||||||
|
[AddComponentMenu("Depthkit/Core/Sources/Depthkit Core Mesh Source")]
|
||||||
|
public class CoreMeshSource : MeshSource
|
||||||
|
{
|
||||||
|
public float surfaceTriangleCountPercent = 0.70f;
|
||||||
|
|
||||||
|
[SerializeField, HideInInspector]
|
||||||
|
private MeshDensity m_meshDensity = 0;
|
||||||
|
|
||||||
|
public MeshDensity meshDensity
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (m_meshDensity == 0) ? MeshDensity.Medium : m_meshDensity;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (m_meshDensity != value && clip.isSetup)
|
||||||
|
{
|
||||||
|
m_meshDensity = value;
|
||||||
|
maxSurfaceTriangles = 0;
|
||||||
|
ScheduleResize();
|
||||||
|
ScheduleGenerate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[SerializeField, HideInInspector]
|
||||||
|
protected Vector2Int m_latticeResolution = Vector2Int.one;
|
||||||
|
|
||||||
|
[SerializeField, HideInInspector]
|
||||||
|
protected uint m_latticeMaxTriangles = 0;
|
||||||
|
public uint latticeMaxTriangles
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_latticeMaxTriangles;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public Vector2Int latticeResolution
|
||||||
|
{
|
||||||
|
get { return m_latticeResolution; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector2Int scaledPerspectiveResolution
|
||||||
|
{
|
||||||
|
get { return new Vector2Int(clip.metadata.perspectiveResolution.x / (int)meshDensity, clip.metadata.perspectiveResolution.y / (int)meshDensity); }
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void ResizeLattice()
|
||||||
|
{
|
||||||
|
// Note: we add 1 to the dimensions here to ensure we have enough verts for one quad per pixel of the CPP
|
||||||
|
m_latticeResolution = new Vector2Int(Math.Max(1 + clip.metadata.paddedTextureDimensions.x / (int)meshDensity, 1), Math.Max(1 + clip.metadata.paddedTextureDimensions.y / (int)meshDensity, 1));
|
||||||
|
m_latticeMaxTriangles = (uint)(m_latticeResolution.x - 1) * (uint)(m_latticeResolution.y - 1) * 2;
|
||||||
|
vertexCount = (uint)m_latticeResolution.x * (uint)m_latticeResolution.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NormalGenerationTechnique normalGenerationTechnique = NormalGenerationTechnique.None;
|
||||||
|
|
||||||
|
[Range(1.0f, 1500.0f)]
|
||||||
|
public float adjustableNormalSlope = 255.0f;
|
||||||
|
|
||||||
|
[Range(0.0f, 1.0f)]
|
||||||
|
public float edgeCompressionNoiseThreshold = 0.25f;
|
||||||
|
|
||||||
|
[Range(0.0f, 1.0f)]
|
||||||
|
public float clipThreshold = 0.5f;
|
||||||
|
|
||||||
|
public bool ditherEdge = false;
|
||||||
|
|
||||||
|
[Range(0.0f, 0.2f)]
|
||||||
|
public float ditherWidth = 0.1f;
|
||||||
|
|
||||||
|
#region VertexBuffer
|
||||||
|
public uint vertexCount = 0;
|
||||||
|
protected ComputeBuffer m_vertexBuffer;
|
||||||
|
public ComputeBuffer vertexBuffer { get { return m_vertexBuffer; } }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region TriangleGeneration
|
||||||
|
protected enum Phase
|
||||||
|
{
|
||||||
|
Vertices_Horizontal = 0,
|
||||||
|
Vertices_Vertical = 1,
|
||||||
|
Normals = 2,
|
||||||
|
Triangles = 3
|
||||||
|
}
|
||||||
|
|
||||||
|
[SerializeField, HideInInspector]
|
||||||
|
protected int m_vertexBufferSlices = 1;
|
||||||
|
|
||||||
|
protected static class CoreShaderIds
|
||||||
|
{
|
||||||
|
public static readonly int
|
||||||
|
_EdgeChoke = Shader.PropertyToID("_EdgeChoke"), //override clip default
|
||||||
|
_VertexBuffer = Shader.PropertyToID("_VertexBuffer"),
|
||||||
|
_NormalHeight = Shader.PropertyToID("_NormalHeight"),
|
||||||
|
_LatticeSize = Shader.PropertyToID("_LatticeSize"), // padded to be multiple of 8
|
||||||
|
_PerspectiveTextureSize = Shader.PropertyToID("_PerspectiveTextureSize");
|
||||||
|
public static readonly string _DitherEdgeKW = "DK_SCREEN_DOOR_TRANSPARENCY";
|
||||||
|
public static readonly string _UseGroupSharedMemory = "DK_USE_GROUPSHARED_MEMORY";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual string GetComputeShaderName()
|
||||||
|
{
|
||||||
|
return "Shaders/DataSource/DepthkitCoreMeshSource";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ComputeShader m_generateDataCompute;
|
||||||
|
|
||||||
|
protected virtual string GetKernelNamePostfix(string prefix, bool edgeBuffer, bool edgeMask, int submesh = -1)
|
||||||
|
{
|
||||||
|
return prefix + (edgeBuffer ? "WEdgeBuffer" : "") + (edgeMask ? "WEdgeMask" : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int FindKernelId(Phase phase, bool edgeBuffer, bool edgeMask = false, int submesh = -1)
|
||||||
|
{
|
||||||
|
switch (phase)
|
||||||
|
{
|
||||||
|
case Phase.Vertices_Horizontal:
|
||||||
|
return m_generateDataCompute.FindKernel(GetKernelNamePostfix("KGenerateVertices_Horizontal", edgeBuffer, edgeMask, submesh));
|
||||||
|
case Phase.Vertices_Vertical:
|
||||||
|
return m_generateDataCompute.FindKernel(GetKernelNamePostfix("KGenerateVertices_Vertical", edgeBuffer, edgeMask, submesh));
|
||||||
|
case Phase.Normals:
|
||||||
|
switch (normalGenerationTechnique)
|
||||||
|
{
|
||||||
|
case NormalGenerationTechnique.Smooth:
|
||||||
|
return m_generateDataCompute.FindKernel(GetKernelNamePostfix("KGenerateNormals", edgeBuffer, edgeMask, submesh));
|
||||||
|
case NormalGenerationTechnique.Adjustable:
|
||||||
|
return m_generateDataCompute.FindKernel(GetKernelNamePostfix("KGenerateNormalsAdjustable", edgeBuffer, edgeMask, submesh));
|
||||||
|
case NormalGenerationTechnique.AdjustableSmoother:
|
||||||
|
return m_generateDataCompute.FindKernel(GetKernelNamePostfix("KGenerateNormalsAdjustableSmoother", edgeBuffer, edgeMask, submesh));
|
||||||
|
case NormalGenerationTechnique.DepthCamera:
|
||||||
|
return m_generateDataCompute.FindKernel(GetKernelNamePostfix("KGenerateNormalsDepthCamera", edgeBuffer, edgeMask, submesh));
|
||||||
|
case NormalGenerationTechnique.None:
|
||||||
|
return m_generateDataCompute.FindKernel(GetKernelNamePostfix("KGenerateNormalsNone", edgeBuffer, edgeMask, submesh));
|
||||||
|
default: return -1;
|
||||||
|
}
|
||||||
|
case Phase.Triangles:
|
||||||
|
return m_generateDataCompute.FindKernel(GetKernelNamePostfix("KGenerateTriangles", edgeBuffer, edgeMask, submesh));
|
||||||
|
default: return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void GenerateVertexBuffer()
|
||||||
|
{
|
||||||
|
// generate all vertices
|
||||||
|
// Vertex generation samples the edge mask to create the vertex data
|
||||||
|
int kernel = FindKernelId(Phase.Vertices_Horizontal, false, true);
|
||||||
|
GenerateVertices(kernel, m_vertexBufferSlices);
|
||||||
|
|
||||||
|
kernel = FindKernelId(Phase.Vertices_Vertical, false);
|
||||||
|
GenerateVertices(kernel, m_vertexBufferSlices);
|
||||||
|
|
||||||
|
kernel = FindKernelId(Phase.Normals, false);
|
||||||
|
GenerateNormals(kernel, m_vertexBufferSlices);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void GenerateTriangles()
|
||||||
|
{
|
||||||
|
int kernel = FindKernelId(Phase.Triangles, false);
|
||||||
|
GenerateTriangles(kernel, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GenerateVertices(int kernel, int slices = 1)
|
||||||
|
{
|
||||||
|
clip.SetProperties(ref m_generateDataCompute, kernel);
|
||||||
|
|
||||||
|
// mask props
|
||||||
|
maskGenerator.SetProperties(ref m_generateDataCompute, kernel);
|
||||||
|
|
||||||
|
// downscaled mask props
|
||||||
|
if (maskGenerator.downScaledMaskTexture != null)
|
||||||
|
m_generateDataCompute.SetTexture(kernel, MaskGenerator.MaskGeneratorShaderIds._MaskTexture, maskGenerator.downScaledMaskTexture);
|
||||||
|
|
||||||
|
m_generateDataCompute.SetFloat(CoreShaderIds._EdgeChoke, edgeCompressionNoiseThreshold);
|
||||||
|
m_generateDataCompute.SetBuffer(kernel, CoreShaderIds._VertexBuffer, vertexBuffer);
|
||||||
|
m_generateDataCompute.SetVector(CoreShaderIds._LatticeSize, new Vector2(m_latticeResolution.x, m_latticeResolution.y));
|
||||||
|
m_generateDataCompute.SetVector(CoreShaderIds._PerspectiveTextureSize, new Vector2(scaledPerspectiveResolution.x, scaledPerspectiveResolution.y));
|
||||||
|
m_generateDataCompute.SetVectorArray(MeshSourceShaderIds._RadialBiasPerspInMeters, radialBiasPerspInMeters);
|
||||||
|
|
||||||
|
if (Application.platform == RuntimePlatform.Android) // Quest 2 has issues with using too much group shared memory
|
||||||
|
{
|
||||||
|
m_generateDataCompute.DisableKeyword(CoreShaderIds._UseGroupSharedMemory);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_generateDataCompute.EnableKeyword(CoreShaderIds._UseGroupSharedMemory);
|
||||||
|
}
|
||||||
|
|
||||||
|
Util.DispatchGroups(m_generateDataCompute, kernel, m_latticeResolution.x, m_latticeResolution.y, slices);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GenerateNormals(int kernel, int perspectives = 1)
|
||||||
|
{
|
||||||
|
clip.SetProperties(ref m_generateDataCompute, kernel);
|
||||||
|
m_generateDataCompute.SetFloat(CoreShaderIds._EdgeChoke, edgeCompressionNoiseThreshold);
|
||||||
|
m_generateDataCompute.SetBuffer(kernel, CoreShaderIds._VertexBuffer, vertexBuffer);
|
||||||
|
m_generateDataCompute.SetVector(CoreShaderIds._LatticeSize, new Vector2(m_latticeResolution.x, m_latticeResolution.y));
|
||||||
|
m_generateDataCompute.SetVector(CoreShaderIds._PerspectiveTextureSize, new Vector2(scaledPerspectiveResolution.x, scaledPerspectiveResolution.y));
|
||||||
|
if (normalGenerationTechnique == NormalGenerationTechnique.Adjustable || normalGenerationTechnique == NormalGenerationTechnique.AdjustableSmoother)
|
||||||
|
m_generateDataCompute.SetFloat(CoreShaderIds._NormalHeight, adjustableNormalSlope);
|
||||||
|
Util.DispatchGroups(m_generateDataCompute, kernel, m_latticeResolution.x, m_latticeResolution.y, perspectives);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GenerateTriangles(int kernel, int perspectives = 1)
|
||||||
|
{
|
||||||
|
triangleBuffer.SetCounterValue(0);
|
||||||
|
|
||||||
|
clip.SetProperties(ref m_generateDataCompute, kernel);
|
||||||
|
m_generateDataCompute.SetFloat(CoreShaderIds._EdgeChoke, edgeCompressionNoiseThreshold);
|
||||||
|
m_generateDataCompute.SetBuffer(kernel, CoreShaderIds._VertexBuffer, vertexBuffer);
|
||||||
|
m_generateDataCompute.SetVector(CoreShaderIds._LatticeSize, new Vector2(m_latticeResolution.x, m_latticeResolution.y));
|
||||||
|
m_generateDataCompute.SetVector(CoreShaderIds._PerspectiveTextureSize, new Vector2(scaledPerspectiveResolution.x, scaledPerspectiveResolution.y));
|
||||||
|
m_generateDataCompute.SetBuffer(kernel, SubMesh.TriangleDataShaderIds._TriangleBuffer, triangleBuffer);
|
||||||
|
|
||||||
|
Util.DispatchGroups(m_generateDataCompute, kernel, scaledPerspectiveResolution.x, scaledPerspectiveResolution.y, perspectives);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region DataSource
|
||||||
|
public override string DataSourceName()
|
||||||
|
{
|
||||||
|
return "Depthkit Core Mesh Source";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void EnsureVertexBuffer()
|
||||||
|
{
|
||||||
|
if (vertexCount > 0)
|
||||||
|
{
|
||||||
|
if (Util.EnsureComputeBuffer(ComputeBufferType.Structured, ref m_vertexBuffer, (int)vertexCount, Marshal.SizeOf(typeof(Core.Vertex))))
|
||||||
|
{
|
||||||
|
m_vertexBuffer.name = "Depthkit Core Mesh Source Vertex Buffer";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void OnNewMetadata()
|
||||||
|
{
|
||||||
|
// if the metatada is completely different (differing number of perspectives) or it contains defaultReconstructionSettings, reset the reconstruction settings, else leave them be
|
||||||
|
if (maskGenerator.sliceCount != clip.metadata.perspectivesCount || clip.metadata._versionMajor > 0 || (clip.metadata._versionMajor == 0 && m_clip.metadata._versionMinor > 4))
|
||||||
|
{
|
||||||
|
if (clip.metadata.perspectivesCount > 1)
|
||||||
|
radialBias = Util.metersToCm(clip.metadata.defaultReconstructionSettings.depthBiasAdjustment);
|
||||||
|
else
|
||||||
|
radialBias = 0.0f;
|
||||||
|
|
||||||
|
maskGenerator.blurRadius = clip.metadata.defaultReconstructionSettings.edgeMaskBlurAmount;
|
||||||
|
maskGenerator.sobelMultiplier = clip.metadata.defaultReconstructionSettings.edgeMaskSobelMultiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
EnsureMaskGenerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void AcquireResources()
|
||||||
|
{
|
||||||
|
base.AcquireResources();
|
||||||
|
if (m_latticeResolution.x > 0 && m_latticeResolution.y > 0)
|
||||||
|
{
|
||||||
|
if (clip != null && maskGenerator != null && maskGenerator.clip == null) maskGenerator.clip = clip;
|
||||||
|
}
|
||||||
|
|
||||||
|
EnsureVertexBuffer();
|
||||||
|
|
||||||
|
if (m_clip)
|
||||||
|
{
|
||||||
|
m_clip.newMetadata += OnNewMetadata;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void FreeResources()
|
||||||
|
{
|
||||||
|
if (m_clip)
|
||||||
|
{
|
||||||
|
m_clip.newMetadata -= OnNewMetadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
Util.ReleaseComputeBuffer(ref m_vertexBuffer);
|
||||||
|
maskGenerator?.Release();
|
||||||
|
base.FreeResources();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool OnSetup()
|
||||||
|
{
|
||||||
|
Util.EnsureComputeShader(ref m_generateDataCompute, GetComputeShaderName());
|
||||||
|
EnsureMaskGenerator();
|
||||||
|
return base.OnSetup();
|
||||||
|
}
|
||||||
|
|
||||||
|
//allows us to call mesh source onResize directly from inherited classes
|
||||||
|
protected bool baseResize()
|
||||||
|
{
|
||||||
|
return base.OnResize();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnResize()
|
||||||
|
{
|
||||||
|
if (m_clip.isSetup)
|
||||||
|
{
|
||||||
|
m_vertexBufferSlices = 1;
|
||||||
|
|
||||||
|
ReserveSubMeshes<IndexedCoreTriangleSubMesh>(1);
|
||||||
|
|
||||||
|
ResizeLattice();
|
||||||
|
|
||||||
|
if (maxSurfaceTriangles == 0 || !useTriangleMesh)
|
||||||
|
{
|
||||||
|
if (useTriangleMesh)
|
||||||
|
{
|
||||||
|
maxSurfaceTriangles = (uint)(surfaceTriangleCountPercent * latticeMaxTriangles);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
maxSurfaceTriangles = latticeMaxTriangles;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CurrentSubMesh().Init();
|
||||||
|
EnsureVertexBuffer();
|
||||||
|
|
||||||
|
EnsureMaskGenerator();
|
||||||
|
|
||||||
|
return baseResize();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void GenerateEdgeMask()
|
||||||
|
{
|
||||||
|
maskGenerator.EnsureTexture();
|
||||||
|
maskGenerator.GenerateMask();
|
||||||
|
//set thresholds
|
||||||
|
maskGenerator.perspectivesToSlice[0].y = clipThreshold;
|
||||||
|
maskGenerator.perspectivesToSlice[0].z = ditherWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnGenerate()
|
||||||
|
{
|
||||||
|
if(clip.cppTexture == null) return false;
|
||||||
|
|
||||||
|
GenerateEdgeMask();
|
||||||
|
|
||||||
|
GenerateVertexBuffer();
|
||||||
|
GenerateTriangles();
|
||||||
|
|
||||||
|
bool recomputeMaxTriangles = recalculateCurrentSurfaceTriangleCount;
|
||||||
|
if (base.OnGenerate())
|
||||||
|
{
|
||||||
|
// base.OnGenerate will recalculate the current surface triangle count if needed and reset the variable to false.
|
||||||
|
if(recomputeMaxTriangles && !recalculateCurrentSurfaceTriangleCount)
|
||||||
|
{
|
||||||
|
// update surfaceTriangleCountPercent
|
||||||
|
surfaceTriangleCountPercent = (float)maxSurfaceTriangles / (float)m_latticeMaxTriangles ;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region IPropertyTransfer
|
||||||
|
|
||||||
|
public override void SetProperties(ref ComputeShader compute, int kernel)
|
||||||
|
{
|
||||||
|
compute.SetBuffer(kernel, CoreShaderIds._VertexBuffer, vertexBuffer);
|
||||||
|
maskGenerator?.SetProperties(ref compute, kernel);
|
||||||
|
base.SetProperties(ref compute, kernel);
|
||||||
|
compute.SetFloat(CoreShaderIds._EdgeChoke, edgeCompressionNoiseThreshold);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SetProperties(ref Material material)
|
||||||
|
{
|
||||||
|
material.SetBuffer(CoreShaderIds._VertexBuffer, vertexBuffer);
|
||||||
|
maskGenerator?.SetProperties(ref material);
|
||||||
|
base.SetProperties(ref material);
|
||||||
|
material.SetFloat(CoreShaderIds._EdgeChoke, edgeCompressionNoiseThreshold);
|
||||||
|
Util.EnsureKeyword(ref material, CoreShaderIds._DitherEdgeKW, ditherEdge);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SetProperties(ref Material material, ref MaterialPropertyBlock block)
|
||||||
|
{
|
||||||
|
block.SetBuffer(CoreShaderIds._VertexBuffer, vertexBuffer);
|
||||||
|
maskGenerator?.SetProperties(ref material, ref block);
|
||||||
|
base.SetProperties(ref material, ref block);
|
||||||
|
block.SetFloat(CoreShaderIds._EdgeChoke, edgeCompressionNoiseThreshold);
|
||||||
|
Util.EnsureKeyword(ref material, CoreShaderIds._DitherEdgeKW, ditherEdge);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region MaskGenerator
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
public MaskGenerator maskGenerator = null;
|
||||||
|
|
||||||
|
public void EnsureMaskGenerator()
|
||||||
|
{
|
||||||
|
if (maskGenerator == null)
|
||||||
|
{
|
||||||
|
maskGenerator = new MaskGenerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clip != null)
|
||||||
|
{
|
||||||
|
maskGenerator.clip = clip;
|
||||||
|
}
|
||||||
|
maskGenerator.Setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d141e4f523dd8314d99067356eb5952d
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {fileID: 2800000, guid: 42c51ff9981f3e24b83cd7ad3c56e235, type: 3}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,323 @@
|
||||||
|
/************************************************************************************
|
||||||
|
|
||||||
|
Depthkit Unity SDK License v1
|
||||||
|
Copyright 2016-2024 Simile Inc dba Scatter. All Rights reserved.
|
||||||
|
|
||||||
|
Licensed under the the Simile Inc dba Scatter ("Scatter")
|
||||||
|
Software Development Kit License Agreement (the "License");
|
||||||
|
you may not use this SDK except in compliance with the License,
|
||||||
|
which is provided at the time of installation or download,
|
||||||
|
or which otherwise accompanies this software in either electronic or hard copy form.
|
||||||
|
|
||||||
|
You may obtain a copy of the License at http://www.depthkit.tv/license-agreement-v1
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
the SDK distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Depthkit
|
||||||
|
{
|
||||||
|
[ExecuteInEditMode]
|
||||||
|
[DefaultExecutionOrder(-15)]
|
||||||
|
public abstract class DataSource : MonoBehaviour
|
||||||
|
{
|
||||||
|
public DataSourceEvents events;
|
||||||
|
[SerializeField]
|
||||||
|
private bool m_bIsSetup = false;
|
||||||
|
protected Depthkit.Clip m_clip;
|
||||||
|
public Depthkit.Clip clip
|
||||||
|
{
|
||||||
|
get { return m_clip; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
private string m_parent = "root";
|
||||||
|
public string dataSourceParent
|
||||||
|
{
|
||||||
|
get { return m_parent; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool m_doUpdate = false;
|
||||||
|
private bool m_doResize = false;
|
||||||
|
public abstract string DataSourceName();
|
||||||
|
|
||||||
|
private List<WeakReference> m_children;
|
||||||
|
public T GetChild<T>(bool create = true) where T : DataSource
|
||||||
|
{
|
||||||
|
if (m_children == null)
|
||||||
|
{
|
||||||
|
ResetChildren();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_children.RemoveAll(x => x.Target == null);
|
||||||
|
}
|
||||||
|
//check if we already had it cached
|
||||||
|
foreach (var generator in m_children)
|
||||||
|
{
|
||||||
|
if (generator.Target.GetType().Equals(typeof(T)))
|
||||||
|
{
|
||||||
|
return generator.Target as T;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!create) return null;
|
||||||
|
//create it if its missing
|
||||||
|
T gen = gameObject.GetComponent<T>();
|
||||||
|
if (gen == null)
|
||||||
|
{
|
||||||
|
//add it
|
||||||
|
gen = gameObject.AddComponent<T>();
|
||||||
|
m_doUpdate = true;
|
||||||
|
}
|
||||||
|
gen.m_parent = DataSourceName();
|
||||||
|
m_children.Add(new WeakReference(gen));
|
||||||
|
return gen;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void ResetChildren()
|
||||||
|
{
|
||||||
|
if (m_children == null)
|
||||||
|
{
|
||||||
|
m_children = new List<WeakReference>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_children.Clear();
|
||||||
|
}
|
||||||
|
var dataSources = GetComponents<DataSource>();
|
||||||
|
foreach (var source in dataSources)
|
||||||
|
{
|
||||||
|
if (source.dataSourceParent == DataSourceName())
|
||||||
|
{
|
||||||
|
m_children.Add(new WeakReference(source));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void AcquireResources() { }
|
||||||
|
protected virtual void FreeResources() { }
|
||||||
|
protected virtual void OnAwake() { }
|
||||||
|
public virtual void OnCleanup() { }
|
||||||
|
|
||||||
|
public abstract bool OnSetup();
|
||||||
|
protected abstract bool OnResize();
|
||||||
|
protected abstract bool OnGenerate();
|
||||||
|
|
||||||
|
protected virtual void OnUpdate() { }
|
||||||
|
|
||||||
|
protected virtual bool CanGenerate() { return true; }
|
||||||
|
|
||||||
|
void Awake()
|
||||||
|
{
|
||||||
|
m_children = new List<WeakReference>();
|
||||||
|
events = new DataSourceEvents();
|
||||||
|
m_clip = GetComponent<Depthkit.Clip>();
|
||||||
|
OnAwake();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
ResetChildren();
|
||||||
|
m_bIsSetup = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ScheduleGenerate()
|
||||||
|
{
|
||||||
|
m_doUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ScheduleResize()
|
||||||
|
{
|
||||||
|
m_doResize = true;
|
||||||
|
}
|
||||||
|
public void UnscheduleGenerate()
|
||||||
|
{
|
||||||
|
m_doUpdate = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UnscheduleResize()
|
||||||
|
{
|
||||||
|
m_doResize = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
protected virtual void OnAssemblyReload()
|
||||||
|
{
|
||||||
|
Setup();
|
||||||
|
ScheduleResize();
|
||||||
|
ScheduleGenerate();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void OnEnable()
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
AssemblyReloadEvents.afterAssemblyReload += OnAssemblyReload;
|
||||||
|
#endif
|
||||||
|
ResetChildren();
|
||||||
|
foreach (var child in m_children)
|
||||||
|
{
|
||||||
|
var gen = child.Target as DataSource;
|
||||||
|
if (gen != null)
|
||||||
|
gen.hideFlags = HideFlags.None;
|
||||||
|
}
|
||||||
|
AcquireResources();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDisable()
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
AssemblyReloadEvents.afterAssemblyReload -= OnAssemblyReload;
|
||||||
|
#endif
|
||||||
|
FreeResources();
|
||||||
|
|
||||||
|
if (m_children == null) return;
|
||||||
|
|
||||||
|
foreach (var child in m_children)
|
||||||
|
{
|
||||||
|
var gen = child.Target as DataSource;
|
||||||
|
if (gen != null)
|
||||||
|
gen.hideFlags = HideFlags.NotEditable;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Reset()
|
||||||
|
{
|
||||||
|
m_bIsSetup = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
ResetChildren();
|
||||||
|
AcquireResources();
|
||||||
|
//Debug.Log(DataSourceName() + " - generator setup started...");
|
||||||
|
m_bIsSetup = OnSetup();
|
||||||
|
if (m_bIsSetup)
|
||||||
|
{
|
||||||
|
foreach (var child in m_children)
|
||||||
|
{
|
||||||
|
var gen = child.Target as DataSource;
|
||||||
|
if (gen != null)
|
||||||
|
gen.Setup();
|
||||||
|
}
|
||||||
|
//Debug.Log(DataSourceName() + " - setup SUCCESS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Cleanup()
|
||||||
|
{
|
||||||
|
OnCleanup();
|
||||||
|
foreach (var child in m_children)
|
||||||
|
{
|
||||||
|
var gen = child.Target as DataSource;
|
||||||
|
if (gen != null)
|
||||||
|
gen.Cleanup();
|
||||||
|
}
|
||||||
|
m_children.RemoveAll(x => x.Target == null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Resize()
|
||||||
|
{
|
||||||
|
//Debug.Log(DataSourceName() + " - generator resize started...");
|
||||||
|
if (!gameObject.activeInHierarchy || !gameObject.activeSelf)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!m_bIsSetup)
|
||||||
|
{
|
||||||
|
//Debug.Log(DataSourceName() + " - setting up insize resize...");
|
||||||
|
Setup();
|
||||||
|
}
|
||||||
|
if (m_bIsSetup)
|
||||||
|
{
|
||||||
|
if (OnResize())
|
||||||
|
{
|
||||||
|
//Debug.Log(DataSourceName() + " - resize SUCCESS");
|
||||||
|
events.OnDataResized();
|
||||||
|
}
|
||||||
|
//refresh children regardless
|
||||||
|
foreach (var child in m_children)
|
||||||
|
{
|
||||||
|
var gen = child.Target as DataSource;
|
||||||
|
if (gen != null)
|
||||||
|
gen.Resize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsSetup()
|
||||||
|
{
|
||||||
|
return m_bIsSetup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Generate()
|
||||||
|
{
|
||||||
|
//Debug.Log(DataSourceName() + " - generator generate started...");
|
||||||
|
if (!gameObject.activeInHierarchy || !gameObject.activeSelf)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_bIsSetup)
|
||||||
|
{
|
||||||
|
Setup();
|
||||||
|
if (!m_bIsSetup)
|
||||||
|
{
|
||||||
|
return; //early out if setup fails
|
||||||
|
}
|
||||||
|
Resize();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CanGenerate()) return;
|
||||||
|
|
||||||
|
if (OnGenerate())
|
||||||
|
{
|
||||||
|
//Debug.Log(DataSourceName() + " - calling on generated event.");
|
||||||
|
events.OnDataGenerated();
|
||||||
|
//only generate child data if we processed
|
||||||
|
foreach (var child in m_children)
|
||||||
|
{
|
||||||
|
var gen = child.Target as DataSource;
|
||||||
|
if (gen != null)
|
||||||
|
gen.Generate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
if (!Application.isPlaying)
|
||||||
|
{
|
||||||
|
//prompt the editor to update everything so the looks can update themselves with the new data
|
||||||
|
EditorApplication.delayCall += EditorApplication.QueuePlayerLoopUpdate;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
//Debug.Log(DataSourceName() + " - generator generate complete");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
if (m_doResize)
|
||||||
|
{
|
||||||
|
Resize();
|
||||||
|
m_doResize = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void LateUpdate()
|
||||||
|
{
|
||||||
|
if (m_doUpdate)
|
||||||
|
{
|
||||||
|
Generate();
|
||||||
|
m_doUpdate = false;
|
||||||
|
}
|
||||||
|
OnUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: acdb98fea3f6ee54586aae0b04aef7bc
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,103 @@
|
||||||
|
/************************************************************************************
|
||||||
|
|
||||||
|
Depthkit Unity SDK License v1
|
||||||
|
Copyright 2016-2024 Simile Inc dba Scatter. All Rights reserved.
|
||||||
|
|
||||||
|
Licensed under the the Simile Inc dba Scatter ("Scatter")
|
||||||
|
Software Development Kit License Agreement (the "License");
|
||||||
|
you may not use this SDK except in compliance with the License,
|
||||||
|
which is provided at the time of installation or download,
|
||||||
|
or which otherwise accompanies this software in either electronic or hard copy form.
|
||||||
|
|
||||||
|
You may obtain a copy of the License at http://www.depthkit.tv/license-agreement-v1
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
the SDK distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
namespace Depthkit
|
||||||
|
{
|
||||||
|
public delegate void DataSourceEventHandler();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Class that contains events a given player could potentially emit for listening. </summary>
|
||||||
|
[System.Serializable]
|
||||||
|
public class DataSourceEvents
|
||||||
|
{
|
||||||
|
private event DataSourceEventHandler m_dataGenerated;
|
||||||
|
public event DataSourceEventHandler dataGenerated
|
||||||
|
{
|
||||||
|
add
|
||||||
|
{
|
||||||
|
if (m_dataGenerated != null)
|
||||||
|
{
|
||||||
|
foreach(DataSourceEventHandler existingHandler in m_dataGenerated.GetInvocationList())
|
||||||
|
{
|
||||||
|
if (existingHandler == value)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_dataGenerated += value;
|
||||||
|
}
|
||||||
|
remove
|
||||||
|
{
|
||||||
|
if (m_dataGenerated != null)
|
||||||
|
{
|
||||||
|
foreach(DataSourceEventHandler existingHandler in m_dataGenerated.GetInvocationList())
|
||||||
|
{
|
||||||
|
if (existingHandler == value)
|
||||||
|
{
|
||||||
|
m_dataGenerated -= value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private event DataSourceEventHandler m_dataResized;
|
||||||
|
public event DataSourceEventHandler dataResized
|
||||||
|
{
|
||||||
|
add
|
||||||
|
{
|
||||||
|
if (m_dataResized != null)
|
||||||
|
{
|
||||||
|
foreach(DataSourceEventHandler existingHandler in m_dataResized.GetInvocationList())
|
||||||
|
{
|
||||||
|
if (existingHandler == value)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_dataResized += value;
|
||||||
|
}
|
||||||
|
remove
|
||||||
|
{
|
||||||
|
if (m_dataResized != null)
|
||||||
|
{
|
||||||
|
foreach(DataSourceEventHandler existingHandler in m_dataResized.GetInvocationList())
|
||||||
|
{
|
||||||
|
if (existingHandler == value)
|
||||||
|
{
|
||||||
|
m_dataResized -= value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnDataGenerated()
|
||||||
|
{
|
||||||
|
if(m_dataGenerated != null) { m_dataGenerated(); }
|
||||||
|
}
|
||||||
|
public virtual void OnDataResized()
|
||||||
|
{
|
||||||
|
if(m_dataResized != null) { m_dataResized(); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d19808a84026d5a4491d90429bd0dd13
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,409 @@
|
||||||
|
/************************************************************************************
|
||||||
|
|
||||||
|
Depthkit Unity SDK License v1
|
||||||
|
Copyright 2016-2024 Simile Inc dba Scatter. All Rights reserved.
|
||||||
|
|
||||||
|
Licensed under the the Simile Inc dba Scatter ("Scatter")
|
||||||
|
Software Development Kit License Agreement (the "License");
|
||||||
|
you may not use this SDK except in compliance with the License,
|
||||||
|
which is provided at the time of installation or download,
|
||||||
|
or which otherwise accompanies this software in either electronic or hard copy form.
|
||||||
|
|
||||||
|
You may obtain a copy of the License at http://www.depthkit.tv/license-agreement-v1
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
the SDK distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
using System.Collections;
|
||||||
|
using UnityEngine;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Depthkit
|
||||||
|
{
|
||||||
|
[System.Serializable]
|
||||||
|
public class MaskGenerator : IPropertyTransfer
|
||||||
|
{
|
||||||
|
public Clip clip;
|
||||||
|
|
||||||
|
public Texture externalSourceTexture = null;
|
||||||
|
|
||||||
|
[Range(1, 8)]
|
||||||
|
public int scale = 1;
|
||||||
|
|
||||||
|
protected ComputeShader m_maskGeneratorCompute;
|
||||||
|
[SerializeField, HideInInspector]
|
||||||
|
protected RenderTextureFormat m_maskTextureFormat = RenderTextureFormat.RFloat;
|
||||||
|
protected RenderTexture m_maskTexture;
|
||||||
|
protected Vector4 m_maskTextureTS; // TODO check if needed
|
||||||
|
protected ComputeBuffer m_sobelMultiplierBuffer = null;
|
||||||
|
|
||||||
|
// Core & Studio Lite use a lower strength than the Studio renderer.
|
||||||
|
public bool useStudioCoefficients = false;
|
||||||
|
|
||||||
|
public static class MaskGeneratorShaderIds
|
||||||
|
{
|
||||||
|
public static readonly int
|
||||||
|
_LatticeSize = Shader.PropertyToID("_LatticeSize"),
|
||||||
|
_MaskTexture = Shader.PropertyToID("_MaskTexture"),
|
||||||
|
_SobelMultiplier = Shader.PropertyToID("_SobelMultiplier"),
|
||||||
|
_StaticSobelMultiplier = Shader.PropertyToID("_StaticSobelMultiplier"),
|
||||||
|
_StaticSobelPower = Shader.PropertyToID("_StaticSobelPower"),
|
||||||
|
_SobelInvalidateStrength = Shader.PropertyToID("_SobelInvalidateStrength"),
|
||||||
|
_MaskTextureTS = Shader.PropertyToID("_MaskTextureTS"),
|
||||||
|
_PerspectiveToSlice = Shader.PropertyToID("_PerspectiveToSlice"),
|
||||||
|
_SliceCount = Shader.PropertyToID("_SliceCount"),
|
||||||
|
_SliceToPerspective = Shader.PropertyToID("_SliceToPerspective"),
|
||||||
|
_Downscaled = Shader.PropertyToID("_Downscaled"),
|
||||||
|
_FullRes = Shader.PropertyToID("_FullRes"),
|
||||||
|
_PaddedUVScaleFactor = Shader.PropertyToID("_PaddedUVScaleFactor"),
|
||||||
|
_DownsampledMaskTexture = Shader.PropertyToID("_DownsampledMaskTexture"),
|
||||||
|
_SobelInvalidateEdgeWidth = Shader.PropertyToID("_SobelInvalidateEdgeWidth"),
|
||||||
|
_CPPTexture = Shader.PropertyToID("_CPPTexture");
|
||||||
|
public static readonly string _UseEdgeMask = "DK_USE_EDGEMASK";
|
||||||
|
public static readonly string _DebugEdgeMask = "DK_DEBUG_EDGEMASK";
|
||||||
|
public static readonly string _DitherEdgeKW = "DK_SCREEN_DOOR_TRANSPARENCY";
|
||||||
|
}
|
||||||
|
|
||||||
|
//passing arrays to shaders requires padding, so just use Vector4
|
||||||
|
//https://cmwdexint.com/2017/12/04/computeshader-setfloats/
|
||||||
|
protected Vector4[] m_perspectivesToSlice;
|
||||||
|
public Vector4[] perspectivesToSlice
|
||||||
|
{
|
||||||
|
get { return m_perspectivesToSlice; }
|
||||||
|
set { m_perspectivesToSlice = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
//passing arrays to shaders requires padding, so just use Vector4
|
||||||
|
//https://cmwdexint.com/2017/12/04/computeshader-setfloats/
|
||||||
|
protected Vector4[] m_sliceToPerspective;
|
||||||
|
public Vector4[] sliceToPerspective
|
||||||
|
{
|
||||||
|
get { return m_sliceToPerspective; }
|
||||||
|
set { m_sliceToPerspective = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int sliceCount
|
||||||
|
{
|
||||||
|
get { return m_blurFilter != null ? m_blurFilter.slices : 1; }
|
||||||
|
set { if (m_blurFilter != null) m_blurFilter.slices = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public float blurRadius
|
||||||
|
{
|
||||||
|
get { return m_blurFilter != null ? m_blurFilter.radius : Metadata.DefaultReconstructionSettingsDefaults.edgeMaskBlurAmount; }
|
||||||
|
set { if (m_blurFilter != null) m_blurFilter.radius = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector2 paddedUVScaleFactor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return clip == null ? Vector2.zero : new Vector2(clip.metadata.perspectiveResolution.x, clip.metadata.perspectiveResolution.y) / new Vector2(clip.metadata.paddedTextureDimensions.x, clip.metadata.paddedTextureDimensions.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool enableMaskDebug = false;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
protected GaussianBlurFilter m_blurFilter;
|
||||||
|
|
||||||
|
[Range(0.1f, 100.0f)]
|
||||||
|
public float sobelMultiplier = Metadata.DefaultReconstructionSettingsDefaults.edgeMaskSobelMultiplier; //cm
|
||||||
|
|
||||||
|
protected ComputeShader m_sobelFilterCompute;
|
||||||
|
protected int m_sobelFilterKId = -1;
|
||||||
|
|
||||||
|
public RenderTexture maskTexture
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_maskTexture;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
protected int m_downScale = 0;
|
||||||
|
protected ComputeShader m_downScaleCompute;
|
||||||
|
protected int m_downScaleKId = -1;
|
||||||
|
|
||||||
|
public int downScale {
|
||||||
|
get { return m_downScale; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_downScale = Math.Max(value, scale);
|
||||||
|
DownScaleMaskTexture();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected RenderTexture m_downScaledMaskTexture = null;
|
||||||
|
|
||||||
|
public RenderTexture downScaledMaskTexture
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return downScale != scale ? m_downScaledMaskTexture : m_maskTexture;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void DownScalePass(RenderTexture src, RenderTexture dst)
|
||||||
|
{
|
||||||
|
m_downScaleCompute.SetTexture(m_downScaleKId, MaskGeneratorShaderIds._FullRes, src);
|
||||||
|
m_downScaleCompute.SetTexture(m_downScaleKId, MaskGeneratorShaderIds._Downscaled, dst);
|
||||||
|
Util.DispatchGroups(m_downScaleCompute, m_downScaleKId, dst.width, dst.height, dst.volumeDepth);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void DownScaleMaskTexture()
|
||||||
|
{
|
||||||
|
int downlevels = (int)Mathf.Log((float)m_downScale, 2.0f);
|
||||||
|
int mainlevels = (int)Mathf.Log((float)scale, 2.0f);
|
||||||
|
int levels = downlevels - mainlevels;
|
||||||
|
|
||||||
|
m_downScaleKId = m_downScaleCompute.FindKernel(Util.GetScaled2DKernelName("MinMaxDownscaleByHalf"));
|
||||||
|
|
||||||
|
//only scale if we need to
|
||||||
|
if (levels > 0 && maskTexture != null)
|
||||||
|
{
|
||||||
|
Vector2Int newSize = new Vector2Int(clip.metadata.paddedTextureDimensions.x / m_downScale, clip.metadata.paddedTextureDimensions.y / m_downScale);
|
||||||
|
if (m_downScaledMaskTexture == null || m_downScaledMaskTexture.width != newSize.x || m_downScaledMaskTexture.height != newSize.y || m_downScaledMaskTexture.volumeDepth != maskTexture.volumeDepth)
|
||||||
|
{
|
||||||
|
if(m_downScaledMaskTexture != null && m_downScaledMaskTexture.IsCreated())
|
||||||
|
{
|
||||||
|
m_downScaledMaskTexture.Release();
|
||||||
|
}
|
||||||
|
m_downScaledMaskTexture = new RenderTexture(newSize.x, newSize.y, maskTexture.depth, RenderTextureFormat.ARGBHalf);
|
||||||
|
m_downScaledMaskTexture.dimension = maskTexture.dimension;
|
||||||
|
m_downScaledMaskTexture.volumeDepth = maskTexture.volumeDepth;
|
||||||
|
m_downScaledMaskTexture.filterMode = maskTexture.filterMode;
|
||||||
|
m_downScaledMaskTexture.name = "Downscaled Mask Texture";
|
||||||
|
m_downScaledMaskTexture.enableRandomWrite = true;
|
||||||
|
m_downScaledMaskTexture.autoGenerateMips = maskTexture.autoGenerateMips;
|
||||||
|
m_downScaledMaskTexture.Create();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(levels > 1)
|
||||||
|
{
|
||||||
|
//use temp target hald the res of the mask texture.
|
||||||
|
var desc = maskTexture.descriptor;
|
||||||
|
desc.graphicsFormat = m_downScaledMaskTexture.descriptor.graphicsFormat;
|
||||||
|
desc.colorFormat = m_downScaledMaskTexture.descriptor.colorFormat;
|
||||||
|
desc.width /= 2;
|
||||||
|
desc.height /= 2;
|
||||||
|
|
||||||
|
RenderTexture[] tmp = new RenderTexture[2];
|
||||||
|
|
||||||
|
int current = 0;
|
||||||
|
|
||||||
|
tmp[0] = RenderTexture.GetTemporary(desc);
|
||||||
|
if(!tmp[0].IsCreated()) tmp[0].Create();
|
||||||
|
|
||||||
|
DownScalePass(maskTexture, tmp[current]);
|
||||||
|
|
||||||
|
for (int level = 1; level < levels - 1; ++level)
|
||||||
|
{
|
||||||
|
int next = (current + 1) % 2;
|
||||||
|
|
||||||
|
desc.width /= 2;
|
||||||
|
desc.height /= 2;
|
||||||
|
tmp[next] = RenderTexture.GetTemporary(desc);
|
||||||
|
if (!tmp[next].IsCreated()) tmp[next].Create();
|
||||||
|
|
||||||
|
DownScalePass(tmp[current], tmp[next]);
|
||||||
|
|
||||||
|
RenderTexture.ReleaseTemporary(tmp[current]);
|
||||||
|
current = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
//commit to final tex
|
||||||
|
DownScalePass(tmp[current], m_downScaledMaskTexture);
|
||||||
|
|
||||||
|
RenderTexture.ReleaseTemporary(tmp[current]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//commit to final tex
|
||||||
|
DownScalePass(maskTexture, m_downScaledMaskTexture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
if (clip == null || !clip.isSetup) return;
|
||||||
|
|
||||||
|
if (m_blurFilter == null)
|
||||||
|
{
|
||||||
|
m_blurFilter = new GaussianBlurFilter();
|
||||||
|
m_blurFilter.clip = clip;
|
||||||
|
}
|
||||||
|
m_blurFilter.Setup();
|
||||||
|
Util.EnsureComputeShader(ref m_sobelFilterCompute, "Shaders/Util/SobelFilter");
|
||||||
|
Util.EnsureComputeShader(ref m_downScaleCompute, "Shaders/Util/MinMaxDownscaleByHalf");
|
||||||
|
|
||||||
|
m_sobelFilterKId = m_sobelFilterCompute.FindKernel(Util.GetScaled2DKernelName("KSobelFilter"));
|
||||||
|
|
||||||
|
if (m_perspectivesToSlice == null || m_perspectivesToSlice.Length != Metadata.MaxPerspectives ||
|
||||||
|
m_sliceToPerspective == null || m_sliceToPerspective.Length != Metadata.MaxPerspectives)
|
||||||
|
{
|
||||||
|
m_perspectivesToSlice = new Vector4[Metadata.MaxPerspectives];
|
||||||
|
m_sliceToPerspective = new Vector4[Metadata.MaxPerspectives];
|
||||||
|
}
|
||||||
|
for (int ind = 0; ind < clip.metadata.perspectivesCount; ++ind)
|
||||||
|
{
|
||||||
|
// map perspective id to slice index and slice to perspective id
|
||||||
|
// they are the same value as the slices are not priortized and are in the same order as the perspectives
|
||||||
|
m_perspectivesToSlice[ind] = new Vector4(ind, 0, 0, 0);
|
||||||
|
m_sliceToPerspective[ind] = new Vector4(ind, 0, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EnsureTexture()
|
||||||
|
{
|
||||||
|
if (clip == null || clip.isSetup == false) return;
|
||||||
|
Vector2Int originalRes = clip.metadata.perspectiveResolution;
|
||||||
|
Vector2Int paddedRes = clip.metadata.paddedTextureDimensions;
|
||||||
|
|
||||||
|
if (Util.EnsureRenderTexture(
|
||||||
|
ref m_maskTexture,
|
||||||
|
paddedRes.x / scale, paddedRes.y / scale,
|
||||||
|
RenderTextureFormat.RFloat,
|
||||||
|
RenderTextureReadWrite.Linear,
|
||||||
|
false,
|
||||||
|
FilterMode.Bilinear,
|
||||||
|
true,
|
||||||
|
RenderTextureFormat.RFloat,
|
||||||
|
UnityEngine.Rendering.TextureDimension.Tex2DArray,
|
||||||
|
sliceCount))
|
||||||
|
{
|
||||||
|
m_maskTexture.name = "Depthkit Mask Texture";
|
||||||
|
m_maskTextureFormat = m_maskTexture.format;
|
||||||
|
m_maskTextureTS = new Vector4(1.0f / (originalRes.x / (float)scale), 1.0f / (originalRes.y / (float)scale), originalRes.x / (float)scale, originalRes.y / (float)scale);
|
||||||
|
}
|
||||||
|
m_blurFilter.EnsureTextures(m_maskTexture);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Release()
|
||||||
|
{
|
||||||
|
Util.ReleaseComputeBuffer(ref m_sobelMultiplierBuffer);
|
||||||
|
if (m_blurFilter != null) m_blurFilter.Release();
|
||||||
|
Util.ReleaseRenderTexture(ref m_maskTexture);
|
||||||
|
Util.ReleaseRenderTexture(ref m_downScaledMaskTexture);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SobelFilterMask()
|
||||||
|
{
|
||||||
|
clip.SetProperties(ref m_sobelFilterCompute, m_sobelFilterKId);
|
||||||
|
|
||||||
|
if (externalSourceTexture != null)
|
||||||
|
{
|
||||||
|
m_sobelFilterCompute.SetTexture(m_sobelFilterKId, MaskGeneratorShaderIds._CPPTexture, externalSourceTexture);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_sobelFilterCompute.SetInt(MaskGeneratorShaderIds._SliceCount, sliceCount);
|
||||||
|
m_sobelFilterCompute.SetVectorArray(MaskGeneratorShaderIds._SliceToPerspective, m_sliceToPerspective);
|
||||||
|
|
||||||
|
m_sobelFilterCompute.SetTexture(m_sobelFilterKId, MaskGeneratorShaderIds._MaskTexture, m_maskTexture);
|
||||||
|
|
||||||
|
Util.EnsureComputeBuffer(ComputeBufferType.Structured, ref m_sobelMultiplierBuffer, sliceCount, sizeof(float));
|
||||||
|
|
||||||
|
// compute new sobel strength based on scale differences to original texture size
|
||||||
|
float[] sobelMultipliers = new float[sliceCount];
|
||||||
|
for (int i = 0; i < sliceCount; i++)
|
||||||
|
{
|
||||||
|
ref Metadata.Perspective perspective = ref clip.metadata.perspectives[i];
|
||||||
|
float minOriginalDim = Mathf.Min(perspective.depthImageSize.x, perspective.depthImageSize.y);
|
||||||
|
Vector2 croppedDim = perspective.depthImageSize * new Vector2(perspective.crop.z, perspective.crop.w);
|
||||||
|
|
||||||
|
Vector2 scale = new Vector2(m_maskTexture.width, m_maskTexture.height) / croppedDim;
|
||||||
|
|
||||||
|
sobelMultipliers[i] = sobelMultiplier * Mathf.Min(scale.x, scale.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_sobelMultiplierBuffer.SetData(sobelMultipliers);
|
||||||
|
m_sobelFilterCompute.SetBuffer(m_sobelFilterKId, MaskGeneratorShaderIds._SobelMultiplier, m_sobelMultiplierBuffer);
|
||||||
|
m_sobelFilterCompute.SetFloat(MaskGeneratorShaderIds._SobelInvalidateStrength, useStudioCoefficients ? 0.25f : 1.0f);
|
||||||
|
m_sobelFilterCompute.SetFloat(MaskGeneratorShaderIds._StaticSobelMultiplier, useStudioCoefficients ? 24.0f : 1.0f);
|
||||||
|
m_sobelFilterCompute.SetFloat(MaskGeneratorShaderIds._StaticSobelPower, useStudioCoefficients ? 1.5f : 1.0f);
|
||||||
|
m_sobelFilterCompute.SetVector(MaskGeneratorShaderIds._MaskTextureTS, m_maskTextureTS);
|
||||||
|
m_sobelFilterCompute.SetFloat(MaskGeneratorShaderIds._SobelInvalidateEdgeWidth, m_blurFilter.radius);
|
||||||
|
Util.DispatchGroups(m_sobelFilterCompute, m_sobelFilterKId, m_maskTexture.width, m_maskTexture.height, sliceCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void BlurMask()
|
||||||
|
{
|
||||||
|
m_blurFilter.clip = clip;
|
||||||
|
m_blurFilter.DoBlur(m_maskTexture);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GenerateMask()
|
||||||
|
{
|
||||||
|
EnsureTexture();
|
||||||
|
|
||||||
|
SobelFilterMask();
|
||||||
|
|
||||||
|
if (blurRadius > float.Epsilon)
|
||||||
|
{
|
||||||
|
BlurMask();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(downScale > 0)
|
||||||
|
{
|
||||||
|
DownScaleMaskTexture();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetProperties(ref ComputeShader compute, int kernel)
|
||||||
|
{
|
||||||
|
if (perspectivesToSlice != null && perspectivesToSlice.Length != 0)
|
||||||
|
compute.SetVectorArray(MaskGeneratorShaderIds._PerspectiveToSlice, perspectivesToSlice);
|
||||||
|
compute.SetInt(MaskGeneratorShaderIds._SliceCount, sliceCount);
|
||||||
|
compute.SetVector(MaskGeneratorShaderIds._PaddedUVScaleFactor, paddedUVScaleFactor);
|
||||||
|
if (maskTexture != null)
|
||||||
|
{
|
||||||
|
compute.SetTexture(kernel, MaskGeneratorShaderIds._MaskTexture, maskTexture);
|
||||||
|
compute.SetVector(MaskGeneratorShaderIds._MaskTextureTS, m_maskTextureTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetProperties(ref Material material)
|
||||||
|
{
|
||||||
|
if (perspectivesToSlice != null && perspectivesToSlice.Length != 0)
|
||||||
|
material.SetVectorArray(MaskGeneratorShaderIds._PerspectiveToSlice, perspectivesToSlice);
|
||||||
|
material.SetInt(MaskGeneratorShaderIds._SliceCount, sliceCount);
|
||||||
|
material.SetVector(MaskGeneratorShaderIds._PaddedUVScaleFactor, paddedUVScaleFactor);
|
||||||
|
Util.EnsureKeyword(ref material, MaskGeneratorShaderIds._UseEdgeMask, true);
|
||||||
|
Util.EnsureKeyword(ref material, MaskGeneratorShaderIds._DebugEdgeMask, enableMaskDebug);
|
||||||
|
if (maskTexture != null)
|
||||||
|
{
|
||||||
|
material.SetTexture(MaskGeneratorShaderIds._MaskTexture, maskTexture);
|
||||||
|
material.SetVector(MaskGeneratorShaderIds._MaskTextureTS, m_maskTextureTS);
|
||||||
|
}
|
||||||
|
if (enableMaskDebug && downScaledMaskTexture != null)
|
||||||
|
{
|
||||||
|
material.SetTexture(MaskGeneratorShaderIds._DownsampledMaskTexture, downScaledMaskTexture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetProperties(ref Material material, ref MaterialPropertyBlock block)
|
||||||
|
{
|
||||||
|
if(perspectivesToSlice != null && perspectivesToSlice.Length != 0)
|
||||||
|
block.SetVectorArray(MaskGeneratorShaderIds._PerspectiveToSlice, perspectivesToSlice);
|
||||||
|
block.SetInt(MaskGeneratorShaderIds._SliceCount, sliceCount);
|
||||||
|
block.SetVector(MaskGeneratorShaderIds._PaddedUVScaleFactor, paddedUVScaleFactor);
|
||||||
|
Util.EnsureKeyword(ref material, MaskGeneratorShaderIds._UseEdgeMask, true);
|
||||||
|
Util.EnsureKeyword(ref material, MaskGeneratorShaderIds._DebugEdgeMask, enableMaskDebug);
|
||||||
|
if (maskTexture != null)
|
||||||
|
{
|
||||||
|
block.SetTexture(MaskGeneratorShaderIds._MaskTexture, maskTexture);
|
||||||
|
block.SetVector(MaskGeneratorShaderIds._MaskTextureTS, m_maskTextureTS);
|
||||||
|
}
|
||||||
|
if (enableMaskDebug && downScaledMaskTexture != null)
|
||||||
|
{
|
||||||
|
block.SetTexture(MaskGeneratorShaderIds._DownsampledMaskTexture, downScaledMaskTexture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9da6cdd240e7d0f429b6ea45e868be43
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,497 @@
|
||||||
|
/************************************************************************************
|
||||||
|
|
||||||
|
Depthkit Unity SDK License v1
|
||||||
|
Copyright 2016-2024 Simile Inc dba Scatter. All Rights reserved.
|
||||||
|
|
||||||
|
Licensed under the the Simile Inc dba Scatter ("Scatter")
|
||||||
|
Software Development Kit License Agreement (the "License");
|
||||||
|
you may not use this SDK except in compliance with the License,
|
||||||
|
which is provided at the time of installation or download,
|
||||||
|
or which otherwise accompanies this software in either electronic or hard copy form.
|
||||||
|
|
||||||
|
You may obtain a copy of the License at http://www.depthkit.tv/license-agreement-v1
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
the SDK distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.XR;
|
||||||
|
using System.Linq;
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace Depthkit
|
||||||
|
{
|
||||||
|
public abstract class MeshSource : DataSource, IPropertyTransfer
|
||||||
|
{
|
||||||
|
#region SubMeshes
|
||||||
|
|
||||||
|
public bool recalculateCurrentSurfaceTriangleCount = false;
|
||||||
|
|
||||||
|
private SubMesh[] m_subMeshes;
|
||||||
|
|
||||||
|
// Note: this is to serialize the max triangles, as the m_subMeshes array cannot be serialized.
|
||||||
|
[SerializeField]
|
||||||
|
private uint[] m_subMeshMaxTriangles;
|
||||||
|
|
||||||
|
public SubMesh GetSubMesh(int index)
|
||||||
|
{
|
||||||
|
if (m_subMeshes == null || index >= m_subMeshes.Length) return null;
|
||||||
|
return m_subMeshes[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
public T GetSubMesh<T>(int index) where T : SubMesh
|
||||||
|
{
|
||||||
|
return GetSubMesh(index) as T;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SubMesh CurrentSubMesh()
|
||||||
|
{
|
||||||
|
if (m_subMeshes == null || currentSubmeshIndex >= m_subMeshes.Length) return null;
|
||||||
|
return m_subMeshes[currentSubmeshIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
public T CurrentSubMesh<T>() where T : SubMesh
|
||||||
|
{
|
||||||
|
return CurrentSubMesh() as T;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ReserveSubMeshes<T>(int count) where T : SubMesh, new()
|
||||||
|
{
|
||||||
|
if (m_subMeshMaxTriangles == null || m_subMeshMaxTriangles.Length != count)
|
||||||
|
{
|
||||||
|
m_subMeshMaxTriangles = new uint[count];
|
||||||
|
for (int idx = 0; idx < count; idx++)
|
||||||
|
{
|
||||||
|
m_subMeshMaxTriangles[idx] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_subMeshes == null || m_subMeshes.Length != count)
|
||||||
|
{
|
||||||
|
if (m_subMeshes != null)
|
||||||
|
{
|
||||||
|
foreach (var sm in m_subMeshes)
|
||||||
|
{
|
||||||
|
sm.Release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_subMeshes = Enumerable.Range(0, count).Select(i =>
|
||||||
|
{
|
||||||
|
return new T();
|
||||||
|
}).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int idx = 0; idx < count; idx++)
|
||||||
|
{
|
||||||
|
m_subMeshes[idx].source = this;
|
||||||
|
m_subMeshes[idx].maxTriangles = m_subMeshMaxTriangles[idx];
|
||||||
|
m_subMeshes[idx].useTriangleMesh = m_useTriangleMesh;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
public static class MeshSourceShaderIds
|
||||||
|
{
|
||||||
|
public static readonly int
|
||||||
|
_RadialBiasPerspInMeters = Shader.PropertyToID("_RadialBiasPerspInMeters");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected bool m_forceStereo = false;
|
||||||
|
|
||||||
|
protected uint m_currentSubmeshIndex;
|
||||||
|
public uint currentSubmeshIndex
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_currentSubmeshIndex;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_currentSubmeshIndex = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ComputeBuffer triangleBuffer
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_subMeshes == null ? null : m_subMeshes.Length <= m_currentSubmeshIndex ? null : m_subMeshes[m_currentSubmeshIndex].triangleBuffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ComputeBuffer triangleBufferDispatchIndirectArgs
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_subMeshes == null ? null : m_subMeshes.Length <= m_currentSubmeshIndex ? null : m_subMeshes[m_currentSubmeshIndex].dispatchIndirectArgs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ComputeBuffer triangleBufferDrawIndirectArgs
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_subMeshes == null ? null : m_subMeshes.Length <= m_currentSubmeshIndex ? null : m_subMeshes[m_currentSubmeshIndex].drawIndirectArgs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public uint maxSurfaceTriangles
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_subMeshes == null ? 0 : m_subMeshes.Length <= m_currentSubmeshIndex ? 0 : m_subMeshes[m_currentSubmeshIndex].maxTriangles;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (m_subMeshes != null)
|
||||||
|
{
|
||||||
|
m_subMeshes[m_currentSubmeshIndex].maxTriangles = value;
|
||||||
|
m_subMeshMaxTriangles[m_currentSubmeshIndex] = value;
|
||||||
|
ScheduleResize();
|
||||||
|
ScheduleGenerate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[SerializeField, HideInInspector]
|
||||||
|
bool m_useTriangleMesh = false;
|
||||||
|
public bool useTriangleMesh
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_useTriangleMesh;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (m_subMeshes != null)
|
||||||
|
{
|
||||||
|
foreach (var persp in m_subMeshes)
|
||||||
|
{
|
||||||
|
persp.useTriangleMesh = value;
|
||||||
|
}
|
||||||
|
m_useTriangleMesh = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public TriangleMesh triangleMesh
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_subMeshes == null ? null : m_subMeshes[m_currentSubmeshIndex].triangleMesh;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region RadialBias
|
||||||
|
public const float radialBiasMin = 0.0f;
|
||||||
|
public const float radialBiasMax = 2.50f;
|
||||||
|
[Range(radialBiasMin, radialBiasMax)]
|
||||||
|
public float radialBias = Metadata.DefaultReconstructionSettingsDefaults.depthBiasAdjustment;
|
||||||
|
|
||||||
|
[SerializeField, HideInInspector]
|
||||||
|
public float[] radialBiasPersp = null;
|
||||||
|
// The datatype for the per perspective bias is a float4 because float arrays get pushed to the shader as 4 component float vectors.
|
||||||
|
[SerializeField, HideInInspector]
|
||||||
|
protected Vector4[] radialBiasPerspInMeters = null;
|
||||||
|
void EnsureRadialBias()
|
||||||
|
{
|
||||||
|
// This way of sizing the radialBiasPersp array will cause multiperspective core clips to be sized to 12
|
||||||
|
if (radialBiasPersp == null || radialBiasPersp.Length != clip.metadata.perspectivesCount)
|
||||||
|
{
|
||||||
|
radialBiasPersp = new float[clip.metadata.perspectivesCount];
|
||||||
|
for (int i = 0; i < clip.metadata.perspectivesCount; ++i)
|
||||||
|
{
|
||||||
|
radialBiasPersp[i] = radialBias;
|
||||||
|
}
|
||||||
|
radialBiasPerspInMeters = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This way of sizing the radialBiasPersp array will cause multiperspective core clips to be sized to 12
|
||||||
|
int size = (clip.metadata.perspectivesCount > 1) ? 12 : 1;
|
||||||
|
if (radialBiasPerspInMeters == null || radialBiasPerspInMeters.Length != size)
|
||||||
|
{
|
||||||
|
Vector4 defaultVal = new Vector4(Util.cmToMeters(radialBias), 0, 0, 0);
|
||||||
|
radialBiasPerspInMeters = new Vector4[size];
|
||||||
|
for (int i = 0; i < size; ++i)
|
||||||
|
{
|
||||||
|
radialBiasPerspInMeters[i] = defaultVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region DataSource
|
||||||
|
protected override void AcquireResources()
|
||||||
|
{
|
||||||
|
if (m_subMeshes != null)
|
||||||
|
{
|
||||||
|
int index = 0;
|
||||||
|
foreach (var persp in m_subMeshes)
|
||||||
|
{
|
||||||
|
persp.EnsureBuffers(index++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_clip.isSetup) return;
|
||||||
|
EnsureRadialBias();
|
||||||
|
base.AcquireResources();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void FreeResources()
|
||||||
|
{
|
||||||
|
if (m_subMeshes != null)
|
||||||
|
{
|
||||||
|
foreach (var submesh in m_subMeshes)
|
||||||
|
{
|
||||||
|
submesh.Release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
base.FreeResources();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool CanGenerate()
|
||||||
|
{
|
||||||
|
if (m_subMeshes == null) return false;
|
||||||
|
|
||||||
|
bool usesTriangleMesh = false;
|
||||||
|
foreach (var persp in m_subMeshes)
|
||||||
|
{
|
||||||
|
if (persp.useTriangleMesh) usesTriangleMesh = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!usesTriangleMesh && (pauseDataGenerationWhenInvisible || pausePlayerWhenInvisible))
|
||||||
|
{
|
||||||
|
CheckVisibility();
|
||||||
|
}
|
||||||
|
return m_doGeneration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool OnSetup()
|
||||||
|
{
|
||||||
|
Util.ArgsBufferPrep.Setup();
|
||||||
|
|
||||||
|
//TODO this is a hack b/c the openVR plugin doesn't properly report XRSettings.stereoRenderingMode
|
||||||
|
if (XRSettings.supportedDevices.Length > 0)
|
||||||
|
{
|
||||||
|
foreach (var dev in XRSettings.supportedDevices)
|
||||||
|
{
|
||||||
|
if (dev.Contains("OpenVR"))
|
||||||
|
{
|
||||||
|
m_forceStereo = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnResize()
|
||||||
|
{
|
||||||
|
if (!m_clip.isSetup || m_clip.metadata.textureWidth == 0 || m_clip.metadata.textureHeight == 0) return true;
|
||||||
|
|
||||||
|
// This way of sizing the radialBiasPersp array will cause multiperspective core clips to be sized to 12
|
||||||
|
if (radialBiasPersp == null || radialBiasPersp.Length != clip.metadata.perspectivesCount)
|
||||||
|
{
|
||||||
|
radialBiasPersp = new float[clip.metadata.perspectivesCount];
|
||||||
|
for (int i = 0; i < clip.metadata.perspectivesCount; ++i)
|
||||||
|
{
|
||||||
|
radialBiasPersp[i] = radialBias;
|
||||||
|
}
|
||||||
|
radialBiasPerspInMeters = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This way of sizing the radialBiasPersp array will cause multiperspective core clips to be sized to 12
|
||||||
|
int size = (clip.metadata.perspectivesCount > 1) ? 12 : 1;
|
||||||
|
if (radialBiasPerspInMeters == null || radialBiasPerspInMeters.Length != size)
|
||||||
|
{
|
||||||
|
Vector4 defaultVal = new Vector4(Util.cmToMeters(radialBias), 0, 0, 0);
|
||||||
|
radialBiasPerspInMeters = new Vector4[size];
|
||||||
|
for (int i = 0; i < size; ++i)
|
||||||
|
{
|
||||||
|
radialBiasPerspInMeters[i] = defaultVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnUpdate()
|
||||||
|
{
|
||||||
|
if (m_wasPlaying && !m_pausedFromRenderer)
|
||||||
|
{
|
||||||
|
CheckVisibility();
|
||||||
|
}
|
||||||
|
else if (pauseDataGenerationWhenInvisible && !m_seenOnce)
|
||||||
|
{
|
||||||
|
CheckVisibility();
|
||||||
|
m_seenOnce = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clip != null && clip.isSetup && radialBiasPersp != null && radialBiasPerspInMeters != null)
|
||||||
|
{
|
||||||
|
// propagate radialBias value to per perspective
|
||||||
|
for (int i = 0; i < radialBiasPersp.Length; ++i)
|
||||||
|
{
|
||||||
|
if (radialBiasPerspInMeters != null && radialBiasPerspInMeters.Length > 0)
|
||||||
|
{
|
||||||
|
radialBiasPerspInMeters[i].x = Util.cmToMeters(radialBias);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
base.OnUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnGenerate()
|
||||||
|
{
|
||||||
|
if (m_subMeshes == null) return false;
|
||||||
|
|
||||||
|
foreach (var submesh in m_subMeshes)
|
||||||
|
{
|
||||||
|
submesh.CopyTriangleCount();
|
||||||
|
Util.ArgsBufferPrep.PrepareDrawArgs(submesh.trianglesCount, submesh.drawIndirectArgs, m_forceStereo);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (recalculateCurrentSurfaceTriangleCount)
|
||||||
|
{
|
||||||
|
uint tempSubMeshIndex = currentSubmeshIndex;
|
||||||
|
for (uint i = 0; i < m_subMeshes.Length; i++)
|
||||||
|
{
|
||||||
|
currentSubmeshIndex = i;
|
||||||
|
maxSurfaceTriangles = m_subMeshes[i].calculateMaxTrianglesNeeded();
|
||||||
|
}
|
||||||
|
currentSubmeshIndex = tempSubMeshIndex;
|
||||||
|
|
||||||
|
recalculateCurrentSurfaceTriangleCount = false;
|
||||||
|
ScheduleResize();
|
||||||
|
ScheduleGenerate();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Visibility
|
||||||
|
|
||||||
|
public bool pauseDataGenerationWhenInvisible = false;
|
||||||
|
public bool pausePlayerWhenInvisible = false;
|
||||||
|
|
||||||
|
protected bool m_wasPlaying = false;
|
||||||
|
protected bool m_doGeneration = true;
|
||||||
|
protected bool m_pausedFromRenderer = false;
|
||||||
|
protected bool m_seenOnce = false;
|
||||||
|
|
||||||
|
public virtual Bounds GetLocalBounds()
|
||||||
|
{
|
||||||
|
return clip != null ?
|
||||||
|
new Bounds(clip.metadata.boundsCenter, clip.metadata.boundsSize) :
|
||||||
|
new Bounds(Vector3.zero, Vector3.one);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual Bounds GetWorldBounds()
|
||||||
|
{
|
||||||
|
Bounds bounds = GetLocalBounds();
|
||||||
|
Vector3 alt1 = bounds.center - new Vector3(-bounds.extents.x, -bounds.extents.y, bounds.extents.z);
|
||||||
|
Vector3 alt2 = bounds.center + new Vector3(-bounds.extents.x, -bounds.extents.y, bounds.extents.z);
|
||||||
|
return GeometryUtility.CalculateBounds(new Vector3[] { bounds.min, bounds.max, alt1, alt2 }, transform.localToWorldMatrix);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void Pause()
|
||||||
|
{
|
||||||
|
if (pausePlayerWhenInvisible)
|
||||||
|
{
|
||||||
|
if (clip.player.IsPlaying())
|
||||||
|
{
|
||||||
|
m_wasPlaying = true;
|
||||||
|
clip.player.Pause();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pauseDataGenerationWhenInvisible || pausePlayerWhenInvisible)
|
||||||
|
{
|
||||||
|
m_doGeneration = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void Continue()
|
||||||
|
{
|
||||||
|
if (pausePlayerWhenInvisible)
|
||||||
|
{
|
||||||
|
if (!clip.player.IsPlaying() && m_wasPlaying)
|
||||||
|
{
|
||||||
|
clip.player.Play();
|
||||||
|
m_wasPlaying = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pauseDataGenerationWhenInvisible || pausePlayerWhenInvisible)
|
||||||
|
{
|
||||||
|
m_doGeneration = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnBecameVisible()
|
||||||
|
{
|
||||||
|
Continue();
|
||||||
|
m_pausedFromRenderer = false;
|
||||||
|
m_seenOnce = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnBecameInvisible()
|
||||||
|
{
|
||||||
|
Pause();
|
||||||
|
m_pausedFromRenderer = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void CheckVisibility()
|
||||||
|
{
|
||||||
|
bool visible = Util.IsVisible(GetWorldBounds());
|
||||||
|
if (visible != m_doGeneration) //these should always be the same
|
||||||
|
{
|
||||||
|
if (visible)
|
||||||
|
{
|
||||||
|
Continue();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Pause();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region IPropertyTransfer
|
||||||
|
|
||||||
|
public virtual void SetProperties(ref ComputeShader compute, int kernel)
|
||||||
|
{
|
||||||
|
if (radialBiasPerspInMeters != null)
|
||||||
|
compute.SetVectorArray(MeshSourceShaderIds._RadialBiasPerspInMeters, radialBiasPerspInMeters);
|
||||||
|
if (m_subMeshes != null && m_subMeshes.Length > currentSubmeshIndex)
|
||||||
|
m_subMeshes[currentSubmeshIndex].SetProperties(ref compute, kernel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void SetProperties(ref Material material)
|
||||||
|
{
|
||||||
|
if (radialBiasPerspInMeters != null)
|
||||||
|
material.SetVectorArray(MeshSourceShaderIds._RadialBiasPerspInMeters, radialBiasPerspInMeters);
|
||||||
|
if (m_subMeshes != null && m_subMeshes.Length > currentSubmeshIndex)
|
||||||
|
m_subMeshes[currentSubmeshIndex].SetProperties(ref material);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void SetProperties(ref Material material, ref MaterialPropertyBlock block)
|
||||||
|
{
|
||||||
|
if (radialBiasPerspInMeters != null)
|
||||||
|
block.SetVectorArray(MeshSourceShaderIds._RadialBiasPerspInMeters, radialBiasPerspInMeters);
|
||||||
|
if (m_subMeshes != null && m_subMeshes.Length > currentSubmeshIndex)
|
||||||
|
m_subMeshes[currentSubmeshIndex].SetProperties(ref material, ref block);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6e298b291aebe7a4797e9ea0020f2d44
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,200 @@
|
||||||
|
/************************************************************************************
|
||||||
|
|
||||||
|
Depthkit Unity SDK License v1
|
||||||
|
Copyright 2016-2024 Simile Inc dba Scatter. All Rights reserved.
|
||||||
|
|
||||||
|
Licensed under the the Simile Inc dba Scatter ("Scatter")
|
||||||
|
Software Development Kit License Agreement (the "License");
|
||||||
|
you may not use this SDK except in compliance with the License,
|
||||||
|
which is provided at the time of installation or download,
|
||||||
|
or which otherwise accompanies this software in either electronic or hard copy form.
|
||||||
|
|
||||||
|
You may obtain a copy of the License at http://www.depthkit.tv/license-agreement-v1
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
the SDK distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
using System.Collections;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.XR;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace Depthkit
|
||||||
|
{
|
||||||
|
[System.Serializable]
|
||||||
|
public abstract class SubMesh : IPropertyTransfer
|
||||||
|
{
|
||||||
|
public uint maxTriangles;
|
||||||
|
|
||||||
|
#region TriangleData
|
||||||
|
|
||||||
|
public static class TriangleDataShaderIds
|
||||||
|
{
|
||||||
|
public static readonly int
|
||||||
|
_TriangleBuffer = Shader.PropertyToID("_TriangleBuffer"),
|
||||||
|
_TrianglesDispatchIndirectArgs = Shader.PropertyToID("_TrianglesDispatchIndirectArgs"),
|
||||||
|
_TrianglesCount = Shader.PropertyToID("_TrianglesCount"),
|
||||||
|
_TrianglesDrawIndirectArgs = Shader.PropertyToID("_TrianglesDrawIndirectArgs");
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract int GetDataTypeSizeInBytes();
|
||||||
|
|
||||||
|
protected ComputeBuffer m_triangleBuffer;
|
||||||
|
protected ComputeBuffer m_trianglesCount = null;
|
||||||
|
protected ComputeBuffer m_dispatchIndirectArgs = null;
|
||||||
|
protected ComputeBuffer m_drawIndirectArgs = null;
|
||||||
|
|
||||||
|
//returns appendable buffer that contains packed valid triangle data
|
||||||
|
public ComputeBuffer triangleBuffer { get { return m_triangleBuffer; } }
|
||||||
|
|
||||||
|
//returns a buffer that contains only the count of appended triangles
|
||||||
|
public ComputeBuffer trianglesCount { get { return m_trianglesCount; } }
|
||||||
|
|
||||||
|
//returns buffer with triangle count in the x dispatch for DispatchIndirect
|
||||||
|
public ComputeBuffer dispatchIndirectArgs { get { return m_dispatchIndirectArgs; } }
|
||||||
|
|
||||||
|
//returns buffer with drawable vertex count and instanced stereo count for DrawIndirect
|
||||||
|
public ComputeBuffer drawIndirectArgs { get { return m_drawIndirectArgs; } }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region BufferManagement
|
||||||
|
public virtual void Init(int subMeshIndex = -1)
|
||||||
|
{
|
||||||
|
if (maxTriangles == 0)
|
||||||
|
{
|
||||||
|
maxTriangles = 200000;
|
||||||
|
}
|
||||||
|
|
||||||
|
EnsureBuffers(subMeshIndex);
|
||||||
|
triangleBuffer.SetCounterValue(0);
|
||||||
|
|
||||||
|
if (useTriangleMesh)
|
||||||
|
{
|
||||||
|
triangleMesh.EnsureTriangleMesh((int)maxTriangles);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CopyTriangleCount()
|
||||||
|
{
|
||||||
|
ComputeBuffer.CopyCount(triangleBuffer, trianglesCount, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public uint calculateMaxTrianglesNeeded() {
|
||||||
|
int[] bufferDataTris = new int[1];
|
||||||
|
trianglesCount.GetData(bufferDataTris);
|
||||||
|
return (uint)bufferDataTris[0] + (uint)((float)bufferDataTris[0] * 0.2f); // set 20% higher to account for frame variations in triangle count
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PrepareDrawArgs(bool forceStereo)
|
||||||
|
{
|
||||||
|
Util.ArgsBufferPrep.PrepareDrawArgs(trianglesCount, drawIndirectArgs, forceStereo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PrepareDispatchArgs(int groupSize, int dispatchY = 1, int dispatchZ = 1)
|
||||||
|
{
|
||||||
|
Util.ArgsBufferPrep.PrepareDispatchArgs(trianglesCount, dispatchIndirectArgs, groupSize, dispatchY, dispatchZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region LifeCycle
|
||||||
|
public virtual void EnsureBuffers(int submeshIndex = -1)
|
||||||
|
{
|
||||||
|
if (maxTriangles > 0)
|
||||||
|
{
|
||||||
|
if (Util.EnsureComputeBuffer(ComputeBufferType.Append, ref m_triangleBuffer, (int)maxTriangles, GetDataTypeSizeInBytes()))
|
||||||
|
{
|
||||||
|
triangleBuffer.name = "Depthkit Mesh Source Triangles Buffer " + (submeshIndex == -1 ? "" : submeshIndex.ToString());
|
||||||
|
}
|
||||||
|
if (Util.EnsureComputeBuffer(ComputeBufferType.IndirectArguments, ref m_trianglesCount, 1, sizeof(int)))
|
||||||
|
{
|
||||||
|
trianglesCount.name = "Depthkit Mesh Source Triangles Count Buffer " + (submeshIndex == -1 ? "" : submeshIndex.ToString());
|
||||||
|
trianglesCount.SetData(new int[] { 0 });
|
||||||
|
}
|
||||||
|
if (Util.EnsureComputeBuffer(ComputeBufferType.IndirectArguments, ref m_dispatchIndirectArgs, 3, sizeof(int)))
|
||||||
|
{
|
||||||
|
dispatchIndirectArgs.name = "Depthkit Mesh Source Triangles Dispatch Args Buffer " + (submeshIndex == -1 ? "" : submeshIndex.ToString());
|
||||||
|
dispatchIndirectArgs.SetData(new int[] { 0, 1, 1 });
|
||||||
|
}
|
||||||
|
if (Util.EnsureComputeBuffer(ComputeBufferType.IndirectArguments, ref m_drawIndirectArgs, 5, sizeof(int)))
|
||||||
|
{
|
||||||
|
drawIndirectArgs.name = "Depthkit Mesh Source Triangles Indirect Draw Args Buffer " + (submeshIndex == -1 ? "" : submeshIndex.ToString());
|
||||||
|
drawIndirectArgs.SetData(new int[] { 0, (XRSettings.stereoRenderingMode == XRSettings.StereoRenderingMode.SinglePassInstanced || XRSettings.stereoRenderingMode == XRSettings.StereoRenderingMode.SinglePassMultiview) ? 2 : 1, 0, 0 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useTriangleMesh) triangleMesh.EnsureTriangleMesh((int)maxTriangles);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void Release()
|
||||||
|
{
|
||||||
|
Util.ReleaseComputeBuffer(ref m_triangleBuffer);
|
||||||
|
Util.ReleaseComputeBuffer(ref m_trianglesCount);
|
||||||
|
Util.ReleaseComputeBuffer(ref m_dispatchIndirectArgs);
|
||||||
|
Util.ReleaseComputeBuffer(ref m_drawIndirectArgs);
|
||||||
|
if (useTriangleMesh && m_triangleMesh != null) m_triangleMesh.ReleaseMesh();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region TriangleMesh
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
private MeshSource m_source = null;
|
||||||
|
|
||||||
|
public MeshSource source
|
||||||
|
{
|
||||||
|
set { m_source = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool useTriangleMesh = false;
|
||||||
|
|
||||||
|
private Depthkit.TriangleMesh m_triangleMesh;
|
||||||
|
public Depthkit.TriangleMesh triangleMesh
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (m_triangleMesh == null)
|
||||||
|
{
|
||||||
|
if (useTriangleMesh)
|
||||||
|
{
|
||||||
|
m_triangleMesh = new Depthkit.TriangleMesh();
|
||||||
|
m_triangleMesh.source = m_source;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return m_triangleMesh;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region IPropertyTransfer
|
||||||
|
public virtual void SetProperties(ref ComputeShader compute, int kernel)
|
||||||
|
{
|
||||||
|
compute.SetBuffer(kernel, TriangleDataShaderIds._TriangleBuffer, triangleBuffer);
|
||||||
|
compute.SetBuffer(kernel, TriangleDataShaderIds._TrianglesCount, trianglesCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void SetProperties(ref Material material)
|
||||||
|
{
|
||||||
|
material.SetBuffer(TriangleDataShaderIds._TriangleBuffer, triangleBuffer);
|
||||||
|
material.SetBuffer(TriangleDataShaderIds._TrianglesCount, trianglesCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void SetProperties(ref Material material, ref MaterialPropertyBlock block)
|
||||||
|
{
|
||||||
|
block.SetBuffer(TriangleDataShaderIds._TriangleBuffer, triangleBuffer);
|
||||||
|
block.SetBuffer(TriangleDataShaderIds._TrianglesCount, trianglesCount);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class SubMesh<TriangleType> : SubMesh where TriangleType : struct
|
||||||
|
{
|
||||||
|
public override int GetDataTypeSizeInBytes() { return Marshal.SizeOf(typeof(TriangleType)); }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d274ecb28ac19da4d8d3462bd93bab50
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"name": "Depthkit.Core",
|
||||||
|
"rootNamespace": "",
|
||||||
|
"references": [],
|
||||||
|
"includePlatforms": [],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": false,
|
||||||
|
"overrideReferences": false,
|
||||||
|
"precompiledReferences": [],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": [],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d757665d4a59fe94bab8bd5391e60e3d
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: fe8d6b0623f8c6b4587602c74181d4da
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,33 @@
|
||||||
|
/************************************************************************************
|
||||||
|
|
||||||
|
Depthkit Unity SDK License v1
|
||||||
|
Copyright 2016-2024 Simile Inc dba Scatter. All Rights reserved.
|
||||||
|
|
||||||
|
Licensed under the the Simile Inc dba Scatter ("Scatter")
|
||||||
|
Software Development Kit License Agreement (the "License");
|
||||||
|
you may not use this SDK except in compliance with the License,
|
||||||
|
which is provided at the time of installation or download,
|
||||||
|
or which otherwise accompanies this software in either electronic or hard copy form.
|
||||||
|
|
||||||
|
You may obtain a copy of the License at http://www.depthkit.tv/license-agreement-v1
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
the SDK distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
using System.Collections;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Depthkit
|
||||||
|
{
|
||||||
|
//Transfer properties from a source to a target compute, material or material prop block
|
||||||
|
public interface IPropertyTransfer
|
||||||
|
{
|
||||||
|
void SetProperties(ref ComputeShader compute, int kernel);
|
||||||
|
void SetProperties(ref Material material);
|
||||||
|
void SetProperties(ref Material material, ref MaterialPropertyBlock block);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 59a956bcb59b6084d82c60bd04b23e96
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0d618fb68f1d05549a1b8e6672caadcd
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,70 @@
|
||||||
|
/************************************************************************************
|
||||||
|
|
||||||
|
Depthkit Unity SDK License v1
|
||||||
|
Copyright 2016-2024 Simile Inc dba Scatter. All Rights reserved.
|
||||||
|
|
||||||
|
Licensed under the the Simile Inc dba Scatter ("Scatter")
|
||||||
|
Software Development Kit License Agreement (the "License");
|
||||||
|
you may not use this SDK except in compliance with the License,
|
||||||
|
which is provided at the time of installation or download,
|
||||||
|
or which otherwise accompanies this software in either electronic or hard copy form.
|
||||||
|
|
||||||
|
You may obtain a copy of the License at http://www.depthkit.tv/license-agreement-v1
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
the SDK distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
using System.Collections;
|
||||||
|
using System.IO;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Depthkit
|
||||||
|
{
|
||||||
|
[ExecuteInEditMode]
|
||||||
|
[AddComponentMenu("Depthkit/Core/Built-in RP/Depthkit Core Built-in Look")]
|
||||||
|
public class CoreLook : ProceduralLook
|
||||||
|
{
|
||||||
|
protected static Shader s_defaultUnlitPhotoLookShader = null;
|
||||||
|
protected static Material s_defaultUnlitPhotoLookMaterial = null;
|
||||||
|
|
||||||
|
protected static Material GetDefaultMaterial()
|
||||||
|
{
|
||||||
|
if(s_defaultUnlitPhotoLookShader == null)
|
||||||
|
{
|
||||||
|
s_defaultUnlitPhotoLookShader = Shader.Find("Depthkit/Core/Depthkit Core Photo Look Built-in RP");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(s_defaultUnlitPhotoLookMaterial == null)
|
||||||
|
{
|
||||||
|
s_defaultUnlitPhotoLookMaterial = new Material(s_defaultUnlitPhotoLookShader);
|
||||||
|
}
|
||||||
|
return s_defaultUnlitPhotoLookMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string GetLookName(){ return "Depthkit Core Look"; }
|
||||||
|
|
||||||
|
protected override void SetDefaults()
|
||||||
|
{
|
||||||
|
if(lookMaterial == null)
|
||||||
|
{
|
||||||
|
lookMaterial = GetDefaultMaterial();
|
||||||
|
}
|
||||||
|
base.SetDefaults();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void SetDataSources()
|
||||||
|
{
|
||||||
|
if (meshSource == null)
|
||||||
|
{
|
||||||
|
meshSource = depthkitClip.GetDataSource<Depthkit.CoreMeshSource>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 03bb0f90eda0bf24e9fe79bcd169940b
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {fileID: 2800000, guid: 42c51ff9981f3e24b83cd7ad3c56e235, type: 3}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,238 @@
|
||||||
|
/************************************************************************************
|
||||||
|
|
||||||
|
Depthkit Unity SDK License v1
|
||||||
|
Copyright 2016-2024 Simile Inc dba Scatter. All Rights reserved.
|
||||||
|
|
||||||
|
Licensed under the the Simile Inc dba Scatter ("Scatter")
|
||||||
|
Software Development Kit License Agreement (the "License");
|
||||||
|
you may not use this SDK except in compliance with the License,
|
||||||
|
which is provided at the time of installation or download,
|
||||||
|
or which otherwise accompanies this software in either electronic or hard copy form.
|
||||||
|
|
||||||
|
You may obtain a copy of the License at http://www.depthkit.tv/license-agreement-v1
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
the SDK distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
using System.Collections;
|
||||||
|
using System.IO;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Depthkit
|
||||||
|
{
|
||||||
|
public delegate void DepthkitLookEventHandler();
|
||||||
|
|
||||||
|
[DefaultExecutionOrder(-10)]
|
||||||
|
[RequireComponent(typeof(BoxCollider))]
|
||||||
|
[ExecuteInEditMode]
|
||||||
|
public abstract class Look : MonoBehaviour
|
||||||
|
{
|
||||||
|
protected static class LookCommonShaderIds
|
||||||
|
{
|
||||||
|
internal static readonly int _LocalTransformInverse = Shader.PropertyToID("_LocalTransformInverse");
|
||||||
|
internal static readonly int _LocalTransform = Shader.PropertyToID("_LocalTransform");
|
||||||
|
internal static readonly string _DebugKeyword = "DK_USE_DEBUG_COLOR";
|
||||||
|
}
|
||||||
|
|
||||||
|
public Clip depthkitClip = null;
|
||||||
|
public bool showPerViewColorDebug = false;
|
||||||
|
public bool showCameraFrustums = false;
|
||||||
|
public DepthkitLookEventHandler onUpdated;
|
||||||
|
|
||||||
|
private MaterialPropertyBlock m_materialPropertyBlock = null;
|
||||||
|
|
||||||
|
protected void EnsureMaterialPropertyBlock()
|
||||||
|
{
|
||||||
|
if (UsesMaterialPropertyBlock())
|
||||||
|
{
|
||||||
|
if (m_materialPropertyBlock == null)
|
||||||
|
{
|
||||||
|
m_materialPropertyBlock = new MaterialPropertyBlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected MaterialPropertyBlock materialPropertyBlock
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
EnsureMaterialPropertyBlock();
|
||||||
|
return m_materialPropertyBlock;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HideInInspector]
|
||||||
|
public MeshSource meshSource = null;
|
||||||
|
|
||||||
|
/// The bounding box collider</summary>
|
||||||
|
[HideInInspector, SerializeField]
|
||||||
|
protected BoxCollider m_collider = null;
|
||||||
|
|
||||||
|
private bool m_bIsInit = false;
|
||||||
|
|
||||||
|
|
||||||
|
public abstract string GetLookName();
|
||||||
|
protected abstract bool UsesMaterial();
|
||||||
|
protected abstract Material GetMaterial();
|
||||||
|
protected virtual bool UsesMaterialPropertyBlock() { return true; }
|
||||||
|
protected virtual MaterialPropertyBlock GetMaterialPropertyBlock() { return materialPropertyBlock; }
|
||||||
|
protected abstract void SetDataSources();
|
||||||
|
protected virtual bool ValidateDataSources()
|
||||||
|
{
|
||||||
|
return meshSource != null;
|
||||||
|
}
|
||||||
|
protected virtual void SetMaterialProperties(ref Material material) { }
|
||||||
|
protected virtual void SetMaterialProperties(ref Material material, ref MaterialPropertyBlock block) { }
|
||||||
|
|
||||||
|
protected virtual void OnUpdate()
|
||||||
|
{
|
||||||
|
SetLookProperties();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void SetDefaults()
|
||||||
|
{
|
||||||
|
EnsureMaterialPropertyBlock();
|
||||||
|
m_collider = GetComponent<BoxCollider>();
|
||||||
|
}
|
||||||
|
protected virtual void SetLookProperties()
|
||||||
|
{
|
||||||
|
SyncColliderToBounds();
|
||||||
|
|
||||||
|
var material = GetMaterial();
|
||||||
|
if (material == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (UsesMaterialPropertyBlock())
|
||||||
|
{
|
||||||
|
MaterialPropertyBlock block = GetMaterialPropertyBlock();
|
||||||
|
block.Clear();
|
||||||
|
depthkitClip.SetProperties(ref material, ref block);
|
||||||
|
meshSource.SetProperties(ref material, ref block);
|
||||||
|
Util.EnsureKeyword(ref material, LookCommonShaderIds._DebugKeyword, showPerViewColorDebug);
|
||||||
|
block.SetMatrix(LookCommonShaderIds._LocalTransform, transform.localToWorldMatrix);
|
||||||
|
block.SetMatrix(LookCommonShaderIds._LocalTransformInverse, transform.localToWorldMatrix.inverse);
|
||||||
|
SetMaterialProperties(ref material, ref block);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
depthkitClip.SetProperties(ref material);
|
||||||
|
meshSource.SetProperties(ref material);
|
||||||
|
Util.EnsureKeyword(ref material, LookCommonShaderIds._DebugKeyword, showPerViewColorDebug);
|
||||||
|
material.SetMatrix(LookCommonShaderIds._LocalTransform, transform.localToWorldMatrix);
|
||||||
|
material.SetMatrix(LookCommonShaderIds._LocalTransformInverse, transform.localToWorldMatrix.inverse);
|
||||||
|
SetMaterialProperties(ref material);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Awake()
|
||||||
|
{
|
||||||
|
if (m_materialPropertyBlock == null)
|
||||||
|
{
|
||||||
|
m_materialPropertyBlock = new MaterialPropertyBlock();
|
||||||
|
}
|
||||||
|
if (depthkitClip == null)
|
||||||
|
{
|
||||||
|
depthkitClip = GetComponentInParent<Depthkit.Clip>();
|
||||||
|
}
|
||||||
|
SetDefaults();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual bool Init()
|
||||||
|
{
|
||||||
|
if (depthkitClip == null)
|
||||||
|
{
|
||||||
|
depthkitClip = GetComponent<Depthkit.Clip>();
|
||||||
|
}
|
||||||
|
if (!ValidateDataSources())
|
||||||
|
{
|
||||||
|
if (depthkitClip != null)
|
||||||
|
{
|
||||||
|
depthkitClip.newMetadata += OnMetaDataUpdated;
|
||||||
|
OnMetaDataUpdated();
|
||||||
|
SetDataSources();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return depthkitClip != null && ValidateDataSources();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
m_bIsInit = Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
protected virtual void OnAssemblyReload()
|
||||||
|
{
|
||||||
|
Awake();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void OnEnable()
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
AssemblyReloadEvents.afterAssemblyReload += OnAssemblyReload;
|
||||||
|
#endif
|
||||||
|
if (depthkitClip != null)
|
||||||
|
{
|
||||||
|
depthkitClip.newMetadata += OnMetaDataUpdated;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDisable()
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
AssemblyReloadEvents.afterAssemblyReload -= OnAssemblyReload;
|
||||||
|
#endif
|
||||||
|
if (depthkitClip != null)
|
||||||
|
{
|
||||||
|
depthkitClip.newMetadata -= OnMetaDataUpdated;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void SyncColliderToBounds()
|
||||||
|
{
|
||||||
|
if (meshSource != null)
|
||||||
|
{
|
||||||
|
Bounds localBounds = meshSource.GetLocalBounds();
|
||||||
|
m_collider.center = localBounds.center;
|
||||||
|
m_collider.size = localBounds.size;
|
||||||
|
}
|
||||||
|
else if (depthkitClip != null)
|
||||||
|
{
|
||||||
|
m_collider.center = depthkitClip.metadata.boundsCenter;
|
||||||
|
m_collider.size = depthkitClip.metadata.boundsSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnMetaDataUpdated()
|
||||||
|
{
|
||||||
|
SyncColliderToBounds();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LateUpdate()
|
||||||
|
{
|
||||||
|
if (depthkitClip == null) m_bIsInit = false;
|
||||||
|
if (!m_bIsInit)
|
||||||
|
{
|
||||||
|
m_bIsInit = Init();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!depthkitClip.isSetup) return;
|
||||||
|
OnUpdate();
|
||||||
|
if (onUpdated != null)
|
||||||
|
{
|
||||||
|
onUpdated();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 56bfcdaaeb8c5c840b47b3d8effb9b7b
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,77 @@
|
||||||
|
/************************************************************************************
|
||||||
|
|
||||||
|
Depthkit Unity SDK License v1
|
||||||
|
Copyright 2016-2024 Simile Inc dba Scatter. All Rights reserved.
|
||||||
|
|
||||||
|
Licensed under the the Simile Inc dba Scatter ("Scatter")
|
||||||
|
Software Development Kit License Agreement (the "License");
|
||||||
|
you may not use this SDK except in compliance with the License,
|
||||||
|
which is provided at the time of installation or download,
|
||||||
|
or which otherwise accompanies this software in either electronic or hard copy form.
|
||||||
|
|
||||||
|
You may obtain a copy of the License at http://www.depthkit.tv/license-agreement-v1
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
the SDK distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Rendering;
|
||||||
|
|
||||||
|
namespace Depthkit
|
||||||
|
{
|
||||||
|
public abstract class ProceduralLook : Look
|
||||||
|
{
|
||||||
|
public ShadowCastingMode shadowCastingMode = ShadowCastingMode.On;
|
||||||
|
public bool receiveShadows = true;
|
||||||
|
public bool interpolateLightProbes = true;
|
||||||
|
public Transform anchorOverride = null;
|
||||||
|
public Material lookMaterial = null;
|
||||||
|
|
||||||
|
protected override bool UsesMaterial() { return true; }
|
||||||
|
protected override Material GetMaterial() { return lookMaterial; }
|
||||||
|
|
||||||
|
protected override bool UsesMaterialPropertyBlock() { return true; }
|
||||||
|
|
||||||
|
protected override void SetMaterialProperties(ref Material material, ref MaterialPropertyBlock block)
|
||||||
|
{
|
||||||
|
if (interpolateLightProbes)
|
||||||
|
{
|
||||||
|
Vector3[] positions = new Vector3[1] { anchorOverride != null ? anchorOverride.position : transform.position };
|
||||||
|
SphericalHarmonicsL2[] harmonics = new SphericalHarmonicsL2[1];
|
||||||
|
Vector4[] occlusions = new Vector4[1];
|
||||||
|
|
||||||
|
LightProbes.CalculateInterpolatedLightAndOcclusionProbes(positions, harmonics, occlusions);
|
||||||
|
|
||||||
|
block.CopyProbeOcclusionArrayFrom(occlusions, 0, 0, 1);
|
||||||
|
block.CopySHCoefficientArraysFrom(harmonics, 0, 0, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnUpdate()
|
||||||
|
{
|
||||||
|
base.OnUpdate();
|
||||||
|
if (meshSource.triangleBufferDrawIndirectArgs == null ||
|
||||||
|
!meshSource.triangleBufferDrawIndirectArgs.IsValid() ||
|
||||||
|
meshSource.triangleBuffer == null ||
|
||||||
|
!meshSource.triangleBuffer.IsValid())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Graphics.DrawProceduralIndirect(
|
||||||
|
GetMaterial(),
|
||||||
|
meshSource.GetWorldBounds(),
|
||||||
|
MeshTopology.Triangles,
|
||||||
|
meshSource.triangleBufferDrawIndirectArgs, 0,
|
||||||
|
null,
|
||||||
|
GetMaterialPropertyBlock(),
|
||||||
|
shadowCastingMode, //cast shadows
|
||||||
|
receiveShadows, //receive shadows
|
||||||
|
gameObject.layer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 12aed2a2b7dd1434ebc10bc2aa9a0ced
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4d8fa63134a15f342a95986e48f49159
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,148 @@
|
||||||
|
/************************************************************************************
|
||||||
|
|
||||||
|
Depthkit Unity SDK License v1
|
||||||
|
Copyright 2016-2024 Simile Inc dba Scatter. All Rights reserved.
|
||||||
|
|
||||||
|
Licensed under the the Simile Inc dba Scatter ("Scatter")
|
||||||
|
Software Development Kit License Agreement (the "License");
|
||||||
|
you may not use this SDK except in compliance with the License,
|
||||||
|
which is provided at the time of installation or download,
|
||||||
|
or which otherwise accompanies this software in either electronic or hard copy form.
|
||||||
|
|
||||||
|
You may obtain a copy of the License at http://www.depthkit.tv/license-agreement-v1
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
the SDK distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
namespace Depthkit
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The base class that any Depthkit player implementation will derrive from </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This class provides methods that are implemented in child classes to allow
|
||||||
|
/// a way for clip to generically interact with a given player backend. </remarks>
|
||||||
|
|
||||||
|
[RequireComponent(typeof(Depthkit.Clip))]
|
||||||
|
[ExecuteInEditMode]
|
||||||
|
public abstract class ClipPlayer : MonoBehaviour
|
||||||
|
{
|
||||||
|
public bool videoLoaded { get; protected set; }
|
||||||
|
|
||||||
|
[HideInInspector]
|
||||||
|
public Depthkit.PlayerEvents events = new Depthkit.PlayerEvents();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// creates the appropriate player
|
||||||
|
/// </summary>
|
||||||
|
public abstract void CreatePlayer();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// returns player created status
|
||||||
|
/// </summary>
|
||||||
|
public abstract bool IsPlayerCreated();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// returns true if the video player has a video configured and is ready to play
|
||||||
|
/// </summary>
|
||||||
|
public abstract bool IsPlayerSetup();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Load the implemented player video.
|
||||||
|
/// </summary>
|
||||||
|
public abstract IEnumerator Load();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Method to dispatch the video loader to start </summary>
|
||||||
|
public abstract void StartVideoLoad();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Load a video and then play through the implemented player.</summary>
|
||||||
|
public abstract IEnumerator LoadAndPlay();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the video from a path. Assumed absolute file path.</summary>
|
||||||
|
public abstract void SetVideoPath(string path);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the absolute path to the video.</summary>
|
||||||
|
public abstract string GetVideoPath();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Callback for metadata updated on the clip.</summary>
|
||||||
|
public abstract void OnMetadataUpdated(Depthkit.Metadata metadata);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Play through the implemented player. Worth using in combination with VideoLoaded to ensure playback will start when called. </summary>
|
||||||
|
public abstract void Play();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Pause through the implemented player. </summary>
|
||||||
|
public abstract void Pause();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stop playback through the player. </summary>
|
||||||
|
public abstract void Stop();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove the player components from this GameObject. </summary>
|
||||||
|
public abstract void RemoveComponents();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Return the texture for Depthkit to use by Renderers </summary>
|
||||||
|
public abstract Texture GetTexture();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns if texture generated is flipped </summary>
|
||||||
|
public abstract bool IsTextureFlipped();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns if shader needs to gamma correct depth value on this texture</summary>
|
||||||
|
public abstract GammaCorrection GammaCorrectDepth();
|
||||||
|
|
||||||
|
/// Returns if shader needs to gamma correct color value on this shader</summary>
|
||||||
|
public abstract GammaCorrection GammaCorrectColor();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Return the type name of player being used </summary>
|
||||||
|
public abstract string GetPlayerTypeName();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Return the pretty name of player being used </summary>
|
||||||
|
public static string GetPlayerPrettyName(){ return "Must Provide this function"; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if video is playing right now or not </summary>
|
||||||
|
public abstract bool IsPlaying();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the current playback time of the video in seconds. </summary>
|
||||||
|
public abstract double GetCurrentTime();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the current playback frame of the video. </summary>
|
||||||
|
public abstract int GetCurrentFrame();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get duration of video in seconds </summary>
|
||||||
|
public abstract double GetDuration();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Seek to a time point in the video in seconds </summary>
|
||||||
|
public abstract void Seek(float toTimeSeconds);
|
||||||
|
|
||||||
|
public abstract uint GetVideoWidth();
|
||||||
|
|
||||||
|
public abstract uint GetVideoHeight();
|
||||||
|
|
||||||
|
public abstract bool SupportsPosterFrame();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3d8da4e768aedd64dba1ce3c10d7d5cd
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,61 @@
|
||||||
|
/************************************************************************************
|
||||||
|
|
||||||
|
Depthkit Unity SDK License v1
|
||||||
|
Copyright 2016-2024 Simile Inc dba Scatter. All Rights reserved.
|
||||||
|
|
||||||
|
Licensed under the the Simile Inc dba Scatter ("Scatter")
|
||||||
|
Software Development Kit License Agreement (the "License");
|
||||||
|
you may not use this SDK except in compliance with the License,
|
||||||
|
which is provided at the time of installation or download,
|
||||||
|
or which otherwise accompanies this software in either electronic or hard copy form.
|
||||||
|
|
||||||
|
You may obtain a copy of the License at http://www.depthkit.tv/license-agreement-v1
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
the SDK distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
namespace Depthkit
|
||||||
|
{
|
||||||
|
public delegate void ClipPlayerEventHandler();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Class that contains events a given player could potentially emit for listening. </summary>
|
||||||
|
[System.Serializable]
|
||||||
|
public class PlayerEvents
|
||||||
|
{
|
||||||
|
public event ClipPlayerEventHandler playbackStarted;
|
||||||
|
public event ClipPlayerEventHandler playbackPaused;
|
||||||
|
public event ClipPlayerEventHandler playbackStopped;
|
||||||
|
public event ClipPlayerEventHandler loadingStarted;
|
||||||
|
public event ClipPlayerEventHandler loadingFinished;
|
||||||
|
|
||||||
|
public virtual void OnClipPlaybackStarted()
|
||||||
|
{
|
||||||
|
if(playbackStarted != null) { playbackStarted(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnClipPlaybackPaused()
|
||||||
|
{
|
||||||
|
if(playbackPaused != null) { playbackPaused(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnClipPlaybackStopped()
|
||||||
|
{
|
||||||
|
if(playbackStopped != null) { playbackStopped(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnClipLoadingStarted()
|
||||||
|
{
|
||||||
|
if(loadingStarted != null) { loadingStarted(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnClipLoadingFinished()
|
||||||
|
{
|
||||||
|
if(loadingFinished != null) { loadingFinished(); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a90e680aea53a2642b46483fa081088a
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,286 @@
|
||||||
|
/************************************************************************************
|
||||||
|
|
||||||
|
Depthkit Unity SDK License v1
|
||||||
|
Copyright 2016-2024 Simile Inc dba Scatter. All Rights reserved.
|
||||||
|
|
||||||
|
Licensed under the the Simile Inc dba Scatter ("Scatter")
|
||||||
|
Software Development Kit License Agreement (the "License");
|
||||||
|
you may not use this SDK except in compliance with the License,
|
||||||
|
which is provided at the time of installation or download,
|
||||||
|
or which otherwise accompanies this software in either electronic or hard copy form.
|
||||||
|
|
||||||
|
You may obtain a copy of the License at http://www.depthkit.tv/license-agreement-v1
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
the SDK distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
namespace Depthkit
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Implementation of the Depthkit player with the Unity VideoPlayer-based backend.
|
||||||
|
/// </summary>
|
||||||
|
[AddComponentMenu("Depthkit/Players/Depthkit Video Player (Unity)")]
|
||||||
|
public class UnityVideoPlayer : Depthkit.ClipPlayer
|
||||||
|
{
|
||||||
|
//reference to the MovieTexture passed in through Clip
|
||||||
|
[SerializeField, HideInInspector]
|
||||||
|
protected UnityEngine.Video.VideoPlayer m_mediaPlayer;
|
||||||
|
[SerializeField, HideInInspector]
|
||||||
|
protected AudioSource m_audioSource;
|
||||||
|
|
||||||
|
public override void CreatePlayer()
|
||||||
|
{
|
||||||
|
m_mediaPlayer = gameObject.GetComponent<UnityEngine.Video.VideoPlayer>();
|
||||||
|
|
||||||
|
if (m_mediaPlayer == null)
|
||||||
|
{
|
||||||
|
m_mediaPlayer = gameObject.AddComponent<UnityEngine.Video.VideoPlayer>();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_audioSource = gameObject.GetComponent<AudioSource>();
|
||||||
|
|
||||||
|
if (m_audioSource == null)
|
||||||
|
{
|
||||||
|
m_audioSource = gameObject.AddComponent<AudioSource>();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_mediaPlayer.audioOutputMode = UnityEngine.Video.VideoAudioOutputMode.AudioSource;
|
||||||
|
m_mediaPlayer.SetTargetAudioSource(0, m_audioSource);
|
||||||
|
m_mediaPlayer.renderMode = UnityEngine.Video.VideoRenderMode.APIOnly;
|
||||||
|
m_mediaPlayer.prepareCompleted += OnVideoLoadingComplete;
|
||||||
|
m_mediaPlayer.EnableAudioTrack(0, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool IsPlayerCreated()
|
||||||
|
{
|
||||||
|
return m_mediaPlayer != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool IsPlayerSetup()
|
||||||
|
{
|
||||||
|
if(!IsPlayerCreated())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_mediaPlayer.source == UnityEngine.Video.VideoSource.VideoClip)
|
||||||
|
{
|
||||||
|
return m_mediaPlayer.clip != null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return m_mediaPlayer.url != null && m_mediaPlayer.url != "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the video from a path. Assumed relative to data folder file path.</summary>
|
||||||
|
public override void SetVideoPath(string path)
|
||||||
|
{
|
||||||
|
if (!IsPlayerCreated())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// path = path.Replace("\\", "/");
|
||||||
|
// if (path.StartsWith(Application.dataPath))
|
||||||
|
// {
|
||||||
|
// path = "Assets" + path.Substring(Application.dataPath.Length);
|
||||||
|
// }
|
||||||
|
// m_mediaPlayer.source = UnityEngine.Video.VideoSource.Url;
|
||||||
|
m_mediaPlayer.url = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the absolute path to the video.</summary>
|
||||||
|
public override string GetVideoPath()
|
||||||
|
{
|
||||||
|
if (!IsPlayerSetup())
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_mediaPlayer.source == UnityEngine.Video.VideoSource.VideoClip)
|
||||||
|
{
|
||||||
|
return m_mediaPlayer.clip.originalPath;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return m_mediaPlayer.url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void StartVideoLoad()
|
||||||
|
{
|
||||||
|
|
||||||
|
StartCoroutine(Load());
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerator Load()
|
||||||
|
{
|
||||||
|
events.OnClipLoadingStarted();
|
||||||
|
m_mediaPlayer.Prepare();
|
||||||
|
yield return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnVideoLoadingComplete(UnityEngine.Video.VideoPlayer player)
|
||||||
|
{
|
||||||
|
videoLoaded = true;
|
||||||
|
events.OnClipLoadingFinished();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnMetadataUpdated(Depthkit.Metadata metadata){ /* do nothing */ }
|
||||||
|
|
||||||
|
public override IEnumerator LoadAndPlay()
|
||||||
|
{
|
||||||
|
StartVideoLoad();
|
||||||
|
while (!videoLoaded)
|
||||||
|
{
|
||||||
|
yield return null;
|
||||||
|
}
|
||||||
|
Play();
|
||||||
|
yield return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Play()
|
||||||
|
{
|
||||||
|
m_mediaPlayer.Play();
|
||||||
|
events.OnClipPlaybackStarted();
|
||||||
|
}
|
||||||
|
public override void Pause()
|
||||||
|
{
|
||||||
|
m_mediaPlayer.Pause();
|
||||||
|
events.OnClipPlaybackPaused();
|
||||||
|
}
|
||||||
|
public override void Stop()
|
||||||
|
{
|
||||||
|
m_mediaPlayer.Stop();
|
||||||
|
events.OnClipPlaybackStopped();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetCurrentFrame()
|
||||||
|
{
|
||||||
|
return (int)m_mediaPlayer.frame;
|
||||||
|
}
|
||||||
|
public override double GetCurrentTime()
|
||||||
|
{
|
||||||
|
return m_mediaPlayer.time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override double GetDuration()
|
||||||
|
{
|
||||||
|
return m_mediaPlayer.clip.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Texture GetTexture()
|
||||||
|
{
|
||||||
|
return m_mediaPlayer.texture;
|
||||||
|
}
|
||||||
|
public override bool IsTextureFlipped ()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public override GammaCorrection GammaCorrectDepth()
|
||||||
|
{
|
||||||
|
if (QualitySettings.activeColorSpace == ColorSpace.Linear)
|
||||||
|
{
|
||||||
|
#if UNITY_2018_2_OR_NEWER
|
||||||
|
return GammaCorrection.LinearToGammaSpace;
|
||||||
|
#elif UNITY_2017_1_OR_NEWER
|
||||||
|
//https://issuetracker.unity3d.com/issues/regression-videos-are-dark-when-using-linear-color-space?page=1
|
||||||
|
Debug.LogWarning("Video Player (Unity) does not display correct color on Windows between version 2017.1 and 2018.2. Use AVPro, switch to Gamma Color Space, or upgrade Unity to use Depthkit with this project.");
|
||||||
|
return GammaCorrection.LinearToGammaSpace2x;
|
||||||
|
#else
|
||||||
|
return GammaCorrection.LinearToGammaSpace;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return GammaCorrection.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public override GammaCorrection GammaCorrectColor()
|
||||||
|
{
|
||||||
|
if (QualitySettings.activeColorSpace == ColorSpace.Linear)
|
||||||
|
{
|
||||||
|
#if UNITY_2018_2_OR_NEWER
|
||||||
|
return GammaCorrection.None;
|
||||||
|
#elif UNITY_2017_1_OR_NEWER
|
||||||
|
return GammaCorrection.LinearToGammaSpace;
|
||||||
|
#else
|
||||||
|
return GammaCorrection.None;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return GammaCorrection.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public override bool IsPlaying()
|
||||||
|
{
|
||||||
|
return m_mediaPlayer.isPlaying;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void RemoveComponents()
|
||||||
|
{
|
||||||
|
if(!Application.isPlaying)
|
||||||
|
{
|
||||||
|
DestroyImmediate(m_mediaPlayer, true);
|
||||||
|
DestroyImmediate(m_audioSource, true);
|
||||||
|
DestroyImmediate(this, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Destroy(m_mediaPlayer);
|
||||||
|
Destroy(m_audioSource);
|
||||||
|
Destroy(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string GetPlayerTypeName()
|
||||||
|
{
|
||||||
|
return typeof(Depthkit.UnityVideoPlayer).Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public new static string GetPlayerPrettyName()
|
||||||
|
{
|
||||||
|
return "Video Player (Unity)";
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnityEngine.Video.VideoPlayer GetPlayerBackend()
|
||||||
|
{
|
||||||
|
return m_mediaPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Seek(float toTime)
|
||||||
|
{
|
||||||
|
if (m_mediaPlayer == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_mediaPlayer.time = toTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override uint GetVideoWidth()
|
||||||
|
{
|
||||||
|
return m_mediaPlayer != null ? m_mediaPlayer.width : 0;
|
||||||
|
}
|
||||||
|
public override uint GetVideoHeight()
|
||||||
|
{
|
||||||
|
return m_mediaPlayer != null ? m_mediaPlayer.height : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool SupportsPosterFrame()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 78d45f7d508d0a14884bec1201260eff
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {fileID: 2800000, guid: 42c51ff9981f3e24b83cd7ad3c56e235, type: 3}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 32fcbcdb90b345c459b070716a724e41
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4216d3a85251c074ab509288dbd7e17b
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 988c575dd5c87004aa7e679acd4c89bb
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,57 @@
|
||||||
|
/************************************************************************************
|
||||||
|
|
||||||
|
Depthkit Unity SDK License v1
|
||||||
|
Copyright 2016-2024 Simile Inc dba Scatter. All Rights reserved.
|
||||||
|
|
||||||
|
Licensed under the the Simile Inc dba Scatter ("Scatter")
|
||||||
|
Software Development Kit License Agreement (the "License");
|
||||||
|
you may not use this SDK except in compliance with the License,
|
||||||
|
which is provided at the time of installation or download,
|
||||||
|
or which otherwise accompanies this software in either electronic or hard copy form.
|
||||||
|
|
||||||
|
You may obtain a copy of the License at http://www.depthkit.tv/license-agreement-v1
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
the SDK distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
//vertices
|
||||||
|
#pragma kernel KGenerateVertices_Horizontal TILE_BORDER=3
|
||||||
|
#pragma kernel KGenerateVertices_HorizontalWEdgeMask DK_CORE_USE_EDGEMASK TILE_BORDER=3
|
||||||
|
#pragma kernel KGenerateVertices_Vertical TILE_BORDER=3
|
||||||
|
#pragma kernel KGenerateVertices_VerticalWEdgeMask DK_CORE_USE_EDGEMASK TILE_BORDER=3
|
||||||
|
|
||||||
|
//normals
|
||||||
|
#pragma kernel KGenerateNormals DK_CORE_SMOOTH_NORMALS TILE_BORDER=1
|
||||||
|
#pragma kernel KGenerateNormalsAdjustable DK_CORE_ADJUSTABLE_NORMALS TILE_BORDER=1
|
||||||
|
#pragma kernel KGenerateNormalsAdjustableSmoother DK_CORE_ADJUSTABLE_NORMALS DK_CORE_ADJUSTABLE_NORMALS_SMOOTHER TILE_BORDER=1
|
||||||
|
#pragma kernel KGenerateNormalsNone DK_CORE_NO_NORMALS TILE_BORDER=0
|
||||||
|
#pragma kernel KGenerateNormalsDepthCamera DK_CORE_DEPTHCAMERA_NORMALS TILE_BORDER=0
|
||||||
|
|
||||||
|
//triangles
|
||||||
|
#pragma kernel KGenerateTriangles DK_VERTEX_BUFFER_READONLY TILE_BORDER=1
|
||||||
|
#pragma kernel KGenerateTrianglesWEdgeMask DK_CORE_USE_EDGEMASK DK_VERTEX_BUFFER_READONLY TILE_BORDER=1
|
||||||
|
|
||||||
|
#pragma multi_compile_local __ DK_USE_GROUPSHARED_MEMORY
|
||||||
|
|
||||||
|
#include "Packages/nyc.scatter.depthkit.core/Runtime/Resources/Shaders/Includes/CoreVertex.cginc"
|
||||||
|
#include "Packages/nyc.scatter.depthkit.core/Runtime/Resources/Shaders/Includes/CoreTriangle.cginc"
|
||||||
|
#include "Packages/nyc.scatter.depthkit.core/Runtime/Resources/Shaders/DataSource/DepthkitCoreMeshSourceCommon.cginc"
|
||||||
|
#include "Packages/nyc.scatter.depthkit.core/Runtime/Resources/Shaders/DataSource/GenerateVertices.cginc"
|
||||||
|
#include "Packages/nyc.scatter.depthkit.core/Runtime/Resources/Shaders/DataSource/GenerateNormals.cginc"
|
||||||
|
#include "Packages/nyc.scatter.depthkit.core/Runtime/Resources/Shaders/DataSource/GenerateTriangles.cginc"
|
||||||
|
|
||||||
|
[numthreads(BLOCK_SIZE, BLOCK_SIZE, 1)]
|
||||||
|
void KGenerateTriangles(uint3 id : SV_DispatchThreadID, uint3 GroupId : SV_GroupID, uint3 GroupThreadId : SV_GroupThreadID, uint GroupIndex : SV_GroupIndex)
|
||||||
|
{
|
||||||
|
GenerateTriangles(id, GroupId, GroupThreadId, GroupIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
[numthreads(BLOCK_SIZE, BLOCK_SIZE, 1)]
|
||||||
|
void KGenerateTrianglesWEdgeMask(uint3 id : SV_DispatchThreadID, uint3 GroupId : SV_GroupID, uint3 GroupThreadId : SV_GroupThreadID, uint GroupIndex : SV_GroupIndex)
|
||||||
|
{
|
||||||
|
GenerateTriangles(id, GroupId, GroupThreadId, GroupIndex);
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue