Jump to content

Color modified by fill tool


vic
 Share

Recommended Posts

Hi,

 

I'm trying to follow advice given in another thread to preserve the alpha and color information in my images (by saving as PDN instead of PNG), however I'm still having an issue. The steps are :

 

  • Create an image
  • Use fill tool in overwrite mode with color C0C0C0, alpha = 0
  • Use the color picker on a pixel : the color is 000000

Is it the intended behavior?

Link to comment
Share on other sites

Sorry but you can not expect that pixel operations with an alpha value will keep the color. Some operations may some may not. This means the color is undefined.

 

Quite often if the alpha value is zero then there is a shortcut in the code to improve the speed of the operation. This is what a lot of effect plugins are doing.

 

If the destination pixel of an argb pixel does not support alpha then you have to render the pixel against a solid color which means that you will get the solid color if the alpha value is zero. It is not ok just to remove the alpha value.

 

I guess Rick tried to say that as long as you are working with a pdn file the color of such a pixel is not of interest.

midoras signature.gif

Link to comment
Share on other sites

If you have my plugin pack installed, you can accomplish what you want this way:

1. Select the area you want to fill

2. Select the color C0C0C0, alpha > 0 (255 for example)

3. Press Backspace key to fill the selected area

4. Run the Adjustments > Transparency effect and move the slider all the way to transparent

Result: your selected area is filled with color C0C0C0, alpha = 0.

Just don't expect the color information to remain once you save the file. After all, alpha 0 means the color information is undefined. Better if you can keep the alpha level at 1 instead of 0.

Click to play:
j.pngs.pngd.pnga.pngp.png
Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game

Link to comment
Share on other sites

The problem is that I need that color information in the file. OpenGL textures need this for proper rendering. I already tried to set alpha to 1, but the colors are still modified, for example FF9F5B with alpha 1 becomes FFFF00.

 

Oh well, I guess I can't use Paint.NET for my work.

Link to comment
Share on other sites

But then there must be a bug in your OpenGL implementation. If alpha is zero each renderer has to take 0% of the color.

See, that's the thing. OpenGL doesn't use the Alpha channel as alpha. I believe they use it as a height map... or some such non-standard usage.

Click to play:
j.pngs.pngd.pnga.pngp.png
Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game

Link to comment
Share on other sites

I'm using the images as normal textures. The way OpenGL works is that you upload a texture image to a texture unit, which is then used to map between the coordinates related to the projection of the 3D model on the screen and a color. The coordinates are floating point numbers and they rarely fall on exact pixel centers, so interpolation is used.

 

For example, let's say that the texture is 2x1 pixels, left pixel is RGBA [0.5,0.5,0.5,0], right pixel is [0.5,0.5,0.5,1], and I need to know the color at coordinates (0.5, 0.5) (the center of the image). Interpolation will be done and result in [0.5,0.5,0.5,0.5]. Now if instead left pixel is [0,0,0,0], as Paint.NET would create it, the interpolated intermediary pixel becomes [0.25,0.25,0.25,0.5]. Even though the image looks the same at a 1/1 ratio, when interpolating it is different. The color information is needed here.

 

Strangely GPUs have no concept of color, blending, or even geometry. They are just big number crunchers. Thanks to this discussion I think I now know how to fix the problem (by premultiplying RGB with alpha after having loaded the images).

 

One last thing: in my example in my previous post, if I set the alpha to 1, shouldn't the color information be preserved?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...