You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
786 B

  1. Shader "Hidden/VertexBinormalNode"
  2. {
  3. SubShader
  4. {
  5. Pass
  6. {
  7. CGPROGRAM
  8. #pragma vertex vert_img
  9. #pragma fragment frag
  10. #include "UnityCG.cginc"
  11. float4 frag( v2f_img i ) : SV_Target
  12. {
  13. float2 xy = 2 * i.uv - 1;
  14. float z = -sqrt(1-saturate(dot(xy,xy)));
  15. float3 vertexPos = float3(xy, z);
  16. float3 normal = normalize(vertexPos);
  17. float3 worldNormal = UnityObjectToWorldNormal(normal);
  18. float3 tangent = normalize(float3( -z, xy.y*0.01, xy.x ));
  19. float3 worldPos = mul(unity_ObjectToWorld, vertexPos).xyz;
  20. float3 worldTangent = UnityObjectToWorldDir(tangent);
  21. float tangentSign = -1;
  22. float3 worldBinormal = normalize( cross(worldNormal, worldTangent) * tangentSign);
  23. return float4(worldBinormal, 1);
  24. }
  25. ENDCG
  26. }
  27. }
  28. }