# Checkerboard overlay with alpha

**URL:** <https://discourse.libcinder.org/t/checkerboard-overlay-with-alpha/1036>\
**Category:** Using Cinder\
**Created:** [January 30, 2018, 11:59pm UTC](https://discourse.libcinder.org/t/checkerboard-overlay-with-alpha/1036 "2018-01-30T23:59:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SteveH](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@SteveH](https://discourse.libcinder.org/u/SteveH)\
**Post date:** [January 30, 2018, 11:59pm UTC](https://discourse.libcinder.org/t/checkerboard-overlay-with-alpha/1036/1 "2018-01-30T23:59:45Z")

</div>

Howdy,

I’m using NVIDIA’s fabulous Optix raytracer to[render my scene](https://youtu.be/TInYdyitVUo)

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);
}
```

---

<div class="post-metadata">

**Author:** ![lithium](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/lithium/32/38_2.png) [@lithium](https://discourse.libcinder.org/u/lithium)\
**Post date:** [January 31, 2018, 8:32am UTC](https://discourse.libcinder.org/t/checkerboard-overlay-with-alpha/1036/2 "2018-01-31T08:32:11Z")

</div>

have you enabled alpha blending?

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

---

<div class="post-metadata">

**Author:** ![SteveH](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@SteveH](https://discourse.libcinder.org/u/SteveH)\
**Post date:** [January 31, 2018, 1:30pm UTC](https://discourse.libcinder.org/t/checkerboard-overlay-with-alpha/1036/3 "2018-01-31T13:30:31Z")

</div>

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

Thanks for the help.

---

<div class="post-metadata">

**Author:** ![lithium](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/lithium/32/38_2.png) [@lithium](https://discourse.libcinder.org/u/lithium)\
**Post date:** [January 31, 2018, 1:46pm UTC](https://discourse.libcinder.org/t/checkerboard-overlay-with-alpha/1036/4 "2018-01-31T13:46:57Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![SteveH](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@SteveH](https://discourse.libcinder.org/u/SteveH)\
**Post date:** [February 1, 2018, 1:45pm UTC](https://discourse.libcinder.org/t/checkerboard-overlay-with-alpha/1036/5 "2018-02-01T13:45:01Z")

</div>

> 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!
