Jump to content
  • Advertisement
Sign in to follow this  
Zee Man

Bump map causing weird transparency

This topic is 4549 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

Hi all, I'm trying to get some dot3 bump mapping working in my FPS engine. I've been working from the implementation at http://www.two-kings.de/tutorials/dxgraphics/dxgraphics14.html I'm trying to blend the results from the bump with my diffuse map, however I have strange areas where you can see through the bump map. Heres a pic of the problem Heres my code:
[SOURCE]
//texture factor
	DWORD dwTFactor;                      

	//convert the light vector to a dword
	DWORD dwR = (DWORD)(127 * Light.x + 128);
	DWORD dwG = (DWORD)(127 * Light.y + 128);
	DWORD dwB = (DWORD)(127 * Light.z + 128);
	dwTFactor = (DWORD)(0xff000000 + (dwR << 16) + (dwG << 8) + dwB);
	
	device->SetRenderState(D3DRS_TEXTUREFACTOR,dwTFactor);

	//set filtering type
	device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_ANISOTROPIC);
	device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_ANISOTROPIC);
	device->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_ANISOTROPIC);

	device->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_ANISOTROPIC);
	device->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_ANISOTROPIC);
	device->SetSamplerState(1, D3DSAMP_MIPFILTER, D3DTEXF_ANISOTROPIC);

	//normal map blending
	device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_DOTPRODUCT3);
	device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
	device->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR);
		
	//blend normal map with diffuse
	device->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
	device->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
	device->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);

	for(unsigned int i = 0; i < Mtrls.size(); i++){
		
		device->SetMaterial( &Mtrls );
		
		device->SetTexture( 0, Bumps );	
		device->SetTexture( 1, Textures );	
		
		newMesh->DrawSubset(i);
	}

[/SOURCE]
[/source] Heres how I create my bump map:
[SOURCE]

D3DXCreateTextureFromFile(g_engine->getDevice(), L"bump.jpg", &height);

D3DSURFACE_DESC desc;
height->GetLevelDesc(0, &desc);

D3DXCreateTexture(device, desc.Width, desc.Height, 0, 0, D3DFMT_R8G8B8,D3DPOOL_MANAGED, &bump);

D3DXComputeNormalMap(bump, height, NULL, 0, D3DX_CHANNEL_LUMINANCE, 6.0f);
					

Textures.push_back( tex );
Bumps.push_back( bump );


[Edited by - Zee Man on July 3, 2006 1:08:04 AM]

Share this post


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

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!