turnage/valora

Question: Pixel manipulation and alpha

Closed this issue · 4 comments

Hi!
I don't know if this is where you want to keep discussions, feel free to delete.
I've been implementing Anders Hoff's DOF technique in valora as a starting project, but I can't find any pixel manipulation tools. Is there a way to directly set pixels on the canvas other than a line to 1 pixel away? The main issue I'm running into is that the technique require a very large number of samples at very low alpha, and using alpha values that low (e.g. 0.001) the colour never reaches full brightness. A solution would be to create my own array of brightness values and draw them as pixels.

MVP of low alpha:

use valora::prelude::*;

fn main() -> Result<()> {
    run_fn(Options::from_args(), |_gpu, world, _rng| {
        Ok(move |ctx: Context, canvas: &mut Canvas| {
            canvas.set_color_alpha(LinSrgb::new(1., 1., 1.), 0.001);
            canvas.paint(Filled(ctx.world));
        })
    })
}

Or perhaps this is simply not the intended use case for the framework.
Cheers!

Ahh yes of course a 1 pixel square should be better. The lines seem to do the trick as well though.
I'll give rendering to file a try then, thanks!

I redirected rendering to an intermediate buffer to accumulate alpha before drawing to screen in the linked commit. I think the rest of this issue is covered in #37.