Checkerboard overlay with alpha


#1

Howdy,

I’m using NVIDIA’s fabulous Optix raytracer torender my scene

In Cinder, I’m pasting the rendered pixels into a Surface, which is fed into Texture that’s applied to a full screen solid rectangle. I’d like to overlay a semi-transparent checerkboard pattern onto the render but the alpha does not seem to be working … all I get is a solid checkerboard completely blocking the render. Can someone tell me what I’m doing wrong here.

Thanks!

void renderInCinder ()
{
Pixels pixels = renderer->getFrontBuffer();
raytraceImage = ci::Surface(&pixels[0], windowSize.x, windowSize.y, windowSize.x * 4, ci::SurfaceChannelOrder::RGBA);

ci::ip::flipVertical(&raytraceImage);
ci::ip::checkerboard(&raytraceImage, windowBounds, 64, ci::ColorA8u(120, 220, 120, 128), ci::ColorA8u(180, 180, 180,128));
raytraceTexture->update(raytraceImage);
	
ci::gl::setMatricesWindow(windowSize);

ci::gl::ScopedGlslProg shader(raytraceShader);
raytraceShader->uniform("tex0", 0);

ci::gl::ScopedTextureBind tex0(raytraceTexture);

ci::gl::drawSolidRect(windowBounds);
}

#2

have you enabled alpha blending?

gl::ScopedBlendAlpha blend
or
gl::enableAlphaBlending()


#3

I didn’t have alpha blending enabled. But when I do, it has no effect.

Thanks for the help.


#4

What does raytraceShader look like? Is it ignoring the alpha value of tex0 and explicitly setting the alpha to 1?
i.e OutColor = vec4 ( texture ( tex0, UV ).rgb, 1.0 ) as opposed to texture ( tex0, UV )?

Also, are you sure checkerboard is an additive function? Is it possibly just replacing your entire raytraceImage contents?


#5

Also, are you sure checkerboard is an additive function? Is it possibly just replacing your entire raytraceImage contents?

D’uh. That was it. I just assumed because it took an alpha channel that it would blend the checkerboard onto the underlying surface. Instead, it was just replacing it.

Thanks for the help!