Jump to content
  • Advertisement
Sign in to follow this  

Multicoloured nightmare )

This topic is 5039 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

http://www.ireallydontcare.com/images/mushroommode.zip Now, it looks all very well and good, but its NOT MEANT TO BE LIKE THAT. Whats actually meant to be there, is a sand texture, here is the code:

	m_Device->SetTexture( 0, m_pSandTexture );	

    m_Device->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_MODULATE );
    m_Device->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
    m_Device->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
    m_Device->SetTextureStageState( 0, D3DTSS_ALPHAOP,   D3DTOP_DISABLE );

	D3DXMatrixIdentity( &WorldMat );
	m_Device->SetTransform(D3DTS_WORLD, &WorldMat);

	for(int cellRow = 0 ; cellRow < CELLS_DIM ; ++cellRow)
		for(int cellColumn = 0; cellColumn < CELLS_DIM ; ++cellColumn)

			int cellNumber = cellColumn + ( cellRow * CELLS_DIM );

	m_Device->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
	m_Device->SetTexture(0, NULL);

If I change the attribute 'modulate' to using hte current argument only, I get my sand texture that I desired in the first place (and yes, I know there should be mipmapping, this is a small portion of what was my terrain rendering function, complete with water and vertex shaders :/. Anyway, my declarations and vertex filling function is below in part


typedef struct D3DTERRAINVERTEX
	D3DXVECTOR3 Position; //v0
	DWORD	dwColor;	  //v1 - Alpha Used for blending, high = grass, low = sand
	D3DXVECTOR3 Normal; //v2
	float tu1, tv1;	// grass texture //v3
//	float tu2, tv2; // sand texture //v4


int CurrentTexPointU = 0;
	int CurrentTexPointV = 0;

	for( int cellrow = 0; cellrow < CELLS_DIM; ++cellrow )
		for( int cellcolumn = 0; cellcolumn < CELLS_DIM; ++cellcolumn )
		{ //cycle through the cells
			bool CellVisible = 0;
			for(int subrow = 0 ; subrow <= CELLWIDTH ; ++subrow)

				for(int subcolumn = 0 ; subcolumn <= CELLWIDTH ; ++subcolumn)
					int row = subrow + ( cellrow * CELLWIDTH );
					int column = subcolumn + ( cellcolumn * CELLWIDTH );

					float PosX = float(row - HEIGHTMAPSIZE/2)*SCALE;
					float PosZ = float(column - HEIGHTMAPSIZE/2)*SCALE;

					v.Position = D3DXVECTOR3(PosX,HeightArray[row][column],PosZ);
					v.tu1 = (float)CurrentTexPointU;
					v.tv1 = (float)CurrentTexPointV;
//					v.tu2 = (float)CurrentTexPointU;
//					v.tv2 = (float)CurrentTexPointV;
					int Alpha = (int)(HeightArray[row][column]/(64/5.0f));
					Alpha *= 3;
					if(Alpha > 255)
						Alpha = 255;
					v.dwColor = D3DCOLOR_ARGB(Alpha , 255, 255, 255);

					CurrentTexPointU += 1;
					if(CurrentTexPointU > 1)
						CurrentTexPointU = 0;

					v.dwColor = 0xFFFFFFFF; //for now, as the other version aint working either, this will be good for now.
					*pBuffer++ = v;

Help, as this is very annoying, I will carry on working on it, but if anyone has any ideas....

Share this post

Link to post
Share on other sites
I'm not sure, but I think if you swap the normal and the colour around in the structure decleration, that might work. I remember you need to have them in a certain order, just cant find the bit in the SDK where it tells you the order.

Share this post

Link to post
Share on other sites
You are of course, perfectly correct, I sussed it last night after removing the normal and going 'ooh, it works' :/

Thanks though :)
www.ireallydontcare.com/blog <-- history of yesterdays coding hehe.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!