www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: Terrabus on July 01, 2012, 04:39:44 pm

Title: Two textures on one object, one repeated?
Post by: Terrabus 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...
Title: Re: Two textures on one object, one repeated?
Post by: EgonOlsen 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 (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.
Title: Re: Two textures on one object, one repeated?
Post by: Terrabus 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]
Title: Re: Two textures on one object, one repeated?
Post by: EgonOlsen 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);
Title: Re: Two textures on one object, one repeated?
Post by: Terrabus on July 02, 2012, 03:32:14 pm
That's perfect. Thanks again.