import "includes/math"; import "includes/structs"; [[vk::binding(0, 0)]] ConstantBuffer _Global; [[vk::binding(1, 0)]] SamplerState _Sampler; [[vk::binding(2, 0)]] TextureCube _Texture; struct Vertex { [[vk::location(0)]] float3 directionWS; } struct Varyings { float4 positionCS : SV_Position; float3 texCoord; } [shader("vertex")] Varyings vertexMain(Vertex vert) { Varyings out; let directionVS = mul(_Global.matrixWStoVS, float4(vert.directionWS, 0.0)).xyz; let directionCS = mul(_Global.matrixVStoCS, float4(directionVS, 0.0)); out.positionCS = float4(directionCS.xy, 0.0, directionCS.w); out.texCoord = -vert.directionWS; return out; } [shader("fragment")] float4 fragmentMain(Varyings frag) : SV_Target { let texel = _Texture.Sample(_Sampler, frag.texCoord); let outgoingRadiance = texel.rgb; let toneMappedLinearColor = toneMapAcesNarkowicz(outgoingRadiance); let toneMappedSrgbColor = linearToSrgbColor(toneMappedLinearColor); return float4(toneMappedSrgbColor, 1.0); }