Featured Article

glsl How to Properly Blend Colors Across Two Triangles and Remove Seamless Transitions

Ethan Aug 04, 2026

Overview of Glsl How To Properly Blend Colors Across Two Triangles And Remove

glsl How to properly blend colors across two triangles and remove
glsl How to properly blend colors across two triangles and remove

Given the same four colors and the same size rectangle, is there a way to render this so the edge between the two triangles isn't so apparent? Maybe more vertices, or a different blending function? I'm not sure exactly what the colors should be at each pixel; I just want to know how to get rid of the diagonal smear.

Premium
Premium

I'm drawing two triangles : the bottom left, and the top right. I think I would get similar results using OpenGL instead of WebGL. Given the same four colors and the same size rectangle, is there a way to render this so the edge between the two triangles isn't so apparent? Maybe more vertices, or a different blending function?

Key Details About Glsl How To Properly Blend Colors Across Two Triangles And Remove

How To Use A Blending Pencil
How To Use A Blending Pencil

The four vertices were assigned red, green, blue and white colours as vertex attributes and the fragment shader had those colours interpolated across the triangles as expected. This leads to the ugly visual artefact on the diagonal where the two triangles meet.

As I understand it, the interpolation will only be happening across each triangle , and so where the two triangles meet the interpolation doesn't cross the boundary. How could you, generally in any rendering api, have the colours smoothly interpolated over all four corners for a nice colour wheel affect without having this hard line?

Smooth Gradient Background Blending Colors
Smooth Gradient Background Blending Colors

Color Mixing

Learn to use the mix function for color blending and understand the concept and application of linear interpolation. To blend between two colors you don't need to do the math yourself — GLSL has mix.

The demo shows all blend modes switchable via a drop down. For this, there is an additional 'all' glsl function that can be required to import all blend mode functions at once and specify which one to use via an integer.

Seamless blending of colors creates gentle gradients transitioning
Seamless blending of colors creates gentle gradients transitioning

Blend Mode Reference

This page is a complete reference for all 25 blend modes implemented in glsl - blend . For each mode it records the integer constant, require path, exported GLSL function name, the corresponding modes.js key, the per-channel formula, and a brief description of the visual effect.

The demo shows all blend modes switchable via a drop down. For this, there is an additional 'all' glsl function that can be required to import all blend mode functions at once and specify which one to use via an integer.

Smooth Gradient Background Blending Colors
Smooth Gradient Background Blending Colors

Key Details About Glsl How To Properly Blend Colors Across Two Triangles And Remove

Blending Advanced-OpenGL/Blending Blending in OpenGL is commonly known as the technique to implement transparency within objects. Transparency is all about objects (or parts of them) not having a solid color , but having a combination of colors from the object itself and any other object behind it with varying intensity. A colored glass window is a transparent object; the glass has a color of ...

Color Palette Blending Gradients Stock Illustrations 2 093 Color
Color Palette Blending Gradients Stock Illustrations 2 093 Color
How To Color Gradient With Colored Pencil
How To Color Gradient With Colored Pencil
colorful set of vibrant gradients Download Free Vector Art Stock
colorful set of vibrant gradients Download Free Vector Art Stock
Smooth Gradient Background Blending Colors
Smooth Gradient Background Blending Colors
What Is A Gradient In Color
What Is A Gradient In Color
Premium
Premium
Smooth Gradient Background Blending Colors
Smooth Gradient Background Blending Colors
Smooth Gradient Background Blending Colors
Smooth Gradient Background Blending Colors