VRTest
parent
91b77885bc
commit
615ab0cdc7
|
@ -0,0 +1,327 @@
|
||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!91 &9100000
|
||||||
|
AnimatorController:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: VRTest
|
||||||
|
serializedVersion: 5
|
||||||
|
m_AnimatorParameters:
|
||||||
|
- m_Name: Play
|
||||||
|
m_Type: 9
|
||||||
|
m_DefaultFloat: 0
|
||||||
|
m_DefaultInt: 0
|
||||||
|
m_DefaultBool: 0
|
||||||
|
m_Controller: {fileID: 9100000}
|
||||||
|
m_AnimatorLayers:
|
||||||
|
- serializedVersion: 5
|
||||||
|
m_Name: Base Layer
|
||||||
|
m_StateMachine: {fileID: 1107074086602143662}
|
||||||
|
m_Mask: {fileID: 0}
|
||||||
|
m_Motions: []
|
||||||
|
m_Behaviours: []
|
||||||
|
m_BlendingMode: 0
|
||||||
|
m_SyncedLayerIndex: -1
|
||||||
|
m_DefaultWeight: 0
|
||||||
|
m_IKPass: 0
|
||||||
|
m_SyncedLayerAffectsTiming: 0
|
||||||
|
m_Controller: {fileID: 9100000}
|
||||||
|
--- !u!74 &74247020000484542
|
||||||
|
AnimationClip:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: Animation
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Legacy: 0
|
||||||
|
m_Compressed: 0
|
||||||
|
m_UseHighQualityCurve: 1
|
||||||
|
m_RotationCurves: []
|
||||||
|
m_CompressedRotationCurves: []
|
||||||
|
m_EulerCurves: []
|
||||||
|
m_PositionCurves: []
|
||||||
|
m_ScaleCurves: []
|
||||||
|
m_FloatCurves:
|
||||||
|
- curve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: -100
|
||||||
|
tangentMode: 69
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: -100
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 1
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 3
|
||||||
|
value: 100
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 136
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 4
|
||||||
|
value: -0.38867188
|
||||||
|
inSlope: -100.38867
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 5
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
attribute: m_AnchoredPosition.x
|
||||||
|
path:
|
||||||
|
classID: 224
|
||||||
|
script: {fileID: 0}
|
||||||
|
- curve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: -100
|
||||||
|
tangentMode: 65
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: -100
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 136
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 3
|
||||||
|
value: 100
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 136
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 4
|
||||||
|
value: 0
|
||||||
|
inSlope: -100
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 69
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
attribute: m_AnchoredPosition.y
|
||||||
|
path:
|
||||||
|
classID: 224
|
||||||
|
script: {fileID: 0}
|
||||||
|
m_PPtrCurves: []
|
||||||
|
m_SampleRate: 60
|
||||||
|
m_WrapMode: 0
|
||||||
|
m_Bounds:
|
||||||
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
|
m_Extent: {x: 0, y: 0, z: 0}
|
||||||
|
m_ClipBindingConstant:
|
||||||
|
genericBindings:
|
||||||
|
- serializedVersion: 2
|
||||||
|
path: 0
|
||||||
|
attribute: 1460864421
|
||||||
|
script: {fileID: 0}
|
||||||
|
typeID: 224
|
||||||
|
customType: 28
|
||||||
|
isPPtrCurve: 0
|
||||||
|
- serializedVersion: 2
|
||||||
|
path: 0
|
||||||
|
attribute: 538195251
|
||||||
|
script: {fileID: 0}
|
||||||
|
typeID: 224
|
||||||
|
customType: 28
|
||||||
|
isPPtrCurve: 0
|
||||||
|
pptrCurveMapping: []
|
||||||
|
m_AnimationClipSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_AdditiveReferencePoseClip: {fileID: 0}
|
||||||
|
m_AdditiveReferencePoseTime: 0
|
||||||
|
m_StartTime: 0
|
||||||
|
m_StopTime: 4
|
||||||
|
m_OrientationOffsetY: 0
|
||||||
|
m_Level: 0
|
||||||
|
m_CycleOffset: 0
|
||||||
|
m_HasAdditiveReferencePose: 0
|
||||||
|
m_LoopTime: 1
|
||||||
|
m_LoopBlend: 0
|
||||||
|
m_LoopBlendOrientation: 0
|
||||||
|
m_LoopBlendPositionY: 0
|
||||||
|
m_LoopBlendPositionXZ: 0
|
||||||
|
m_KeepOriginalOrientation: 0
|
||||||
|
m_KeepOriginalPositionY: 1
|
||||||
|
m_KeepOriginalPositionXZ: 0
|
||||||
|
m_HeightFromFeet: 0
|
||||||
|
m_Mirror: 0
|
||||||
|
m_EditorCurves:
|
||||||
|
- curve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: -100
|
||||||
|
tangentMode: 69
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: -100
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 1
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 3
|
||||||
|
value: 100
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 136
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 4
|
||||||
|
value: -0.38867188
|
||||||
|
inSlope: -100.38867
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 5
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
attribute: m_AnchoredPosition.x
|
||||||
|
path:
|
||||||
|
classID: 224
|
||||||
|
script: {fileID: 0}
|
||||||
|
- curve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: -100
|
||||||
|
tangentMode: 65
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: -100
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 136
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 3
|
||||||
|
value: 100
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 136
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 4
|
||||||
|
value: 0
|
||||||
|
inSlope: -100
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 69
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
attribute: m_AnchoredPosition.y
|
||||||
|
path:
|
||||||
|
classID: 224
|
||||||
|
script: {fileID: 0}
|
||||||
|
m_EulerEditorCurves: []
|
||||||
|
m_HasGenericRootTransform: 0
|
||||||
|
m_HasMotionFloatCurves: 0
|
||||||
|
m_Events: []
|
||||||
|
--- !u!1102 &1102583906311020750
|
||||||
|
AnimatorState:
|
||||||
|
serializedVersion: 5
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: Animation
|
||||||
|
m_Speed: 0.1
|
||||||
|
m_CycleOffset: 0
|
||||||
|
m_Transitions: []
|
||||||
|
m_StateMachineBehaviours: []
|
||||||
|
m_Position: {x: 50, y: 50, z: 0}
|
||||||
|
m_IKOnFeet: 0
|
||||||
|
m_WriteDefaultValues: 1
|
||||||
|
m_Mirror: 0
|
||||||
|
m_SpeedParameterActive: 0
|
||||||
|
m_MirrorParameterActive: 0
|
||||||
|
m_CycleOffsetParameterActive: 0
|
||||||
|
m_TimeParameterActive: 0
|
||||||
|
m_Motion: {fileID: 74247020000484542}
|
||||||
|
m_Tag:
|
||||||
|
m_SpeedParameter:
|
||||||
|
m_MirrorParameter:
|
||||||
|
m_CycleOffsetParameter:
|
||||||
|
m_TimeParameter:
|
||||||
|
--- !u!1107 &1107074086602143662
|
||||||
|
AnimatorStateMachine:
|
||||||
|
serializedVersion: 5
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: Base Layer
|
||||||
|
m_ChildStates:
|
||||||
|
- serializedVersion: 1
|
||||||
|
m_State: {fileID: 1102583906311020750}
|
||||||
|
m_Position: {x: 240, y: 180, z: 0}
|
||||||
|
m_ChildStateMachines: []
|
||||||
|
m_AnyStateTransitions: []
|
||||||
|
m_EntryTransitions: []
|
||||||
|
m_StateMachineTransitions: {}
|
||||||
|
m_StateMachineBehaviours: []
|
||||||
|
m_AnyStatePosition: {x: 50, y: 20, z: 0}
|
||||||
|
m_EntryPosition: {x: 50, y: 120, z: 0}
|
||||||
|
m_ExitPosition: {x: 800, y: 120, z: 0}
|
||||||
|
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||||
|
m_DefaultState: {fileID: 1102583906311020750}
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2b36f7ccd9c9745399649fd6dab242b1
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 9100000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,66 @@
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace Coffee.UISoftMask.Demos
|
||||||
|
{
|
||||||
|
class VRMenu
|
||||||
|
{
|
||||||
|
private const string kMenuVirtualRealitySupported = "VR/Virtual Reality Supported";
|
||||||
|
private const string kMenuMultiPass = "VR/Multi Pass";
|
||||||
|
private const string kMenuSinglePass = "VR/Single Pass";
|
||||||
|
private const string kMenuSinglePassInstancing = "VR/Single Pass Instancing";
|
||||||
|
|
||||||
|
[MenuItem(kMenuVirtualRealitySupported, false, 0)]
|
||||||
|
private static void VirtualRealitySupported()
|
||||||
|
{
|
||||||
|
PlayerSettings.virtualRealitySupported = !PlayerSettings.virtualRealitySupported;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MenuItem(kMenuVirtualRealitySupported, true)]
|
||||||
|
private static bool _VirtualRealitySupported()
|
||||||
|
{
|
||||||
|
Menu.SetChecked(kMenuVirtualRealitySupported, PlayerSettings.virtualRealitySupported);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MenuItem(kMenuMultiPass, false, 100)]
|
||||||
|
private static void MultiPass()
|
||||||
|
{
|
||||||
|
PlayerSettings.stereoRenderingPath = StereoRenderingPath.MultiPass;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MenuItem(kMenuMultiPass, true)]
|
||||||
|
private static bool _MultiPass()
|
||||||
|
{
|
||||||
|
Menu.SetChecked(kMenuMultiPass, PlayerSettings.stereoRenderingPath == StereoRenderingPath.MultiPass);
|
||||||
|
return PlayerSettings.virtualRealitySupported;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MenuItem(kMenuSinglePass, false, 101)]
|
||||||
|
private static void SinglePass()
|
||||||
|
{
|
||||||
|
PlayerSettings.stereoRenderingPath = StereoRenderingPath.SinglePass;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MenuItem(kMenuSinglePass, true)]
|
||||||
|
private static bool _SinglePass()
|
||||||
|
{
|
||||||
|
Menu.SetChecked(kMenuSinglePass, PlayerSettings.stereoRenderingPath == StereoRenderingPath.SinglePass);
|
||||||
|
return PlayerSettings.virtualRealitySupported;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MenuItem(kMenuSinglePassInstancing, false, 102)]
|
||||||
|
private static void SinglePassInstancing()
|
||||||
|
{
|
||||||
|
PlayerSettings.stereoRenderingPath = StereoRenderingPath.Instancing;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MenuItem(kMenuSinglePassInstancing, true)]
|
||||||
|
private static bool _SinglePassInstancing()
|
||||||
|
{
|
||||||
|
Menu.SetChecked(kMenuSinglePassInstancing, PlayerSettings.stereoRenderingPath == StereoRenderingPath.Instancing);
|
||||||
|
return PlayerSettings.virtualRealitySupported;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 618e7f50c17174046ae17185bca8692b
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1f1a25a99acfd4ab6b014e26410120be
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -1,7 +1,6 @@
|
||||||
using System.Collections;
|
using UnityEngine;
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
using UnityEngine.XR;
|
||||||
|
|
||||||
namespace Coffee.UISoftMask.Demos
|
namespace Coffee.UISoftMask.Demos
|
||||||
{
|
{
|
||||||
|
@ -16,17 +15,20 @@ namespace Coffee.UISoftMask.Demos
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void OnEnable()
|
void OnEnable()
|
||||||
{
|
{
|
||||||
title.SetActive(true);
|
if (title)
|
||||||
|
title.SetActive(true);
|
||||||
|
|
||||||
text.text = string.Format("GPU: {0}\nDeviceType: {1}\nShaderLevel: {2}\nUVStartsAtTop: {3}",
|
if (text)
|
||||||
SystemInfo.graphicsDeviceName,
|
text.text = string.Format("VRSettings: {0}\nloadedDeviceName: {1}\nstereoRenderingMode: {2}\nUVStartsAtTop: {3}",
|
||||||
SystemInfo.graphicsDeviceType,
|
XRSettings.enabled,
|
||||||
SystemInfo.graphicsShaderLevel,
|
XRSettings.loadedDeviceName,
|
||||||
SystemInfo.graphicsUVStartsAtTop);
|
XRSettings.stereoRenderingMode,
|
||||||
|
SystemInfo.graphicsUVStartsAtTop);
|
||||||
|
|
||||||
for (int i = 0; i < softMask.Length; i++)
|
for (int i = 0; i < softMask.Length; i++)
|
||||||
{
|
{
|
||||||
softMaskBufferViewer[i].texture = softMask[i].softMaskBuffer;
|
softMaskBufferViewer[i].texture = softMask[i].softMaskBuffer;
|
||||||
|
softMaskBufferViewer[i+1].texture = softMask[i].softMaskBuffer2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,7 @@ namespace Coffee.UISoftMask
|
||||||
var tex = current.softMaskBuffer;
|
var tex = current.softMaskBuffer;
|
||||||
var width = tex.width * k_PreviewSize / tex.height;
|
var width = tex.width * k_PreviewSize / tex.height;
|
||||||
EditorGUI.DrawPreviewTexture(GUILayoutUtility.GetRect(width, k_PreviewSize), tex, null, ScaleMode.ScaleToFit);
|
EditorGUI.DrawPreviewTexture(GUILayoutUtility.GetRect(width, k_PreviewSize), tex, null, ScaleMode.ScaleToFit);
|
||||||
|
EditorGUI.DrawPreviewTexture(GUILayoutUtility.GetRect(width, k_PreviewSize), current.softMaskBuffer2, null, ScaleMode.ScaleToFit);
|
||||||
Repaint();
|
Repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@ namespace Coffee.UISoftMask
|
||||||
private CommandBuffer _cb;
|
private CommandBuffer _cb;
|
||||||
private Material _material;
|
private Material _material;
|
||||||
private RenderTexture _softMaskBuffer;
|
private RenderTexture _softMaskBuffer;
|
||||||
|
private RenderTexture _softMaskBuffer2;
|
||||||
private int _stencilDepth;
|
private int _stencilDepth;
|
||||||
private Mesh _mesh;
|
private Mesh _mesh;
|
||||||
private SoftMask _parent;
|
private SoftMask _parent;
|
||||||
|
@ -198,6 +199,39 @@ namespace Coffee.UISoftMask
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The soft mask buffer.
|
||||||
|
/// </summary>
|
||||||
|
public RenderTexture softMaskBuffer2
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_parent)
|
||||||
|
{
|
||||||
|
ReleaseRt(ref _softMaskBuffer2);
|
||||||
|
return _parent.softMaskBuffer2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check the size of soft mask buffer.
|
||||||
|
int w, h;
|
||||||
|
GetDesamplingSize(m_DesamplingRate, out w, out h);
|
||||||
|
if (_softMaskBuffer2 && (_softMaskBuffer2.width != w || _softMaskBuffer2.height != h))
|
||||||
|
{
|
||||||
|
ReleaseRt(ref _softMaskBuffer2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_softMaskBuffer2)
|
||||||
|
{
|
||||||
|
_softMaskBuffer2 = RenderTexture.GetTemporary(w, h, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default);
|
||||||
|
hasChanged = true;
|
||||||
|
_hasStencilStateChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _softMaskBuffer2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool hasChanged
|
public bool hasChanged
|
||||||
{
|
{
|
||||||
get { return _parent ? _parent.hasChanged : _hasChanged; }
|
get { return _parent ? _parent.hasChanged : _hasChanged; }
|
||||||
|
@ -553,7 +587,7 @@ namespace Coffee.UISoftMask
|
||||||
GetDesamplingSize(DesamplingRate.None, out s_PreviousWidth, out s_PreviousHeight);
|
GetDesamplingSize(DesamplingRate.None, out s_PreviousWidth, out s_PreviousHeight);
|
||||||
if (w != s_PreviousWidth || h != s_PreviousHeight)
|
if (w != s_PreviousWidth || h != s_PreviousHeight)
|
||||||
{
|
{
|
||||||
Canvas.ForceUpdateCanvases();
|
//Canvas.ForceUpdateCanvases();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -606,8 +640,14 @@ namespace Coffee.UISoftMask
|
||||||
var cam = c.worldCamera ?? Camera.main;
|
var cam = c.worldCamera ?? Camera.main;
|
||||||
if (c && c.renderMode != RenderMode.ScreenSpaceOverlay && cam)
|
if (c && c.renderMode != RenderMode.ScreenSpaceOverlay && cam)
|
||||||
{
|
{
|
||||||
var p = GL.GetGPUProjectionMatrix(cam.projectionMatrix, false);
|
var camP = cam.GetStereoProjectionMatrix(Camera.StereoscopicEye.Left);
|
||||||
_cb.SetViewProjectionMatrices(cam.worldToCameraMatrix, p);
|
var camV = cam.GetStereoViewMatrix(Camera.StereoscopicEye.Left);
|
||||||
|
|
||||||
|
Debug.Log("Left");
|
||||||
|
Debug.Log(camP);
|
||||||
|
Debug.Log(camV);
|
||||||
|
var p = GL.GetGPUProjectionMatrix(camP, false);
|
||||||
|
_cb.SetViewProjectionMatrices(camV, p);
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
var pv = p * cam.worldToCameraMatrix;
|
var pv = p * cam.worldToCameraMatrix;
|
||||||
|
@ -634,6 +674,63 @@ namespace Coffee.UISoftMask
|
||||||
|
|
||||||
Profiler.EndSample();
|
Profiler.EndSample();
|
||||||
|
|
||||||
|
// Draw soft masks.
|
||||||
|
Profiler.BeginSample("Draw Mesh");
|
||||||
|
for (var i = 0; i < s_TmpSoftMasks.Length; i++)
|
||||||
|
{
|
||||||
|
var count = s_TmpSoftMasks[i].Count;
|
||||||
|
for (var j = 0; j < count; j++)
|
||||||
|
{
|
||||||
|
var sm = s_TmpSoftMasks[i][j];
|
||||||
|
|
||||||
|
if (i != 0)
|
||||||
|
{
|
||||||
|
sm._stencilDepth = MaskUtilities.GetStencilDepth(sm.transform, MaskUtilities.FindRootSortOverrideCanvas(sm.transform));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set material property.
|
||||||
|
sm.material.SetInt(s_ColorMaskId, (int) 1 << (3 - _stencilDepth - i));
|
||||||
|
sm._mpb.SetTexture(s_MainTexId, sm.graphic.mainTexture);
|
||||||
|
sm._mpb.SetFloat(s_SoftnessId, sm.m_Softness);
|
||||||
|
sm._mpb.SetFloat(s_Alpha, sm.m_Alpha);
|
||||||
|
|
||||||
|
// Draw mesh.
|
||||||
|
_cb.DrawMesh(sm.mesh, sm.transform.localToWorldMatrix, sm.material, 0, 0, sm._mpb);
|
||||||
|
}
|
||||||
|
|
||||||
|
//s_TmpSoftMasks[i].Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
Profiler.EndSample();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Set view and projection matrices.
|
||||||
|
Profiler.BeginSample("Set view and projection matrices");
|
||||||
|
_cb.SetRenderTarget(softMaskBuffer2);
|
||||||
|
_cb.ClearRenderTarget(false, true, s_ClearColors[_stencilDepth]);
|
||||||
|
if (c && c.renderMode != RenderMode.ScreenSpaceOverlay && cam)
|
||||||
|
{
|
||||||
|
var camP = cam.GetStereoProjectionMatrix(Camera.StereoscopicEye.Right);
|
||||||
|
var camV = cam.GetStereoViewMatrix(Camera.StereoscopicEye.Right);
|
||||||
|
|
||||||
|
var p = GL.GetGPUProjectionMatrix(camP, false);
|
||||||
|
Debug.Log("Right");
|
||||||
|
Debug.Log(camP);
|
||||||
|
Debug.Log(camV);
|
||||||
|
// p = Matrix4x4.Translate(new Vector3(1/2f,0,0)) * p * Matrix4x4.Scale(new Vector3( 1/2f,1,1));
|
||||||
|
_cb.SetViewProjectionMatrices(camV, p);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var pos = c.transform.position;
|
||||||
|
var vm = Matrix4x4.TRS(new Vector3(-pos.x, -pos.y, -1000), Quaternion.identity, new Vector3(1, 1, -1f));
|
||||||
|
var pm = Matrix4x4.TRS(new Vector3(0, 0, -1), Quaternion.identity, new Vector3(1 / pos.x, 1 / pos.y, -2 / 10000f));
|
||||||
|
_cb.SetViewProjectionMatrices(vm, pm);
|
||||||
|
}
|
||||||
|
|
||||||
|
Profiler.EndSample();
|
||||||
|
|
||||||
// Draw soft masks.
|
// Draw soft masks.
|
||||||
Profiler.BeginSample("Draw Mesh");
|
Profiler.BeginSample("Draw Mesh");
|
||||||
for (var i = 0; i < s_TmpSoftMasks.Length; i++)
|
for (var i = 0; i < s_TmpSoftMasks.Length; i++)
|
||||||
|
@ -663,6 +760,9 @@ namespace Coffee.UISoftMask
|
||||||
|
|
||||||
Profiler.EndSample();
|
Profiler.EndSample();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Graphics.ExecuteCommandBuffer(_cb);
|
Graphics.ExecuteCommandBuffer(_cb);
|
||||||
Profiler.EndSample();
|
Profiler.EndSample();
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,9 +130,10 @@ namespace Coffee.UISoftMask
|
||||||
{
|
{
|
||||||
mat.shader = Shader.Find(string.Format("Hidden/{0} (SoftMaskable)", mat.shader.name));
|
mat.shader = Shader.Find(string.Format("Hidden/{0} (SoftMaskable)", mat.shader.name));
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
mat.EnableKeyword("SOFTMASK_EDITOR");
|
//mat.EnableKeyword("SOFTMASK_EDITOR");
|
||||||
#endif
|
#endif
|
||||||
mat.SetTexture(s_SoftMaskTexId, softMask.softMaskBuffer);
|
mat.SetTexture(s_SoftMaskTexId, softMask.softMaskBuffer);
|
||||||
|
mat.SetTexture("_SoftMaskTex2", softMask.softMaskBuffer2);
|
||||||
mat.SetInt(s_StencilCompId, m_UseStencil ? (int) CompareFunction.Equal : (int) CompareFunction.Always);
|
mat.SetInt(s_StencilCompId, m_UseStencil ? (int) CompareFunction.Equal : (int) CompareFunction.Always);
|
||||||
|
|
||||||
var root = MaskUtilities.FindRootSortOverrideCanvas(transform);
|
var root = MaskUtilities.FindRootSortOverrideCanvas(transform);
|
||||||
|
|
|
@ -76,7 +76,6 @@ Shader "Hidden/UI/Default (SoftMaskable)"
|
||||||
UNITY_VERTEX_OUTPUT_STEREO
|
UNITY_VERTEX_OUTPUT_STEREO
|
||||||
};
|
};
|
||||||
|
|
||||||
sampler2D _MainTex;
|
|
||||||
fixed4 _Color;
|
fixed4 _Color;
|
||||||
fixed4 _TextureSampleAdd;
|
fixed4 _TextureSampleAdd;
|
||||||
float4 _ClipRect;
|
float4 _ClipRect;
|
||||||
|
@ -85,7 +84,9 @@ Shader "Hidden/UI/Default (SoftMaskable)"
|
||||||
v2f vert(appdata_t v)
|
v2f vert(appdata_t v)
|
||||||
{
|
{
|
||||||
v2f OUT;
|
v2f OUT;
|
||||||
|
|
||||||
UNITY_SETUP_INSTANCE_ID(v);
|
UNITY_SETUP_INSTANCE_ID(v);
|
||||||
|
UNITY_INITIALIZE_OUTPUT(v2f, OUT);
|
||||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
|
||||||
OUT.worldPosition = v.vertex;
|
OUT.worldPosition = v.vertex;
|
||||||
OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
|
OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
|
||||||
|
@ -97,9 +98,22 @@ Shader "Hidden/UI/Default (SoftMaskable)"
|
||||||
return OUT;
|
return OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
|
||||||
|
|
||||||
fixed4 frag(v2f IN) : SV_Target
|
fixed4 frag(v2f IN) : SV_Target
|
||||||
{
|
{
|
||||||
half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(IN);
|
||||||
|
//half2 viewa = IN.vertex.xy/_ScreenParams.xy;
|
||||||
|
|
||||||
|
//fixed4 c = lerp(tex2D(_SoftMaskTex, viewa), tex2D(_SoftMaskTex2, viewa), unity_StereoEyeIndex);
|
||||||
|
//viewa = lerp(viewa, viewa - half2(1, 0), unity_StereoEyeIndex);
|
||||||
|
//fixed4 c = unity_StereoEyeIndex;
|
||||||
|
//c.a = 1;
|
||||||
|
// c.rg = viewa;
|
||||||
|
// c.b = 0;
|
||||||
|
//return c;
|
||||||
|
|
||||||
|
half4 color = (UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
|
||||||
|
|
||||||
color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
|
color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define UI_SOFTMASK_INCLUDED
|
#define UI_SOFTMASK_INCLUDED
|
||||||
|
|
||||||
sampler2D _SoftMaskTex;
|
sampler2D _SoftMaskTex;
|
||||||
|
sampler2D _SoftMaskTex2;
|
||||||
float _Stencil;
|
float _Stencil;
|
||||||
float4x4 _GameVP;
|
float4x4 _GameVP;
|
||||||
float4x4 _GameTVP;
|
float4x4 _GameTVP;
|
||||||
|
@ -36,7 +37,10 @@ float SoftMaskInternal(float4 clipPos)
|
||||||
view.y = lerp(view.y, 1 - view.y, step(0, _ProjectionParams.x));
|
view.y = lerp(view.y, 1 - view.y, step(0, _ProjectionParams.x));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fixed4 mask = tex2D(_SoftMaskTex, view);
|
#if UNITY_SINGLE_PASS_STEREO
|
||||||
|
view = lerp(view, view - half2(1, 0), unity_StereoEyeIndex);
|
||||||
|
#endif
|
||||||
|
fixed4 mask = lerp(tex2D(_SoftMaskTex, view), tex2D(_SoftMaskTex2, view), unity_StereoEyeIndex);
|
||||||
half4 alpha = saturate(lerp(fixed4(1, 1, 1, 1), lerp(mask, 1 - mask, _MaskInteraction - 1), _MaskInteraction))
|
half4 alpha = saturate(lerp(fixed4(1, 1, 1, 1), lerp(mask, 1 - mask, _MaskInteraction - 1), _MaskInteraction))
|
||||||
#if SOFTMASK_EDITOR
|
#if SOFTMASK_EDITOR
|
||||||
* step(0, view.x) * step(view.x, 1) * step(0, view.y) * step(view.y, 1)
|
* step(0, view.x) * step(view.x, 1) * step(0, view.y) * step(view.y, 1)
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"com.unity.package-manager-ui": "2.0.8",
|
"com.unity.package-manager-ui": "2.0.8",
|
||||||
"com.unity.textmeshpro": "1.4.1",
|
"com.unity.textmeshpro": "1.4.1",
|
||||||
|
"com.unity.xr.oculus.standalone": "1.38.4",
|
||||||
|
"com.unity.xr.openvr.standalone": "1.0.5",
|
||||||
"com.unity.modules.ai": "1.0.0",
|
"com.unity.modules.ai": "1.0.0",
|
||||||
"com.unity.modules.animation": "1.0.0",
|
"com.unity.modules.animation": "1.0.0",
|
||||||
"com.unity.modules.assetbundle": "1.0.0",
|
"com.unity.modules.assetbundle": "1.0.0",
|
||||||
|
|
|
@ -6,5 +6,9 @@ EditorBuildSettings:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Scenes:
|
m_Scenes:
|
||||||
- enabled: 1
|
- enabled: 1
|
||||||
path: Assets/SoftMask_Demo/SoftMask_Demo.unity
|
path: Assets/VRTest.unity
|
||||||
|
guid: 1f1a25a99acfd4ab6b014e26410120be
|
||||||
|
- enabled: 0
|
||||||
|
path: Packages/com.coffee.softmask-for-ugui/Samples/Demo/SoftMask_Demo.unity
|
||||||
guid: aa372e7b286d0416eb942adfc3e442ec
|
guid: aa372e7b286d0416eb942adfc3e442ec
|
||||||
|
m_configObjects: {}
|
||||||
|
|
|
@ -36,7 +36,8 @@ GraphicsSettings:
|
||||||
- {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
|
- {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
- {fileID: 10782, guid: 0000000000000000f000000000000000, type: 0}
|
- {fileID: 10782, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
- {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
|
- {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
- {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0}
|
- {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
- {fileID: 16002, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
m_PreloadedShaders:
|
m_PreloadedShaders:
|
||||||
- {fileID: 20000000, guid: 73036fa061ee340dcb3c04b9d8872e66, type: 2}
|
- {fileID: 20000000, guid: 73036fa061ee340dcb3c04b9d8872e66, type: 2}
|
||||||
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
|
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
|
||||||
|
@ -62,3 +63,4 @@ GraphicsSettings:
|
||||||
m_AlbedoSwatchInfos: []
|
m_AlbedoSwatchInfos: []
|
||||||
m_LightsUseLinearIntensity: 0
|
m_LightsUseLinearIntensity: 0
|
||||||
m_LightsUseColorTemperature: 0
|
m_LightsUseColorTemperature: 0
|
||||||
|
m_LogWhenShaderIsCompiled: 0
|
||||||
|
|
|
@ -165,7 +165,7 @@ PlayerSettings:
|
||||||
buildNumber:
|
buildNumber:
|
||||||
iOS: 0
|
iOS: 0
|
||||||
AndroidBundleVersionCode: 1
|
AndroidBundleVersionCode: 1
|
||||||
AndroidMinSdkVersion: 16
|
AndroidMinSdkVersion: 23
|
||||||
AndroidTargetSdkVersion: 0
|
AndroidTargetSdkVersion: 0
|
||||||
AndroidPreferredInstallLocation: 1
|
AndroidPreferredInstallLocation: 1
|
||||||
aotOptions:
|
aotOptions:
|
||||||
|
@ -278,7 +278,21 @@ PlayerSettings:
|
||||||
m_BuildTargetPlatformIcons: []
|
m_BuildTargetPlatformIcons: []
|
||||||
m_BuildTargetBatching: []
|
m_BuildTargetBatching: []
|
||||||
m_BuildTargetGraphicsAPIs: []
|
m_BuildTargetGraphicsAPIs: []
|
||||||
m_BuildTargetVRSettings: []
|
m_BuildTargetVRSettings:
|
||||||
|
- m_BuildTarget: Standalone
|
||||||
|
m_Enabled: 1
|
||||||
|
m_Devices:
|
||||||
|
- MockHMD
|
||||||
|
- OpenVR
|
||||||
|
- Oculus
|
||||||
|
- m_BuildTarget: Android
|
||||||
|
m_Enabled: 1
|
||||||
|
m_Devices:
|
||||||
|
- MockHMD
|
||||||
|
- m_BuildTarget: iOS
|
||||||
|
m_Enabled: 1
|
||||||
|
m_Devices:
|
||||||
|
- cardboard
|
||||||
m_BuildTargetEnableVuforiaSettings: []
|
m_BuildTargetEnableVuforiaSettings: []
|
||||||
openGLRequireES31: 0
|
openGLRequireES31: 0
|
||||||
openGLRequireES31AEP: 0
|
openGLRequireES31AEP: 0
|
||||||
|
@ -300,7 +314,7 @@ PlayerSettings:
|
||||||
enableInternalProfiler: 0
|
enableInternalProfiler: 0
|
||||||
logObjCUncaughtExceptions: 1
|
logObjCUncaughtExceptions: 1
|
||||||
enableCrashReportAPI: 0
|
enableCrashReportAPI: 0
|
||||||
cameraUsageDescription:
|
cameraUsageDescription: Used to scan QR codes
|
||||||
locationUsageDescription:
|
locationUsageDescription:
|
||||||
microphoneUsageDescription:
|
microphoneUsageDescription:
|
||||||
switchNetLibKey:
|
switchNetLibKey:
|
||||||
|
|
|
@ -3,29 +3,29 @@
|
||||||
--- !u!310 &1
|
--- !u!310 &1
|
||||||
UnityConnectSettings:
|
UnityConnectSettings:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
serializedVersion: 1
|
||||||
m_Enabled: 0
|
m_Enabled: 0
|
||||||
m_TestMode: 0
|
m_TestMode: 0
|
||||||
m_TestEventUrl:
|
m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events
|
||||||
m_TestConfigUrl:
|
m_EventUrl: https://cdp.cloud.unity3d.com/v1/events
|
||||||
|
m_ConfigUrl: https://config.uca.cloud.unity3d.com
|
||||||
m_TestInitMode: 0
|
m_TestInitMode: 0
|
||||||
CrashReportingSettings:
|
CrashReportingSettings:
|
||||||
m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes
|
m_EventUrl: https://perf-events.cloud.unity3d.com
|
||||||
m_Enabled: 0
|
m_Enabled: 0
|
||||||
|
m_LogBufferSize: 10
|
||||||
m_CaptureEditorExceptions: 1
|
m_CaptureEditorExceptions: 1
|
||||||
UnityPurchasingSettings:
|
UnityPurchasingSettings:
|
||||||
m_Enabled: 0
|
m_Enabled: 0
|
||||||
m_TestMode: 0
|
m_TestMode: 0
|
||||||
UnityAnalyticsSettings:
|
UnityAnalyticsSettings:
|
||||||
m_Enabled: 0
|
m_Enabled: 0
|
||||||
m_InitializeOnStartup: 1
|
|
||||||
m_TestMode: 0
|
m_TestMode: 0
|
||||||
m_TestEventUrl:
|
m_InitializeOnStartup: 1
|
||||||
m_TestConfigUrl:
|
|
||||||
UnityAdsSettings:
|
UnityAdsSettings:
|
||||||
m_Enabled: 0
|
m_Enabled: 0
|
||||||
m_InitializeOnStartup: 1
|
m_InitializeOnStartup: 1
|
||||||
m_TestMode: 0
|
m_TestMode: 0
|
||||||
m_EnabledPlatforms: 4294967295
|
|
||||||
m_IosGameId:
|
m_IosGameId:
|
||||||
m_AndroidGameId:
|
m_AndroidGameId:
|
||||||
m_GameIds: {}
|
m_GameIds: {}
|
||||||
|
|
Loading…
Reference in New Issue