Texture atlases and mipmapping

Node-based Shader Editor

Texture atlases and mipmapping

Postby shruikan » Thu Dec 27, 2018 9:50 pm

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
shruikan
 
Posts: 3
Joined: Thu Dec 27, 2018 9:12 pm

Re: Texture atlases and mipmapping

Postby Amplify_Borba » Wed Jan 02, 2019 2:42 pm

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?
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: Texture atlases and mipmapping

Postby shruikan » Wed Jan 09, 2019 10:37 am

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.
Attachments
ASE TexAtlas Shader.zip
ASE Ground Normals Distance TexAtlas shader and AtlasPicker shader function
(17.51 KiB) Downloaded 211 times
shruikan
 
Posts: 3
Joined: Thu Dec 27, 2018 9:12 pm

Re: Texture atlases and mipmapping

Postby Amplify_Borba » Wed Jan 09, 2019 11:59 am

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.
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am


Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 19 guests