Two textures on one object, one repeated?

Started by Terrabus, July 01, 2012, 04:39:44 PM

Previous topic - Next topic

Terrabus

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:

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...

EgonOlsen

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.

Terrabus

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]

EgonOlsen

I was wrong about the scaling of the texture matrix (it alway confuses me), but something like this should work:


    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);

Terrabus