Multi-texture Sprite example (SOLVED)

What is missing in this project to be able to use the multi-texture feature?

I prepared a small project:
MultiTextureSprite.zip (31.2 KB)

I have a sprite with material that has 3 samplers:

Atlases are prepared according to documentation, e.g. rename patterns are provided:

obraz obraz obraz

And a very simple Fragment Program:

varying mediump vec2 var_texcoord0;

uniform lowp sampler2D albedo;
uniform lowp sampler2D normalmap;
uniform lowp sampler2D heightmap;
uniform lowp vec4 tint;

void main()
{
    // Pre-multiply alpha since all runtime textures already are
    lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w);
    lowp vec4 albedo_color = texture2D(albedo, var_texcoord0.xy);
    lowp vec4 normal_color = texture2D(normalmap, var_texcoord0.xy);
    lowp vec4 height_color = texture2D(heightmap, var_texcoord0.xy);
    normal_color.x = 1.0;
    normal_color.y = 1.0;
    normal_color.z = 1.0;
    height_color.x = 1.0;
    height_color.y = 1.0;
    height_color.z = 1.0;
    gl_FragColor = albedo_color * normal_color * height_color * tint_pm;
}

But nothing is visible in the main.collection nor when running it:

Looks like you may be missing an underscore in the rename patterns. _pattern_=

1 Like

Sadly, it’s not an issue :frowning:

I think the documentation is correct there, because in the example they replace from the middle of the name, e.g.: frame_normal_1.png, so to make it fame1.png they used _normal_ pattern to be replaced with nothing.

Analogically, in my case images are named platform_normal.png, so to make platform.png I use _normal pattern to be replaced with nothing.

So _ is the actual sign to be replaced.

EDIT:

Plus in Editor - when you set a correct rename pattern, you see the change in Outline:

Correct (name of image is “platform”) vs incorrect (name of image is “platform_heightmap”, because of typo in Rename Pattern):
obraz obraz

1 Like

Yup you are right ! I took a quick look and tint seems to be the problem here, changing it to a positive value will show your results and you may want to bring the go with with sprite into view a little more as it is sitting in the bottom left corner.

1 Like

Yes! Thank you for spotting it :heart:

Indeed, I forgot to change the default 0,0,0,0. When I set it to 1,1,1,1, everything is correct :wink:
obraz

2 Likes