PIXON_P Alpha blending
|
05-06-2017, 05:35 PM
Post: #1
|
|||
|
|||
PIXON_P Alpha blending
Hello,
I have a doubt on how the alpha blending algorithm works. Basically, I want to draw a black screen, and then I want to draw pixels so that the first time I draw a given pixel, it's just barely visible, then after drawing over it more and more, it gets more and more white. But I noticed that if I do for example: PIXON_P(X,Y,#F0FFFFFFh) (which is a pure white pixel with an alpha channel of #F0h), I don't get what I expect. What I get is that after very few "overlaps" (around 10) the pixel stops getting brighter, and stays at a rather dark grey. If I modify the alpha value, to i.e. #F5h, the pixels still saturate after about 10 overlaps, but to a very dark grey instead. I was expecting that, since I'm drawing a partially transparent pure white pixel, the "saturated" color would be pure white, and that it would take more or less overlaps to get there depending on the transparency level... What am I doing wrong? How can I get the result I need? Ideally, I'd like to have the pixels get a (1,1,1) color after the first drawing, and get to (255,255,255) after n overlaps, with n variable but ideally 255... Thank you, Cristian |
|||
05-07-2017, 11:22 AM
Post: #2
|
|||
|
|||
RE: PIXON_P Alpha blending
You do not have use error, it is normal that the color does not arrive completely to the color supuerpuesto, not even has much presicion by the definition of 16 bits by color.
What you can do is to swap, if you want the final color to be white, then paint white and it is the black who will change alpha, an inverse process. Or just after finishing with the overlay loop, intentionally painting white with the pixon, saves problems in this way. Viga C | TD | FB |
|||
05-07-2017, 01:28 PM
Post: #3
|
|||
|
|||
RE: PIXON_P Alpha blending
Thank you for your reply. Unfortunately, I don't think I can use your method, because I don't know in advance what pixels need to be turned on, and with what color. Basically I want to make a 2D graph of a chaotic formula, so I calculate the orbits (where the result falls for every iteration) and I want to display where it falls, and also how many times it fell there; so I keep iterating, and I wanted to see, for every pixel of the display, if (and how often) the formula landed there.
If the alpha is unusable for this (but why? How does Alpha work exactly?) the only other solution I can think of, is to create a matrix of integers, as big as the display, and then add 1 to a cell every time the orbit falls there. And then, at the end, I can draw every pixel with a color proportional to the value of the corresponding matrix cell. But this means creating a very large matrix (which I don't know how to use); and furthermore, I can not see the progress until the end of the iterating loop. And... it will be slower. Cristian |
|||
05-07-2017, 02:27 PM
Post: #4
|
|||
|
|||
RE: PIXON_P Alpha blending
Why not just use a color gradient instead of alpha blending?
Graph 3D | QPI | SolveSys |
|||
05-07-2017, 03:41 PM
Post: #5
|
|||
|
|||
RE: PIXON_P Alpha blending
You mean simply reading the color of the pixel, increasing the value, and writing it back? That works (sort of), but it gets MUCH slower, because for every single iteration I have to run a read command on the screen, and a write command. And I run many thousands of iterations. The rendering time almost doubles, with respect to the alpha blending (where I only have one graphic command per iteration)...
Cristian |
|||
05-08-2017, 05:21 AM
Post: #6
|
|||
|
|||
RE: PIXON_P Alpha blending
Hello,
Han is correct in saying that doing repeat alpha will "max out" following the sequence Un+1=((256-a)*Un+a*c2)/256, which has an asymptotic value which is not 255... Depending on the number of drawn pixels, it might be better to create a matrix of numbers that you increment "off screen", and that you then display. The fastest, assuming that you do not get over 65536 iterations per points might be to use a string... Create a string of size 320*240, fill it with 0s str(i):=0; and then inc the item of interest on each iteration str(y*320+x+1):= str(y*320+x+1)+1; then display the content of the string. Cyrille Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP. |
|||
09-12-2017, 09:33 AM
Post: #7
|
|||
|
|||
RE: PIXON_P Alpha blending
Also having done a lot of work with video in the past, be aware that our brains don't view alpha with the same linear gradient that the values we put in the argb values. i.e. 50% alpha might appear visually to be 50% mixed colors, but then 70% numerically might appear visually (to our eye-brain connection) to be 95%!
Just be aware of that. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)