Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // slang bug, using 2024.13
- // slangc -profile ms_6_5 -entry main test_ms.slang -o test_ms.spv
- // The shader constant is totally random UNLESS I add some EXTRA code that uses it
- // See line 48 - if I add the multiply it works perfectrly
- struct UniformBufferObject {
- float time;
- };
- [[vk::binding(0, 0)]] ConstantBuffer<UniformBufferObject> ubo;
- struct MeshOutput {
- float4 Position : SV_Position;
- float3 Color : COLOR;
- };
- [shader("mesh")]
- [numthreads(1, 1, 1)]
- [outputtopology("triangle")]
- void main(uint threadID : SV_GroupIndex, out indices uint3 Triangles[1], out vertices MeshOutput Vertices[3])
- {
- SetMeshOutputCounts(3, 1);
- // Define three vertices of a triangle
- float2 positions[3] = {
- float2( 0.0, 0.5), // Top
- float2( 0.5, -0.5), // Right
- float2(-0.5, -0.5) // Left
- };
- float3 colors[3] = {
- float3(1, 0, 0), // Red
- float3(0, 1, 0), // Green
- float3(0, 0, 1) // Blue
- };
- // Assign vertex data
- for (uint i = 0; i < 3; i++)
- {
- float t = ubo.time;
- float2 p = positions[i];
- float x = p.x * cos(t) - p.y * sin(t);
- float y = p.x * sin(t) + p.y * cos(t);
- Vertices[i].Position = float4(x, y, 0.0, 1.0);
- Vertices[i].Color = colors[i]; // * fmod(t, 1.0); // Comment the fmod in, and it works!
- }
- // Define triangle indices
- Triangles[0] = uint3(0, 1, 2);
- }
Advertisement
Add Comment
Please, Sign In to add comment