Cewein / nerv_pathtracer

a pathtracer with physically based rendering in mind
MIT License
27 stars 1 forks source link

cannot load transparent texture #4

Closed Cewein closed 4 years ago

Cewein commented 5 years ago

as of now we can't load texture with a alpha channel ? why i'm look for it. I might be related to this part of the code :

          ```
            glGenTextures(1, &(this->id));
    glBindTexture(GL_TEXTURE_2D, this->id);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    switch (this->nbChannels)
    {
    case 3:
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, this->width, this->height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
        break;
    case 4:
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this->width, this->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
        break;
    default:
        break;
    }
    glGenerateMipmap(GL_TEXTURE_2D);
    logger.initLog("uploaded texture to GC");
    stbi_image_free(data);
    logger.initLog("cleaned texture's data");
Cewein commented 4 years ago

since 17dad21c8d6206c54d625964f719d6dc029c0a3c and maybe priore we can load HDR, transparent and other type of texture, so this bug is fix