LightingMetaPass.hlsl 956 B

12345678910111213141516171819202122232425262728293031323334
  1. #ifndef SG_LIT_META_INCLUDED
  2. #define SG_LIT_META_INCLUDED
  3. PackedVaryings vert(Attributes input)
  4. {
  5. Varyings output = (Varyings)0;
  6. output = BuildVaryings(input);
  7. PackedVaryings packedOutput = (PackedVaryings)0;
  8. packedOutput = PackVaryings(output);
  9. return packedOutput;
  10. }
  11. half4 frag(PackedVaryings packedInput) : SV_TARGET
  12. {
  13. Varyings unpacked = UnpackVaryings(packedInput);
  14. UNITY_SETUP_INSTANCE_ID(unpacked);
  15. SurfaceDescription surfaceDescription = BuildSurfaceDescription(unpacked);
  16. #if _ALPHATEST_ON
  17. clip(surfaceDescription.Alpha - surfaceDescription.AlphaClipThreshold);
  18. #endif
  19. MetaInput metaInput = (MetaInput)0;
  20. metaInput.Albedo = surfaceDescription.BaseColor;
  21. metaInput.Emission = surfaceDescription.Emission;
  22. #ifdef EDITOR_VISUALIZATION
  23. metaInput.VizUV = unpacked.texCoord1.xy;
  24. metaInput.LightCoord = unpacked.texCoord2;
  25. #endif
  26. return UnityMetaFragment(metaInput);
  27. }
  28. #endif