Skip to content

Commit

Permalink
Implement workaround to avoid AVPro screen flickering issue. (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
JLChnToZ committed Jan 27, 2024
1 parent 2a85b03 commit c7316f0
Show file tree
Hide file tree
Showing 14 changed files with 584 additions and 70 deletions.
4 changes: 2 additions & 2 deletions Packages/idv.jlchntoz.vvmw/Editor/VVMW/CoreEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void DrawAutoPlayField() {
playerNames[i] = "null";
else {
playerNames[i] = string.IsNullOrEmpty(playerHandler.playerName) ? playerHandler.name : playerHandler.playerName;
playerTypes[i] = playerHandler.isAvPro;
playerTypes[i] = playerHandler.IsAvPro;
}
}
var rect = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight);
Expand Down Expand Up @@ -211,7 +211,7 @@ void DrawAudioSourcesListHeader(Rect rect) {
for (int i = 0, count = playerHandlersProperty.arraySize; i < count; i++) {
var playerHandler = playerHandlersProperty.GetArrayElementAtIndex(i).objectReferenceValue as VideoPlayerHandler;
if (playerHandler == null) continue;
if (!playerHandler.isAvPro)
if (!playerHandler.IsAvPro)
builtinPlayerHandlers.Add(playerHandler);
else if (avProPlayerHandler == null)
avProPlayerHandler = playerHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ void UpdatePlayerHandlerInfos() {
continue;
}
playerHandlerNames[i] = string.IsNullOrEmpty(handler.playerName) ? handler.name : handler.playerName;
if (handler.isAvPro) {
if (handler.IsAvPro) {
playerHandlerTypes[i] = true;
if (firstAvProPlayerIndex < 0) firstAvProPlayerIndex = i;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace JLChnToZ.VRC.VVMW.Editors {
[CustomEditor(typeof(VideoPlayerHandler))]
public class VideoPlayerHandlerEditor : VVMWEditorBase {

SerializedProperty texturePropertyNameProperty, useSharedMaterialProperty, isAvProProperty, playerNameProperty, primaryAudioSourceProperty;
SerializedProperty texturePropertyNameProperty, useSharedMaterialProperty, isAvProProperty, playerNameProperty, primaryAudioSourceProperty, useFlickerWorkaroundProperty, blitMaterialProperty;

protected override void OnEnable() {
base.OnEnable();
Expand All @@ -18,6 +18,8 @@ protected override void OnEnable() {
playerNameProperty = serializedObject.FindProperty("playerName");
isAvProProperty = serializedObject.FindProperty("isAvPro");
primaryAudioSourceProperty = serializedObject.FindProperty("primaryAudioSource");
useFlickerWorkaroundProperty = serializedObject.FindProperty("useFlickerWorkaround");
blitMaterialProperty = serializedObject.FindProperty("blitMaterial");
}

public override void OnInspectorGUI() {
Expand Down Expand Up @@ -104,6 +106,11 @@ public override void OnInspectorGUI() {
}
}
EditorGUILayout.PropertyField(primaryAudioSourceProperty);
if (isAvProProperty.boolValue) {
EditorGUILayout.PropertyField(useFlickerWorkaroundProperty);
if (useFlickerWorkaroundProperty.boolValue)
EditorGUILayout.PropertyField(blitMaterialProperty);
}
serializedObject.ApplyModifiedProperties();
}

Expand Down
33 changes: 33 additions & 0 deletions Packages/idv.jlchntoz.vvmw/Materials/VVMW/VideoBlit.mat
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: VideoBlit
m_Shader: {fileID: 4800000, guid: ba3c4c4d4f48fc244a80fc6efc777525, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats: []
m_Colors: []
m_BuildTextureStacks: []
8 changes: 8 additions & 0 deletions Packages/idv.jlchntoz.vvmw/Materials/VVMW/VideoBlit.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6236179273397461376}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &6236179273397461439
MonoBehaviour:
Expand Down Expand Up @@ -90,10 +91,12 @@ MeshRenderer:
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 0
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 0
m_ReflectionProbeUsage: 0
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
Expand All @@ -118,6 +121,7 @@ MeshRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!114 &6236179273397461378
MonoBehaviour:
m_ObjectHideFlags: 0
Expand All @@ -144,7 +148,9 @@ MonoBehaviour:
texturePropertyName: _MainTex
useSharedMaterial: 1
primaryAudioSource: {fileID: 0}
useFlickerWorkaround: 1
isAvPro: 1
blitMaterial: {fileID: 2100000, guid: 5b5dbeef5a3594c488799aa48b7b7cb3, type: 2}
--- !u!114 &6236179273397461379
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down
2 changes: 1 addition & 1 deletion Packages/idv.jlchntoz.vvmw/Runtime/VVMW/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public float SyncOffset {
}
}

public bool IsAVPro => activeHandler != null && activeHandler.isAvPro;
public bool IsAVPro => activeHandler != null && activeHandler.IsAvPro;

public VRCUrl Url => localUrl;

Expand Down
Loading

0 comments on commit c7316f0

Please sign in to comment.