Texture with Alpha

Help
ypuech
2008-11-06
2013-04-25
  • ypuech

    ypuech - 2008-11-06

    Hello,

    I'm having a problem when trying to use a texture with an alpha channel in a shader. The output color and alpha seems wrong. Does anyone succeed in ?

    Here is the shader:

    surface paintedalpha ( string texturename = ""; )
    {
        Ci = Cs;
        Oi = Os;
       
        if (texturename != "")
        {
            Ci = color texture (texturename);
            Oi *= float texture (texturename[3], "fill", 1.0, "width", 0.0);
        }
       
        Ci *= Oi;
    }

    Yannick

     
    • Aasimon

      Aasimon - 2008-11-06

      Last time I checked the code (it was a while ago) it did not support channel selections "texturename[3]" or single channel reads correctly.
      You will need to create a second texture that is gray scale values in an RGB format and use that for your alpha values.

       
    • ypuech

      ypuech - 2008-11-06

      Hi,

      Thanks a lot for the information.

      I'm writting the textures in the code using libtiff. So I can write 2 textures: one RGB texture with the color data and write another RGB texture with the alpha values assigned to R, G or B. Right ?

      So the shader would be:

      surface paintedalpha ( string colortexturename = ""; string alphatexturename = ""; )
      {
          Ci = Cs;
          Oi = Os;
         
          if (texturename != "")
          {
              Ci = color texture (colortexturename);
              color alpha = color texture (alphatexturename);
              Oi *= comp(alpha, 0);
          }
         
          Ci *= Oi;
      }

      Yannick

       
    • Cedric PAILLE

      Cedric PAILLE - 2008-11-06

      Hi,

      It's possible to access R,G,B channels from texture function call (on latest SVN):

      float tex = float texture ("texname")[0-2]

      But not alpha yet.

      Cheers.

       
    • ypuech

      ypuech - 2008-11-07

      Hi Cedric,

      Thanks for the reply.
      It would be very useful to be able to access the alpha in future versions.

      Yannick

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks