smooth texture

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

but the problem is all there is only 1 texture coord. You need to tell the 2nd and 3rd stages to use the texture coord of the 1st stage. I'm sorry, I'm on travel right now, I'll be able to post some code and explain better tomorrow night.
Image
crhro
Posts: 9
Joined: Tue Dec 05, 2006 9:24 pm

Post by crhro »

you are tilling the blend map to , to avoid this you need a second set of UV's that maps the entire terrain over the blend map.
Strong99
Admin
Posts: 687
Joined: Fri Mar 31, 2006 7:06 pm
Location: Netherlands
Contact:

Post by Strong99 »

and how to avoid the 2nd map tiled?
You use the same texture map as the first 1 guess so we have to overide it for the 2nd?
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

Try it at first without tiling, just to make sure it's working. Then what you can do, is set it up so that the 3rd texture stage uses the 1st texture stage( and you can tile those texture coords ) but leave the 2nd texture stage to use use it's default texture coords and don't tile them, so that the alpha map is correct.

I'm still looking at getting this working properly myself. I'm noticing different results on different computers. I'll let you know when I can figure something out.
Image
Strong99
Admin
Posts: 687
Joined: Fri Mar 31, 2006 7:06 pm
Location: Netherlands
Contact:

Post by Strong99 »

hestill tiles it. the strangest is that the tiling times stay the same, even if they have no tile only strecth on the x model
Strong99
Admin
Posts: 687
Joined: Fri Mar 31, 2006 7:06 pm
Location: Netherlands
Contact:

Post by Strong99 »

@Spintz
the texture stays tiling. The 2nd texture stretches to the ends of the model, but why when i use the blend it tiles 400 times on the model?
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

do you have code for the creation of the terrain and setting of the material?
Image
Strong99
Admin
Posts: 687
Joined: Fri Mar 31, 2006 7:06 pm
Location: Netherlands
Contact:

Post by Strong99 »

I load data from special xml file,
irr::scene::IAnimatedMesh* anim = Device->getSceneManager()->getMesh(StructXML->Filepath);
if (anim) {
irr::scene::ISceneNode* node = Device->getSceneManager()->addAnimatedMeshSceneNode(anim,0,-1,StructXML->pos,StructXML->rot,StructXML->Scale,false);
if (StructXML->collosion == 1) {
irr::scene::ITriangleSelector* selectos = Device->getSceneManager()->createOctTreeTriangleSelector(anim->getMesh(0),node,128);
node->setTriangleSelector(selectos);
selector->addTriangleSelector(selectos); //meta select
selectos->drop();
}
node->setMaterialFlag(video::EMF_FOG_ENABLE,true);
node->setMaterialFlag(video::EMF_NORMALIZE_NORMALS,true);
video::ITexture* texture1 = Device->getVideoDriver()->getTexture(StructXML->texture0.c_str());
video::ITexture* texture2 = Device->getVideoDriver()->getTexture(StructXML->texture1.c_str());
video::ITexture* texture3 = Device->getVideoDriver()->getTexture(StructXML->texture2.c_str());
node->setMaterialTexture(0,texture1);
node->setMaterialTexture(1,texture2);
node->setMaterialTexture(2,texture3);
node->setMaterialType(video::EMT_SOLID_2_LAYER);
}
Strong99
Admin
Posts: 687
Joined: Fri Mar 31, 2006 7:06 pm
Location: Netherlands
Contact:

Post by Strong99 »

Doens't make any difernce when i say

Code: Select all

Device->getSceneManager()->getMeshManipulator()->makePlanarTextureMapping(anim->getMesh(0),0.01f);
this should set all textures layers the same right?

even this doens't help. i only have 1 texture layer

Code: Select all

node->getMaterial(0).Texture1 = texture1;
									node->getMaterial(0).Texture2 = texture2;
									node->getMaterial(0).Texture3 = texture3;
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

makePlanarTextureMapping only modifies the 1st texture coordinate. So, this will only scale your base texture. A workaround, so you don't have to modify the makePlanarTextureMapping function, would be to change the material to -

