Guest User

Untitled

a guest
Mar 19th, 2025
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. // slang bug, using 2024.13
  2. // slangc -profile ms_6_5 -entry main test_ms.slang -o test_ms.spv
  3.  
  4. // The shader constant is totally random UNLESS I add some EXTRA code that uses it
  5. // See line 48 - if I add the multiply it works perfectrly
  6.  
  7. struct UniformBufferObject {
  8. float time;
  9. };
  10.  
  11. [[vk::binding(0, 0)]] ConstantBuffer<UniformBufferObject> ubo;
  12.  
  13. struct MeshOutput {
  14. float4 Position : SV_Position;
  15. float3 Color : COLOR;
  16. };
  17.  
  18. [shader("mesh")]
  19. [numthreads(1, 1, 1)]
  20. [outputtopology("triangle")]
  21. void main(uint threadID : SV_GroupIndex, out indices uint3 Triangles[1], out vertices MeshOutput Vertices[3])
  22. {
  23. SetMeshOutputCounts(3, 1);
  24.  
  25. // Define three vertices of a triangle
  26. float2 positions[3] = {
  27. float2( 0.0, 0.5), // Top
  28. float2( 0.5, -0.5), // Right
  29. float2(-0.5, -0.5) // Left
  30. };
  31.  
  32. float3 colors[3] = {
  33. float3(1, 0, 0), // Red
  34. float3(0, 1, 0), // Green
  35. float3(0, 0, 1) // Blue
  36. };
  37.  
  38. // Assign vertex data
  39. for (uint i = 0; i < 3; i++)
  40. {
  41. float t = ubo.time;
  42. float2 p = positions[i];
  43.  
  44. float x = p.x * cos(t) - p.y * sin(t);
  45. float y = p.x * sin(t) + p.y * cos(t);
  46.  
  47. Vertices[i].Position = float4(x, y, 0.0, 1.0);
  48. Vertices[i].Color = colors[i]; // * fmod(t, 1.0); // Comment the fmod in, and it works!
  49. }
  50.  
  51. // Define triangle indices
  52. Triangles[0] = uint3(0, 1, 2);
  53. }
  54.  
  55.  
Advertisement
Add Comment
Please, Sign In to add comment