Jump to content

BlindWanderer

Newbies
  • Posts

    3
  • Joined

  • Last visited

Everything posted by BlindWanderer

  1. I realized I can do what I want by using Color Dodge (which also removes the need to negate the mask when generating the base image). How to recover lost alpha channels when you can render on the image onto different color backgrounds 1) Create a new image with two layers. 2) render target with a white background and paste it into the top layer 3) render target with a black background and past it into the background layer 4) duplicate the background layer 5) in the top layer properties change the blending mode to Difference 6) flatten the top layer down onto the middle layer 7) Save a copy of the image as a bmp or png ("Mask.png") it's going to want to auto flatten the image, let it. 8) undo the auto flatten so you have two layers again. 9) in the top layer properties change the blending mode to Color Dodge 10) flatten the image 11) Activate the Alpha Mask effect (in Object sub-menu) 12) Set the alpha mask to your previously saved copy of the image ("Mask.png") and check the "Invert Mask" checkbox. You are done! You have just restored the alpha channel to your target image. Caveats: You may notice that the pixels are a one or two shades off, this is due to rounding and can't be avoided. Math: In case anyone is remotely interested in this, here is the math. Alpha = 255 + Black - White; Orig = 255 * Black / Alpha;
  2. Yes it does, it returns zero. INT_DIV is a macro that uses a lookup table, it's actually quiet scary. // i = z * 3; // (x / z) = ((x * masTable) + masTable) >> masTable
  3. For reasons that will become plane I want to be able to divide images. I've looked at the source and it's really easy to add, it requires a few lines of code added to UserBlendOps.Generated.H.cs Why? Recently I wanted to generate an image with an alpha channel from two images. One image is rendered on a black background the other a white background. Determining the alpha channel is easy, you subtract the black image from the white image and invert the result. Once you have the mask to determine the original image you must multiply the black image by 255 and divide it by the mask. Then you just have to apply the alpha to that resulting image. Insert after line 309. #define DIVIDE(A, B, r) \ { \ INT_DIV(((A) * 255), (, r); \ } Insert after line 589. DEFINE_STANDARD_OP(Divide, DIVIDE) I tried to make an effect to do all this but... it crashed x_x
×
×
  • Create New...