# Disabling color blending of a shape in P3D

**URL:** <https://discourse.processing.org/t/disabling-color-blending-of-a-shape-in-p3d/33779>\
**Category:** Coding Questions\
**Created:** [November 27, 2021, 1:08am UTC](https://discourse.processing.org/t/disabling-color-blending-of-a-shape-in-p3d/33779 "2021-11-27T01:08:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lurion](https://avatars.discourse-cdn.com/v4/letter/l/ad7895/32.png) [@Lurion](https://discourse.processing.org/u/Lurion)\
**Post date:** [November 27, 2021, 1:08am UTC](https://discourse.processing.org/t/disabling-color-blending-of-a-shape-in-p3d/33779/1 "2021-11-27T01:08:23Z")

</div>

I got a simple TRIANGLE\_STRIP shape with 3 vertexs. I need to have each triangle with only one solid color, but Processing is blending the colors when I’m on P3d (it works fine on P2D).

How can I disable it?

```auto
void setup() {
  size(400, 400, P3D);

  fill(255, 0, 0);
  beginShape(TRIANGLE_STRIP);
  vertex(120, 300);
  vertex(160, 80);
  vertex(200, 300);

  fill(0, 0, 255);

  vertex(240, 80);

  endShape();
}

```

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/d/d2bfcd9c82f47d8f5a2832b7e84cf9fe92fec5ba.png)

---

<div class="post-metadata">

**Author:** ![hamoid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hamoid/32/58_2.png) [@hamoid](https://discourse.processing.org/u/hamoid)\
**Post date:** [November 27, 2021, 12:49pm UTC](https://discourse.processing.org/t/disabling-color-blending-of-a-shape-in-p3d/33779/2 "2021-11-27T12:49:02Z")

</div>

Hi! Welcome to the forum 🙂

I haven’t tried this, but maybe using the `flat` keywoard in front of the `varying` used to pass the color from the vertex shader to the fragment shader?

> <https://stackoverflow.com/questions/27581271/flat-qualifier-in-glsl>

If that works, you could tweak the [vert](https://github.com/processing/processing/blob/master/core/src/processing/opengl/shaders/ColorVert.glsl) and [frag](https://github.com/processing/processing/blob/master/core/src/processing/opengl/shaders/ColorFrag.glsl) shaders, and write `flat` in front of the line that starts with `varying` in each file, then load and enable the shader, and draw your shapes.

But it’s possible that this only works in other versions of opengl.

But why do that? 🙂

---

<div class="post-metadata">

**Author:** ![Lurion](https://avatars.discourse-cdn.com/v4/letter/l/ad7895/32.png) [@Lurion](https://discourse.processing.org/u/Lurion)\
**Post date:** [November 27, 2021, 1:59pm UTC](https://discourse.processing.org/t/disabling-color-blending-of-a-shape-in-p3d/33779/3 "2021-11-27T13:59:19Z")

</div>

Hey, thank you for answering me, but I really didn’t understand how to do that in Processing.

---

<div class="post-metadata">

**Author:** ![hamoid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hamoid/32/58_2.png) [@hamoid](https://discourse.processing.org/u/hamoid)\
**Post date:** [November 27, 2021, 6:11pm UTC](https://discourse.processing.org/t/disabling-color-blending-of-a-shape-in-p3d/33779/4 "2021-11-27T18:11:03Z")

</div>

Yeah, it’s a bit advanced.

You will have 3 files:

```auto
yourSketch.pde
data/ColorFrag.glsl
data/ColorVert.glsl

```

## yourSketch.pde

```auto
PShader flatRender;

void setup() {
  size(400, 400, P3D);
  
  flatRender = loadShader("ColorFrag.glsl", "ColorVert.glsl");
  shader(flatRender);

  fill(255, 0, 0);
  beginShape(TRIANGLE_STRIP);
  vertex(120, 300);
  vertex(160, 80);
  vertex(200, 300);
  fill(0, 0, 255);
  vertex(240, 80);
  endShape();
}

```

## ColorFrag.glsl

```glsl
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif

flat varying vec4 vertColor;

void main() {
  gl_FragColor = vertColor;
}

```

## ColorVert.glsl

```glsl
uniform mat4 transformMatrix;

attribute vec4 position;
attribute vec4 color;

flat varying vec4 vertColor;

void main() {
  gl_Position = transformMatrix * position;
    
  vertColor = color;
}

```

 ![a](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/1/16a2677a2e8cd6856b6bbbf2119cb35b8e763f9f.png)

But maybe if you explain why you need this simpler approaches can be found 🙂