Code: Select all

//! Solid 2 layer material renderer
class CD3D9MaterialRenderer_SOLID_2_LAYER : public CD3D9MaterialRenderer
{
public:

	CD3D9MaterialRenderer_SOLID_2_LAYER(IDirect3DDevice9* p, video::IVideoDriver* d)
		: CD3D9MaterialRenderer(p, d) {}

	virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial,
		bool resetAllRenderstates, IMaterialRendererServices* services) 
	{
		// base texture( texture stage 0, normal operations, but save them to the temp register )
		pID3DDevice->SetTextureStageState( 0, D3DTSS_RESULTARG, D3DTA_TEMP );

		// alpha texture( texture stage 1, we just need to grab the alpha value from the texture at this stage
		pID3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
		pID3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );

		// this the the blend texture, we want to blend this color with the color from texture stage 0( which is
		// in the temp register ) using the alpha we got from texture stage 1.
		pID3DDevice->SetTextureStageState( 2, D3DTSS_COLOROP, D3DTOP_BLENDCURRENTALPHA );
		pID3DDevice->SetTextureStageState( 2, D3DTSS_COLORARG1, D3DTA_TEXTURE );
		pID3DDevice->SetTextureStageState( 2, D3DTSS_COLORARG2, D3DTA_TEMP );
		pID3DDevice->SetTextureStageState( 2, D3DTSS_TEXCOORDINDEX, 0 );

		services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
	}

	virtual void OnUnsetMaterial()
	{ 
		// base texture( texture stage 0, return the target to current, rather than the temp register )
		pID3DDevice->SetTextureStageState( 0, D3DTSS_RESULTARG, D3DTA_CURRENT );

		pID3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );
		pID3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );

		pID3DDevice->SetTextureStageState( 2, D3DTSS_COLOROP, D3DTOP_DISABLE );
		pID3DDevice->SetTextureStageState( 2, D3DTSS_COLORARG1, D3DTA_TEXTURE );
		pID3DDevice->SetTextureStageState( 2, D3DTSS_COLORARG2, D3DTA_CURRENT );
		pID3DDevice->SetTextureStageState( 2, D3DTSS_TEXCOORDINDEX, 2 );
	}
};
This will make the 3rd texture stage use the 1st texture stage's texture coordinates and take advantage of the scaled texture coordinates from makePlanarTextureMapping.
Last edited by Spintz on Sun Mar 04, 2007 2:36 pm, edited 1 time in total.
Image
Strong99
Admin
Posts: 687
Joined: Fri Mar 31, 2006 7:06 pm
Location: Netherlands
Contact:

Post by Strong99 »

100% thanks, there's still something wrong with the coords but i think that's the model, i think i can fix that.

:D
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

Glad to help. Would love to see it when it's working :D
Last edited by Spintz on Sun Mar 04, 2007 2:36 pm, edited 1 time in total.
Image
Strong99
Admin
Posts: 687
Joined: Fri Mar 31, 2006 7:06 pm
Location: Netherlands
Contact:

Post by Strong99 »

i have to give texture 1 als the coords of texture 0 else its still wrong, but the problem is that i want to tile texture 0 and 2 and 1 must stretch. and that goes totaly wrong. and by this way even texture 1 is tiled.
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

you using a mesh with 2 tcoords, right?
Last edited by Spintz on Sun Mar 04, 2007 2:36 pm, edited 1 time in total.
Image
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

strong99 wrote:i have to give texture 1 als the coords of texture 0 else its still wrong, but the problem is that i want to tile texture 0 and 2 and 1 must stretch. and that goes totaly wrong. and by this way even texture 1 is tiled.
You can't currently do that with Irrlicht. There's one setting for wrap/clamp that gets applied to all four texure units. It's one of the around dozen issues I've pointed out that are being addressed by Hybrid, I believe.

I also mentioned this to Spintz and he has already addressed this in IrrSpintz. He's also added per-texunit texture addressing *and* spcifying filtering per wrap-direction (UVW).
Post Reply