Page 1 of 1

Texture atlases and mipmapping

PostPosted: Thu Dec 27, 2018 9:50 pm
by shruikan
Hi, currently I'm creating a shader that is based on Read From Atlas Tiled sample. Shader will be used on mesh terrain on mobile to handle more than 8 textures (4 atlases: 2x albedo and 2x normals).

I gave up using texture arrays becouse shader in testing on mobile was black (on older devices like sgs5, on newer devices like pixel looks fine, open gl 3 enabled). I was using references in sampling texture arrays but is there something more to get this work?

Anyway back to the topic, there is problem with tiling textures from altas: a thin line between tiles.
Image
I know that disabling mipmapping in texture atlas or setting mip level to 0 or more for texture sampler will fix this. But is there another option to get this working without disabling mipmapping? I've tried to calculate mipmap level to imitate unity standard mipmapping by recreating this code in amplify
Code: Select all
float mip_map_level(in vec2 texture_coordinate)
{
    // The OpenGL Graphics System: A Specification 4.2
    //  - chapter 3.9.11, equation 3.21

    vec2  dx_vtc        = dFdx(texture_coordinate);
    vec2  dy_vtc        = dFdy(texture_coordinate);
    float delta_max_sqr = max(dot(dx_vtc, dx_vtc), dot(dy_vtc, dy_vtc));
 
    //return max(0.0, 0.5 * log2(delta_max_sqr) - 1.0); // == log2(sqrt(delta_max_sqr));
    return 0.5 * log2(delta_max_sqr); // == log2(sqrt(delta_max_sqr));

but it always give me level 0...
Here's nodes:
Image

Re: Texture atlases and mipmapping

PostPosted: Wed Jan 02, 2019 2:42 pm
by Amplify_Borba
Hello, thank you for getting in touch and for your support!

Can you confirm if your texture's Wrap Mode is set to Clamp?

Could you share a sample for us to test on our side?

Re: Texture atlases and mipmapping

PostPosted: Wed Jan 09, 2019 10:37 am
by shruikan
Hello again :)
Wrap mode is set to Clamp and lines still exists:
Image
Atlas used:
Image
To avoid them I used Derivatives in texture sampler - they are calculated in AtlasPicker shader function. But using them causes that shader is black on mobiles. Or something else is the problem so I attached all necessary files shader and shader function. There is also calculation for mip map level for one texture as I mentioned in first post.

Re: Texture atlases and mipmapping

PostPosted: Wed Jan 09, 2019 11:59 am
by Amplify_Borba
Thank you for taking the time to share a sample, I've escalated this situation to the developer so that he can investigate the issue.

We'll get back in touch as soon as we have any findings to share.