Migrate GLSL to Slang, text shader

This commit is contained in:
2026-09-12 23:48:30 +02:00
parent 8d5a2db342
commit f7576a941d
30 changed files with 868 additions and 632 deletions

View File

@@ -0,0 +1,38 @@
import "includes/math";
import "includes/structs";
[[vk::binding(0, 0)]] ConstantBuffer<GlobalUniforms> _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);
}