1
\$\begingroup\$

So I've just managed to get Texturing via GLSL shaders to work and i can pass a sampler2d textureHandler + my uv coordinates into my shader to specify the texture to be displayed on my Tiles.

Now im Wondering how I could define which tile should get which Texture cause right now I can only put 1 single texture on ALL tiles I have...

My vertex shader:

in vec3 position; 
in vec2 vertexUV;

uniform mat4 orthoMatrix;

out vec2 UV;

void main()
{
    gl_Position = orthoMatrix * vec4(position, 1.0);
    UV = vertexUV;
}

my fragment shader:

in vec2 UV;

out vec4 outColor;

uniform sampler2D myTextureSampler1;

void main()
{
    outColor = texture2D(myTextureSampler1, UV);
}

My Texture Loading right now looks like this: http://puu.sh/62MhS.png

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

"myTextureSampler1" should be a big texture containing all your tiles (Texture Atlas). This way, all you need to do is pass the right UV for each tile.

\$\endgroup\$
1
  • 3
    \$\begingroup\$ Welcome to the site! this would be a more useful answer if you showed an example of how to pass the correct tiles UVs. \$\endgroup\$
    – concept3d
    Dec 29, 2013 at 23:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .