Derive Tangent Basis.asset 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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: 78b2425a2284af743826c689403a4924, type: 3}
  13. m_Name: Derive Tangent Basis
  14. m_EditorClassIdentifier:
  15. m_functionInfo: "// Made with Amplify Shader Editor v1.9.1\n// Available at the
  16. Unity Asset Store - http://u3d.as/y3X \n/*ASEBEGIN\nVersion=19100\nNode;AmplifyShaderEditor.WorldNormalVector;10;-821.4876,20.21545;Inherit;False;False;1;0;FLOAT3;0,0,1;False;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3\nNode;AmplifyShaderEditor.FunctionInput;5;-784.8259,164.9036;Inherit;False;UV;2;0;False;1;0;FLOAT2;0,0;False;1;FLOAT2;0\nNode;AmplifyShaderEditor.WorldPosInputsNode;13;-823.4999,-127.2658;Inherit;False;0;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3\nNode;AmplifyShaderEditor.CustomExpressionNode;1;-529.4937,-4.008303;Inherit;False;#if
  17. (SHADER_TARGET >= 45)$float3 dPdx = ddx_fine( WorldPosition )@$float3 dPdy =
  18. ddy_fine( WorldPosition )@$#else$float3 dPdx = ddx( WorldPosition )@$float3 dPdy
  19. = ddy( WorldPosition )@$#endif$$float3 sigmaX = dPdx - dot( dPdx, WorldNormal
  20. ) * WorldNormal@$float3 sigmaY = dPdy - dot( dPdy, WorldNormal ) * WorldNormal@$$float
  21. flip_sign = dot( dPdy, cross( WorldNormal, dPdx ) ) < 0 ? -1 : 1@$$#if (SHADER_TARGET
  22. >= 45)$float2 dSTdx = ddx_fine( UV )@$float2 dSTdy = ddy_fine( UV )@$#else$float2
  23. dSTdx = ddx( UV )@$float2 dSTdy = ddy( UV )@$#endif$$float det = dot( dSTdx,
  24. float2( dSTdy.y, -dSTdy.x ) )@$float sign_det = ( det < 0 ) ? -1 : 1@$$float2
  25. invC0 = sign_det * float2( dSTdy.y, -dSTdx.y )@$$float3 T = sigmaX * invC0.x
  26. + sigmaY * invC0.y@$if ( abs( det ) > 0 ) T = normalize( T )@$$float3 B = ( sign_det
  27. * flip_sign ) * cross( WorldNormal, T )@$$WorldToTangent = float3x3( T, B, WorldNormal
  28. )@$TangentToWorld = transpose( WorldToTangent )@$return@;7;Create;5;True;WorldPosition;FLOAT3;0,0,0;In;;Float;False;True;WorldNormal;FLOAT3;0,0,0;In;;Float;False;True;UV;FLOAT2;0,0;In;;Float;False;True;TangentToWorld;FLOAT3x3;1,0,0,1,1,1,1,0,1;Out;;Float;False;True;WorldToTangent;FLOAT3x3;1,0,0,1,1,1,1,0,1;Out;;Float;False;Derive
  29. Tangent Basis;False;False;0;;False;6;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT2;0,0;False;4;FLOAT3x3;1,0,0,1,1,1,1,0,1;False;5;FLOAT3x3;1,0,0,1,1,1,1,0,1;False;3;FLOAT3;0;FLOAT3x3;5;FLOAT3x3;6\nNode;AmplifyShaderEditor.FunctionOutput;0;-147.9617,-6.546963;Inherit;False;True;-1;Tangent
  30. To World;0;False;1;0;FLOAT3x3;0,0,0,1,1,1,1,0,1;False;1;FLOAT3x3;0\nNode;AmplifyShaderEditor.FunctionOutput;6;-143.2227,68.66327;Inherit;False;False;-1;World
  31. To Tangent;1;False;1;0;FLOAT3x3;0,0,0,1,1,1,1,0,1;False;1;FLOAT3x3;0\nWireConnection;1;1;13;0\nWireConnection;1;2;10;0\nWireConnection;1;3;5;0\nWireConnection;0;0;1;5\nWireConnection;6;0;1;6\nASEEND*/\n//CHKSM=5290087D1BB63169DE2BC6B31F3E508BBF2F0784"
  32. m_functionName:
  33. m_description: 'This function derives a per-pixel tangent basis for a specific set
  34. of UV coordinates. The built-in tangent basis is based on UV0. This function allows
  35. normal mapping for UV1 or any other UV set, including runtime generated.
  36. Typical usage case:
  37. Blending additional normal mapped layers that require non-UV0 coordinates.
  38. Based on "Surface Gradient Based Bump Mapping Framework" by Morten S. Mikkelsen'
  39. m_additionalIncludes:
  40. m_additionalIncludes: []
  41. m_outsideIncludes: []
  42. m_additionalPragmas:
  43. m_additionalPragmas: []
  44. m_outsidePragmas: []
  45. m_additionalDirectives:
  46. m_validData: 0
  47. m_isDirty: 0
  48. m_moduleName: ' Additional Directives'
  49. m_independentModule: 1
  50. m_customEdited: 0
  51. m_additionalDirectives: []
  52. m_shaderFunctionDirectives: []
  53. m_nativeDirectives: []
  54. m_nativeDirectivesIndex: -1
  55. m_nativeDirectivesFoldout: 0
  56. m_directivesSaveItems: []
  57. m_nodeCategory: 3
  58. m_headerStyle: 1
  59. m_headerColor: {r: 1, g: 0.4, b: 0, a: 1}
  60. m_customNodeCategory:
  61. m_previewPosition: 0
  62. m_hidden: 0
  63. m_url: