diff --git a/Assets/test/QRCode.mat b/Assets/test/QRCode.mat new file mode 100644 index 0000000..5d4bc57 --- /dev/null +++ b/Assets/test/QRCode.mat @@ -0,0 +1,85 @@ +%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: QRCode + m_Shader: {fileID: 4800000, guid: 4bdd5767586f3a92993efea8febe2aa2, type: 3} + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _: + 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} + m_Ints: + - _Version: 63 + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + m_BuildTextureStacks: [] diff --git a/Assets/test/QRCode.mat.meta b/Assets/test/QRCode.mat.meta new file mode 100644 index 0000000..fa3802e --- /dev/null +++ b/Assets/test/QRCode.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8f2337a79bd22fcb39da95f427c01590 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/test/QRCode.shader b/Assets/test/QRCode.shader new file mode 100644 index 0000000..6e0ed5d --- /dev/null +++ b/Assets/test/QRCode.shader @@ -0,0 +1,99 @@ +Shader "CrispyPin/QRCode" { +Properties { + [HideInInspector] + _("",2D)="" + _Version("Version", Integer) = 1 +} +SubShader { +Tags { "RenderType"="Opaque" } +LOD 100 +CGPROGRAM + #pragma surface s Standard + struct Input{float2 uv_;}; + uint _Version; + + // #define VERSION 15 + #define VERSION _Version + #define WIDTH (21 + (VERSION-1)*4) + #define ALIGNERS ((VERSION / 7) + 2) + #define ALIGNER_SPACING ((WIDTH - 8 - 5) / (ALIGNERS-1)) + #define MISALIGNMENT ((WIDTH - 13) % (ALIGNERS-1)) + + /* + v = 15 + width = 77 + aligners = 4 + spacing = (77-13)/3 + */ + + #define WHITE 1 + #define BLACK 0 + #define PINK float4(1, .3, .5, 1) + + float4 finder_pattern(uint x, uint y) { + if (x < 6 && x > 0 && y < 6 && y > 0) return !(x < 5 && x > 1 && y < 5 && y > 1); + return (x > 6 || y > 6); + } + + float4 main (float2 uv){ + const uint data[] = {0x68656c6c,0x6f20776f,0x726c6421}; + uv.y = 1 - uv.y; + uv = uv * 1.5 - 0.25; + // Quiet zone + if (uv.x < 0 || uv.x > 1 || uv.y < 0 || uv.y > 1) return 1; + + uint px = uv.x * WIDTH; + uint py = uv.y * WIDTH; + + + // Finder patterns + if (px < 8 && py < 8) return finder_pattern(px, py); + if (px < 8 && py > WIDTH - 9) return finder_pattern(px, py - WIDTH + 7); + if (px > WIDTH - 9 && py < 8) return finder_pattern(px - WIDTH + 7, py); + + // Timing patterns + if (px == 6) return py & 1; + if (py == 6) return px & 1; + + // Aligners + if (VERSION > 1 + && (px > 8 || py > 8) // top left + && (px < WIDTH - 9 || py > 8) // top right + && (py < WIDTH - 9 || px > 8) // bottom left + ) { + // if (MISALIGNMENT != 0) return PINK; + + uint x = px + ALIGNER_SPACING - 4;// - MISALIGNMENT; + uint y = py + ALIGNER_SPACING - 4;// - MISALIGNMENT; + // if (px > WIDTH-15) x -= MISALIGNMENT; + // if (py > WIDTH-15) y -= MISALIGNMENT; + // if (px < 10) { + // x += MISALIGNMENT; + // } + // if (py < 10) { + // y += MISALIGNMENT; + // } + uint ax = x % ALIGNER_SPACING; + uint ay = y % ALIGNER_SPACING; + if (ax < 5 && ay < 5){ + // return PINK; + // return (ax|ay) & 1; + return (ax < 4 && ax > 0 && ay < 4 && ay > 0 && !(ax == 2 && ay == 2)); + } + } + + + // Format bits + if (px == 8 && (py < 9 || py > WIDTH - 9)) return 0.8; + if (py == 8 && (px < 9 || px > WIDTH - 9)) return 0.8; + + uint column = (WIDTH - px - (px > 6))/2; + uint direction_up = column & 1; + return column / 10.; + // return direction_up; + return 0.5; + } + + void s (Input IN, inout SurfaceOutputStandard o) {o.Albedo = main(IN.uv_); } +ENDCG +}} \ No newline at end of file diff --git a/Assets/test/QRCode.shader.meta b/Assets/test/QRCode.shader.meta new file mode 100644 index 0000000..e768850 --- /dev/null +++ b/Assets/test/QRCode.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 4bdd5767586f3a92993efea8febe2aa2 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/test/TestProps.unity b/Assets/test/TestProps.unity index c176cee..982416b 100644 --- a/Assets/test/TestProps.unity +++ b/Assets/test/TestProps.unity @@ -1360,7 +1360,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1500710831} m_LocalRotation: {x: 0, y: 1, z: 0, w: 0} - m_LocalPosition: {x: 0, y: 0, z: 1} + m_LocalPosition: {x: 0, y: 0.45, z: 1} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -1418,7 +1418,7 @@ MonoBehaviour: m_EditorClassIdentifier: type: 3 objectId: 55dfb9cd-3184-4c4f-bfd1-1412ce1aa79b - randomNum: 63286940 + randomNum: 50015399 unityVersion: 2021.3.41f1 cckVersion: 3.10:132 --- !u!114 &1557152371 @@ -1538,6 +1538,162 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 11 m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0} +--- !u!1 &1905057115 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1905057122} + - component: {fileID: 1905057121} + - component: {fileID: 1905057120} + - component: {fileID: 1905057119} + - component: {fileID: 1905057118} + - component: {fileID: 1905057117} + - component: {fileID: 1905057116} + m_Layer: 0 + m_Name: QRCode + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1905057116 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1905057115} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 990f6f4efb7f4ec98ad99f6dff1bc6f6, type: 3} + m_Name: + m_EditorClassIdentifier: + type: 3 + objectId: 9fee86b2-a9bd-46a3-a364-5f94506c4253 + randomNum: 24356558 + unityVersion: 2021.3.41f1 + cckVersion: 3.10:132 +--- !u!114 &1905057117 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1905057115} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a37fd8d654d5c2840a0ab3a5ad65a5ae, type: 3} + m_Name: + m_EditorClassIdentifier: + spawnHeight: 0 + useAdditionalValues: 0 + syncValues: [] + propPrivacy: 1 + subSyncs: [] + spawnableType: 0 + preGeneratedInstanceId: +--- !u!114 &1905057118 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1905057115} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 12974925555b471580cacf5d2d5fa9e3, type: 3} + m_Name: + m_EditorClassIdentifier: + gripType: 1 + gripOrigin: {fileID: 0} + disallowTheft: 0 + maximumGrabDistance: 0 + snappingReferences: [] + autoHold: 0 + updateWithPhysics: 1 + ikReference: {fileID: 0} +--- !u!65 &1905057119 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1905057115} + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 0.05} + m_Center: {x: 0, y: 0, z: 0} +--- !u!23 &1905057120 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1905057115} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 8f2337a79bd22fcb39da95f427c01590, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &1905057121 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1905057115} + m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &1905057122 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1905057115} + m_LocalRotation: {x: 0, y: 1, z: 0, w: 0} + m_LocalPosition: {x: 0, y: 1, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 12 + m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0} --- !u!1001 &2026983552 PrefabInstance: m_ObjectHideFlags: 0 @@ -1791,7 +1947,7 @@ MonoBehaviour: m_EditorClassIdentifier: type: 3 objectId: 9fee86b2-a9bd-46a3-a364-5f94506c4253 - randomNum: 67628025 + randomNum: 24356558 unityVersion: 2021.3.41f1 cckVersion: 3.10:132 --- !u!114 &2046637845