Last active
March 28, 2025 02:41
-
-
Save gamemachine/2fe6e1f919f6fa6cf5b20eb942ddc0da to your computer and use it in GitHub Desktop.
Revisions
-
gamemachine revised this gist
Feb 23, 2020 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,6 @@ // For the new DOTS animation. Although you need to use DrawMeshInstanced yourself, Hybrid renderer does not support instanced // props for builtin. Shader "Custom/VertexSkinning" { Properties @@ -19,7 +22,7 @@ Shader "Custom/VertexSkinning" // Upgrade NOTE: excluded shader from OpenGL ES 2.0 because it uses non-square matrices #pragma exclude_renderers gles #pragma surface surf Standard addshadow fullforwardshadows vertex:vert #pragma target 4.5 #pragma only_renderers d3d11 ps4 xboxone vulkan metal switch #pragma multi_compile_instancing -
gamemachine revised this gist
Feb 22, 2020 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,8 +11,9 @@ Shader "Custom/VertexSkinning" } SubShader { Tags { "RenderType"="Opaque" } CGPROGRAM // Upgrade NOTE: excluded shader from OpenGL ES 2.0 because it uses non-square matrices @@ -72,10 +73,9 @@ Shader "Custom/VertexSkinning" } #endif void vert(inout appdata v) { #ifdef SHADER_API_D3D11 UNITY_SETUP_INSTANCE_ID(v); int offset = (int)_SkinMatricesOffset; -
gamemachine created this gist
Feb 21, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,103 @@ Shader "Custom/VertexSkinning" { Properties { _Color ("Color", Color) = (1,1,1,1) _MainTex ("Albedo (RGB)", 2D) = "white" {} _Glossiness ("Smoothness", Range(0,1)) = 0.5 _Metallic ("Metallic", Range(0,1)) = 0.0 _SkinMatricesOffset("Bone Index Offset", Float) = 0 } SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM // Upgrade NOTE: excluded shader from OpenGL ES 2.0 because it uses non-square matrices #pragma exclude_renderers gles #pragma surface surf Standard fullforwardshadows vertex:vert #pragma target 4.5 #pragma only_renderers d3d11 ps4 xboxone vulkan metal switch #pragma multi_compile_instancing sampler2D _MainTex; half _Glossiness; half _Metallic; fixed4 _Color; struct appdata { float4 vertex : POSITION; float3 normal : NORMAL; float4 tangent : TANGENT; float4 weights : BLENDWEIGHTS; uint4 indices : BLENDINDICES; float2 texcoord : TEXCOORD0; float2 texcoord1 : TEXCOORD1; float2 texcoord2 : TEXCOORD2; UNITY_VERTEX_INPUT_INSTANCE_ID }; struct Input { float2 uv_MainTex; }; UNITY_INSTANCING_BUFFER_START(Props) UNITY_DEFINE_INSTANCED_PROP(float, _SkinMatricesOffset_Array) #define _SkinMatricesOffset UNITY_ACCESS_INSTANCED_PROP(Props, _SkinMatricesOffset_Array) UNITY_INSTANCING_BUFFER_END(Props) #ifdef SHADER_API_D3D11 uniform StructuredBuffer<float3x4> _SkinMatrices; void Unity_LinearBlendSkinning_float(uint4 indices, int indexOffset, float4 weights, float3 positionIn, float3 normalIn, float3 tangentIn, out float3 positionOut, out float3 normalOut, out float3 tangentOut) { for (int i = 0; i < 4; i++) { float3x4 skinMatrix = _SkinMatrices[indices[i] + indexOffset]; float3 vtransformed = mul(skinMatrix, float4(positionIn, 1)); float3 ntransformed = mul(skinMatrix, float4(normalIn, 0)); float3 ttransformed = mul(skinMatrix, float4(tangentIn, 0)); positionOut += vtransformed * weights[i]; normalOut += ntransformed * weights[i]; tangentOut += ttransformed * weights[i]; } } #endif void vert(inout appdata v, out Input o) { #ifdef SHADER_API_D3D11 UNITY_INITIALIZE_OUTPUT(Input, o); UNITY_SETUP_INSTANCE_ID(v); int offset = (int)_SkinMatricesOffset; float3 positionOut = 0; float3 normalOut = 0; float3 tangentOut = 0; Unity_LinearBlendSkinning_float(v.indices, offset, v.weights, v.vertex.xyz, v.normal, v.tangent.xyz, positionOut, normalOut, tangentOut); v.vertex = float4(positionOut.xyz, v.vertex.w); v.normal = normalOut; v.tangent = float4(tangentOut.xyz, v.tangent.w); #endif } void surf (Input IN, inout SurfaceOutputStandard o) { fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; o.Albedo = c.rgb; o.Metallic = _Metallic; o.Smoothness = _Glossiness; o.Alpha = c.a; } ENDCG } FallBack "Diffuse" }