Advertisement
Zgragselus

Basic metal shader

May 18th, 2022
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. //
  2. // Shaders.metal
  3. // engine
  4. //
  5. // Created by Vilem Otte on 09.05.2022.
  6. //
  7.  
  8. #include <metal_stdlib>
  9. using namespace metal;
  10.  
  11. struct VertexIn {
  12. float3 position;
  13. float4 color;
  14. };
  15.  
  16. struct VertexOut {
  17. float4 position [[ position ]];
  18. float4 color;
  19. };
  20.  
  21. vertex VertexOut basic_vertex_function(const device VertexIn* vertices [[ buffer(0) ]],
  22. uint vertexID [[ vertex_id ]]) {
  23. VertexOut out;
  24. out.position = float4(vertices[vertexID].position, 1.0);
  25. out.color = vertices[vertexID].color;
  26. return out;
  27. }
  28.  
  29. fragment float4 basic_fragment_function(VertexOut in [[ stage_in ]]) {
  30. return in.color;
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement