Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 137 additions & 0 deletions Assets/DMXPreview.mat
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
%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: DMXPreview
m_Shader: {fileID: 4800000, guid: 4fc1f1ce49986f7cc8ddd9ee320dca3e, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 2000
stringTagMap: {}
disabledShaderPasses:
- MOTIONVECTORS
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _AddPrecomputedVelocity: 0
- _AlphaClip: 0
- _AlphaToMask: 0
- _Blend: 0
- _BlendModePreserveSpecular: 1
- _BumpScale: 1
- _ClearCoatMask: 0
- _ClearCoatSmoothness: 0
- _Cull: 2
- _Cutoff: 0.5
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _DstBlendAlpha: 0
- _EnvironmentReflections: 1
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.005
- _QueueOffset: 0
- _ReceiveShadows: 1
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _SrcBlendAlpha: 1
- _Surface: 0
- _WorkflowMode: 1
- _XRMotionVectorsPass: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _ChromaKeyColor: {r: 0, g: 1, b: 0, a: 0}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []
m_AllowLocking: 1
--- !u!114 &4268825121767374158
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Editor::UnityEditor.Rendering.Universal.AssetVersion
version: 10
8 changes: 8 additions & 0 deletions Assets/DMXPreview.mat.meta

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

71 changes: 71 additions & 0 deletions Assets/DMXPreview.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
Shader "Custom/DMXPreview"
{
Properties
{
_ChromaKeyColor("Chroma Key Color", Color) = (0.0, 0.0, 0.0, 0.0)
[MainTexture] _BaseMap("DMX Texture", 2D) = "Black"
}

SubShader
{
Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" }

Pass
{
HLSLPROGRAM

#pragma vertex vert
#pragma fragment frag

#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"

struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};

struct v2f
{
float4 vertex : SV_POSITION;
float3 uv : TEXCOORD0;
};

TEXTURE2D(_BaseMap);

CBUFFER_START(UnityPerMaterial)
half4 _ChromaKeyColor;
float4 _BaseMap_TexelSize;
CBUFFER_END

v2f vert(appdata v)
{
v2f o;

o.vertex = v.vertex;
o.vertex.xy *= 5.0;

#ifdef UNITY_REVERSED_Z
o.vertex.z = 1.0;
#else
o.vertex.z = 0.0;
#endif
o.uv = ComputeScreenPos(o.vertex).xyw;

return o;
}

float4 frag(v2f i) : SV_Target
{
float2 pixel = floor((i.uv.xy / i.uv.z) * _ScreenParams.xy);

pixel.y += (_BaseMap_TexelSize.w - _ScreenParams.y);

float4 color = _BaseMap[pixel];

return lerp(_ChromaKeyColor, color, color.a);
}
ENDHLSL
}
}
}
9 changes: 9 additions & 0 deletions Assets/DMXPreview.shader.meta

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

65 changes: 65 additions & 0 deletions Assets/DMXPreviewToggle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using UnityEngine;
using UnityEngine.InputSystem;

public class DMXPreviewToggle : MonoBehaviour
{
public InputAction fullscreenAction;
public MeshRenderer previewMesh;
public Canvas mainUI;
public Canvas graphyUI;

public bool dmxPreview {
get => _dmxPreview;
}

private bool _dmxPreview;
private int _windowResolutionWidth;
private int _windowResolutionHeight;

public void SetPreviewChromaColor(Color color)
{
previewMesh.material.SetColor("_ChromaKeyColor", color);
}

public void EnableDMXPreview(bool enablePreview)
{
if (enablePreview == _dmxPreview)
return;

_dmxPreview = enablePreview;

previewMesh.enabled = _dmxPreview;
mainUI.enabled = !_dmxPreview;

if (graphyUI != null)
graphyUI.enabled = !_dmxPreview;
}

public void ToggleDMXPreview(InputAction.CallbackContext ctx)
{
EnableDMXPreview(!_dmxPreview);

if (_dmxPreview)
{
_windowResolutionWidth = Screen.width;
_windowResolutionHeight = Screen.height;

Screen.SetResolution(Screen.mainWindowDisplayInfo.width, Screen.mainWindowDisplayInfo.height, _dmxPreview);
} else Screen.SetResolution(_windowResolutionWidth, _windowResolutionHeight, _dmxPreview);
}

void Awake()
{
fullscreenAction.performed += ToggleDMXPreview;
}

void OnEnable()
{
fullscreenAction.Enable();
}

void OnDisable()
{
fullscreenAction.Disable();
}
}
2 changes: 2 additions & 0 deletions Assets/DMXPreviewToggle.cs.meta

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

4 changes: 4 additions & 0 deletions Assets/Loader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class Loader : MonoBehaviour
public static SpoutReceiver spoutReceiver;
public static SpoutSender spoutSender;
public static ArtNetReceiver artNetReceiver;
public static DMXPreviewToggle previewToggle;

public static ShowConfiguration showconf = new ShowConfiguration();

Expand All @@ -36,6 +37,7 @@ void Start()
spoutReceiver = FindObjectOfType<SpoutReceiver>();
spoutSender = FindObjectOfType<SpoutSender>();
artNetReceiver = FindObjectOfType<ArtNetReceiver>();
previewToggle = FindAnyObjectByType<DMXPreviewToggle>();

//load in all the serializers
serializers = GetAllInterfaceImplementations<IDMXSerializer>();
Expand Down Expand Up @@ -254,6 +256,8 @@ public static void LoadShowConf()

SetFramerate(showconf.TargetFramerate);

previewToggle.SetPreviewChromaColor(showconf.PreviewChromaColor);

SetupDynamicUI();
}

Expand Down
Loading