Skip to main content
gamedev.net
🔒 Locked

Texture Scaling

Started by subi 1 reply 1.8k views
Original Post
subi
subi
Hi Guys I am trying to scale my texture so that it repeats it self accross the given surface. I know the easy way todo this and that is to multiply my texture coords by my scaling factor and this works perfect. The problem is i don't want to do this because that means i have to have 2 set's of texture coords(i only need 1 set) and also that means i have to compute the texture coords again everytime i want to change the scaling factor. So i thought i would play with D3DXMatrixScaling and do it that way. here is what i got but it doesn't work

		d3D9dev->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_ADDSIGNED );
		d3D9dev->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE ); 
		d3D9dev->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT ); 

		D3DXMatrixIdentity(&TMatrix);
		D3DXMatrixScaling(&TMatrix,10.0f,10.0f,1.0f); 
		d3D9dev->SetTransform(D3DTS_TEXTURE1,&TMatrix);
		d3D9dev->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );


as you can see i am trying to have my texture repeat 10 times, i obviouslly stuffed something up. if this helps here is how i do it in opengl (i am actually porting some of my GL code to D3D9)

	glMatrixMode(GL_TEXTURE);
        glLoadIdentity();
        glScalef(10.0f, 10.0f,1.0f);
        glMatrixMode(GL_MODELVIEW);


subi
subi
ok just an update:

if i apply the matrix code above to my first texture it scales perfectly! but when applied to my second texture it doesn't.

so here is the complete code for my 2 textures

		m_d3D9dev->SetTexture( 0, m_pBaseMap );		m_d3D9dev->SetTexture( 1,  m_pDetailMap );		m_d3D9dev->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_MODULATE );        m_d3D9dev->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );		m_d3D9dev->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_ADDSIGNED );		m_d3D9dev->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE ); 		m_d3D9dev->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT ); 		D3DXMatrixIdentity(&TMatrix);		D3DXMatrixScaling(&TMatrix,10.0f,10.0f,1.0f);		m_d3D9dev->SetTransform(D3DTS_TEXTURE1,&TMatrix);		m_d3D9dev->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );


incase you are wondering i am trying to apply a detail map to my terrain. My only other question is, when multitexturing in D3D9, do i require 1 set of texture coords per texture or can i use 1 set of texture coords for every texture i use?
subi
subi
oops sorry never mind guys i figured it all out, was missing this one line

m_d3D9dev->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_PASSTHRU);

EDIT

ok i do have a question, when i do apply the matrix transformation to the second texture it kills the FPS, it drops from 120 odd down to 40.

haha anwsered my own question again, turned on MipMapping for the texture and problem solved

[Edited by - subi on April 10, 2006 8:33:18 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.