lilleyse / Sparse-Texture-Voxels

GigaVoxels + Sparse Textures
12 stars 4 forks source link

Manual mipmap lookup interpolation #78

Closed nopjia closed 12 years ago

nopjia commented 12 years ago

So there is no black outlines when color fades to alpha for cone tracing.

nopjia commented 12 years ago

I'm implementing this, but this in fact is not the root of the problem. The cause for the black rims is GL linear interpolation.

lilleyse commented 12 years ago

as for the GL linear interpolation there are some ideas me and Ian had that use either the voxelizer or mipmapper stage to somehow write sorrounding voxels that have the same color but alpha of 0. And then interp isnt a problem.

nopjia commented 12 years ago

yup. that would be the solution. as to how, we'll have to discuss.

nopjia commented 12 years ago

I just did a few tests. Performance took a hit (as expected), and there is no visible difference. I'm closing this issue we irrelevant and unnecessary.

I'll paste the code snippet here in case we'd need it later.

    // get average value between two mips
    vec4 texel;
    if (pixSize > gTexelSize) {
        float mipLevel = log2(pixSize/gTexelSize);
        float mipLevelFloor = floor(mipLevel);
        float mipLevelFract = fract(mipLevel);

        vec4 texelFloor = textureLod(tVoxColor, pos, mipLevelFloor);
        vec4 texelCeil = textureLod(tVoxColor, pos, mipLevelFloor+1.0);

        float sumAlpha = texelFloor.a+texelCeil.a;
        if (sumAlpha != 0.0) {
            texel = vec4( (texelFloor.rgb+texelCeil.rgb)/(sumAlpha), sumAlpha/2.0);
        }
    }
    else {
        texel = textureLod(tVoxColor, pos, 0.0);
        pixSize = gTexelSize;
    }
lilleyse commented 12 years ago

yeah i think the linear is more important as far as the black borders goes

nopjia commented 12 years ago

the padding thing is similar to what i did manually with the rainbow sphere example we had. thats why it does not have black edges. disabling linear is definitely not an option since we need that to produce any kind of decent image.

nopjia commented 12 years ago

but what i'm saying here is, we don't need manual mipmap interp when reading, since it produced no visual difference.