Texture atlases and mipmapping
Posted: 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.
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
but it always give me level 0...
Here's nodes:
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.
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: