├── .gitignore ├── Addon.meta ├── Example.meta ├── Example ├── Animated Character 1.meta ├── Animated Character 1 │ ├── auto.meta │ ├── auto │ │ ├── characterMediumDataPlayer.mat │ │ ├── characterMediumDataPlayer.mat.meta │ │ ├── characterMediumDataPlayer.mesh │ │ ├── characterMediumDataPlayer.mesh.meta │ │ ├── characterMediumPlayer.mat │ │ ├── characterMediumPlayer.mat.meta │ │ ├── characterMediumPlayer.mesh │ │ ├── characterMediumPlayer.mesh.meta │ │ ├── characterMediumRecorder.mesh │ │ └── characterMediumRecorder.mesh.meta │ ├── characterMedium.fbx │ ├── characterMedium.fbx.meta │ ├── skin.mat │ ├── skin.mat.meta │ ├── survivorMaleB.png │ └── survivorMaleB.png.meta ├── Example.unity ├── Example.unity.meta ├── Material.meta ├── Material │ ├── Motion.mat │ ├── Motion.mat.meta │ ├── Unlit.mat │ ├── Unlit.mat.meta │ ├── UnlitGamma.mat │ └── UnlitGamma.mat.meta ├── Motion.meta └── Motion │ ├── FancyFeet.mp4 │ ├── FancyFeet.mp4.meta │ ├── Floss.mp4 │ ├── Floss.mp4.meta │ ├── Run.controller │ ├── Run.controller.meta │ ├── run.fbx │ └── run.fbx.meta ├── GameView.png ├── LICENSE.txt ├── LICENSE.txt.meta ├── Material.meta ├── Material ├── Motion.renderTexture ├── Motion.renderTexture.meta ├── MotionDec.asset ├── MotionDec.asset.meta ├── MotionDec.mat ├── MotionDec.mat.meta ├── Resources.meta └── Resources │ ├── DataPlayer.mat │ ├── DataPlayer.mat.meta │ ├── MeshPlayer.mat │ ├── MeshPlayer.mat.meta │ ├── MeshRecorder.mat │ ├── MeshRecorder.mat.meta │ ├── MeshRecorderInst.mat │ └── MeshRecorderInst.mat.meta ├── README.md ├── README.md.meta ├── Script.meta ├── Script ├── Common.meta ├── Common │ ├── GPUReader.cs │ ├── GPUReader.cs.meta │ ├── HumanAxes.cs │ ├── HumanAxes.cs.meta │ ├── HumanPoser.cs │ ├── HumanPoser.cs.meta │ ├── MeshPlayerGen.cs │ ├── MeshPlayerGen.cs.meta │ ├── MeshRecorderGen.cs │ ├── MeshRecorderGen.cs.meta │ ├── MeshUtil.cs │ ├── MeshUtil.cs.meta │ ├── Morph.cs │ ├── Morph.cs.meta │ ├── MotionDecoder.cs │ ├── MotionDecoder.cs.meta │ ├── MotionLayout.cs │ ├── MotionLayout.cs.meta │ ├── ShaderImpl.cs │ ├── ShaderImpl.cs.meta │ ├── Skeleton.cs │ └── Skeleton.cs.meta ├── Editor.meta ├── Editor │ ├── AnimRecorder.cs │ ├── AnimRecorder.cs.meta │ ├── MeshPlayer.cs │ ├── MeshPlayer.cs.meta │ ├── MeshRecorder.cs │ ├── MeshRecorder.cs.meta │ ├── MorphSettingsEditor.cs │ ├── MorphSettingsEditor.cs.meta │ ├── ShaderMotion.Editor.asmdef │ └── ShaderMotion.Editor.asmdef.meta ├── Runtime.meta ├── Runtime │ ├── MorphSettings.cs │ ├── MorphSettings.cs.meta │ ├── MotionPlayer.cs │ └── MotionPlayer.cs.meta ├── ShaderMotion.asmdef └── ShaderMotion.asmdef.meta ├── Shader.meta ├── Shader ├── Codec.hlsl ├── Codec.hlsl.meta ├── DataPlayer.shader ├── DataPlayer.shader.meta ├── MeshPlayer.hlsl ├── MeshPlayer.hlsl.meta ├── MeshPlayer.shader ├── MeshPlayer.shader.meta ├── MeshRecorder.hlsl ├── MeshRecorder.hlsl.meta ├── MeshRecorder.shader ├── MeshRecorder.shader.meta ├── MeshRecorderInst.shader ├── MeshRecorderInst.shader.meta ├── Rotation.hlsl ├── Rotation.hlsl.meta ├── Skinning.hlsl ├── Skinning.hlsl.meta ├── UnlitGamma.shader ├── UnlitGamma.shader.meta ├── VideoDecoder.shader ├── VideoDecoder.shader.meta ├── VideoLayout.hlsl └── VideoLayout.hlsl.meta ├── VRC_Avatar_Addon.meta ├── VRC_Avatar_Addon ├── Animation.meta ├── Animation │ ├── CalibrateOff.anim │ ├── CalibrateOff.anim.meta │ ├── CalibrateOn.anim │ ├── CalibrateOn.anim.meta │ ├── Layer0.anim │ ├── Layer0.anim.meta │ ├── Layer1.anim │ ├── Layer1.anim.meta │ ├── Layer2.anim │ ├── Layer2.anim.meta │ ├── Layer3.anim │ ├── Layer3.anim.meta │ ├── OtherOff.anim │ ├── OtherOff.anim.meta │ ├── OtherOn.anim │ ├── OtherOn.anim.meta │ ├── PlayerOff.anim │ ├── PlayerOff.anim.meta │ ├── PlayerOn.anim │ ├── PlayerOn.anim.meta │ ├── RecorderOff.anim │ ├── RecorderOff.anim.meta │ ├── RecorderOn.anim │ └── RecorderOn.anim.meta ├── Editor.meta ├── Editor │ ├── AnimatorControllerUtil.cs │ ├── AnimatorControllerUtil.cs.meta │ ├── VRCA2Descriptor.cs │ ├── VRCA2Descriptor.cs.meta │ ├── VRCA3Descriptor.cs │ ├── VRCA3Descriptor.cs.meta │ ├── VRCASetup.cs │ └── VRCASetup.cs.meta ├── Material.meta ├── Material │ ├── Anchor.mat │ ├── Anchor.mat.meta │ ├── Anchor.png │ └── Anchor.png.meta ├── Resources.meta ├── Resources │ ├── SMVRCA.prefab │ ├── SMVRCA.prefab.meta │ ├── SMVRCAFX.controller │ ├── SMVRCAFX.controller.meta │ ├── SMVRCAMenu.asset │ ├── SMVRCAMenu.asset.meta │ ├── SMVRCAMenu2.asset │ ├── SMVRCAMenu2.asset.meta │ ├── SMVRCAMenu3.asset │ ├── SMVRCAMenu3.asset.meta │ ├── SMVRCAParams.asset │ ├── SMVRCAParams.asset.meta │ ├── SMVRCAPlayer.mat │ └── SMVRCAPlayer.mat.meta ├── Shader.meta └── Shader │ ├── MeshPlayerGlobal.shader │ └── MeshPlayerGlobal.shader.meta ├── VRC_World_Addon.meta └── VRC_World_Addon ├── MotionLink.meta ├── MotionLink ├── GrabMotionDec.shader ├── GrabMotionDec.shader.meta ├── MotionLink.mat ├── MotionLink.mat.meta ├── MotionLink.prefab └── MotionLink.prefab.meta ├── SampleWorld.unity ├── SampleWorld.unity.meta ├── UdonPlayer.meta └── UdonPlayer ├── DataRT.renderTexture ├── DataRT.renderTexture.meta ├── DataTex.asset ├── DataTex.asset.meta ├── Script.meta └── Script ├── CamRTReader.asset ├── CamRTReader.asset.meta ├── CamRTReader.cs ├── CamRTReader.cs.meta ├── UdonPlayer.asset ├── UdonPlayer.asset.meta ├── UdonPlayer.cs └── UdonPlayer.cs.meta /.gitignore: -------------------------------------------------------------------------------- 1 | Test* 2 | ~* 3 | *~ 4 | *2 5 | *2.meta -------------------------------------------------------------------------------- /Addon.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5598ccbc110cd2042adb878004eb048f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Example.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 16acb1ce14378f04483632ff542c5ab1 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Example/Animated Character 1.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 343518e16ae7f6c4d96398b8956522f1 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Example/Animated Character 1/auto.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 924d08044ffb64f4d953a6e65c276a6b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Example/Animated Character 1/auto/characterMediumDataPlayer.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: characterMediumDataPlayer 11 | m_Shader: {fileID: 4800000, guid: 4a0493aef72f2774184a5696b941e9a6, type: 3} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 1 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _Bone: 23 | m_Texture: {fileID: 8444366053336339451, guid: ce2031e0224978b44987b7ff57f37a86, 24 | type: 2} 25 | m_Scale: {x: 1, y: 1} 26 | m_Offset: {x: 0, y: 0} 27 | - _MotionDec: 28 | m_Texture: {fileID: 8600000, guid: 0247e5cfe3e145b4d9cba5360c02bfea, type: 2} 29 | m_Scale: {x: 1, y: 1} 30 | m_Offset: {x: 0, y: 0} 31 | - _Shape: 32 | m_Texture: {fileID: 1480200366197994797, guid: ce2031e0224978b44987b7ff57f37a86, 33 | type: 2} 34 | m_Scale: {x: 1, y: 1} 35 | m_Offset: {x: 0, y: 0} 36 | m_Floats: 37 | - _AutoHide: 1 38 | - _HumanScale: -1 39 | - _Layer: 0 40 | - _RotationTolerance: 0.1 41 | m_Colors: [] 42 | -------------------------------------------------------------------------------- /Example/Animated Character 1/auto/characterMediumDataPlayer.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dcee348be4a94644a8d555bbb303a99e 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Example/Animated Character 1/auto/characterMediumDataPlayer.mesh.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ce2031e0224978b44987b7ff57f37a86 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 4300000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Example/Animated Character 1/auto/characterMediumPlayer.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: characterMediumPlayer 11 | m_Shader: {fileID: 4800000, guid: dd06eb73e4fc7a84fbb5fecce12d7d07, type: 3} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _Armature: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _Bone: 27 | m_Texture: {fileID: 28261413282981026, guid: 66477ede8cb6acd42a1fafe3bf5a2a9e, 28 | type: 2} 29 | m_Scale: {x: 1, y: 1} 30 | m_Offset: {x: 0, y: 0} 31 | - _MainTex: 32 | m_Texture: {fileID: 2800000, guid: aebb532dd9bbb7d458f971f471d03afa, type: 3} 33 | m_Scale: {x: 1, y: 1} 34 | m_Offset: {x: 0, y: 0} 35 | - _MotionDec: 36 | m_Texture: {fileID: 8600000, guid: 0247e5cfe3e145b4d9cba5360c02bfea, type: 2} 37 | m_Scale: {x: 1, y: 1} 38 | m_Offset: {x: 0, y: 0} 39 | - _Shape: 40 | m_Texture: {fileID: 28856249214143266, guid: 66477ede8cb6acd42a1fafe3bf5a2a9e, 41 | type: 2} 42 | m_Scale: {x: 1, y: 1} 43 | m_Offset: {x: 0, y: 0} 44 | m_Floats: 45 | - _AlphaTest: 0 46 | - _ApplyScale: 1 47 | - _Cull: 2 48 | - _Cutoff: 0 49 | - _Decoded: 0 50 | - _HumanScale: 0 51 | - _Layer: 0 52 | - _NearClip: 0 53 | - _RotationTolerance: 0.1 54 | m_Colors: 55 | - _Color: {r: 1, g: 1, b: 1, a: 1} 56 | -------------------------------------------------------------------------------- /Example/Animated Character 1/auto/characterMediumPlayer.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ccc28c0f4faf4b04db0dac220fc06179 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Example/Animated Character 1/auto/characterMediumPlayer.mesh.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 66477ede8cb6acd42a1fafe3bf5a2a9e 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 4300000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Example/Animated Character 1/auto/characterMediumRecorder.mesh.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bfd3a6739a4639a4b84ff639cba3039c 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 4300000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Example/Animated Character 1/characterMedium.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CuteWaterBeary/ShaderMotion/9d53d6e8588501764674e031ef196e22b6f332ef/Example/Animated Character 1/characterMedium.fbx -------------------------------------------------------------------------------- /Example/Animated Character 1/skin.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: skin 11 | m_Shader: {fileID: 10752, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 2800000, guid: aebb532dd9bbb7d458f971f471d03afa, type: 3} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BumpScale: 1 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0 65 | - _GlossyReflections: 1 66 | - _Metallic: 0 67 | - _Mode: 0 68 | - _OcclusionStrength: 1 69 | - _Parallax: 0.02 70 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _UVSec: 0 74 | - _ZWrite: 1 75 | m_Colors: 76 | - _Color: {r: 0.8, g: 0.8, b: 0.8, a: 1} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 0} 78 | -------------------------------------------------------------------------------- /Example/Animated Character 1/skin.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 21c523da74de5e640b1b068246fd96e1 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Example/Animated Character 1/survivorMaleB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CuteWaterBeary/ShaderMotion/9d53d6e8588501764674e031ef196e22b6f332ef/Example/Animated Character 1/survivorMaleB.png -------------------------------------------------------------------------------- /Example/Animated Character 1/survivorMaleB.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aebb532dd9bbb7d458f971f471d03afa 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | externalObjects: {} 6 | serializedVersion: 9 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: 1 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: -1 38 | wrapV: -1 39 | wrapW: -1 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 0 53 | spriteTessellationDetail: -1 54 | textureType: 0 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | platformSettings: 61 | - serializedVersion: 2 62 | buildTarget: DefaultTexturePlatform 63 | maxTextureSize: 2048 64 | resizeAlgorithm: 0 65 | textureFormat: -1 66 | textureCompression: 1 67 | compressionQuality: 50 68 | crunchedCompression: 0 69 | allowsAlphaSplitting: 0 70 | overridden: 0 71 | androidETC2FallbackOverride: 0 72 | - serializedVersion: 2 73 | buildTarget: Standalone 74 | maxTextureSize: 2048 75 | resizeAlgorithm: 0 76 | textureFormat: -1 77 | textureCompression: 1 78 | compressionQuality: 50 79 | crunchedCompression: 0 80 | allowsAlphaSplitting: 0 81 | overridden: 0 82 | androidETC2FallbackOverride: 0 83 | - serializedVersion: 2 84 | buildTarget: Nintendo Switch 85 | maxTextureSize: 2048 86 | resizeAlgorithm: 0 87 | textureFormat: -1 88 | textureCompression: 1 89 | compressionQuality: 50 90 | crunchedCompression: 0 91 | allowsAlphaSplitting: 0 92 | overridden: 0 93 | androidETC2FallbackOverride: 0 94 | spriteSheet: 95 | serializedVersion: 2 96 | sprites: [] 97 | outline: [] 98 | physicsShape: [] 99 | bones: [] 100 | spriteID: 101 | vertices: [] 102 | indices: 103 | edges: [] 104 | weights: [] 105 | spritePackingTag: 106 | pSDRemoveMatte: 0 107 | pSDShowRemoveMatteOption: 0 108 | userData: 109 | assetBundleName: 110 | assetBundleVariant: 111 | -------------------------------------------------------------------------------- /Example/Example.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 13ae5f3b4fb48b44488ec1c074df63ce 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Example/Material.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 03f1690d2c011ee4281baac367221f0c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Example/Material/Motion.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: Motion 11 | m_Shader: {fileID: 10752, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 8400000, guid: d20659993e9dc5541bdd19d0d47fd9c7, type: 2} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BumpScale: 1 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0.5 65 | - _GlossyReflections: 1 66 | - _Metallic: 0 67 | - _Mode: 0 68 | - _OcclusionStrength: 1 69 | - _Parallax: 0.02 70 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _UVSec: 0 74 | - _ZWrite: 1 75 | m_Colors: 76 | - _Color: {r: 1, g: 1, b: 1, a: 1} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 78 | -------------------------------------------------------------------------------- /Example/Material/Motion.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3dc076090d06d1146b0df7ad15494d29 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Example/Material/Unlit.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: Unlit 11 | m_Shader: {fileID: 10752, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BumpScale: 1 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0.5 65 | - _GlossyReflections: 1 66 | - _Metallic: 0 67 | - _Mode: 0 68 | - _OcclusionStrength: 1 69 | - _Parallax: 0.02 70 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _UVSec: 0 74 | - _ZWrite: 1 75 | m_Colors: 76 | - _Color: {r: 1, g: 1, b: 1, a: 1} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 78 | -------------------------------------------------------------------------------- /Example/Material/Unlit.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bab33161ed2852a4fa269411a3e3a490 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Example/Material/UnlitGamma.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: UnlitGamma 11 | m_Shader: {fileID: 4800000, guid: 08297a8faa70b86468c83e77ded9bff0, type: 3} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BumpScale: 1 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0.5 65 | - _GlossyReflections: 1 66 | - _Metallic: 0 67 | - _Mode: 0 68 | - _OcclusionStrength: 1 69 | - _Parallax: 0.02 70 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _UVSec: 0 74 | - _ZWrite: 1 75 | m_Colors: 76 | - _Color: {r: 1, g: 1, b: 1, a: 1} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 78 | -------------------------------------------------------------------------------- /Example/Material/UnlitGamma.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2393de9b03c0f694da1f87fdc35bf0a3 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Example/Motion.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6be37c8034b21d1438dfea6153871707 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Example/Motion/FancyFeet.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CuteWaterBeary/ShaderMotion/9d53d6e8588501764674e031ef196e22b6f332ef/Example/Motion/FancyFeet.mp4 -------------------------------------------------------------------------------- /Example/Motion/FancyFeet.mp4.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 83452be5896340d48a50f67331ac9127 3 | VideoClipImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | frameRange: 0 7 | startFrame: -1 8 | endFrame: -1 9 | colorSpace: 0 10 | deinterlace: 0 11 | encodeAlpha: 0 12 | flipVertical: 0 13 | flipHorizontal: 0 14 | importAudio: 1 15 | targetSettings: {} 16 | userData: 17 | assetBundleName: 18 | assetBundleVariant: 19 | -------------------------------------------------------------------------------- /Example/Motion/Floss.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CuteWaterBeary/ShaderMotion/9d53d6e8588501764674e031ef196e22b6f332ef/Example/Motion/Floss.mp4 -------------------------------------------------------------------------------- /Example/Motion/Floss.mp4.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e12e116cea8fe9446a93807d90a441ba 3 | VideoClipImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | frameRange: 0 7 | startFrame: -1 8 | endFrame: -1 9 | colorSpace: 0 10 | deinterlace: 0 11 | encodeAlpha: 0 12 | flipVertical: 0 13 | flipHorizontal: 0 14 | importAudio: 0 15 | targetSettings: 16 | 0: 17 | enableTranscoding: 0 18 | codec: 0 19 | resizeFormat: 0 20 | aspectRatio: 0 21 | customWidth: 640 22 | customHeight: 360 23 | bitrateMode: 2 24 | spatialQuality: 2 25 | userData: 26 | assetBundleName: 27 | assetBundleVariant: 28 | -------------------------------------------------------------------------------- /Example/Motion/Run.controller: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!91 &9100000 4 | AnimatorController: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_Name: Run 10 | serializedVersion: 5 11 | m_AnimatorParameters: [] 12 | m_AnimatorLayers: 13 | - serializedVersion: 5 14 | m_Name: Base Layer 15 | m_StateMachine: {fileID: 1107446842575855264} 16 | m_Mask: {fileID: 0} 17 | m_Motions: [] 18 | m_Behaviours: [] 19 | m_BlendingMode: 0 20 | m_SyncedLayerIndex: -1 21 | m_DefaultWeight: 0 22 | m_IKPass: 0 23 | m_SyncedLayerAffectsTiming: 0 24 | m_Controller: {fileID: 9100000} 25 | --- !u!1102 &1102118929278206206 26 | AnimatorState: 27 | serializedVersion: 5 28 | m_ObjectHideFlags: 1 29 | m_CorrespondingSourceObject: {fileID: 0} 30 | m_PrefabInstance: {fileID: 0} 31 | m_PrefabAsset: {fileID: 0} 32 | m_Name: Run 33 | m_Speed: 1 34 | m_CycleOffset: 0 35 | m_Transitions: [] 36 | m_StateMachineBehaviours: [] 37 | m_Position: {x: 50, y: 50, z: 0} 38 | m_IKOnFeet: 0 39 | m_WriteDefaultValues: 1 40 | m_Mirror: 0 41 | m_SpeedParameterActive: 0 42 | m_MirrorParameterActive: 0 43 | m_CycleOffsetParameterActive: 0 44 | m_TimeParameterActive: 0 45 | m_Motion: {fileID: 7400002, guid: f06fcb6250ed56643b597d6c6a6cb9e9, type: 3} 46 | m_Tag: 47 | m_SpeedParameter: 48 | m_MirrorParameter: 49 | m_CycleOffsetParameter: 50 | m_TimeParameter: 51 | --- !u!1107 &1107446842575855264 52 | AnimatorStateMachine: 53 | serializedVersion: 5 54 | m_ObjectHideFlags: 1 55 | m_CorrespondingSourceObject: {fileID: 0} 56 | m_PrefabInstance: {fileID: 0} 57 | m_PrefabAsset: {fileID: 0} 58 | m_Name: Base Layer 59 | m_ChildStates: 60 | - serializedVersion: 1 61 | m_State: {fileID: 1102118929278206206} 62 | m_Position: {x: 498.8305, y: 126.70288, z: 0} 63 | m_ChildStateMachines: [] 64 | m_AnyStateTransitions: [] 65 | m_EntryTransitions: [] 66 | m_StateMachineTransitions: {} 67 | m_StateMachineBehaviours: [] 68 | m_AnyStatePosition: {x: 50, y: 20, z: 0} 69 | m_EntryPosition: {x: 50, y: 120, z: 0} 70 | m_ExitPosition: {x: 800, y: 120, z: 0} 71 | m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} 72 | m_DefaultState: {fileID: 1102118929278206206} 73 | -------------------------------------------------------------------------------- /Example/Motion/Run.controller.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 94cf5b025f624444c8e45edf033f0262 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 9100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Example/Motion/run.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CuteWaterBeary/ShaderMotion/9d53d6e8588501764674e031ef196e22b6f332ef/Example/Motion/run.fbx -------------------------------------------------------------------------------- /GameView.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CuteWaterBeary/ShaderMotion/9d53d6e8588501764674e031ef196e22b6f332ef/GameView.png -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2020-2021 lox9973 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /LICENSE.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 00c61db6c810ded4ab5cc385daa5b647 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Material.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e4faa63548e4474fb26f9dd96935627 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Material/Motion.renderTexture: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!84 &8400000 4 | RenderTexture: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_Name: Motion 10 | m_ImageContentsHash: 11 | serializedVersion: 2 12 | Hash: 00000000000000000000000000000000 13 | m_ForcedFallbackFormat: 4 14 | m_DownscaleFallback: 0 15 | m_Width: 640 16 | m_Height: 360 17 | m_AntiAliasing: 1 18 | m_DepthFormat: 0 19 | m_ColorFormat: 0 20 | m_MipMap: 0 21 | m_GenerateMips: 1 22 | m_SRGB: 1 23 | m_UseDynamicScale: 0 24 | m_BindMS: 0 25 | m_TextureSettings: 26 | serializedVersion: 2 27 | m_FilterMode: 1 28 | m_Aniso: 0 29 | m_MipBias: 0 30 | m_WrapU: 1 31 | m_WrapV: 1 32 | m_WrapW: 1 33 | m_Dimension: 2 34 | m_VolumeDepth: 1 35 | -------------------------------------------------------------------------------- /Material/Motion.renderTexture.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d20659993e9dc5541bdd19d0d47fd9c7 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 8400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Material/MotionDec.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!86 &8600000 4 | CustomRenderTexture: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_Name: MotionDec 10 | m_ImageContentsHash: 11 | serializedVersion: 2 12 | Hash: 00000000000000000000000000000000 13 | m_ForcedFallbackFormat: 4 14 | m_DownscaleFallback: 0 15 | m_Width: 160 16 | m_Height: 90 17 | m_AntiAliasing: 1 18 | m_DepthFormat: 0 19 | m_ColorFormat: 11 20 | m_MipMap: 0 21 | m_GenerateMips: 1 22 | m_SRGB: 0 23 | m_UseDynamicScale: 0 24 | m_BindMS: 0 25 | m_TextureSettings: 26 | serializedVersion: 2 27 | m_FilterMode: 0 28 | m_Aniso: 0 29 | m_MipBias: 0 30 | m_WrapU: 1 31 | m_WrapV: 1 32 | m_WrapW: 1 33 | m_Dimension: 2 34 | m_VolumeDepth: 1 35 | m_Material: {fileID: 2100000, guid: 72f44237014098041bcd7763c99a5288, type: 2} 36 | m_InitSource: 0 37 | m_InitMaterial: {fileID: 0} 38 | m_InitColor: {r: 0, g: 0, b: 0, a: 0} 39 | m_InitTexture: {fileID: 0} 40 | m_UpdateMode: 1 41 | m_InitializationMode: 0 42 | m_UpdateZoneSpace: 0 43 | m_CurrentUpdateZoneSpace: 0 44 | m_UpdateZones: 45 | - updateZoneCenter: {x: 0.5, y: 0.5, z: 0.5} 46 | updateZoneSize: {x: 1, y: 1, z: 1} 47 | rotation: 0 48 | passIndex: 0 49 | needSwap: 1 50 | - updateZoneCenter: {x: 0.5, y: 0.5, z: 0.5} 51 | updateZoneSize: {x: 1, y: 1, z: 1} 52 | rotation: 0 53 | passIndex: 1 54 | needSwap: 1 55 | m_UpdatePeriod: 0 56 | m_ShaderPass: 0 57 | m_CubemapFaceMask: 4294967295 58 | m_DoubleBuffered: 1 59 | m_WrapUpdateZones: 0 60 | -------------------------------------------------------------------------------- /Material/MotionDec.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0247e5cfe3e145b4d9cba5360c02bfea 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 8600000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Material/MotionDec.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: MotionDec 11 | m_Shader: {fileID: 4800000, guid: 4f62389260affe24a8a4a999b611a7db, type: 3} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _MainTex: 23 | m_Texture: {fileID: 8400000, guid: d20659993e9dc5541bdd19d0d47fd9c7, type: 2} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | m_Floats: [] 27 | m_Colors: [] 28 | -------------------------------------------------------------------------------- /Material/MotionDec.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 72f44237014098041bcd7763c99a5288 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Material/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c40f878db2887d741a8f4e919b0673af 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Material/Resources/DataPlayer.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: DataPlayer 11 | m_Shader: {fileID: 4800000, guid: 4a0493aef72f2774184a5696b941e9a6, type: 3} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 1 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _MotionDec: 23 | m_Texture: {fileID: 8600000, guid: 0247e5cfe3e145b4d9cba5360c02bfea, type: 2} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | -------------------------------------------------------------------------------- /Material/Resources/DataPlayer.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ec81b35709453a247bfb4331cd6c7075 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Material/Resources/MeshPlayer.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: MeshPlayer 11 | m_Shader: {fileID: 4800000, guid: dd06eb73e4fc7a84fbb5fecce12d7d07, type: 3} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 1 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _MainTex: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _MotionDec: 27 | m_Texture: {fileID: 8600000, guid: 0247e5cfe3e145b4d9cba5360c02bfea, type: 2} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | m_Floats: 31 | - _AlphaTest: 0 32 | - _Cull: 2 33 | - _Cutoff: 0 34 | - _Layer: 0 35 | - _NearClip: 0 36 | - _RotationTolerance: 0.1 37 | m_Colors: 38 | - _Color: {r: 1, g: 1, b: 1, a: 1} 39 | -------------------------------------------------------------------------------- /Material/Resources/MeshPlayer.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c89ccec4feb5b814db6b6c23c6bc1351 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Material/Resources/MeshRecorder.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: MeshRecorder 11 | m_Shader: {fileID: 4800000, guid: 9687b2da23383b847b1f5a464badac15, type: 3} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: [] 22 | m_Floats: 23 | - _AutoHide: 1 24 | - _Layer: 0 25 | m_Colors: [] 26 | -------------------------------------------------------------------------------- /Material/Resources/MeshRecorder.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ec41a2b90a56a7e48ab2ea7983eea893 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Material/Resources/MeshRecorderInst.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 05599adb38fac7e4ea0f7293bafa919c 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ceff1bbedc4921f4d8843981cf0bb685 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Script.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 477e239c2d96f8d4bac0806e79b02a75 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Script/Common.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e18b6dc64419a904b9d7e8b9b1bef678 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Script/Common/GPUReader.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using UnityEngine; 4 | using Unity.Collections; 5 | using AsyncGPUReadback = UnityEngine.Rendering.AsyncGPUReadback; 6 | using AsyncGPUReadbackRequest = UnityEngine.Rendering.AsyncGPUReadbackRequest; 7 | 8 | namespace ShaderMotion { 9 | public class GPUReader { 10 | Queue requests = new Queue(); 11 | public AsyncGPUReadbackRequest? Request(Texture tex) { 12 | AsyncGPUReadbackRequest? request = null; 13 | while(requests.Count > 0) { 14 | var r = requests.Peek(); 15 | if(!r.done) 16 | break; 17 | request = requests.Dequeue(); 18 | } 19 | if(requests.Count < 2) 20 | requests.Enqueue(AsyncGPUReadback.Request(tex)); 21 | return request; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Script/Common/GPUReader.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0ca6fafee99157d48a15cf26104f9e2f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Script/Common/HumanAxes.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Reflection; 4 | using UnityEngine; 5 | #if UNITY_EDITOR 6 | using UnityEditor; 7 | #endif 8 | 9 | namespace ShaderMotion { 10 | public struct HumanAxes { 11 | public Quaternion postQ; // tip == bone.position + bone.rotation * postQ * Vector3.right * limit.axisLength 12 | public Quaternion preQ; // bone.localRotation * postQ == preQ * SwingTwist(sign * degrees) 13 | public Vector3 sign; // abs(sign) != 1 is possible for custom limit range 14 | public HumanAxes(Transform bone, Vector3 dir=new Vector3()) { 15 | if(dir == Vector3.zero) { // guess bone direction 16 | foreach(Transform c in bone) 17 | dir += c.localPosition; 18 | if(dir == Vector3.zero) 19 | dir = -bone.InverseTransformPoint(bone.parent.position); 20 | dir = bone.InverseTransformVector(Vector3.down); 21 | } 22 | postQ = Quaternion.FromToRotation(Vector3.right, dir); 23 | preQ = bone.localRotation * postQ; 24 | sign = Vector3.one; 25 | } 26 | public HumanAxes(Avatar avatar, HumanBodyBones humanBone) { 27 | postQ = (Quaternion)GetPostRotation.Invoke(avatar, new object[]{humanBone}); 28 | preQ = (Quaternion)GetPreRotation .Invoke(avatar, new object[]{humanBone}); 29 | sign = GetLimitSignScaled(avatar, humanBone); 30 | } 31 | public static Quaternion SwingTwist(Vector3 degree) { 32 | var degreeYZ = new Vector3(0, degree.y, degree.z); 33 | return Quaternion.AngleAxis(degreeYZ.magnitude, degreeYZ.normalized) 34 | * Quaternion.AngleAxis(degree.x, new Vector3(1,0,0)); 35 | } 36 | 37 | // this method is based on GetLimitSign with two modifications: 38 | // 1. non-muscle axis sign is chosen to match ancestor's, while GetLimitSign always returns +1 39 | // 2. sign is scaled to reflect the limit range change from its default value 40 | static Vector3 GetLimitSignScaled(Avatar avatar, HumanBodyBones humanBone) { 41 | var human = default(HumanBone[]); 42 | #if UNITY_EDITOR // might be improved when unity 2019 exposes avatar.humanDescription 43 | human = ((AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(avatar)) as ModelImporter) 44 | ?.humanDescription)?.human; 45 | #endif 46 | 47 | var sign = Vector3.zero; 48 | for(var b = humanBone; (int)b >= 0; ) { 49 | var limit = GetHumanLimit(human, b); 50 | var s = (Vector3)GetLimitSign.Invoke(avatar, new object[]{b}); 51 | for(int i=0; i<3; i++) { 52 | var m = HumanTrait.MuscleFromBone((int)b, i); 53 | if(m < 0) 54 | s[i] = 0; 55 | else if(sign[i] == 0) { 56 | sign[i] = s[i]; 57 | if(!limit.useDefaultValues) 58 | sign[i] *= (limit.max[i]-limit.min[i]) 59 | / (HumanTrait.GetMuscleDefaultMax(m)-HumanTrait.GetMuscleDefaultMin(m)); 60 | } 61 | } 62 | 63 | if(s.x*s.y*s.z != 0) { 64 | // match orientation 65 | for(int i=0; i<3 && (sign.x*sign.y*sign.z) != (s.x*s.y*s.z); i++) 66 | if(HumanTrait.MuscleFromBone((int)humanBone, i) < 0) 67 | sign[i] *= -1; 68 | return sign; 69 | } 70 | 71 | b = b == HumanBodyBones.LeftShoulder ? HumanBodyBones.LeftUpperArm : 72 | b == HumanBodyBones.RightShoulder ? HumanBodyBones.RightUpperArm : 73 | (HumanBodyBones)HumanTrait.GetParentBone((int)b); 74 | } 75 | return Vector3.one; 76 | } 77 | static HumanLimit GetHumanLimit(HumanBone[] human, HumanBodyBones bone) { 78 | if(human != null) 79 | foreach(var hb in human) 80 | if(hb.humanName == HumanTrait.BoneName[(int)bone]) 81 | return hb.limit; 82 | return new HumanLimit{useDefaultValues = true}; 83 | } 84 | static readonly MethodInfo GetPreRotation = typeof(Avatar).GetMethod("GetPreRotation", BindingFlags.NonPublic | BindingFlags.Instance); 85 | static readonly MethodInfo GetPostRotation = typeof(Avatar).GetMethod("GetPostRotation", BindingFlags.NonPublic | BindingFlags.Instance); 86 | static readonly MethodInfo GetLimitSign = typeof(Avatar).GetMethod("GetLimitSign", BindingFlags.NonPublic | BindingFlags.Instance); 87 | static readonly MethodInfo GetZYRoll = typeof(Avatar).GetMethod("GetZYRoll", BindingFlags.NonPublic | BindingFlags.Instance); 88 | static readonly MethodInfo GetAxisLength = typeof(Avatar).GetMethod("GetAxisLength", BindingFlags.NonPublic | BindingFlags.Instance); 89 | } 90 | } -------------------------------------------------------------------------------- /Script/Common/HumanAxes.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 79cbc46afbec9d84ebcc80729fd187aa 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Script/Common/HumanPoser.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using UnityEngine; 4 | 5 | namespace ShaderMotion { 6 | public class HumanPoser { 7 | public static (Vector3, Quaternion) GetRootMotion(ref HumanPose pose, Animator animator) { 8 | var anim = animator.transform; 9 | // bodyPosition/bodyRotation represents the center of mass relative to animator parent, divided by the human scale 10 | // anim.localScale seems ignored 11 | var rootQ = Quaternion.Inverse(anim.localRotation) * pose.bodyRotation; 12 | var rootT = Quaternion.Inverse(anim.localRotation) * (pose.bodyPosition-anim.localPosition/animator.humanScale); 13 | // Unity <=2019 seems to ignore localScale on the open interval (hips, anim) as well 14 | #if !UNITY_2020_1_OR_NEWER // TODO: tested on 2021 but not 2020 15 | var hips = animator.GetBoneTransform(HumanBodyBones.Hips); 16 | rootT = anim.InverseTransformPoint(hips.parent.TransformPoint( 17 | InverseTransformPointTQ(rootT*animator.humanScale, hips.parent, anim)))/animator.humanScale; 18 | #endif 19 | return (rootT, rootQ); 20 | } 21 | static Vector3 InverseTransformPointTQ(Vector3 pos, Transform begin, Transform end) { 22 | var chainT = Vector3.zero; 23 | var chainQ = Quaternion.identity; 24 | for(var x = begin; x != end; x = x.parent) { 25 | chainT = x.localRotation * chainT + x.localPosition; 26 | chainQ = x.localRotation * chainQ; 27 | } 28 | return Quaternion.Inverse(chainQ) * (pos - chainT); 29 | } 30 | public static void SetHipsPositionRotation(ref HumanPose pose, Vector3 hipsT, Quaternion hipsQ, float humanScale) { 31 | var spreadQ = Quaternion.identity; 32 | foreach(var (i, scale) in spreadMassQ) 33 | spreadQ *= HumanAxes.SwingTwist(new Vector3( 34 | pose.muscles[HumanTrait.MuscleFromBone(i, 0)]*scale[0], 35 | pose.muscles[HumanTrait.MuscleFromBone(i, 1)]*scale[1], 36 | pose.muscles[HumanTrait.MuscleFromBone(i, 2)]*scale[2])); 37 | var t = Quaternion.LookRotation(Vector3.right, Vector3.forward); 38 | pose.bodyPosition = hipsT / humanScale; 39 | pose.bodyRotation = hipsQ * (t * spreadQ * Quaternion.Inverse(t)); 40 | // TODO: account for mass center 41 | } 42 | public static void SetBoneSwingTwists(ref HumanPose pose, Vector3[] swingTwists) { 43 | System.Array.Clear(pose.muscles, 0, pose.muscles.Length); 44 | for(int i=0; i= 0) 48 | pose.muscles[muscle] += swingTwists[i][j] * weight; 49 | } 50 | for(int i=0; i= 0 ? muscleLimits[i,1] : -muscleLimits[i,0]; 52 | } 53 | public static readonly (int, Vector3)[] spreadMassQ = new[]{ 54 | ((int)HumanBodyBones.Spine, new Vector3(20, -30, -30)), 55 | ((int)HumanBodyBones.Chest, new Vector3(20, -20, -20)), 56 | ((int)HumanBodyBones.UpperChest, new Vector3(10, -10, -10)), 57 | }; 58 | public static readonly (int, float)[,] boneMuscles; 59 | public static readonly float[,] muscleLimits; 60 | static HumanPoser() { 61 | boneMuscles = new (int, float)[HumanTrait.BoneCount, 3]; 62 | for(int i=0; i= 0 && dstBindposes[j][3,3] == 0) 33 | if(k == 1) { 34 | dstBindposes[j] = (dstBones[j].worldToLocalMatrix * srcBones[i].localToWorldMatrix) * srcBindposes[i]; 35 | Debug.Log($"[Retarget] bindpose[{(HumanBodyBones)j}] = MAT * bindpose[{srcBones[i]?.name}]", srcBones[i]); 36 | } else if(dstBones[j] == srcBones[i]) 37 | dstBindposes[j] = srcBindposes[i]; 38 | } 39 | } 40 | static Matrix4x4[] RetargetBoneWeights(Transform[] srcBones, Transform[] dstBones, 41 | Matrix4x4[] srcBindposes, Matrix4x4[] dstBindposes, 42 | BoneWeight[] boneWeights, int[] boneMap) { 43 | Debug.Assert(srcBones.Length == srcBindposes.Length && dstBones.Length == dstBindposes.Length); 44 | var vertMatrices = new Matrix4x4[boneWeights.Length]; 45 | for(int v=0; v 1e-8) 70 | Debug.Log($"[Retarget] vertex = MAT * vertex, bones == {{{srcBones[boneWeights[v].boneIndex0]?.name}, {srcBones[boneWeights[v].boneIndex1]?.name}}}", srcBones[boneWeights[v].boneIndex0]); 71 | } 72 | 73 | System.Array.Clear(bw, 0, bw.Length); 74 | var idx = 0; 75 | foreach(var dstBone in Enumerable.Range(0, dstBones.Length).OrderBy(i => -weights[i]).Take(4)) 76 | bw[idx++] = (dstBone, weights[dstBone]); 77 | 78 | vertMatrices[v] = srcMatSum == dstMatSum ? Matrix4x4.identity : dstMatSum.inverse * srcMatSum; 79 | boneWeights[v] = PackBoneWeight(bw); 80 | } 81 | return vertMatrices; 82 | } 83 | public static Matrix4x4[] RetargetBindposesBoneWeights(Transform[] srcBones, Transform[] dstBones, 84 | Matrix4x4[] srcBindposes, Matrix4x4[] dstBindposes, 85 | BoneWeight[] boneWeights) { 86 | var boneMap = RetargetBones(srcBones, dstBones); 87 | // unmap unused srcBones 88 | var used = new bool[srcBones.Length]; 89 | foreach(var bw in boneWeights) 90 | foreach(var (index, weight) in UnpackBoneWeight(bw)) 91 | if(weight != 0) 92 | used[index] = true; 93 | for(int i=0; i x >= 0).FirstOrDefault(); 100 | for(int i=0; i[,][] shapes = new KeyValuePair[3,3][]; 9 | static float GetWeight(Vector2 coord, int i, int j) { 10 | // TODO: try different interpolation? 11 | return Mathf.Clamp01(1-Mathf.Abs(coord.x-(i-1))) * Mathf.Clamp01(1-Mathf.Abs(coord.y-(j-1))); 12 | } 13 | public void Sample(Vector2 coord, IDictionary weights, bool writeDefault=false) { 14 | for(int i=0; i<3; i++) 15 | for(int j=0; j<3; j++) 16 | if(shapes[i,j] != null) { 17 | var w = GetWeight(coord, i, j); 18 | if(writeDefault || w != 0) 19 | foreach(var shape in shapes[i,j]) { 20 | float v; 21 | weights.TryGetValue(shape.Key, out v); 22 | weights[shape.Key] = v + shape.Value * w; 23 | } 24 | } 25 | } 26 | public void Set(Vector2 coord, KeyValuePair[] shapes) { 27 | var i = 1+(int)System.Math.Sign(coord.x); 28 | var j = 1+(int)System.Math.Sign(coord.y); 29 | this.shapes[i,j] = null; 30 | if(shapes != null) { 31 | var w = GetWeight(coord, i, j); 32 | var weights = shapes.ToDictionary(x => x.Key, x => -x.Value); 33 | Sample(coord, weights); 34 | this.shapes[i,j] = weights.Select(x => new KeyValuePair(x.Key, -x.Value/w)).ToArray(); 35 | } 36 | } 37 | } 38 | public class Morph { 39 | public BlendSpace[] blends = new BlendSpace[(int)BlendSpacePreset.LastPreset]; 40 | public Dictionary controls = new Dictionary(); 41 | public Morph(Animator animator) { 42 | MorphSettings.Apply(this, animator); 43 | } 44 | public static void GetBlendShapeVertices(Mesh mesh, IEnumerable> shapes, Vector3[] dstDV, Vector3[] srcDV) { 45 | if(shapes != null) 46 | foreach(var shape in shapes) { 47 | var idx = mesh.GetBlendShapeIndex(shape.Key); 48 | if(idx >= 0) { 49 | mesh.GetBlendShapeFrameVertices(idx, mesh.GetBlendShapeFrameCount(idx)-1, srcDV, null, null); 50 | for(int v=0; v shapes; 13 | public readonly (Vector3 t, Quaternion q, float s)[] motions; 14 | private readonly Vector3Int tileCount; 15 | public MotionDecoder(Skeleton skeleton, Morph morph, MotionLayout layout, int width=80, int height=45, 16 | int tileWidth=2, int tileHeight=1, int tileDepth=3, int tileRadix=3) { 17 | this.skeleton = skeleton; 18 | this.morph = morph; 19 | this.layout = layout; 20 | this.shapes = new Dictionary(); 21 | this.motions = new (Vector3,Quaternion,float)[skeleton.bones.Length]; 22 | 23 | tileCount = new Vector3Int(width/tileWidth, height/tileHeight, 24 | (int)System.Math.Pow(tileRadix, tileWidth*tileHeight*tileDepth)); 25 | } 26 | 27 | const float PositionScale = 2; 28 | const int layerSize = 3; 29 | private NativeArray tex = new NativeArray(); 30 | private Vector3Int texSize; 31 | private int layer; 32 | private float SampleTile(int idx) { 33 | int x = idx / tileCount.y; 34 | int y = idx % tileCount.y; 35 | x += layer/2 * layerSize; 36 | if((layer & 1) != 0) 37 | x = tileCount.x-1-x; 38 | 39 | x *= texSize.x/tileCount.x; 40 | y *= texSize.y/tileCount.y; 41 | return tex[((texSize.y-1-y) * texSize.x + x) * texSize.z]; 42 | } 43 | public void Update(AsyncGPUReadbackRequest req, int layer=0) { 44 | this.tex = req.GetData(); 45 | this.texSize = new Vector3Int(req.width, req.height, req.layerDataSize/(req.width*req.height*4)); 46 | this.layer = layer; 47 | 48 | var vec = new Vector3[5]; 49 | for(int b=0; b= 0) 53 | vec[axis/3][axis%3] = SampleTile(layout.bones[b][axis]); 54 | 55 | if(layout.bones[b].Length <= 3) { 56 | var swingTwist = vec[0] * 180; 57 | motions[b] = (swingTwist, HumanAxes.SwingTwist(Vector3.Scale(skeleton.axes[b].sign, swingTwist)), float.NaN); 58 | } else { 59 | for(int j=0; j<3; j++) 60 | vec[2][j] = ShaderImpl.DecodeVideoFloat(vec[1][j], vec[2][j], tileCount.z); 61 | var (rotY, rotZ) = ShaderImpl.orthogonalize(vec[3], vec[4]); 62 | if(!(rotZ.magnitude > 0)) 63 | (rotY, rotZ) = (Vector3.up, Vector3.forward); 64 | motions[b] = (vec[2] * PositionScale, 65 | Quaternion.LookRotation(rotZ, rotY), rotY.magnitude / rotZ.magnitude); 66 | } 67 | } 68 | 69 | shapes.Clear(); 70 | for(int b=0; b= 0 && blend != null) 74 | blend.Sample(new Vector2(SampleTile(slot), SampleTile(slot+1)), shapes, writeDefault:true); 75 | } 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /Script/Common/MotionDecoder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6719513642788244ea3ac9579cfb0720 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Script/Common/MotionLayout.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using UnityEngine; 4 | using System.Text.RegularExpressions; 5 | 6 | namespace ShaderMotion { 7 | public class MotionLayout { 8 | public readonly int[][] bones; 9 | public readonly int[] blends; 10 | public MotionLayout(Skeleton skeleton, Morph morph, (int,int,int)[] boneLayout=null, (int,int,int)[] blendLayout=null) { 11 | bones = new int[skeleton.bones.Length][]; 12 | int index = -1; 13 | foreach(var (start, length, bone) in boneLayout??defaultHumanLayout) { 14 | index = start >= 0 ? start : index; 15 | var endIndex = index + length; 16 | if(length <= 3) { 17 | bones[bone] = Enumerable.Repeat(-1, 3).ToArray(); 18 | for(int i=0; i<3; i++) 19 | if(length == 3 || HumanTrait.MuscleFromBone(bone, i) >= 0) 20 | bones[bone][i] = index++; 21 | } else if(length == 12) { 22 | bones[bone] = Enumerable.Repeat(-1, 3).Concat(Enumerable.Range(index, 12)).ToArray(); 23 | index += 12; 24 | } 25 | Debug.Assert(index == endIndex); 26 | } 27 | blends = Enumerable.Repeat(-1, morph.blends.Length).ToArray(); 28 | index = -1; 29 | foreach(var (start, length, blend) in blendLayout??defaultBlendLayout) { 30 | index = start >= 0 ? start : index; 31 | blends[blend] = index; 32 | index += length; 33 | } 34 | } 35 | 36 | public static (int, int, int)[] defaultBlendLayout = new []{ 37 | ( 80, 2, (int)BlendSpacePreset.LipSync), 38 | ( 82, 2, (int)BlendSpacePreset.Blink), 39 | ( 88, 2, (int)BlendSpacePreset.Emotion), 40 | }; 41 | public static (int, int, int)[] defaultHumanLayout = new []{ 42 | // roughly ordered by HumanTrait.GetBoneDefaultHierarchyMass 43 | ( 0,12, (int)HumanBodyBones.Hips), 44 | ( -1, 3, (int)HumanBodyBones.Spine), 45 | ( -1, 3, (int)HumanBodyBones.Chest), 46 | ( -1, 3, (int)HumanBodyBones.UpperChest), 47 | ( -1, 3, (int)HumanBodyBones.Neck), 48 | ( -1, 3, (int)HumanBodyBones.Head), 49 | ( 27, 3, (int)HumanBodyBones.LeftUpperLeg), 50 | ( -1, 3, (int)HumanBodyBones.RightUpperLeg), 51 | ( -1, 3, (int)HumanBodyBones.LeftLowerLeg), 52 | ( -1, 3, (int)HumanBodyBones.RightLowerLeg), 53 | ( -1, 3, (int)HumanBodyBones.LeftFoot), 54 | ( -1, 3, (int)HumanBodyBones.RightFoot), 55 | 56 | ( 45, 3, (int)HumanBodyBones.LeftShoulder), 57 | ( -1, 3, (int)HumanBodyBones.RightShoulder), 58 | ( -1, 3, (int)HumanBodyBones.LeftUpperArm), 59 | ( -1, 3, (int)HumanBodyBones.RightUpperArm), 60 | ( -1, 3, (int)HumanBodyBones.LeftLowerArm), 61 | ( -1, 3, (int)HumanBodyBones.RightLowerArm), 62 | ( -1, 3, (int)HumanBodyBones.LeftHand), 63 | ( -1, 3, (int)HumanBodyBones.RightHand), 64 | ( 69, 1, (int)HumanBodyBones.LeftToes), // toe > eye in mass 65 | ( -1, 1, (int)HumanBodyBones.RightToes), 66 | ( -1, 2, (int)HumanBodyBones.LeftEye), // TODO: merge with lookat 67 | ( -1, 2, (int)HumanBodyBones.RightEye), 68 | // ( -1, 2, (int)HumanBodyBones.Jaw), // TODO: deprecated. merge with lipsync 69 | // 77~89: reserved (morph) 70 | 71 | ( 90, 2, (int)HumanBodyBones.LeftThumbProximal), 72 | ( -1, 1, (int)HumanBodyBones.LeftThumbIntermediate), 73 | ( -1, 1, (int)HumanBodyBones.LeftThumbDistal), 74 | ( -1, 2, (int)HumanBodyBones.LeftIndexProximal), 75 | ( -1, 1, (int)HumanBodyBones.LeftIndexIntermediate), 76 | ( -1, 1, (int)HumanBodyBones.LeftIndexDistal), 77 | ( -1, 2, (int)HumanBodyBones.LeftMiddleProximal), 78 | ( -1, 1, (int)HumanBodyBones.LeftMiddleIntermediate), 79 | ( -1, 1, (int)HumanBodyBones.LeftMiddleDistal), 80 | ( -1, 2, (int)HumanBodyBones.LeftRingProximal), 81 | ( -1, 1, (int)HumanBodyBones.LeftRingIntermediate), 82 | ( -1, 1, (int)HumanBodyBones.LeftRingDistal), 83 | ( -1, 2, (int)HumanBodyBones.LeftLittleProximal), 84 | ( -1, 1, (int)HumanBodyBones.LeftLittleIntermediate), 85 | ( -1, 1, (int)HumanBodyBones.LeftLittleDistal), 86 | (110, 2, (int)HumanBodyBones.RightThumbProximal), 87 | ( -1, 1, (int)HumanBodyBones.RightThumbIntermediate), 88 | ( -1, 1, (int)HumanBodyBones.RightThumbDistal), 89 | ( -1, 2, (int)HumanBodyBones.RightIndexProximal), 90 | ( -1, 1, (int)HumanBodyBones.RightIndexIntermediate), 91 | ( -1, 1, (int)HumanBodyBones.RightIndexDistal), 92 | ( -1, 2, (int)HumanBodyBones.RightMiddleProximal), 93 | ( -1, 1, (int)HumanBodyBones.RightMiddleIntermediate), 94 | ( -1, 1, (int)HumanBodyBones.RightMiddleDistal), 95 | ( -1, 2, (int)HumanBodyBones.RightRingProximal), 96 | ( -1, 1, (int)HumanBodyBones.RightRingIntermediate), 97 | ( -1, 1, (int)HumanBodyBones.RightRingDistal), 98 | ( -1, 2, (int)HumanBodyBones.RightLittleProximal), 99 | ( -1, 1, (int)HumanBodyBones.RightLittleIntermediate), 100 | ( -1, 1, (int)HumanBodyBones.RightLittleDistal), 101 | // 130~144: reserved 102 | }; 103 | } 104 | } -------------------------------------------------------------------------------- /Script/Common/MotionLayout.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0afd143e78520194ca7d8daf15a74757 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Script/Common/ShaderImpl.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using UnityEngine; 4 | 5 | namespace ShaderMotion { 6 | public class ShaderImpl { 7 | public static float DecodeVideoFloat(float hi, float lo, int pow) { 8 | hi = hi * ((pow-1)/2) + (pow-1)/2; 9 | lo = lo * ((pow-1)/2) + (pow-1)/2; 10 | var x = Mathf.RoundToInt(lo); 11 | var y = Mathf.Min(lo-x, 0); 12 | var z = Mathf.Max(lo-x, 0); 13 | var r = Mathf.RoundToInt(hi); 14 | if((r & 1) != 0) 15 | (x, y, z) = (pow-1-x, -z, -y); 16 | if(x == 0) 17 | y += Mathf.Min(0, hi-r); 18 | if(x == pow-1) 19 | z += Mathf.Max(0, hi-r); 20 | x += r*pow; 21 | x -= (pow*pow-1)/2; 22 | y += 0.5f; 23 | z -= 0.5f; 24 | return ((y + z) / Mathf.Max(Mathf.Abs(y), Mathf.Abs(z)) * 0.5f + x) / ((pow-1)/2); 25 | } 26 | public static (Vector3, Vector3) orthogonalize(Vector3 u, Vector3 v) { 27 | var B = Vector3.Dot(u,v) * -2; 28 | var A = Vector3.Dot(u,u) + Vector3.Dot(v,v); 29 | A += Mathf.Sqrt(Mathf.Abs(A*A - B*B)); 30 | var U = A*u+B*v; U *= Vector3.Dot(u,U)/Vector3.Dot(U,U); 31 | var V = A*v+B*u; V *= Vector3.Dot(v,V)/Vector3.Dot(V,V); 32 | return (U, V); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /Script/Common/ShaderImpl.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 253dde0dc450152409fb3d19b3c2d498 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Script/Common/Skeleton.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using Array = System.Array; 4 | using UnityEngine; 5 | #if UNITY_EDITOR 6 | using UnityEditor; 7 | #endif 8 | 9 | namespace ShaderMotion { 10 | public class Skeleton { 11 | public readonly Transform[] bones; 12 | public readonly HumanAxes[] axes; 13 | public readonly bool[] dummy; 14 | public readonly int[] parents; 15 | public readonly Transform root; 16 | public readonly float humanScale; 17 | public Skeleton(Animator animator, Transform[] genericBones=null) { 18 | humanScale = GetSkeletonPoseHipsHeight(animator); // animator.humanScale causes floating feet 19 | root = animator.transform; 20 | bones = Enumerable.Range(0, HumanTrait.BoneCount) 21 | .Select(i => animator.GetBoneTransform((HumanBodyBones)i)) 22 | .Concat(genericBones ?? Enumerable.Empty()).ToArray(); 23 | axes = Enumerable.Range(0, HumanTrait.BoneCount) 24 | .Select(i => new HumanAxes(animator.avatar, (HumanBodyBones)i)) 25 | .Concat((genericBones ?? Enumerable.Empty()).Select(t => new HumanAxes(t))).ToArray(); 26 | // add dummy human bones so that animation on missing UpperChest is handled correctly 27 | dummy = new bool[bones.Length]; 28 | foreach(var (i, p) in dummyHumanBones) 29 | if(!bones[i] && bones[p]) 30 | (bones[i], axes[i], dummy[i]) = (bones[p], axes[p], true); 31 | // bone hierarchy 32 | parents = Enumerable.Repeat(-1, bones.Length).ToArray(); 33 | for(int i=0; i= 0 && bones[b] ? b : -1; 37 | } 38 | for(int i=HumanTrait.BoneCount; i(); 30 | if(!shapeRenderer) 31 | shapeRenderer = (animator?.GetComponentsInChildren() ?? new SkinnedMeshRenderer[0]) 32 | .Where(smr => (smr.sharedMesh?.blendShapeCount??0) > 0).FirstOrDefault(); 33 | 34 | skeleton = new Skeleton(animator); 35 | var morph = new Morph(animator); 36 | var layout = new MotionLayout(skeleton, morph); 37 | decoder = new MotionDecoder(skeleton, morph, layout, resolution.x, resolution.y, 38 | tileWidth:tileSize.x, tileHeight:tileSize.y, tileDepth:tileSize.z, tileRadix:tileRadix); 39 | } 40 | void OnDisable() { 41 | skeleton = null; 42 | decoder = null; 43 | } 44 | void Update() { 45 | var request = gpuReader.Request(motionBuffer); 46 | if(request != null && !request.Value.hasError) { 47 | decoder.Update(request.Value, layer); 48 | if(applyHumanPose) 49 | ApplyHumanPose(); 50 | else 51 | ApplyTransform(); 52 | ApplyBlendShape(); 53 | } 54 | } 55 | 56 | const float shapeWeightEps = 0.1f; 57 | private HumanPoseHandler poseHandler; 58 | private HumanPose humanPose; 59 | private Vector3[] swingTwists; 60 | void ApplyScale() { 61 | if(humanScale != 0) 62 | skeleton.root.localScale = (humanScale > 0 ? humanScale : decoder.motions[0].s) 63 | / skeleton.humanScale * Vector3.one; 64 | } 65 | void ApplyHumanPose() { 66 | if(poseHandler == null) { 67 | poseHandler = new HumanPoseHandler(skeleton.root.GetComponent().avatar, skeleton.root); 68 | poseHandler.GetHumanPose(ref humanPose); 69 | } 70 | ApplyScale(); 71 | var motions = decoder.motions; 72 | System.Array.Resize(ref swingTwists, HumanTrait.BoneCount); 73 | for(int i=0; i= 0) 99 | shapeRenderer.SetBlendShapeWeight(idx, 100 | Mathf.Round(Mathf.Clamp01(kv.Value)*100/shapeWeightEps)*shapeWeightEps); 101 | } 102 | } 103 | } 104 | } 105 | } -------------------------------------------------------------------------------- /Script/Runtime/MotionPlayer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e3cc98c69b3122d44a52ee67c404945a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Script/ShaderMotion.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ShaderMotion" 3 | } 4 | -------------------------------------------------------------------------------- /Script/ShaderMotion.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d5ac491a3b989a645a5a9e4b7aa1881c 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b3d9aa876e1e09940aa2181bc85bffc6 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Shader/Codec.hlsl: -------------------------------------------------------------------------------- 1 | //// sRGB linear color <-> sRGB gamma color //// 2 | half3 LinearToGamma(half3 color) { 3 | return color <= 0.0031308 ? 12.92 * color : 1.055 * pow(color, 1/2.4) - 0.055; 4 | } 5 | half3 GammaToLinear(half3 color) { 6 | return color <= 0.04045 ? color / 12.92 : pow(color/1.055 + 0.055/1.055, 2.4); 7 | } 8 | #if defined(UNITY_COLORSPACE_GAMMA) 9 | #define LinearToGamma(x) (x) 10 | #define GammaToLinear(x) (x) 11 | #endif 12 | //// real number <-> render texture color //// 13 | half4 EncodeBufferSnorm(float x) { 14 | float4 scale = 0.25 * (1 << uint4(0, 8, 16, 24)); 15 | float4 v = frac(x * scale + scale); 16 | v.xyz -= v.yzw / (1 << 8); 17 | return v / (255.0/256); 18 | } 19 | float DecodeBufferSnorm(half4 v) { 20 | float4 scale = (255.0/256) / (1 << uint4(0, 8, 16, 24)) * 4; 21 | return dot(v, scale) - 1; 22 | } 23 | #if !defined(SHADER_API_WEBGL) // only webgl doesn't support R32F buffer 24 | #define EncodeBufferSnorm(x) ((x).rrrr) 25 | #define DecodeBufferSnorm(x) ((x).r) 26 | #endif 27 | //// real number <-> Gray curve coordinates //// 28 | uint2 gray_decoder_pop(inout uint2 state, uint radix) { 29 | uint2 d = state % radix; 30 | state /= radix; 31 | return (state & 1) ? radix-1-d : d; 32 | } 33 | void gray_encoder_add(inout float3 state, float x, uint radix, bool cont=true) { 34 | x = (int(state.x) & 1) ? radix-1-x : x; 35 | state.x = state.x*radix + round(x); 36 | state.yz = cont && round(x) == float2(0, radix-1) ? state.yz : x-round(x); 37 | } 38 | float gray_encoder_sum(float3 state) { 39 | float2 p = max(0, state.zy * float2(+2, -2)); 40 | return (min(p.x,p.y)/max(max(p.x,p.y)-p.x*p.y,1e-5)*(p.x-p.y)+(p.x-p.y)) * 0.5 + state.x; 41 | } 42 | //// real number <-> video color tile //// 43 | static const uint ColorTileRadix = 3; 44 | static const uint ColorTileLen = 2; 45 | typedef half3 ColorTile[ColorTileLen]; 46 | 47 | static const uint tilePow = pow(ColorTileRadix, ColorTileLen*3); 48 | void EncodeVideoSnorm(out ColorTile c, float x, bool hi=false) { 49 | x = clamp((tilePow-1)/2 * x, (tilePow*tilePow-1)/2 * -1.0, (tilePow*tilePow-1)/2); 50 | float2 wt = float2(1-frac(x), frac(x))/(ColorTileRadix-1); 51 | uint2 state = (int)floor(x) + int((tilePow*tilePow-1)/2) + int2(0, 1); 52 | {UNITY_UNROLL for(int i=int(ColorTileLen-1); i>=0; i--) { 53 | c[i].b = dot(gray_decoder_pop(state, ColorTileRadix), wt); 54 | c[i].r = dot(gray_decoder_pop(state, ColorTileRadix), wt); 55 | c[i].g = dot(gray_decoder_pop(state, ColorTileRadix), wt); 56 | }} 57 | if(hi) 58 | {UNITY_UNROLL for(int i=int(ColorTileLen-1); i>=0; i--) { 59 | c[i].b = dot(gray_decoder_pop(state, ColorTileRadix), wt); 60 | c[i].r = dot(gray_decoder_pop(state, ColorTileRadix), wt); 61 | c[i].g = dot(gray_decoder_pop(state, ColorTileRadix), wt); 62 | }} 63 | } 64 | float DecodeVideoSnorm(ColorTile c) { 65 | float3 state = 0; 66 | {UNITY_UNROLL for(int i=0; i 26 | #include "MeshPlayer.hlsl" 27 | 28 | float _AutoHide; 29 | UNITY_INSTANCING_BUFFER_START(Props) 30 | UNITY_DEFINE_INSTANCED_PROP(float, _Layer) 31 | UNITY_INSTANCING_BUFFER_END(Props) 32 | 33 | struct GeomInput { 34 | float3 vertex : TEXCOORD0; 35 | float3 normal : TEXCOORD1; 36 | float4 tangent : TEXCOORD2; 37 | float4 texcoord : TEXCOORD3; 38 | float4 boneWeights : TEXCOORD4; 39 | UNITY_VERTEX_INPUT_INSTANCE_ID 40 | }; 41 | struct FragInput { 42 | float2 uv : TEXCOORD0; 43 | float4 pos : SV_Position; 44 | nointerpolation float4x4 mat0 : TEXCOORD1; 45 | UNITY_VERTEX_OUTPUT_STEREO 46 | }; 47 | 48 | void vert(VertInputSkin i, out GeomInput o) { 49 | UNITY_SETUP_INSTANCE_ID(i); 50 | MorphAndSkinVertex(i, UNITY_ACCESS_INSTANCED_PROP(Props, _Layer)); 51 | o = i; 52 | } 53 | float4x4 getMatrix(GeomInput i) { 54 | float4x4 m; 55 | m.c0 = cross(normalize(i.normal), i.tangent.xyz); 56 | m.c1 = i.normal; 57 | m.c2 = i.tangent.xyz; 58 | m.c3 = i.vertex; 59 | m._41_42_43_44 = float4(0,0,0,1); 60 | return m; 61 | } 62 | float4 getDataRect(GeomInput i) { 63 | float idx = i.texcoord.x; 64 | float layer = UNITY_ACCESS_INSTANCED_PROP(Props, _Layer); 65 | float4 rect = float4(idx,layer*4+0, idx+1,layer*4+4); 66 | rect /= abs(_ScreenParams.xyxy); 67 | rect = rect*2-1; 68 | rect.yw *= _ProjectionParams.x; 69 | #if defined(USING_STEREO_MATRICES) 70 | return 0; // hide in VR 71 | #endif 72 | if(any(UNITY_MATRIX_P[2].xy)) 73 | return 0; // hide in mirror (near plane normal != Z axis) 74 | if(_AutoHide && _ProjectionParams.z != 0) 75 | return 0; 76 | return rect; 77 | } 78 | [maxvertexcount(4)] 79 | void geom(point GeomInput i[1], inout TriangleStream stream) { 80 | FragInput o; 81 | UNITY_SETUP_INSTANCE_ID(i[0]); 82 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); 83 | 84 | float4 rect = getDataRect(i[0]); 85 | float4 uv = float4(0,0,1,1); 86 | o.mat0 = getMatrix(i[0]); 87 | o.pos = float4(0, 0, UNITY_NEAR_CLIP_VALUE, 1); 88 | o.uv = uv.xy, o.pos.xy = rect.xy, stream.Append(o); 89 | o.uv = uv.xw, o.pos.xy = rect.xw, stream.Append(o); 90 | o.uv = uv.zy, o.pos.xy = rect.zy, stream.Append(o); 91 | o.uv = uv.zw, o.pos.xy = rect.zw, stream.Append(o); 92 | } 93 | half4 frag(FragInput i) : SV_Target { 94 | switch(floor(i.uv.y*4)) { 95 | case 0: return transpose(i.mat0)[0]; 96 | case 1: return transpose(i.mat0)[1]; 97 | case 2: return transpose(i.mat0)[2]; 98 | case 3: return transpose(i.mat0)[3]; 99 | default: return 0; 100 | } 101 | } 102 | ENDCG 103 | } 104 | } 105 | } -------------------------------------------------------------------------------- /Shader/DataPlayer.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4a0493aef72f2774184a5696b941e9a6 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Shader/MeshPlayer.hlsl: -------------------------------------------------------------------------------- 1 | #include "Rotation.hlsl" 2 | #include "Codec.hlsl" 3 | #include "VideoLayout.hlsl" 4 | #include "Skinning.hlsl" 5 | 6 | float _HumanScale; 7 | float _RotationTolerance; 8 | static const float _PositionScale = 2; 9 | 10 | sampler2D_float _MotionDec; 11 | static float4 _MotionDec_ST; 12 | float3 sampleSnorm3(uint idx) { 13 | // NOTE: the tile for an unused component may lie in a different line! 14 | float3 u = GetTileX(idx+uint4(0,1,2,3)) * _MotionDec_ST.x + _MotionDec_ST.z; 15 | float3 v = GetTileY(idx+uint4(0,1,2,3)) * _MotionDec_ST.y + _MotionDec_ST.w; 16 | return float3( DecodeBufferSnorm(tex2Dlod(_MotionDec, float4(u[0], v[0], 0, 0))), 17 | DecodeBufferSnorm(tex2Dlod(_MotionDec, float4(u[1], v[1], 0, 0))), 18 | DecodeBufferSnorm(tex2Dlod(_MotionDec, float4(u[2], v[2], 0, 0)))); 19 | } 20 | static const float4x4 Identity = {{1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}}; 21 | float3 mergeSnorm3(float3 f0, float3 f1) { 22 | float3 o = 0; 23 | UNITY_LOOP // fewer instructions 24 | for(uint K=0; K<3; K++) 25 | o += DecodeVideoFloat(f0[K], f1[K]) * Identity[K]; 26 | return o; 27 | } 28 | void TransformBone(float4 data, inout float3x3 mat) { 29 | // data == {sign, idx} 30 | mat = mul(swingTwistRotate(UNITY_PI * data.xyz * sampleSnorm3(uint(data.w))), mat); 31 | } 32 | void TransformRoot(float4 data, inout float3x3 mat) { 33 | uint idx = -1-data.w; 34 | float scale = data.z; 35 | 36 | float3 motion[4]; 37 | UNITY_LOOP 38 | for(uint I=0; I<4; I++) 39 | motion[I] = sampleSnorm3(idx+3*I); 40 | motion[1] = mergeSnorm3(motion[0],motion[1]); 41 | 42 | float3 pos = motion[1] * _PositionScale; 43 | float3x3 rot; 44 | float orthoErrSq = orthogonalize(motion[2], motion[3], rot.c1, rot.c2); 45 | float scaleErrSq = pow(sqrt(max(dot(rot.c1,rot.c1), dot(rot.c2,rot.c2)))-1, 2); 46 | if(orthoErrSq + scaleErrSq > _RotationTolerance * _RotationTolerance) 47 | mat.c0 = sqrt(-unity_ObjectToWorld._44); //NaN 48 | 49 | rot.c1 *= rsqrt(dot(rot.c2,rot.c2)); 50 | if(_HumanScale >= 0) { 51 | float humanScale = _HumanScale ? _HumanScale : rcp(scale); 52 | pos *= rsqrt(dot(rot.c1,rot.c1)) * humanScale; 53 | rot.c1 *= rsqrt(dot(rot.c1,rot.c1)) * humanScale; 54 | } 55 | rot.c1 *= scale; 56 | rot.c0 = cross(rot.c1, normalize(rot.c2)); 57 | rot.c2 = normalize(rot.c2) * length(rot.c1); 58 | 59 | mat = mul(rot, mat); 60 | mat.c0 += pos; 61 | } 62 | float2 GetBlendCoord(float4 data) { 63 | return sampleSnorm3(uint(data.w)).xy; 64 | } 65 | 66 | Texture2D_float _Bone; 67 | Texture2D_float _Shape; 68 | void MorphAndSkinVertex(inout VertInputSkin i, uint layer) { 69 | _MotionDec_ST = float4(1, 1, layer/2 * layerRect.z, 0); 70 | if(layer & 1) 71 | _MotionDec_ST.xz = float2(0, 1) - _MotionDec_ST.xz; 72 | MorphVertex(i, _Shape); 73 | SkinVertex(i, _Bone); 74 | } -------------------------------------------------------------------------------- /Shader/MeshPlayer.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 97df0da334300354084cf4636081639d 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Shader/MeshPlayer.shader: -------------------------------------------------------------------------------- 1 | Shader "Motion/MeshPlayer" { 2 | Properties { 3 | [Header(Texture)] 4 | [NoScaleOffset] 5 | _MainTex ("MainTex", 2D) = "white" {} 6 | _Color ("Color", Color) = (1,1,1,1) 7 | 8 | [Header(Culling)] 9 | [Enum(UnityEngine.Rendering.CullMode)] _Cull("Face Culling", Float) = 2 10 | [Toggle(_ALPHATEST_ON)] _AlphaTest("Alpha Test", Float) = 0 11 | _Cutoff ("Alpha Cutoff", Range(0, 1)) = 0 12 | 13 | [Header(Motion)] 14 | [NoScaleOffset] _MotionDec ("MotionDec (decoded motion texture)", 2D) = "black" {} 15 | [HideInInspector] _Bone ("Bone", 2D) = "black" {} 16 | [HideInInspector] _Shape ("Shape", 2D) = "black" {} 17 | _HumanScale ("HumanScale (hips height: 0=original, -1=encoded)", Float) = -1 18 | _Layer ("Layer (location of motion stripe)", Float) = 0 19 | _RotationTolerance ("RotationTolerance", Range(0, 1)) = 0.1 20 | } 21 | SubShader { 22 | Tags { "Queue"="Geometry" "RenderType"="Opaque" } 23 | Pass { 24 | Tags { "LightMode"="ForwardBase" } 25 | Cull [_Cull] 26 | CGPROGRAM 27 | #pragma target 3.5 28 | #pragma vertex vert 29 | #pragma fragment frag 30 | #pragma shader_feature _ _ALPHATEST_ON SHADER_API_WEBGL 31 | #pragma multi_compile_instancing 32 | 33 | #include 34 | #include "MeshPlayer.hlsl" 35 | 36 | UNITY_INSTANCING_BUFFER_START(Props) 37 | UNITY_DEFINE_INSTANCED_PROP(float, _Layer) 38 | UNITY_INSTANCING_BUFFER_END(Props) 39 | 40 | struct FragInput { 41 | half2 tex : TEXCOORD0; 42 | float3 vertex : TEXCOORD1; 43 | half3 normal : TEXCOORD2; 44 | float4 pos : SV_Position; 45 | UNITY_VERTEX_OUTPUT_STEREO 46 | }; 47 | 48 | void vert(VertInputSkin i, out FragInput o) { 49 | UNITY_SETUP_INSTANCE_ID(i); 50 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); 51 | MorphAndSkinVertex(i, UNITY_ACCESS_INSTANCED_PROP(Props, _Layer)); 52 | 53 | o.vertex = mul(unity_ObjectToWorld, float4(i.vertex, 1)); 54 | o.normal = mul(unity_ObjectToWorld, float4(i.normal, 0)); 55 | o.pos = UnityWorldToClipPos(o.vertex); 56 | o.tex = i.texcoord; 57 | } 58 | 59 | //////// 60 | // the following is a basic lit shader 61 | // you should customize it to your needs 62 | 63 | #include 64 | 65 | sampler2D _MainTex; 66 | half4 _Color; 67 | half _Cutoff; 68 | 69 | half4 frag(FragInput i) : SV_Target { 70 | half4 color = tex2D(_MainTex, i.tex); 71 | #if defined(_ALPHATEST_ON) || defined(SHADER_API_WEBGL) 72 | if(color.a < _Cutoff) 73 | discard; 74 | #endif 75 | color *= _Color; 76 | 77 | half3 normal = normalize(i.normal); 78 | half ndl = dot(normal, float3(0,1,0)); 79 | // shadow by saturation 80 | half3 shadow = lerp(color.rgb*0.8, 1, saturate(ndl+1)); 81 | #if defined(SHADER_API_WEBGL) 82 | color.rgb *= shadow; 83 | color.rgb = LinearToGamma(color.rgb); 84 | return color; 85 | #endif 86 | 87 | half3 light = _LightColor0.rgb + ShadeSH9(float4(0,1,0,1)); 88 | light /= max(max(light.x, light.y), max(light.z, 1)); 89 | // rim lighting 90 | half ndv = dot(normal, normalize(_WorldSpaceCameraPos - i.vertex)); 91 | half rim = pow(1-abs(ndv), exp2(lerp(3,0,0.1))); 92 | rim = saturate(rim/0.074) * 0.2; 93 | color.rgb *= (rim*color.rgb+1) * shadow * light; 94 | return color; 95 | } 96 | ENDCG 97 | } 98 | } 99 | } -------------------------------------------------------------------------------- /Shader/MeshPlayer.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dd06eb73e4fc7a84fbb5fecce12d7d07 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Shader/MeshRecorder.hlsl: -------------------------------------------------------------------------------- 1 | #include "Rotation.hlsl" 2 | #include "Codec.hlsl" 3 | #include "VideoLayout.hlsl" 4 | 5 | float _AutoHide; 6 | float _Layer; 7 | static const float _PositionScale = 2; 8 | 9 | struct VertInputTile { 10 | uint axis; 11 | float sign, slot; 12 | float4x4 mat0, mat1; 13 | }; 14 | struct FragInputTile { 15 | nointerpolation ColorTile color : COLOR; 16 | float2 uv : TEXCOORD0; 17 | float4 pos : SV_Position; 18 | UNITY_VERTEX_OUTPUT_STEREO 19 | }; 20 | float4 EncodeTransform(VertInputTile i, inout FragInputTile o) { 21 | // pos, rot, scale 22 | float3 rotY = i.mat1.c1; 23 | float3 rotZ = i.mat1.c2; 24 | float3 pos = i.mat1.c3 - i.mat0.c3; 25 | pos = mul(transpose(i.mat0), pos) / dot(i.mat0.c1, i.mat0.c1); 26 | rotY = mul(transpose(i.mat0), rotY) / dot(i.mat0.c1, i.mat0.c1); 27 | rotZ = mul(transpose(i.mat0), rotZ) / dot(i.mat0.c1, i.mat0.c1); 28 | float scale = length(rotY); 29 | rotY = normalize(rotY); 30 | rotZ = normalize(rotZ); 31 | 32 | // data 33 | float data; 34 | if(i.axis < 3) { 35 | float3x3 rot; 36 | rot.c1 = rotY; 37 | rot.c2 = rotZ; 38 | rot.c0 = cross(rot.c1, rot.c2); 39 | data = swingTwistAngles(rot)[i.axis] / UNITY_PI / i.sign; 40 | } 41 | else if(i.axis < 9) 42 | data = pos[i.axis-(i.axis < 6 ? 3 : 6)] / _PositionScale; 43 | else if(i.axis < 12) 44 | data = rotY[i.axis-9 ] * min(1, scale); 45 | else 46 | data = rotZ[i.axis-12] * min(1, rcp(scale)); 47 | 48 | // color, rect 49 | float4 rect = GetTileRect(uint(i.slot)); 50 | if(i.slot < 0) // background 51 | rect = layerRect, data = 0; 52 | EncodeVideoSnorm(o.color, data, i.axis >= 3 && i.axis < 6); 53 | 54 | // pos 55 | uint layer = _Layer; 56 | rect.xz += layer/2 * layerRect.z; 57 | if(layer & 1) 58 | rect.xz = 1-rect.xz; 59 | 60 | float2 screenSize = _ScreenParams.xy/2; 61 | rect = round(rect * screenSize.xyxy) / screenSize.xyxy; 62 | rect = rect*2-1; 63 | #if !defined(_REQUIRE_UV2) 64 | rect.yw *= _ProjectionParams.x; 65 | #elif UNITY_UV_STARTS_AT_TOP 66 | rect.yw *= -1; 67 | #endif 68 | 69 | o.pos = float4(0, 0, UNITY_NEAR_CLIP_VALUE, 1); 70 | #if !defined(_REQUIRE_UV2) 71 | #if defined(USING_STEREO_MATRICES) 72 | return 0; // hide in VR 73 | #endif 74 | if(any(UNITY_MATRIX_P[2].xy)) 75 | return 0; // hide in mirror (near plane normal != Z axis) 76 | if(_AutoHide && _ProjectionParams.z != 0) 77 | return 0; 78 | #endif 79 | return rect; 80 | } 81 | float4 fragTile(FragInputTile i) : SV_Target { 82 | return RenderTile(i.color, i.uv); 83 | } -------------------------------------------------------------------------------- /Shader/MeshRecorder.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 65b8e4508685f4743abc9062d272dbb2 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Shader/MeshRecorder.shader: -------------------------------------------------------------------------------- 1 | Shader "Motion/MeshRecorder" { 2 | Properties { 3 | [Header(Motion)] 4 | [ToggleUI] _AutoHide ("AutoHide (only visible in camera with farClip=0)", Float) = 1 5 | _Layer ("Layer (location of motion stripe)", Float) = 0 6 | } 7 | SubShader { 8 | Tags { "Queue"="Overlay" "RenderType"="Overlay" "PreviewType"="Plane" } 9 | Pass { 10 | Tags { "LightMode"="ForwardBase" } 11 | Cull Off 12 | ZTest Always ZWrite Off 13 | CGPROGRAM 14 | #pragma target 4.0 15 | #pragma vertex vert 16 | #pragma fragment fragTile 17 | #pragma geometry geom 18 | #pragma shader_feature _REQUIRE_UV2 // used for grabpass output 19 | 20 | #include 21 | #include "MeshRecorder.hlsl" 22 | 23 | struct VertInput { 24 | float3 vertex : POSITION; 25 | float3 normal : NORMAL; 26 | float4 tangent : TANGENT; 27 | float2 uv : TEXCOORD0; 28 | UNITY_VERTEX_INPUT_INSTANCE_ID 29 | }; 30 | struct GeomInput { 31 | float3 vertex : TEXCOORD0; 32 | float3 normal : TEXCOORD1; 33 | float4 tangent : TEXCOORD2; 34 | float2 uv : TEXCOORD3; 35 | UNITY_VERTEX_INPUT_INSTANCE_ID 36 | }; 37 | float4x4 getMatrix(GeomInput i) { 38 | float4x4 m; 39 | m.c0 = cross(normalize(i.normal), i.tangent.xyz); 40 | m.c1 = i.normal; 41 | m.c2 = i.tangent.xyz; 42 | m.c3 = i.vertex; 43 | m._41_42_43_44 = float4(0,0,0,1); 44 | return m; 45 | } 46 | void vert(VertInput i, out GeomInput o) { 47 | o = i; 48 | } 49 | [maxvertexcount(4)] 50 | void geom(line GeomInput i[2], inout TriangleStream stream) { 51 | FragInputTile o; 52 | UNITY_SETUP_INSTANCE_ID(i[0]); 53 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); 54 | 55 | VertInputTile I; 56 | I.slot = i[0].uv.x; 57 | I.axis = i[1].uv.x; 58 | I.sign = i[1].uv.y; 59 | I.mat0 = getMatrix(i[0]); 60 | I.mat1 = getMatrix(i[1]); 61 | if(I.sign == 0) 62 | I.mat0 = float4x4(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1); 63 | 64 | o.uv = 0; 65 | float4 rect = EncodeTransform(I, o); 66 | float4 uv = float4(0,0,1,1); 67 | o.uv = uv.xy, o.pos.xy = rect.xy, stream.Append(o); 68 | o.uv = uv.xw, o.pos.xy = rect.xw, stream.Append(o); 69 | o.uv = uv.zy, o.pos.xy = rect.zy, stream.Append(o); 70 | o.uv = uv.zw, o.pos.xy = rect.zw, stream.Append(o); 71 | } 72 | ENDCG 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /Shader/MeshRecorder.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9687b2da23383b847b1f5a464badac15 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Shader/MeshRecorderInst.shader: -------------------------------------------------------------------------------- 1 | Shader "Motion/MeshRecorderInst" { 2 | Properties { 3 | [Header(Motion)] 4 | [ToggleUI] _AutoHide ("AutoHide (only visible in camera with farClip=0)", Float) = 1 5 | _Layer ("Layer (location of motion stripe)", Float) = 0 6 | _MainTex ("MainTex", 2D) = "black" {} 7 | } 8 | SubShader { 9 | Tags { "Queue"="Overlay" "RenderType"="Overlay" "PreviewType"="Plane" } 10 | Pass { 11 | Tags { "LightMode"="ForwardBase" } 12 | Cull Off 13 | ZTest Always ZWrite Off 14 | CGPROGRAM 15 | #pragma target 3.5 16 | #pragma vertex vert 17 | #pragma fragment fragTile 18 | #pragma multi_compile_instancing 19 | 20 | #include 21 | #include "MeshRecorder.hlsl" 22 | 23 | Texture2D_float _MainTex; 24 | 25 | struct VertInput { 26 | float3 vertex : POSITION; 27 | float3 uv : TEXCOORD0; 28 | UNITY_VERTEX_INPUT_INSTANCE_ID 29 | }; 30 | #if !defined(UNITY_INSTANCING_ENABLED) 31 | void vert() {} 32 | #else 33 | void vert(VertInput i, out FragInputTile o) { 34 | UNITY_SETUP_INSTANCE_ID(i); 35 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); 36 | 37 | float4 data[8]; 38 | UNITY_UNROLL for(uint J=0; J<8; J++) 39 | data[J] = _MainTex.Load(uint3(J, unity_InstanceID, 0)); 40 | float4x4 mat0 = transpose(float4x4(data[0], data[1], data[2], data[3])); 41 | float4x4 mat1 = transpose(float4x4(data[4], data[5], data[6], data[7])); 42 | 43 | VertInputTile I; 44 | bool valid = i.uv.z < mat0[3].z; 45 | I.slot = mat0[3].x + i.uv.z; 46 | I.axis = mat0[3].y + i.uv.z; 47 | I.sign = mat1[3].xyz[I.axis]; 48 | I.mat1 = mul(unity_ObjectToWorld, float4x4(mat1[0], mat1[1], mat1[2], float4(0,0,0,1))); 49 | unity_InstanceID = mat0[3].w; 50 | I.mat0 = mul(unity_ObjectToWorld, float4x4(mat0[0], mat0[1], mat0[2], float4(0,0,0,1))); 51 | 52 | o.uv = i.uv; 53 | float4 rect = EncodeTransform(I, o); 54 | o.pos.xy = valid ? lerp(rect.xy, rect.zw, o.uv) : 0; 55 | } 56 | #endif 57 | ENDCG 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /Shader/MeshRecorderInst.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e04e9c9726d8ff54ca748c8947267372 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Shader/Rotation.hlsl: -------------------------------------------------------------------------------- 1 | #define c0 _11_21_31 2 | #define c1 _12_22_32 3 | #define c2 _13_23_33 4 | #define c3 _14_24_34 5 | 6 | float3x3 axisAngleRotate(float3 axisAngle, float3x3 v, float eps=1e-5) { 7 | float angle = length(axisAngle), co = cos(angle), si = sin(angle); 8 | float3 si_axis = axisAngle * (angle > eps ? si/angle : 1); 9 | float3 rc_axis = axisAngle * (angle > eps ? sqrt(1-co)/angle : rsqrt(2)); 10 | v.c0 = co * v.c0 + (dot(rc_axis, v.c0) * rc_axis + cross(si_axis, v.c0)); // MAD optimization 11 | v.c1 = co * v.c1 + (dot(rc_axis, v.c1) * rc_axis + cross(si_axis, v.c1)); 12 | v.c2 = co * v.c2 + (dot(rc_axis, v.c2) * rc_axis + cross(si_axis, v.c2)); 13 | return v; 14 | } 15 | float3x3 swingTwistRotate(float3 angles) { 16 | float3x3 m = axisAngleRotate(float3(0, angles.yz), float3x3( 17 | 1, 0, 0, 18 | 0, cos(angles.x), -sin(angles.x), 19 | 0, +sin(angles.x), cos(angles.x))); 20 | m.c2 = cross(m.c0, m.c1); // fewer instructions 21 | return m; 22 | } 23 | float3 swingTwistAngles(float3x3 rot, float eps=1e-5) { 24 | // NOTE: doesn't handle the singularity rot.c0 == (-1, 0, 0) 25 | return float3(atan2(rot.c1.z-rot.c2.y, rot.c1.y+rot.c2.z), float2(-rot.c0.z, rot.c0.y) 26 | * (rot.c0.x < 1-eps ? acos(rot.c0.x) * rsqrt(1-rot.c0.x*rot.c0.x) : 4./3 - rot.c0.x/3)); 27 | } 28 | // find an orthogonal pair (U,V) closest to (u,v) 29 | float orthogonalize(float3 u, float3 v, out float3 U, out float3 V) { 30 | float B = dot(u,v) * -2; 31 | float A = dot(u,u) + dot(v,v); 32 | A += sqrt(abs(A*A - B*B)); 33 | U = A*u+B*v, U *= dot(u,U)/dot(U,U); 34 | V = A*v+B*u, V *= dot(v,V)/dot(V,V); 35 | return dot(u-U, u-U) + dot(v-V, v-V); 36 | } -------------------------------------------------------------------------------- /Shader/Rotation.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6aa8f1199fb5514428e815c8d45467ea 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Shader/Skinning.hlsl: -------------------------------------------------------------------------------- 1 | static const uint maxShapeInfluence = 16; 2 | static const uint maxBoneInfluence = 4; 3 | static const uint maxBoneDepth = 16; // standard humanoid only needs 11 4 | void TransformBone(float4 data, inout float3x3 mat); 5 | void TransformRoot(float4 data, inout float3x3 mat); 6 | float2 GetBlendCoord(float4 data); 7 | 8 | SamplerState LinearClampSampler; 9 | struct VertInputSkin { 10 | float3 vertex : POSITION; 11 | float3 normal : NORMAL; 12 | float4 tangent : TANGENT; 13 | float4 texcoord : TEXCOORD0; 14 | float4 boneWeights : TEXCOORD1; 15 | UNITY_VERTEX_INPUT_INSTANCE_ID 16 | }; 17 | void MorphVertex(inout VertInputSkin i, Texture2D shapeTex) { 18 | uint2 size; shapeTex.GetDimensions(size.x, size.y); 19 | uint2 range = round(i.texcoord.zw); // z=length, w=start so that the default (0,0,0,1) has length 0 20 | uint2 loc0 = uint2(range.y%size.x, range.y/size.x); 21 | for(uint K=0; K= range.x) 23 | break; 24 | uint2 loc = uint2(loc0.x+K*3, loc0.y); 25 | float2 coord = GetBlendCoord(shapeTex.Load(uint3(loc.xy, 0))); 26 | i.vertex += shapeTex.SampleLevel(LinearClampSampler, (loc + 0.5 + coord.xy) / size.xy, 0).xyz; 27 | } 28 | } 29 | void SkinVertex(inout VertInputSkin i, Texture2D boneTex) { 30 | float3 vertex = 0, normal = 0, tangent = 0; 31 | for(uint J=0; J 16 | 17 | sampler2D _MainTex; 18 | float4 _MainTex_ST; 19 | float _ApplyGamma; 20 | 21 | struct VertInput { 22 | float3 vertex : POSITION; 23 | float2 uv : TEXCOORD0; 24 | UNITY_VERTEX_INPUT_INSTANCE_ID 25 | }; 26 | struct FragInput { 27 | float2 tex : TEXCOORD1; 28 | float4 pos : SV_Position; 29 | UNITY_VERTEX_OUTPUT_STEREO 30 | }; 31 | 32 | float3 GammaToLinear(float3 value) { 33 | return value <= 0.04045F? value / 12.92F : pow((value + 0.055F)/1.055F, 2.4F); 34 | } 35 | void vert(VertInput i, out FragInput o) { 36 | UNITY_SETUP_INSTANCE_ID(i); 37 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); 38 | o.pos = UnityObjectToClipPos(i.vertex); 39 | o.tex = i.uv * _MainTex_ST.xy + _MainTex_ST.zw; 40 | } 41 | float4 frag(FragInput i) : SV_Target { 42 | float3 sample = tex2Dlod(_MainTex, float4(i.tex, 0, 0)); 43 | if(_ApplyGamma) 44 | sample = GammaToLinear(sample); 45 | return float4(sample, 1); 46 | } 47 | ENDCG 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /Shader/UnlitGamma.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 08297a8faa70b86468c83e77ded9bff0 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Shader/VideoDecoder.shader: -------------------------------------------------------------------------------- 1 | Shader "Motion/VideoDecoder" { 2 | Properties { 3 | _MainTex ("MainTex (motion video texture)", 2D) = "black" {} 4 | _FrameRate ("FrameRate (interpolation fps)", Float) = 0 // 0=disable 5 | [ToggleUI] _ApplyGamma("ApplyGamma", Float) = 0 6 | } 7 | SubShader { 8 | Pass { 9 | CGINCLUDE 10 | #pragma target 3.5 11 | #pragma vertex vert 12 | #pragma fragment frag 13 | #pragma shader_feature SHADER_API_WEBGL 14 | 15 | #include "UnityCustomRenderTexture.cginc" 16 | #include "Rotation.hlsl" 17 | #include "Codec.hlsl" 18 | #include "VideoLayout.hlsl" 19 | 20 | void vert(appdata_customrendertexture i, out float2 texcoord : TEXCOORD0, out float4 vertex : SV_Position) { 21 | texcoord = CustomRenderTextureVertexShader(i).localTexcoord.xy; // lite version 22 | vertex = float4(texcoord*2-1, UNITY_NEAR_CLIP_VALUE, 1); 23 | #if UNITY_UV_STARTS_AT_TOP 24 | vertex.y *= -1; 25 | #endif 26 | } 27 | 28 | Texture2D _MainTex; 29 | float4 _MainTex_ST; 30 | float _ApplyGamma; 31 | float sampleSnorm(float2 uv) { 32 | float4 rect = GetTileRect(uv); 33 | if(uv.x > 0.5) 34 | rect.xz = rect.zx; 35 | ColorTile c; 36 | SampleTile(c, _MainTex, rect * _MainTex_ST.xyxy + _MainTex_ST.zwzw, _ApplyGamma); 37 | return DecodeVideoSnorm(c); 38 | } 39 | 40 | float _FrameRate; 41 | float4 frag(float2 texcoord : TEXCOORD0) : SV_Target { 42 | float v = sampleSnorm(texcoord); 43 | #if defined(SHADER_API_WEBGL) 44 | return EncodeBufferSnorm(v); 45 | #else 46 | float3 buf = tex2Dlod(_SelfTexture2D, float4(texcoord, 0, 0)).yzw; 47 | if(buf.y != v) 48 | buf = float3(buf.y, v, _Time.y); 49 | if(_FrameRate) 50 | v = lerp(buf.x, buf.y, saturate((_Time.y-buf.z + unity_DeltaTime.z)*_FrameRate)); 51 | return float4(v, buf); 52 | #endif 53 | } 54 | ENDCG 55 | CGPROGRAM 56 | ENDCG 57 | } 58 | Pass { // no-op pass, used to populate double buffered CRT 59 | ColorMask 0 60 | CGPROGRAM 61 | ENDCG 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /Shader/VideoDecoder.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4f62389260affe24a8a4a999b611a7db 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: 6 | - _MainTex: {instanceID: 0} 7 | nonModifiableTextures: [] 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Shader/VideoLayout.hlsl: -------------------------------------------------------------------------------- 1 | //// tile index <-> uv //// 2 | static const uint2 VideoResolution = uint2(80, 45); 3 | 4 | static const uint2 tileCount = VideoResolution / uint2(ColorTileLen, 1); 5 | static const float4 tileST = {float2(1,-1) / tileCount, float2(0,1)}; 6 | float4 GetTileRect(float2 uv) { 7 | return (floor(uv * tileCount).xyxy + float4(0,0,1,1)) / tileCount.xyxy; 8 | } 9 | float4 GetTileRect(uint idx) { 10 | return tileST.zwzw + float4(0,0,tileST.xy) + tileST.xyxy*float2(idx/tileCount.y, idx%tileCount.y).xyxy; 11 | } 12 | float4 GetTileX(uint4 idx) { 13 | return tileST.z + tileST.x*0.5 + tileST.x*(idx/tileCount.y); 14 | } 15 | float4 GetTileY(uint4 idx) { 16 | return tileST.w + tileST.y*0.5 + tileST.y*(idx%tileCount.y); 17 | } 18 | static float4 layerRect = float4(0, 0, GetTileRect(134).z, 1); 19 | //// tile uv <-> color //// 20 | SamplerState LinearClamp, PointClamp; 21 | half4 RenderTile(ColorTile c, float2 uv) { 22 | half3 color = uv.x < 0.5 ? c[0] : c[ColorTileLen-1]; // avoid dynamic indexing on varying since it breaks on AMD 23 | #if !defined(SHADER_API_WEBGL) 24 | color = GammaToLinear(color); 25 | #endif 26 | return half4(color, 1); 27 | } 28 | void SampleTile(out ColorTile c, Texture2D_half tex, float4 rect, bool sampleGamma=false) { 29 | UNITY_UNROLL for(int i=0; i x.name != srcLayers[srcIndex].name).Count(); 15 | if(dstIndex == dstLayers.Length) { 16 | dstController.AddLayer(srcLayers[srcIndex].name); 17 | dstLayers = dstController.layers; 18 | } 19 | CopyLayer(srcLayers[srcIndex], srcController, srcIndex, dstLayers[dstIndex], dstController, dstIndex); 20 | dstController.layers = dstLayers; 21 | } 22 | } 23 | public static void CopyParameters(AnimatorController srcController, AnimatorController dstController) { 24 | var srcParams = srcController.parameters; 25 | var dstParams = dstController.parameters; 26 | for(int srcIndex = 0; srcIndex < srcParams.Length; ++srcIndex) { 27 | var dstIndex = dstParams.TakeWhile(x => x.name != srcParams[srcIndex].name).Count(); 28 | if(dstIndex == dstParams.Length) { 29 | dstController.AddParameter(srcParams[srcIndex].name, srcParams[srcIndex].type); 30 | dstParams = dstController.parameters; 31 | } 32 | CopyParameter(srcParams[srcIndex], dstParams[dstIndex]); 33 | dstController.parameters = dstParams; 34 | } 35 | } 36 | static void CopyLayer(AnimatorControllerLayer srcLayer, AnimatorController srcController, int srcIndex, 37 | AnimatorControllerLayer dstLayer, AnimatorController dstController, int dstIndex) { 38 | dstLayer.avatarMask = srcLayer.avatarMask; 39 | dstLayer.blendingMode = srcLayer.blendingMode; 40 | dstLayer.defaultWeight = srcLayer.defaultWeight; 41 | dstLayer.iKPass = srcLayer.iKPass; 42 | Debug.Assert(srcLayer.syncedLayerIndex < 0, "syncedLayer and overrides are not implemented"); 43 | 44 | var srcMachine = srcLayer.stateMachine; 45 | var dstMachine = dstLayer.stateMachine; 46 | AnimatorStateMachine_Clear.Invoke(dstMachine, new object[]{}); 47 | Unsupported.CopyStateMachineDataToPasteboard(srcMachine, srcController, srcIndex); 48 | Unsupported.PasteToStateMachineFromPasteboard(dstMachine, dstController, dstIndex, default(Vector3)); 49 | dstLayer.stateMachine = dstMachine.stateMachines[0].stateMachine; 50 | Undo.DestroyObjectImmediate(dstMachine); 51 | } 52 | static void CopyParameter(AnimatorControllerParameter srcParam, AnimatorControllerParameter dstParam) { 53 | dstParam.defaultBool = srcParam.defaultBool; 54 | dstParam.defaultFloat = srcParam.defaultFloat; 55 | dstParam.defaultInt = srcParam.defaultInt; 56 | dstParam.type = srcParam.type; 57 | } 58 | static readonly MethodInfo AnimatorStateMachine_Clear = typeof(AnimatorStateMachine).GetMethod("Clear", 59 | BindingFlags.NonPublic | BindingFlags.Instance); 60 | } 61 | } 62 | #endif -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Editor/AnimatorControllerUtil.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 94d47abfb701cfa4790dc3c2bd34231b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Editor/VRCA2Descriptor.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_EDITOR 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEngine; 5 | using UnityEditor; 6 | using UnityEditor.Animations; 7 | 8 | namespace ShaderMotion.Addon { 9 | class VRCA2Descriptor { 10 | public SerializedObject serializedObject; 11 | public static VRCA2Descriptor FromGameObject(GameObject go) { 12 | foreach(var mono in go.GetComponents()) { 13 | var so = new SerializedObject(mono); 14 | if(so.FindProperty("CustomStandingAnims") != null) 15 | return new VRCA2Descriptor{serializedObject=so}; 16 | } 17 | return null; 18 | } 19 | 20 | public AnimatorOverrideController GetOverrideController() { 21 | return serializedObject.FindProperty("CustomStandingAnims").objectReferenceValue as AnimatorOverrideController; 22 | } 23 | } 24 | } 25 | #endif -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Editor/VRCA2Descriptor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 80376a2db40ec1b489bfcee43352033e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Editor/VRCA3Descriptor.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_EDITOR 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEngine; 5 | using UnityEditor; 6 | using UnityEditor.Animations; 7 | 8 | namespace ShaderMotion.Addon { 9 | class VRCA3Descriptor { 10 | public SerializedObject serializedObject; 11 | public static VRCA3Descriptor FromGameObject(GameObject go) { 12 | foreach(var mono in go.GetComponents()) { 13 | var so = new SerializedObject(mono); 14 | if(so.FindProperty("customizeAnimationLayers") != null && so.FindProperty("customExpressions") != null) 15 | return new VRCA3Descriptor{serializedObject=so}; 16 | } 17 | return null; 18 | } 19 | 20 | public const int FX = 5; 21 | public void MergeAnimationLayer(int type, AnimatorController source) { 22 | serializedObject.FindProperty("customizeAnimationLayers").boolValue = true; 23 | var baseAnimationLayers = serializedObject.FindProperty("baseAnimationLayers"); 24 | var animationLayer = Enumerable.Range(0, baseAnimationLayers?.arraySize??0) 25 | .Select(i => baseAnimationLayers.GetArrayElementAtIndex(i)) 26 | .FirstOrDefault(x => x.FindPropertyRelative("type")?.intValue == (int?)type); 27 | if(animationLayer != null) { 28 | var isDefault = animationLayer.FindPropertyRelative("isDefault"); 29 | var animatorController = animationLayer.FindPropertyRelative("animatorController"); 30 | var target = (AnimatorController)animatorController.objectReferenceValue; 31 | if(!isDefault.boolValue && target && target != source) { 32 | AnimatorControllerUtil.CopyParameters(source, target); 33 | AnimatorControllerUtil.CopyLayers(source, target); 34 | Debug.Log($"{target} is updated"); 35 | } else { 36 | isDefault.boolValue = false; 37 | animatorController.objectReferenceValue = source; 38 | } 39 | } 40 | serializedObject.ApplyModifiedProperties(); 41 | } 42 | public void MergeExpressions(ScriptableObject sourceMenu, ScriptableObject sourceParams) { 43 | serializedObject.FindProperty("customExpressions").boolValue = true; 44 | var expressionsMenu = serializedObject.FindProperty("expressionsMenu"); 45 | var expressionParameters = serializedObject.FindProperty("expressionParameters"); 46 | var targetMenu = (ScriptableObject)expressionsMenu.objectReferenceValue; 47 | var targetParams = (ScriptableObject)expressionParameters.objectReferenceValue; 48 | if(targetMenu && targetMenu != sourceMenu) { 49 | var sourceSO = new SerializedObject(sourceMenu); 50 | var targetSO = new SerializedObject(targetMenu); 51 | CopyArrayElementsByName(sourceSO.FindProperty("controls"), targetSO.FindProperty("controls")); 52 | targetSO.ApplyModifiedProperties(); 53 | Debug.Log($"{targetMenu} is updated"); 54 | } else 55 | expressionsMenu.objectReferenceValue = sourceMenu; 56 | if(targetParams && targetParams != sourceParams) { 57 | var sourceSO = new SerializedObject(sourceParams); 58 | var targetSO = new SerializedObject(targetParams); 59 | CopyArrayElementsByName(sourceSO.FindProperty("parameters"), targetSO.FindProperty("parameters")); 60 | targetSO.ApplyModifiedProperties(); 61 | Debug.Log($"{targetParams} is updated"); 62 | } else 63 | expressionParameters.objectReferenceValue = sourceParams; 64 | serializedObject.ApplyModifiedProperties(); 65 | } 66 | 67 | static void CopyRecursive(SerializedProperty source, SerializedProperty target) { 68 | var trunc = source.propertyPath.Length+1; 69 | foreach(SerializedProperty sourceProp in source) { 70 | var targetProp = target.FindPropertyRelative(sourceProp.propertyPath.Substring(trunc)); 71 | if(targetProp != null) 72 | switch (targetProp.propertyType) { 73 | case SerializedPropertyType.Integer: targetProp.intValue = sourceProp.intValue; break; 74 | case SerializedPropertyType.Boolean: targetProp.boolValue = sourceProp.boolValue; break; 75 | case SerializedPropertyType.Float: targetProp.floatValue = sourceProp.floatValue; break; 76 | case SerializedPropertyType.String: targetProp.stringValue = sourceProp.stringValue; break; 77 | case SerializedPropertyType.ObjectReference: targetProp.objectReferenceValue = sourceProp.objectReferenceValue; break; 78 | case SerializedPropertyType.Enum: targetProp.enumValueIndex = sourceProp.enumValueIndex; break; 79 | case SerializedPropertyType.ArraySize: targetProp.intValue = sourceProp.intValue; break; 80 | // TODO: other types 81 | } 82 | } 83 | } 84 | static void CopyArrayElementsByName(SerializedProperty source, SerializedProperty target) { 85 | var sourceArr = Enumerable.Range(0, source.arraySize).Select(source.GetArrayElementAtIndex); 86 | var targetMap = Enumerable.Range(0, target.arraySize).Select(target.GetArrayElementAtIndex) 87 | .GroupBy(x => x.FindPropertyRelative("name").stringValue).ToDictionary(g => g.Key, g => g.First()); 88 | foreach(var sourceElem in sourceArr) { 89 | var name = sourceElem.FindPropertyRelative("name").stringValue; 90 | if(string.IsNullOrEmpty(name)) 91 | continue; 92 | if(!targetMap.TryGetValue(name, out var targetElem)) { 93 | target.InsertArrayElementAtIndex(target.arraySize); 94 | targetElem = target.GetArrayElementAtIndex(target.arraySize-1); 95 | } 96 | CopyRecursive(sourceElem, targetElem); 97 | } 98 | } 99 | } 100 | } 101 | #endif -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Editor/VRCA3Descriptor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c08e5b5e6e97d504f826e8f5a7fe546c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Editor/VRCASetup.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_EDITOR 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEngine; 5 | using UnityEngine.Animations; 6 | using UnityEditor; 7 | using UnityEditor.Animations; 8 | using System.Text.RegularExpressions; 9 | 10 | namespace ShaderMotion.Addon { 11 | class VRCASetup : EditorWindow { 12 | [MenuItem("CONTEXT/Animator/SetupAvatar")] 13 | static void SetupAvatar(MenuCommand command) { 14 | var window = EditorWindow.GetWindow("SetupAvatar"); 15 | window.animator = (Animator)command.context; 16 | window.Show(); 17 | } 18 | Animator animator; 19 | void OnGUI() { 20 | animator = (Animator)EditorGUILayout.ObjectField("Avatar", animator, typeof(Animator), true); 21 | using(new EditorGUI.DisabledScope(!(animator && animator.isHuman))) { 22 | if(GUILayout.Button("Setup Motion Recorder")) 23 | CreateRecorder(animator); 24 | if(GUILayout.Button("Setup Motion Player")) 25 | CreatePlayer(animator); 26 | if(GUILayout.Button("Setup Animator")) { 27 | SetupPrefab(animator); 28 | SetupDescriptor(animator); 29 | } 30 | } 31 | } 32 | 33 | public static SkinnedMeshRenderer CreateRecorder(Animator animator) { 34 | var recorder = MeshRecorder.CreateRecorderSkinned( 35 | MeshRecorder.CreateChild(animator, "Recorder"), 36 | MeshRecorder.CreatePath(animator, "Recorder"), 37 | animator); 38 | 39 | recorder.updateWhenOffscreen = true; 40 | return recorder; 41 | } 42 | public static MeshRenderer CreatePlayer(Animator animator) { 43 | var player = MeshPlayer.CreatePlayer( 44 | MeshRecorder.CreateChild(animator, "Player"), 45 | MeshRecorder.CreatePath(animator, "Player"), 46 | animator, animator.gameObject.GetComponentsInChildren() 47 | .Where(smr => !Regex.IsMatch(smr.name, "(Recorder|Player)$")).ToArray()); 48 | 49 | var shader = Resources.Load("SMVRCAPlayer").shader; 50 | var mesh = player.GetComponent().sharedMesh; 51 | mesh.bounds = new Bounds(Vector3.zero, 52 | Vector3.Min(mesh.bounds.size, new Vector3(2.5f, 2.5f, 2.5f))); 53 | foreach(var mat in player.sharedMaterials) 54 | mat.shader = shader; 55 | return player; 56 | } 57 | public static void SetupPrefab(Animator animator) { 58 | var prefab = Resources.Load("SMVRCA"); 59 | var root = animator.transform.Find(prefab.name)?.gameObject 60 | ?? (GameObject)PrefabUtility.InstantiatePrefab(prefab); 61 | root.transform.SetParent(animator.transform, false); 62 | 63 | var anchor = root.GetComponentInChildren().transform; 64 | var hips = animator.GetBoneTransform(HumanBodyBones.Hips); 65 | 66 | // setup camera 67 | var cam = root.GetComponentInChildren(); 68 | cam.GetComponent().SetSource(0, new ConstraintSource{sourceTransform=hips, weight=1}); 69 | 70 | // setup recorder 71 | var recorder = animator.transform.Find("Recorder")?.GetComponent(); 72 | if(recorder) { 73 | recorder.rootBone = anchor; 74 | 75 | if((cam.cullingMask & (1<(); 85 | if(player) { 86 | var constraint = player.GetComponent(); 87 | if(!constraint) 88 | constraint = player.gameObject.AddComponent(); 89 | EditorUtility.CopySerialized(anchor.GetComponent(), constraint); 90 | constraint.SetSource(0, new ConstraintSource{sourceTransform=anchor, weight=1}); 91 | constraint.constraintActive = true; 92 | } 93 | } 94 | public static void SetupDescriptor(Animator animator) { 95 | var desc3 = VRCA3Descriptor.FromGameObject(animator.gameObject); 96 | if(desc3 != null) { 97 | desc3.MergeAnimationLayer(VRCA3Descriptor.FX, Resources.Load("SMVRCAFX")); 98 | desc3.MergeExpressions(Resources.Load("SMVRCAMenu"), 99 | Resources.Load("SMVRCAParams")); 100 | return; 101 | } 102 | var desc2 = VRCA2Descriptor.FromGameObject(animator.gameObject); 103 | if(desc2 != null) { 104 | var overrideController = desc2.GetOverrideController(); 105 | if(!overrideController) { 106 | Debug.LogError("VRCA2 Override controller is missing"); 107 | return; 108 | } 109 | overrideController["EMOTE8"] = Resources.Load("SMVRCAFX") 110 | .animationClips.FirstOrDefault(x => x.name == "Calibrate"); 111 | Debug.Log($"{overrideController} is updated"); 112 | return; 113 | } 114 | Debug.LogError("Avatar descriptor is missing"); 115 | } 116 | } 117 | } 118 | #endif -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Editor/VRCASetup.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 77df37f6fb8b4f14fb0612e89d47f393 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Material.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4dfd8d6d9bc314b42bfc57f20063ffe4 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Material/Anchor.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: Anchor 11 | m_Shader: {fileID: 10750, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 2800000, guid: 2256df3c35328d94a972248250b626ef, type: 3} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BumpScale: 1 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0.5 65 | - _GlossyReflections: 1 66 | - _Metallic: 0 67 | - _Mode: 0 68 | - _OcclusionStrength: 1 69 | - _Parallax: 0.02 70 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _UVSec: 0 74 | - _ZWrite: 1 75 | m_Colors: 76 | - _Color: {r: 1, g: 1, b: 1, a: 1} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 78 | -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Material/Anchor.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 95978eb7157625b46be3213f54c66a59 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Material/Anchor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CuteWaterBeary/ShaderMotion/9d53d6e8588501764674e031ef196e22b6f332ef/VRC_Avatar_Addon/Material/Anchor.png -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Material/Anchor.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2256df3c35328d94a972248250b626ef 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | externalObjects: {} 6 | serializedVersion: 9 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 1 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 1 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: 4 36 | mipBias: -100 37 | wrapU: -1 38 | wrapV: -1 39 | wrapW: -1 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 1 53 | spriteTessellationDetail: -1 54 | textureType: 0 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | platformSettings: 61 | - serializedVersion: 2 62 | buildTarget: DefaultTexturePlatform 63 | maxTextureSize: 2048 64 | resizeAlgorithm: 0 65 | textureFormat: -1 66 | textureCompression: 1 67 | compressionQuality: 100 68 | crunchedCompression: 1 69 | allowsAlphaSplitting: 0 70 | overridden: 0 71 | androidETC2FallbackOverride: 0 72 | - serializedVersion: 2 73 | buildTarget: Standalone 74 | maxTextureSize: 2048 75 | resizeAlgorithm: 0 76 | textureFormat: -1 77 | textureCompression: 1 78 | compressionQuality: 100 79 | crunchedCompression: 1 80 | allowsAlphaSplitting: 0 81 | overridden: 0 82 | androidETC2FallbackOverride: 0 83 | - serializedVersion: 2 84 | buildTarget: Android 85 | maxTextureSize: 2048 86 | resizeAlgorithm: 0 87 | textureFormat: -1 88 | textureCompression: 1 89 | compressionQuality: 100 90 | crunchedCompression: 1 91 | allowsAlphaSplitting: 0 92 | overridden: 0 93 | androidETC2FallbackOverride: 0 94 | spriteSheet: 95 | serializedVersion: 2 96 | sprites: [] 97 | outline: [] 98 | physicsShape: [] 99 | bones: [] 100 | spriteID: 101 | vertices: [] 102 | indices: 103 | edges: [] 104 | weights: [] 105 | spritePackingTag: 106 | pSDRemoveMatte: 0 107 | pSDShowRemoveMatteOption: 0 108 | userData: 109 | assetBundleName: 110 | assetBundleVariant: 111 | -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 55f93b11f7deef4478a862bc619a7d16 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Resources/SMVRCA.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 006c9dc085b21f2469cb68a1db0df62f 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Resources/SMVRCAFX.controller.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d533b54dac653f94f951a15191b27c88 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 9100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Resources/SMVRCAMenu.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: -340790334, guid: 67cc4cb7839cd3741b63733d5adf0442, type: 3} 13 | m_Name: SMVRCAMenu 14 | m_EditorClassIdentifier: 15 | controls: 16 | - name: ShaderMotion 17 | icon: {fileID: 2800000, guid: 44b822c693fbd174d8f994ee312dd8e4, type: 3} 18 | type: 103 19 | parameter: 20 | name: 21 | value: 1 22 | style: 0 23 | subMenu: {fileID: 11400000, guid: 22882eca3e7f94843b520f28ac9aa7be, type: 2} 24 | subParameters: [] 25 | labels: [] 26 | -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Resources/SMVRCAMenu.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6775ec53fc1c60148985d6dd59c49328 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Resources/SMVRCAMenu2.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: -340790334, guid: 67cc4cb7839cd3741b63733d5adf0442, type: 3} 13 | m_Name: SMVRCAMenu2 14 | m_EditorClassIdentifier: 15 | controls: 16 | - name: Record 17 | icon: {fileID: 2800000, guid: 44b822c693fbd174d8f994ee312dd8e4, type: 3} 18 | type: 102 19 | parameter: 20 | name: SMVRCA_Recorder 21 | value: 1 22 | style: 0 23 | subMenu: {fileID: 0} 24 | subParameters: [] 25 | labels: [] 26 | - name: Calibrate 27 | icon: {fileID: 2800000, guid: 30891e000b76dfc4db977fc2238911a0, type: 3} 28 | type: 101 29 | parameter: 30 | name: SMVRCA_Calibrate 31 | value: 1 32 | style: 0 33 | subMenu: {fileID: 0} 34 | subParameters: [] 35 | labels: [] 36 | - name: Multiplayer 37 | icon: {fileID: 2800000, guid: 5acca5d9b1a37724880f1a1dc1bc54d3, type: 3} 38 | type: 103 39 | parameter: 40 | name: 41 | value: 1 42 | style: 0 43 | subMenu: {fileID: 11400000, guid: f90f7dca61428ee4cb47e7ea787eebb0, type: 2} 44 | subParameters: [] 45 | labels: [] 46 | - name: MotionLink 47 | icon: {fileID: 2800000, guid: 29b4286f41c93f84f9ffc6ca7551f2d3, type: 3} 48 | type: 102 49 | parameter: 50 | name: SMVRCA_Player 51 | value: 1 52 | style: 0 53 | subMenu: {fileID: 0} 54 | subParameters: [] 55 | labels: [] 56 | -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Resources/SMVRCAMenu2.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 22882eca3e7f94843b520f28ac9aa7be 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Resources/SMVRCAMenu3.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: -340790334, guid: 67cc4cb7839cd3741b63733d5adf0442, type: 3} 13 | m_Name: SMVRCAMenu3 14 | m_EditorClassIdentifier: 15 | controls: 16 | - name: RecordOther 17 | icon: {fileID: 2800000, guid: 9a20b3a6641e1af4e95e058f361790cb, type: 3} 18 | type: 102 19 | parameter: 20 | name: SMVRCA_Other 21 | value: 1 22 | style: 0 23 | subMenu: {fileID: 0} 24 | subParameters: [] 25 | labels: [] 26 | - name: P1 27 | icon: {fileID: 0} 28 | type: 102 29 | parameter: 30 | name: SMVRCA_Layer 31 | value: 0 32 | style: 0 33 | subMenu: {fileID: 0} 34 | subParameters: [] 35 | labels: [] 36 | - name: P2 37 | icon: {fileID: 0} 38 | type: 102 39 | parameter: 40 | name: SMVRCA_Layer 41 | value: 1 42 | style: 0 43 | subMenu: {fileID: 0} 44 | subParameters: [] 45 | labels: [] 46 | - name: P3 47 | icon: {fileID: 0} 48 | type: 102 49 | parameter: 50 | name: SMVRCA_Layer 51 | value: 2 52 | style: 0 53 | subMenu: {fileID: 0} 54 | subParameters: [] 55 | labels: [] 56 | - name: P4 57 | icon: {fileID: 0} 58 | type: 102 59 | parameter: 60 | name: SMVRCA_Layer 61 | value: 3 62 | style: 0 63 | subMenu: {fileID: 0} 64 | subParameters: [] 65 | labels: [] 66 | -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Resources/SMVRCAMenu3.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f90f7dca61428ee4cb47e7ea787eebb0 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Resources/SMVRCAParams.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: -1506855854, guid: 67cc4cb7839cd3741b63733d5adf0442, type: 3} 13 | m_Name: SMVRCAParams 14 | m_EditorClassIdentifier: 15 | parameters: 16 | - name: SMVRCA_Recorder 17 | valueType: 2 18 | saved: 0 19 | defaultValue: 0 20 | - name: SMVRCA_Calibrate 21 | valueType: 2 22 | saved: 0 23 | defaultValue: 0 24 | - name: SMVRCA_Layer 25 | valueType: 0 26 | saved: 1 27 | defaultValue: 0 28 | - name: SMVRCA_Other 29 | valueType: 2 30 | saved: 0 31 | defaultValue: 0 32 | - name: SMVRCA_Player 33 | valueType: 2 34 | saved: 0 35 | defaultValue: 0 36 | -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Resources/SMVRCAParams.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fdeeeb8904941594891979fa2b6fff6f 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Resources/SMVRCAPlayer.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: SMVRCAPlayer 11 | m_Shader: {fileID: 4800000, guid: c6d45a7e814b5fc43a64dd07588ce926, type: 3} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 1 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _Bone: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _MainTex: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _MotionDec: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _Shape: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | m_Floats: 39 | - _AlphaTest: 0 40 | - _Cull: 2 41 | - _Cutoff: 0 42 | - _HumanScale: 0 43 | - _Layer: 0 44 | - _NearClip: 0 45 | - _RotationTolerance: 0.1 46 | m_Colors: 47 | - _Color: {r: 1, g: 1, b: 1, a: 1} 48 | - _RootErrParams: {r: 0.1, g: 0.15, b: 0.15, a: 0} 49 | -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Resources/SMVRCAPlayer.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b6c7476bbb128fb48b0d5f9ac28ee563 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7a195e4c3fb21e14db60b7732326e828 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Shader/MeshPlayerGlobal.shader: -------------------------------------------------------------------------------- 1 | Shader "Motion/MeshPlayerGlobal" { 2 | Properties { 3 | [Header(Texture)] 4 | [NoScaleOffset] 5 | _MainTex ("MainTex", 2D) = "white" {} 6 | _Color ("Color", Color) = (1,1,1,1) 7 | 8 | [Header(Culling)] 9 | [Enum(UnityEngine.Rendering.CullMode)] _Cull("Face Culling", Float) = 2 10 | [Toggle(_ALPHATEST_ON)] _AlphaTest("Alpha Test", Float) = 0 11 | _Cutoff ("Alpha Cutoff", Range(0, 1)) = 0 12 | 13 | [HideInInspector] _Bone ("Bone", 2D) = "black" {} 14 | [HideInInspector] _Shape ("Shape", 2D) = "black" {} 15 | [Header(Motion)] 16 | _HumanScale ("HumanScale (hips height: 0=original, -1=encoded)", Float) = -1 17 | _Layer ("Layer (location of motion stripe)", Float) = 0 18 | _RotationTolerance ("RotationTolerance", Range(0, 1)) = 0.1 19 | } 20 | SubShader { 21 | Tags { "Queue"="Geometry" "RenderType"="Opaque" } 22 | UsePass "Motion/MeshPlayer/" 23 | } 24 | } -------------------------------------------------------------------------------- /VRC_Avatar_Addon/Shader/MeshPlayerGlobal.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c6d45a7e814b5fc43a64dd07588ce926 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /VRC_World_Addon.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 090d3d8f4bfb40b47abc362c9bde3dc2 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /VRC_World_Addon/MotionLink.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cf36595d19d33ae45a379e6584d0ed9c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /VRC_World_Addon/MotionLink/GrabMotionDec.shader: -------------------------------------------------------------------------------- 1 | Shader "Motion/GrabMotionDec" { 2 | Properties { 3 | [HideInInspector] _MainTex ("MainTex", 2D) = "white" {} 4 | } 5 | SubShader { 6 | Tags { "Queue"="Geometry" "RenderType"="Opaque" } 7 | Pass { 8 | Tags { "LightMode"="Vertex" } 9 | ColorMask 0 10 | ZTest Off 11 | } 12 | GrabPass { 13 | Tags { "LightMode"="Vertex" } 14 | "_MotionDec" 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /VRC_World_Addon/MotionLink/GrabMotionDec.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d9e60d42427c2564d84a37e58300b1a8 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /VRC_World_Addon/MotionLink/MotionLink.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: MotionLink 11 | m_Shader: {fileID: 4800000, guid: d9e60d42427c2564d84a37e58300b1a8, type: 3} 12 | m_ShaderKeywords: ETC1_EXTERNAL_ALPHA 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _MainTex: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | m_Floats: [] 27 | m_Colors: [] 28 | -------------------------------------------------------------------------------- /VRC_World_Addon/MotionLink/MotionLink.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f3af2e781a97242438dd306b35a48a60 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /VRC_World_Addon/MotionLink/MotionLink.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &7928281756291820902 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 7928281756291820900} 12 | - component: {fileID: 7928281756291820901} 13 | - component: {fileID: 7928281756291820907} 14 | m_Layer: 0 15 | m_Name: MotionLink 16 | m_TagString: Untagged 17 | m_Icon: {fileID: 0} 18 | m_NavMeshLayer: 0 19 | m_StaticEditorFlags: 0 20 | m_IsActive: 1 21 | --- !u!4 &7928281756291820900 22 | Transform: 23 | m_ObjectHideFlags: 0 24 | m_CorrespondingSourceObject: {fileID: 0} 25 | m_PrefabInstance: {fileID: 0} 26 | m_PrefabAsset: {fileID: 0} 27 | m_GameObject: {fileID: 7928281756291820902} 28 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 29 | m_LocalPosition: {x: 0, y: 100000000, z: 0} 30 | m_LocalScale: {x: 1, y: 1, z: 1} 31 | m_Children: [] 32 | m_Father: {fileID: 0} 33 | m_RootOrder: 0 34 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 35 | --- !u!20 &7928281756291820901 36 | Camera: 37 | m_ObjectHideFlags: 0 38 | m_CorrespondingSourceObject: {fileID: 0} 39 | m_PrefabInstance: {fileID: 0} 40 | m_PrefabAsset: {fileID: 0} 41 | m_GameObject: {fileID: 7928281756291820902} 42 | m_Enabled: 1 43 | serializedVersion: 2 44 | m_ClearFlags: 4 45 | m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0} 46 | m_projectionMatrixMode: 1 47 | m_SensorSize: {x: 36, y: 24} 48 | m_LensShift: {x: 0, y: 0} 49 | m_GateFitMode: 2 50 | m_FocalLength: 50 51 | m_NormalizedViewPortRect: 52 | serializedVersion: 2 53 | x: 0 54 | y: 0 55 | width: 1 56 | height: 1 57 | near clip plane: -1 58 | far clip plane: 1 59 | field of view: 60 60 | orthographic: 1 61 | orthographic size: 1 62 | m_Depth: -10 63 | m_CullingMask: 64 | serializedVersion: 2 65 | m_Bits: 1 66 | m_RenderingPath: 0 67 | m_TargetTexture: {fileID: 8600000, guid: 0247e5cfe3e145b4d9cba5360c02bfea, type: 2} 68 | m_TargetDisplay: 0 69 | m_TargetEye: 3 70 | m_HDR: 0 71 | m_AllowMSAA: 0 72 | m_AllowDynamicResolution: 0 73 | m_ForceIntoRT: 0 74 | m_OcclusionCulling: 0 75 | m_StereoConvergence: 10 76 | m_StereoSeparation: 0.022 77 | --- !u!212 &7928281756291820907 78 | SpriteRenderer: 79 | m_ObjectHideFlags: 0 80 | m_CorrespondingSourceObject: {fileID: 0} 81 | m_PrefabInstance: {fileID: 0} 82 | m_PrefabAsset: {fileID: 0} 83 | m_GameObject: {fileID: 7928281756291820902} 84 | m_Enabled: 1 85 | m_CastShadows: 0 86 | m_ReceiveShadows: 0 87 | m_DynamicOccludee: 1 88 | m_MotionVectors: 1 89 | m_LightProbeUsage: 1 90 | m_ReflectionProbeUsage: 1 91 | m_RenderingLayerMask: 1 92 | m_RendererPriority: 0 93 | m_Materials: 94 | - {fileID: 2100000, guid: f3af2e781a97242438dd306b35a48a60, type: 2} 95 | m_StaticBatchInfo: 96 | firstSubMesh: 0 97 | subMeshCount: 0 98 | m_StaticBatchRoot: {fileID: 0} 99 | m_ProbeAnchor: {fileID: 0} 100 | m_LightProbeVolumeOverride: {fileID: 0} 101 | m_ScaleInLightmap: 1 102 | m_PreserveUVs: 0 103 | m_IgnoreNormalsForChartDetection: 0 104 | m_ImportantGI: 0 105 | m_StitchLightmapSeams: 0 106 | m_SelectedEditorRenderState: 0 107 | m_MinimumChartSize: 4 108 | m_AutoUVMaxDistance: 0.5 109 | m_AutoUVMaxAngle: 89 110 | m_LightmapParameters: {fileID: 0} 111 | m_SortingLayerID: 0 112 | m_SortingLayer: 0 113 | m_SortingOrder: 0 114 | m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0} 115 | m_Color: {r: 1, g: 1, b: 1, a: 1} 116 | m_FlipX: 0 117 | m_FlipY: 0 118 | m_DrawMode: 0 119 | m_Size: {x: 0.25, y: 0.25} 120 | m_AdaptiveModeThreshold: 0.5 121 | m_SpriteTileMode: 0 122 | m_WasSpriteAssigned: 1 123 | m_MaskInteraction: 0 124 | m_SpriteSortPoint: 0 125 | -------------------------------------------------------------------------------- /VRC_World_Addon/MotionLink/MotionLink.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c12dc0cbe3f469b42a785c041b8b65e7 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /VRC_World_Addon/SampleWorld.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dcfb7a75b4bd54349a896bb7bee69b51 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /VRC_World_Addon/UdonPlayer.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 72f8bc31bad150942a26eaed67106c78 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /VRC_World_Addon/UdonPlayer/DataRT.renderTexture: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!84 &8400000 4 | RenderTexture: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_Name: DataRT 10 | m_ImageContentsHash: 11 | serializedVersion: 2 12 | Hash: 00000000000000000000000000000000 13 | m_ForcedFallbackFormat: 4 14 | m_DownscaleFallback: 0 15 | serializedVersion: 3 16 | m_Width: 64 17 | m_Height: 64 18 | m_AntiAliasing: 1 19 | m_MipCount: -1 20 | m_DepthFormat: 0 21 | m_ColorFormat: 52 22 | m_MipMap: 0 23 | m_GenerateMips: 1 24 | m_SRGB: 0 25 | m_UseDynamicScale: 0 26 | m_BindMS: 0 27 | m_EnableCompatibleFormat: 1 28 | m_TextureSettings: 29 | serializedVersion: 2 30 | m_FilterMode: 0 31 | m_Aniso: 0 32 | m_MipBias: 0 33 | m_WrapU: 1 34 | m_WrapV: 1 35 | m_WrapW: 1 36 | m_Dimension: 2 37 | m_VolumeDepth: 1 38 | -------------------------------------------------------------------------------- /VRC_World_Addon/UdonPlayer/DataRT.renderTexture.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 07cef6e3150d57941a07aa75063b2bf8 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 8400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /VRC_World_Addon/UdonPlayer/DataTex.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!28 &2800000 4 | Texture2D: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_Name: DataTex 10 | m_ImageContentsHash: 11 | serializedVersion: 2 12 | Hash: 00000000000000000000000000000000 13 | m_ForcedFallbackFormat: 4 14 | m_DownscaleFallback: 0 15 | serializedVersion: 2 16 | m_Width: 64 17 | m_Height: 64 18 | m_CompleteImageSize: 65536 19 | m_TextureFormat: 20 20 | m_MipCount: 1 21 | m_IsReadable: 1 22 | m_IgnoreMasterTextureLimit: 0 23 | m_IsPreProcessed: 0 24 | m_StreamingMipmaps: 0 25 | m_StreamingMipmapsPriority: 0 26 | m_AlphaIsTransparency: 0 27 | m_ImageCount: 1 28 | m_TextureDimension: 2 29 | m_TextureSettings: 30 | serializedVersion: 2 31 | m_FilterMode: 0 32 | m_Aniso: 0 33 | m_MipBias: 0 34 | m_WrapU: 0 35 | m_WrapV: 0 36 | m_WrapW: 0 37 | m_LightmapFormat: 0 38 | m_ColorSpace: 0 39 | m_StreamData: 40 | offset: 0 41 | size: 0 42 | path: 43 | -------------------------------------------------------------------------------- /VRC_World_Addon/UdonPlayer/DataTex.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0463e5abeccfa0a4b9b8001b571eb479 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /VRC_World_Addon/UdonPlayer/Script.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6e479e5e3bcd7cb4a92f6451a8e5598e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /VRC_World_Addon/UdonPlayer/Script/CamRTReader.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3} 13 | m_Name: CamRTReader 14 | m_EditorClassIdentifier: 15 | serializedUdonProgramAsset: {fileID: 11400000, guid: 444a09a315d168d44bc11459d7eb123e, 16 | type: 2} 17 | udonAssembly: 18 | assemblyError: 19 | sourceCsScript: {fileID: 11500000, guid: 18579a7eb4b3f5b4588ed713fd73cd44, type: 3} 20 | scriptVersion: 2 21 | compiledVersion: 2 22 | behaviourSyncMode: 1 23 | hasInteractEvent: 0 24 | scriptID: -1319384131020271116 25 | serializationData: 26 | SerializedFormat: 2 27 | SerializedBytes: 28 | ReferencedUnityObjects: [] 29 | SerializedBytesString: 30 | Prefab: {fileID: 0} 31 | PrefabModificationsReferencedUnityObjects: [] 32 | PrefabModifications: [] 33 | SerializationNodes: 34 | - Name: fieldDefinitions 35 | Entry: 7 36 | Data: 0|System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[UdonSharp.Compiler.FieldDefinition, 37 | UdonSharp.Editor]], mscorlib 38 | - Name: comparer 39 | Entry: 7 40 | Data: 1|System.Collections.Generic.GenericEqualityComparer`1[[System.String, 41 | mscorlib]], mscorlib 42 | - Name: 43 | Entry: 8 44 | Data: 45 | - Name: 46 | Entry: 12 47 | Data: 3 48 | - Name: 49 | Entry: 7 50 | Data: 51 | - Name: $k 52 | Entry: 1 53 | Data: outputTexture 54 | - Name: $v 55 | Entry: 7 56 | Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor 57 | - Name: k__BackingField 58 | Entry: 1 59 | Data: outputTexture 60 | - Name: k__BackingField 61 | Entry: 7 62 | Data: 3|System.RuntimeType, mscorlib 63 | - Name: 64 | Entry: 1 65 | Data: UnityEngine.Texture2D, UnityEngine.CoreModule 66 | - Name: 67 | Entry: 8 68 | Data: 69 | - Name: k__BackingField 70 | Entry: 9 71 | Data: 3 72 | - Name: k__BackingField 73 | Entry: 7 74 | Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib 75 | - Name: 76 | Entry: 6 77 | Data: 78 | - Name: 79 | Entry: 8 80 | Data: 81 | - Name: k__BackingField 82 | Entry: 5 83 | Data: true 84 | - Name: _fieldAttributes 85 | Entry: 7 86 | Data: 4|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib 87 | - Name: 88 | Entry: 12 89 | Data: 0 90 | - Name: 91 | Entry: 13 92 | Data: 93 | - Name: 94 | Entry: 8 95 | Data: 96 | - Name: 97 | Entry: 8 98 | Data: 99 | - Name: 100 | Entry: 8 101 | Data: 102 | - Name: 103 | Entry: 7 104 | Data: 105 | - Name: $k 106 | Entry: 1 107 | Data: inputTexture 108 | - Name: $v 109 | Entry: 7 110 | Data: 5|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor 111 | - Name: k__BackingField 112 | Entry: 1 113 | Data: inputTexture 114 | - Name: k__BackingField 115 | Entry: 7 116 | Data: 6|System.RuntimeType, mscorlib 117 | - Name: 118 | Entry: 1 119 | Data: UnityEngine.RenderTexture, UnityEngine.CoreModule 120 | - Name: 121 | Entry: 8 122 | Data: 123 | - Name: k__BackingField 124 | Entry: 9 125 | Data: 6 126 | - Name: k__BackingField 127 | Entry: 7 128 | Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib 129 | - Name: 130 | Entry: 6 131 | Data: 132 | - Name: 133 | Entry: 8 134 | Data: 135 | - Name: k__BackingField 136 | Entry: 5 137 | Data: false 138 | - Name: _fieldAttributes 139 | Entry: 7 140 | Data: 7|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib 141 | - Name: 142 | Entry: 12 143 | Data: 0 144 | - Name: 145 | Entry: 13 146 | Data: 147 | - Name: 148 | Entry: 8 149 | Data: 150 | - Name: 151 | Entry: 8 152 | Data: 153 | - Name: 154 | Entry: 8 155 | Data: 156 | - Name: 157 | Entry: 7 158 | Data: 159 | - Name: $k 160 | Entry: 1 161 | Data: colors 162 | - Name: $v 163 | Entry: 7 164 | Data: 8|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor 165 | - Name: k__BackingField 166 | Entry: 1 167 | Data: colors 168 | - Name: k__BackingField 169 | Entry: 7 170 | Data: 9|System.RuntimeType, mscorlib 171 | - Name: 172 | Entry: 1 173 | Data: UnityEngine.Color[], UnityEngine.CoreModule 174 | - Name: 175 | Entry: 8 176 | Data: 177 | - Name: k__BackingField 178 | Entry: 9 179 | Data: 9 180 | - Name: k__BackingField 181 | Entry: 7 182 | Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib 183 | - Name: 184 | Entry: 6 185 | Data: 186 | - Name: 187 | Entry: 8 188 | Data: 189 | - Name: k__BackingField 190 | Entry: 5 191 | Data: false 192 | - Name: _fieldAttributes 193 | Entry: 7 194 | Data: 10|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib 195 | - Name: 196 | Entry: 12 197 | Data: 0 198 | - Name: 199 | Entry: 13 200 | Data: 201 | - Name: 202 | Entry: 8 203 | Data: 204 | - Name: 205 | Entry: 8 206 | Data: 207 | - Name: 208 | Entry: 8 209 | Data: 210 | - Name: 211 | Entry: 13 212 | Data: 213 | - Name: 214 | Entry: 8 215 | Data: 216 | -------------------------------------------------------------------------------- /VRC_World_Addon/UdonPlayer/Script/CamRTReader.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8428f2bdd9918344190e251fcb369d16 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /VRC_World_Addon/UdonPlayer/Script/CamRTReader.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace ShaderMotion { 4 | [RequireComponent(typeof(Camera))] 5 | #if !UDON 6 | public class CamRTReader : MonoBehaviour 7 | #else 8 | [UdonSharp.UdonBehaviourSyncMode(UdonSharp.BehaviourSyncMode.None)] 9 | public class CamRTReader : UdonSharp.UdonSharpBehaviour 10 | #endif 11 | { 12 | public Texture2D outputTexture; 13 | 14 | private RenderTexture inputTexture; 15 | private Color[] colors; 16 | void OnEnable() { 17 | inputTexture = GetComponent().targetTexture; 18 | colors = new Color[inputTexture.width*inputTexture.height]; 19 | } 20 | void OnPostRender() { 21 | #if !UDON 22 | UnityEngine.Rendering.AsyncGPUReadback.Request(inputTexture, 0, TextureFormat.RGBAFloat, OnAsyncGpuReadbackComplete); 23 | #elif UNITY_ANDROID // TODO: readback doesn't work yet 24 | outputTexture.ReadPixels(new Rect(0, 0, inputTexture.width, inputTexture.height), 0, 0, false); 25 | #else 26 | VRC.SDK3.Rendering.VRCAsyncGPUReadback.Request(inputTexture, 0, TextureFormat.RGBAFloat, (VRC.Udon.Common.Interfaces.IUdonEventReceiver)(Component)this); 27 | #endif 28 | } 29 | 30 | #if !UDON 31 | public void OnAsyncGpuReadbackComplete(UnityEngine.Rendering.AsyncGPUReadbackRequest request) 32 | #else 33 | public void OnAsyncGpuReadbackComplete(VRC.SDK3.Rendering.VRCAsyncGPUReadbackRequest request) 34 | #endif 35 | { 36 | if (request.hasError || !request.done) return; 37 | #if !UDON 38 | request.GetData().CopyTo(colors); 39 | #else 40 | request.TryGetData(colors); 41 | #endif 42 | outputTexture.SetPixels(colors); 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /VRC_World_Addon/UdonPlayer/Script/CamRTReader.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 18579a7eb4b3f5b4588ed713fd73cd44 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /VRC_World_Addon/UdonPlayer/Script/UdonPlayer.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2589d864619a89a41aaf975805a31c17 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /VRC_World_Addon/UdonPlayer/Script/UdonPlayer.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace ShaderMotion { 4 | #if UDON 5 | [UdonSharp.UdonBehaviourSyncMode(UdonSharp.BehaviourSyncMode.None)] 6 | public class UdonPlayer : UdonSharp.UdonSharpBehaviour 7 | #else 8 | public class UdonPlayer : MonoBehaviour 9 | #endif 10 | { 11 | public Texture2D dataTexture; 12 | public Animator animator; 13 | public int layer; 14 | public bool applyScale = true; 15 | public bool applyVisibility = true; 16 | 17 | private Transform root; 18 | private Transform[] bones; 19 | private Renderer[] renderers; 20 | void OnEnable() { 21 | if(!animator) 22 | animator = GetComponent(); 23 | root = animator.transform; 24 | renderers = GetComponentsInChildren(false); 25 | bones = new Transform[HumanTrait.BoneCount]; 26 | for(int i=0; i 0f; 40 | if(applyVisibility) 41 | foreach(var renderer in renderers) 42 | renderer.enabled = valid; 43 | if(!valid) 44 | return; 45 | if(applyScale) 46 | root.localScale = Vector3.one*rescale; 47 | bones[0].position = root.TransformPoint(c3/rescale); 48 | ApplyRotation(offsetY); 49 | } 50 | void ApplyRotation(int offsetY) { 51 | var preQ = root.rotation; 52 | var scale = root.lossyScale; 53 | var postQ = Quaternion.LookRotation(scale.x*scale.y*Vector3.forward, scale.x*scale.z*Vector3.up); // det(sign)*scale(sign) 54 | preQ *= postQ; 55 | for(int n=bones.Length, i=0; i