Skip to content
Merged
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
6 changes: 6 additions & 0 deletions com.microsoft.mrtk.graphicstools.unity/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this package will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [0.6.7] - 2024-01-18

### Changed

- Added rounder corner support to the magnifier shader and sample.

## [0.6.6] - 2023-12-01

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ SubShader {
#pragma multi_compile_local _ _UI_CLIP_RECT_ROUNDED _UI_CLIP_RECT_ROUNDED_INDEPENDENT

#include "UnityCG.cginc"
#include "../../../Shaders/GraphicsToolsCommon.hlsl"
#include "Packages/com.microsoft.mrtk.graphicstools.unity/Runtime/Shaders/GraphicsToolsCommon.hlsl"

CBUFFER_START(UnityPerMaterial)
half4 _Base_Color_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ MonoBehaviour:
version: 4
--- !u!21 &2100000
Material:
serializedVersion: 6
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Magnifier
m_Shader: {fileID: 4800000, guid: 708bca655443cdd41b94ee29b5572b6e, type: 3}
m_ShaderKeywords:
m_ValidKeywords:
- _ROUND_CORNERS
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
Expand All @@ -31,96 +33,11 @@ Material:
disabledShaderPasses: []
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_TexEnvs: []
m_Ints: []
m_Floats:
- Magnification: 0.5
- _AlphaClip: 0
- _Blend: 0
- _BumpScale: 1
- _ClearCoatMask: 0
- _ClearCoatSmoothness: 0
- _Cull: 2
- _Cutoff: 0.5
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _EnvironmentReflections: 1
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _Magnification: 0.5
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.005
- _QueueOffset: 0
- _ReceiveShadows: 1
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Surface: 0
- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- Center: {r: 0.5, g: 0.5, b: 0, a: 0}
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _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}
- _RoundCornerMargin: 0.05
- _RoundCornerRadius: 0.05
- _RoundCorners: 1
m_Colors: []
m_BuildTextureStacks: []
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Shader "Graphics Tools/Magnifier"
{
Properties
{
[Toggle(_ROUND_CORNERS)] _RoundCorners("Round Corners", Float) = 1.0
_RoundCornerRadius("Round Corner Radius", Float) = 0.05
_RoundCornerMargin("Round Corner Margin", Float) = 0.005
}
SubShader
{
Expand All @@ -17,30 +20,47 @@ Shader "Graphics Tools/Magnifier"
{
"RenderType" = "Transparent"
"Queue" = "Transparent"
"DisableBatching" = "True"
}

Pass
{
ZTest Always
Cull Off
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha, One One

HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag

#define _URP
#define _TRANSPARENT
#define _EDGE_SMOOTHING_AUTOMATIC

#pragma shader_feature_local _ROUND_CORNERS

#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.microsoft.mrtk.graphicstools.unity/Runtime/Shaders/GraphicsToolsCommon.hlsl"

CBUFFER_START(UnityPerMaterial)
float _RoundCornerRadius;
float _RoundCornerMargin;
CBUFFER_END

struct appdata
{
float4 vertex : POSITION;
float2 uv0 : TEXCOORD0;

UNITY_VERTEX_INPUT_INSTANCE_ID
};

struct v2f
{
float4 vertex : SV_POSITION;
float2 uv0 : TEXCOORD0;
float3 scale : TEXCOORD3;

UNITY_VERTEX_OUTPUT_STEREO
};
Expand All @@ -63,17 +83,38 @@ Shader "Graphics Tools/Magnifier"
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);

o.vertex = TransformObjectToHClip(v.vertex.xyz);
o.uv0 = v.uv0;
o.scale = GTGetWorldScale();

return o;
}

half4 frag(v2f i) : SV_Target
{
// Rounded corner clipping.
#if defined(_ROUND_CORNERS)
half2 distanceToEdge;
distanceToEdge.x = abs(i.uv0.x - 0.5h) * 2.0h;
distanceToEdge.y = abs(i.uv0.y - 0.5h) * 2.0h;

float2 halfScale = i.scale.xy * 0.5;
float2 cornerPosition = distanceToEdge * halfScale;
float cornerCircleRadius = max(_RoundCornerRadius, GT_MIN_CORNER_VALUE);
float2 cornerCircleDistance = halfScale - _RoundCornerMargin - cornerCircleRadius;
float roundCornerClip = GTRoundCorners(cornerPosition, cornerCircleDistance, cornerCircleRadius, 0.0);
#endif // _ROUND_CORNERS

float2 normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(i.vertex);
float2 normalizedScreenSpaceUVStereo = UnityStereoTransformScreenSpaceTex(normalizedScreenSpaceUV);
float2 zoomedUv = ZoomIn(normalizedScreenSpaceUVStereo, MagnifierMagnification, MagnifierCenter.xy);

return SAMPLE_TEXTURE2D_X(MagnifierTexture, samplerMagnifierTexture, zoomedUv);
half4 output = SAMPLE_TEXTURE2D_X(MagnifierTexture, samplerMagnifierTexture, zoomedUv);

#if defined(_ROUND_CORNERS)
output.a = roundCornerClip;
#endif // _ROUND_CORNERS

return output;
}
ENDHLSL
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ PrefabInstance:
propertyPath: m_Name
value: FlyCamera
objectReference: {fileID: 0}
- target: {fileID: 2605718042319707034, guid: d2eb3a9405371294bb1453b4af85960e, type: 3}
propertyPath: m_ClearFlags
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: d2eb3a9405371294bb1453b4af85960e, type: 3}
--- !u!20 &473039062 stripped
Expand Down Expand Up @@ -228,6 +232,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3}
m_Name:
m_EditorClassIdentifier:
m_SendPointerHoverToParent: 1
m_MoveRepeatDelay: 0.5
m_MoveRepeatRate: 0.1
m_XRTrackingOrigin: {fileID: 0}
Expand All @@ -244,6 +249,7 @@ MonoBehaviour:
m_TrackedDeviceOrientationAction: {fileID: 1025543830046995696, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_DeselectOnBackgroundClick: 1
m_PointerBehavior: 0
m_CursorLockBehavior: 0
--- !u!114 &551594404
MonoBehaviour:
m_ObjectHideFlags: 0
Expand All @@ -269,6 +275,7 @@ Transform:
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: 2
Expand Down Expand Up @@ -299,6 +306,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1298507361}
- {fileID: 1522697104}
Expand Down Expand Up @@ -341,7 +349,14 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 474bcb49853aa07438625e644c072ee6, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Version: 1
m_UsePipelineSettings: 1
m_AdditionalLightsShadowResolutionTier: 2
m_LightLayerMask: 1
m_CustomShadowLayers: 0
m_ShadowLayerMask: 1
m_LightCookieSize: {x: 1, y: 1}
m_LightCookieOffset: {x: 0, y: 0}
--- !u!108 &957735293
Light:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -414,6 +429,7 @@ Transform:
m_LocalRotation: {x: 0.40821788, y: 0.23456976, z: -0.10938167, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
Expand Down Expand Up @@ -582,6 +598,7 @@ MeshRenderer:
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
Expand Down Expand Up @@ -630,6 +647,7 @@ Transform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 1}
m_LocalScale: {x: 0.44704, y: 0.5588, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 656687269}
m_RootOrder: 1
Expand Down Expand Up @@ -727,7 +745,8 @@ Transform:
m_GameObject: {fileID: 1837192617}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1.05, y: 1.1, z: 1}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2055136616}
m_RootOrder: 0
Expand All @@ -743,6 +762,7 @@ MeshRenderer:
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
Expand Down Expand Up @@ -808,8 +828,9 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2055136615}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: -0.2, z: 1.3}
m_LocalScale: {x: 0.8, y: 0.4, z: 1}
m_LocalPosition: {x: 0, y: 0, z: 1.3}
m_LocalScale: {x: 1, y: 0.6, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1837192618}
m_Father: {fileID: 691126601}
Expand All @@ -830,6 +851,10 @@ MonoBehaviour:
magnification: 0.7
magnificationPropertyName: MagnifierMagnification
rendererIndex: 0
AutoAddDrawFullscreenFeature: 1
inLensMode: 0
targetDrawFullscreenFeatureName:
targetDrawFullscreenFeatureAddMode: 0
drawFullscreenSettings:
renderPassEvent: 500
BlitMaterial: {fileID: 2100000, guid: aee43c1cf28a72e48ae850053692e23e, type: 2}
Expand All @@ -839,7 +864,11 @@ MonoBehaviour:
DestinationType: 1
SourceTextureId:
DestinationTextureId: MagnifierTexture
FilterMode: 1
RestoreCameraColorTarget: 1
AutoAddRenderObjectsFeature: 1
targetDrawObjectsFeatureName:
targetDrawObjectsFeatureAddMode: 0
renderObjectsSettings:
passTag:
Event: 500
Expand Down Expand Up @@ -878,6 +907,7 @@ MeshRenderer:
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
Expand Down
Loading