Jump to content

Illnab1024

Members
  • Posts

    1,178
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Illnab1024

  1. The best way to achieve the effect is with material settings; reflectivity, specular settings, etc. If you're looking for high-res, I suggest adding a bit of noise and doing brightness/contrast, and for any hemming you might have, you're likely going to have to draw a good bit of it yourself.

    EDIT: If you can't do lighting settings, then draw some highlights n a new layer, blur the layer, and maybe lower the layer opacity a bit. Mess around, see what you can get.

  2. Hmm.... A prototype for codelab, right here (Really, dirty and hacky)

    int Amount1=120; //Base Hue green=120, blue=240, reds aren't supported very well
    int Amount2=50; //Hue Tolerance
    int Amount3=16; //Value tolerance
    
    const double HSV_UNDEFINED = -999.0;
    
    void Render(Surface dst, Surface src, Rectangle rect)
    {
       float BaseHue = Amount1;
       float HueTol = Amount2;
       float VTol = (float)Amount3;
       double H = 0, S = 0, V = 0;
       VTol /= 100f;
       for(int y = rect.Top; y < rect.Bottom; y++)
       {
    
           for (int x = rect.Left; x < rect.Right; x++)
           {
               ColorBgra col = src[x, y];
    
               EvanRGBtoHSV(col.R, col.G, col.B, ref H, ref S, ref V);
               if (V > VTol) {
                   if (H > (BaseHue-HueTol+3)&&H > (BaseHue+HueTol-3)||H < (BaseHue-HueTol+3)&&H < (BaseHue-HueTol-3)) col.A=255;
                   else col.A = 0;
                   }
               dst[x, y] = col;
               }
    
           }
    
       }
    
    public void EvanRGBtoHSV(int R, int G, int B, ref double outH, ref double outS, ref double outV)
    {
    // R, G, and B must range from 0 to 255
    // Ouput value ranges:
    // outH - 0.0 to 360.0
    // outS - 0.0 to 1.0
    // outV - 0.0 to 1.0
    
    double dR = (double)R/255.0;
    double dG = (double)G/255.0;
    double dB = (double)B/255.0;
    double dmaxRGB = EvanMax3(dR, dG, dB);
    double dminRGB = EvanMin3(dR, dG, dB);
    double delta = dmaxRGB - dminRGB;
    
    // Set value
    outV = dmaxRGB;
    
    // Handle special case
    if (dmaxRGB == 0)
    {
    outH = HSV_UNDEFINED;
    outS = 0.0;
    return;
    }
    
    outS = delta/dmaxRGB;
    if (dmaxRGB == dminRGB)
    {
    outH = HSV_UNDEFINED;
    return;
    }
    
    // Finally, compute hue
    if (dR == dmaxRGB)
    {
    outH = (dG-dB)/delta*60.0;
    }
    else if (dG == dmaxRGB)
    {
    outH = (2.0+(dB-dR)/delta)*60.0;
    }
    else //if (dB == dmaxRGB)
    {
    outH = (4.0+(dR-dG)/delta)*60.0;
    }
    
    if (outH < 0)
    {
    outH += 360.0;
    }
    }
    
    public double EvanMax3(double x, double y, double z)
    {
    return (x>y)?((x>z)?x:z)(y>z)?y:z);
    }
    public double EvanMin3(double x, double y, double z)
    {
    return (x(y}
    

    Last 3 functions were made by EvanOlds, best to attribute him.

    Okay, here's an example for the wine glass.

    I took the white background to blue because white is the most difficult color to mask out.

    blueglass.png

    Now, Amount1 = 240, for blue. Amount2 = 40, for good hue range. Amount3 = 56, to catch some of the edges.

    After:

    transglass.png

    The blue is still visible, but it's a prototype. ;)

×
×
  • Create New...