yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
ed9f42361
master
1//TEST:SIMPLE(filecheck=CHECK):-target spirv -entry main -stage fragment -g2 -emit-spirv-directly 2 3#include "shader-utils.slang" 4 5struct VertexOutput 6{ 7 float4 position : SV_Position; 8 float2 texCoord : TEXCOORD0; 9} 10 11[shader("fragment")] 12float4 main(VertexOutput input) : SV_Target 13{ 14 // Create a simple gradient pattern based on texture coordinates 15 float2 uv = input.texCoord; 16 17 // Call function from the included header file 18 float distanceFromCenter = calculateDistanceFromCenter(uv); 19 20 // Use another function from the header for a radial fade effect 21 float radialFade = createRadialFade(uv, 0.7); 22 23 // Create color pattern with both distance effects 24 float4 color = float4( 25 uv.x * (1.0 - distanceFromCenter * 0.5), // Red with subtle distance fade 26 uv.y * radialFade, // Green with smooth radial fade 27 uv.x * uv.y, // Blue as product of coordinates 28 1.0 // Full opacity 29 ); 30 31 return color; 32} 33 34// Verify that DebugCompilationUnit references this main shader file 35// CHECK: [[MAIN_FILE:%[0-9]+]] = OpString "{{.*}}debug-compilation-unit-main-file.slang" 36// CHECK: [[SOURCE_ID:%[0-9]+]] = OpExtInst %void %{{[0-9]+}} DebugSource [[MAIN_FILE]] %{{[0-9]+}} 37// CHECK: OpExtInst %void %{{[0-9]+}} DebugCompilationUnit %uint_{{[0-9]+}} %uint_{{[0-9]+}} [[SOURCE_ID]] %uint_{{[0-9]+}}