SpriteNormalPass.hlsl 919 B

123456789101112131415161718192021
  1. PackedVaryings vert(Attributes input)
  2. {
  3. Varyings output = (Varyings)0;
  4. output = BuildVaryings(input);
  5. PackedVaryings packedOutput = PackVaryings(output);
  6. return packedOutput;
  7. }
  8. half4 frag(PackedVaryings packedInput) : SV_TARGET
  9. {
  10. Varyings unpacked = UnpackVaryings(packedInput);
  11. UNITY_SETUP_INSTANCE_ID(unpacked);
  12. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked);
  13. SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked);
  14. SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs);
  15. float crossSign = (unpacked.tangentWS.w > 0.0 ? 1.0 : -1.0) * GetOddNegativeScale();
  16. float3 bitangent = crossSign * cross(unpacked.normalWS.xyz, unpacked.tangentWS.xyz);
  17. return NormalsRenderingShared(surfaceDescription.Color, surfaceDescription.Normal, unpacked.tangentWS.xyz, bitangent, unpacked.normalWS);
  18. }