0

I work with glsl and try produce result of displaying one image above another. For example, I have two pixels let it be bg(146,108,147,255) and image(252,0,255,46) I need to implement this calculation in the shader and it should give me a result pixel that will be similar to the pixel if we draw one image after another. An image should be above bg. I try to found a formula to calculate it but formulas that I found do not produce the same result with paint.net, GPU, ... rendering. As I know there should be a formula for this calculation

Andriy Mytroshyn
  • 221
  • 1
  • 5
  • 14
  • bg alpha could be in the range [0-1]. I found the following formula: new.RGB = (image.rgb - (1-image.a) * bg.rgb) / image.a for pixel in question(https://stackoverflow.com/questions/746899/how-to-calculate-an-rgb-colour-by-specifying-an-alpha-blending-amount) it is work, but for my it gives some abnormal value – Andriy Mytroshyn Jul 04 '18 at 08:00
  • 1
    GLSL has a built-in function for that: mix(), see https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/mix.xhtml – rpress Jul 05 '18 at 22:21
  • Please add some code about your questions, both GLSL and paint.net code. It will help us to check what the differences are. – James Zhao Jul 06 '18 at 03:14

0 Answers0