2
0

LineShader.metal 628 B

123456789101112131415161718192021222324252627282930
  1. #include <metal_stdlib>
  2. using namespace metal;
  3. #include "VertexConstants.h"
  4. struct LineVertex
  5. {
  6. float3 iPosition [[attribute(0)]];
  7. uchar4 iColor [[attribute(1)]];
  8. };
  9. struct LineOut
  10. {
  11. float4 oPosition [[position]];
  12. float4 oColor;
  13. };
  14. vertex LineOut LineVertexShader(LineVertex vert [[stage_in]], constant VertexShaderConstantBuffer *constants [[buffer(2)]])
  15. {
  16. LineOut out;
  17. out.oPosition = constants->Projection * constants->View * float4(vert.iPosition, 1.0);
  18. out.oColor = float4(vert.iColor) / 255.0;
  19. return out;
  20. }
  21. fragment float4 LinePixelShader(LineOut in [[stage_in]])
  22. {
  23. return in.oColor;
  24. }