yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
2c2294d33
master
1#version 460 2#extension GL_EXT_ray_tracing : require 3layout (row_major )uniform ; 4layout (row_major )buffer ; 5layout (binding = 0 ) 6uniform texture2D samplerPosition_0 ; 7 8layout (binding = 2 ) 9uniform sampler sampler_0 ; 10 11layout (binding = 1 ) 12uniform texture2D samplerNormal_0 ; 13 14struct Light_0 15{ 16vec4 position_0 ; 17vec4 color_0 ; 18}; 19 20struct Uniforms_0 21{ 22Light_0 light_0 ; 23vec4 viewPos_0 ; 24mat4x4 view_0 ; 25mat4x4 model_0 ; 26}; 27 28layout (binding = 3 ) 29layout (std140 )uniform _S1 30{ 31Light_0 light_0 ; 32vec4 viewPos_0 ; 33mat4x4 view_0 ; 34mat4x4 model_0 ; 35}ubo_0 ; 36layout (binding = 5 ) 37uniform accelerationStructureEXT as_0 ; 38 39layout (rgba32f ) 40layout (binding = 4 ) 41uniform image2D outputImage_0 ; 42 43struct ReflectionRay_0 44{ 45float color_1 ; 46}; 47 48layout (location = 0 ) 49rayPayloadEXT 50ReflectionRay_0 p_0 ; 51 52struct ShadowRay_0 53{ 54float hitDistance_0 ; 55}; 56 57layout (location = 1 ) 58rayPayloadEXT 59ShadowRay_0 p_1 ; 60 61struct RayDesc_0 62{ 63vec3 Origin_0 ; 64float TMin_0 ; 65vec3 Direction_0 ; 66float TMax_0 ; 67}; 68 69void TraceRay_0 (accelerationStructureEXT AccelerationStructure_0 ,uint RayFlags_0 ,uint InstanceInclusionMask_0 ,uint RayContributionToHitGroupIndex_0 ,uint MultiplierForGeometryContributionToHitGroupIndex_0 ,uint MissShaderIndex_0 ,RayDesc_0 Ray_0 ,inout ShadowRay_0 Payload_0 ) 70{ 71p_1 = Payload_0 ; 72traceRayEXT (AccelerationStructure_0 ,RayFlags_0 ,InstanceInclusionMask_0 ,RayContributionToHitGroupIndex_0 ,MultiplierForGeometryContributionToHitGroupIndex_0 ,MissShaderIndex_0 ,Ray_0 .Origin_0 ,Ray_0 .TMin_0 ,Ray_0 .Direction_0 ,Ray_0 .TMax_0 , (1 )); 73Payload_0 = p_1 ; 74return ; 75} 76 77void TraceRay_1 (accelerationStructureEXT AccelerationStructure_1 ,uint RayFlags_1 ,uint InstanceInclusionMask_1 ,uint RayContributionToHitGroupIndex_1 ,uint MultiplierForGeometryContributionToHitGroupIndex_1 ,uint MissShaderIndex_1 ,RayDesc_0 Ray_1 ,inout ReflectionRay_0 Payload_1 ) 78{ 79p_0 = Payload_1 ; 80traceRayEXT (AccelerationStructure_1 ,RayFlags_1 ,InstanceInclusionMask_1 ,RayContributionToHitGroupIndex_1 ,MultiplierForGeometryContributionToHitGroupIndex_1 ,MissShaderIndex_1 ,Ray_1 .Origin_0 ,Ray_1 .TMin_0 ,Ray_1 .Direction_0 ,Ray_1 .TMax_0 , (0 )); 81Payload_1 = p_0 ; 82return ; 83} 84 85float saturate_0 (float x_0 ) 86{ 87return clamp (x_0 ,0.0 ,1.0 ); 88} 89 90void main () 91{ 92uvec3 _S2 = ((gl_LaunchIDEXT )); 93float _S3 = float (_S2 .x )+ 0.5 ; 94uvec3 _S4 = ((gl_LaunchSizeEXT )); 95float _S5 = _S3 /float (_S4 .x ); 96uvec3 _S6 = ((gl_LaunchIDEXT )); 97float _S7 = float (_S6 .y )+ 0.5 ; 98uvec3 _S8 = ((gl_LaunchSizeEXT )); 99vec2 inUV_0 = vec2 (_S5 ,_S7 /float (_S8 .y )); 100vec3 P_0 = (texture (sampler2D (samplerPosition_0 ,sampler_0 ), (inUV_0 ))).xyz ; 101vec3 N_0 = (texture (sampler2D (samplerNormal_0 ,sampler_0 ), (inUV_0 ))).xyz * 2.0 - 1.0 ; 102vec3 lightDelta_0 = ubo_0 .light_0 .position_0 .xyz - P_0 ; 103float lightDist_0 = length (lightDelta_0 ); 104vec3 L_0 = normalize (lightDelta_0 ); 105float _S9 = 1.0 / (lightDist_0 * lightDist_0 ); 106RayDesc_0 ray_0 ; 107ray_0 .Origin_0 = P_0 ; 108ray_0 .TMin_0 = 0.00000099999999747524 ; 109ray_0 .Direction_0 = lightDelta_0 ; 110ray_0 .TMax_0 = lightDist_0 ; 111ShadowRay_0 shadowRay_0 ; 112shadowRay_0 .hitDistance_0 = 0.0 ; 113TraceRay_0 (as_0 ,1U ,255U ,0U ,0U ,2U ,ray_0 ,shadowRay_0 ); 114float atten_0 ; 115if (shadowRay_0 .hitDistance_0 < lightDist_0 ) 116 { 117atten_0 = 0.0 ; 118 } 119else 120 { 121atten_0 = _S9 ; 122 } 123vec3 color_2 = ubo_0 .light_0 .color_0 .xyz * saturate_0 (dot (N_0 ,L_0 ))* atten_0 ; 124ReflectionRay_0 reflectionRay_0 ; 125TraceRay_1 (as_0 ,1U ,255U ,0U ,0U ,2U ,ray_0 ,reflectionRay_0 ); 126vec3 color_3 = color_2 + reflectionRay_0 .color_1 ; 127uvec3 _S10 = ((gl_LaunchIDEXT )); 128imageStore ((outputImage_0 ),ivec2 ((uvec2 (ivec2 (_S10 .xy )))),vec4 (color_3 ,1.0 )); 129return ; 130} 131