Author Topic: Two textures on one object, one repeated?  (Read 3022 times)

Offline Terrabus

  • byte
  • *
  • Posts: 7
    • View Profile
Two textures on one object, one repeated?
« on: July 01, 2012, 04:39:44 pm »
Using GLES 1.1, can one stretch one texture across the entire object and repeat another? I've got the two textures blending with TextureInfo, but I can't figure out the next bit. So far I've got this:

Code: [Select]
TextureManager tm = TextureManager.getInstance();
TextureInfo ti = new TextureInfo(tm.getTextureID("tex_ground")); // repeat me 7 times please
ti.add(tm.getTextureID("tex_ground_shadow"), TextureInfo.MODE_MODULATE);
ground.setTexture(ti);

Even with a 'please', the comment doesn't seem to be enough...

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Two textures on one object, one repeated?
« Reply #1 on: July 01, 2012, 09:32:02 pm »
You have to assign different texture coordinates for both layers. You can either do that when creating the object (if that's possible in your case) or you can modify the method posted in this thread: http://www.jpct.net/forum2/index.php?topic=430.0

Another option (maybe easier to do) is to assign a texture matrix that has been multiplied by 1/7.

Offline Terrabus

  • byte
  • *
  • Posts: 7
    • View Profile
Re: Two textures on one object, one repeated?
« Reply #2 on: July 02, 2012, 02:18:00 pm »
I tried a few things but haven't won just yet.

I thought I should clarify the goal with an image (attached). Ideally the shadow is stretched and the tiles are tiled.

The model in as a 3ds from Blender to which I've since added another UV map. Can I apply the shadow texture using the second UV map? Assuming I did that correctly, I totally appreciate that you're not Blender support.

Thanks for JPCT AE and the help EgonOlson. You are Batman.

[attachment deleted by admin]

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Two textures on one object, one repeated?
« Reply #3 on: July 02, 2012, 03:04:12 pm »
I was wrong about the scaling of the texture matrix (it alway confuses me), but something like this should work:

Code: [Select]
    Matrix texMat = new Matrix();
    texMat.scalarMul(7f);
    TextureInfo ti = new TextureInfo(TextureManager.getInstance().getTextureID("box"));
    ti.add(TextureManager.getInstance().getTextureID("plant"), TextureInfo.MODE_ADD);
    box.setTextureMatrix(texMat);
    box.setTexture(ti);

Offline Terrabus

  • byte
  • *
  • Posts: 7
    • View Profile
Re: Two textures on one object, one repeated?
« Reply #4 on: July 02, 2012, 03:32:14 pm »
That's perfect. Thanks again.