Update samplers in shaders

This commit is contained in:
Kovid Goyal 2026-08-03 16:52:37 +05:30
parent 716c9c0ecf
commit cdbd9ed9dd
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 10 additions and 3 deletions

View file

@ -57,12 +57,12 @@ float3 linear2srgb(float3 x) { // vector
return lerp(lower, upper, step(float3(0.0031308f), x));
}
uniform Sampler2D backbuffer;
uniform Sampler2D backbuffer, a, b, persist;
public float4 pipeline_fragment_main(float2 backbuffer_pos, int group) {
float4 color = backbuffer.Sample(backbuffer_pos); // pre multiplied linear RGB
color = float4(color.rgb / color.a, color.a); // un pre multiplied color passed through pipeline
KittyTextures t = {backbuffer, backbuffer_pos};
KittyTextures t = {backbuffer, a, b, persist, backbuffer_pos};
// PIPELINE
return vec4_premul(color.rgb, color.a);
}

View file

@ -13,8 +13,15 @@ public struct KittyCustomShaderData {
public struct KittyTextures {
// the buffer containing the original rendered pixels from kitty's own rendering. This will
// be updated with the output color only after all custom shaders in the chain have run
// be updated with the output color only after all custom shaders in this group have run
public Sampler2D backbuffer;
// The following are named textures that can be sampled from in custom
// shaders. The persist texture will persist across frames, anything
// written to it in render number N can be read from it in subsequent
// renders.
public Sampler2D a;
public Sampler2D b;
public Sampler2D persist;
public float2 pos; // the position of this pixel in the textures
}