brdf_lut.slang

cross platform rendering playground

src/shaders/ibl/brdf_lut.slang

580 B
#include "shared.h"
#include "renderer_types.h"
#include "lib/brdf.slang"

[shader("vertex")]
VtxOut vsMain(u32 vertexID: SV_VertexID) {
    VtxOut o;

    vec2 positions[3] = { vec2(-1.0, -1.0), vec2(3.0, -1.0), vec2(-1.0, 3.0) };

    vec2 pos = positions[vertexID];
    o.clip_pos = vec4(pos, 0.0, 1.0);
    o.uv = pos * 0.5 + 0.5;

    return o;
}

[shader("fragment")]
vec4 fsMain(VtxOut input) : SV_Target0 {
    f32 NdotV = saturate(input.uv.x);
    f32 roughness = saturate(input.uv.y);

    vec2 brdf = IntegrateBRDF(NdotV, roughness);
    return vec4(brdf, 0.0, 1.0);
}