Bonjour,

J'essaie de faire du bump mapping sur une sphère mais je n'obtients pas l'effet recherché.

voici le code :


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
 
 
 
//création de la texture bump mapping
 
void CWinStars2View::BumpMapping(LPDIRECT3DTEXTURE9 *m_pBumpTexture,char* NomTexture, float m_fBumpFactor)
{
	TCHAR strTexture[512];
	HRESULT hr;
	hr=DXUtil_FindMediaFileCch(strTexture,500, NomTexture);
	if (!FAILED(hr))
	{
		LPDIRECT3DTEXTURE9 pHeightMap=NULL;
		D3DSURFACE_DESC desc;
		hr = D3DUtil_CreateTexture(_device, strTexture, &pHeightMap);
 
		if (!FAILED(hr))
		{
			pHeightMap->GetLevelDesc(0, &desc);
 
			int iWidth = desc.Width;
			int iHeight= desc.Height;
 
			hr= D3DXCreateTexture(_device, iWidth, iHeight,0,0,D3DFMT_Q8W8V8U8, D3DPOOL_MANAGED, m_pBumpTexture);
 
			if (!FAILED(hr))
			{
				D3DXComputeNormalMap( *m_pBumpTexture, pHeightMap, NULL, 0 , D3DX_CHANNEL_RED, m_fBumpFactor);
			}
 
			pHeightMap->Release();
		}
	}
}
 
//rendu d'un objet Mesh avec un effet bump mapping
 
void CWinStars2View::RenderBumpMapping(CD3DMesh *a, LPDIRECT3DTEXTURE9 *texture)
{
	//Texture de base
	_device->SetTexture(0, *a->m_pTextures);    						  
 
	//Bump mapping
	_device->SetTexture(1, *texture);
 
	//paramètres du bump mapping
	_device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
    _device->SetTextureStageState(0, D3DTSS_COLORARG1,D3DTA_TEXTURE);
    _device->SetTextureStageState(0, D3DTSS_COLORARG2,  D3DTA_DIFFUSE);
	_device->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
	_device->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); 
 
    _device->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_BUMPENVMAP);
    _device->SetTextureStageState(1, D3DTSS_COLORARG1,D3DTA_TEXTURE);
    _device->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
 
	//on dessine l'objet
	a->GetLocalMesh()->DrawSubset(0);
 
	//retablissement des paramètres de rendu
    _device->SetTextureStageState(0,D3DTSS_COLOROP, D3DTOP_MODULATE);
    _device->SetTextureStageState(0,D3DTSS_COLORARG1, D3DTA_CURRENT);
    _device->SetTextureStageState(0,D3DTSS_COLORARG2, D3DTA_TEXTURE);
 
    _device->SetTextureStageState(1,D3DTSS_COLOROP, D3DTOP_MODULATE);
    _device->SetTextureStageState(1,D3DTSS_COLORARG1, D3DTA_CURRENT);
    _device->SetTextureStageState(1,D3DTSS_COLORARG2, D3DTA_TEXTURE);	
 
    _device->SetTexture(0, NULL);
    _device->SetTexture(1, NULL);
}
Qu'est-ce qui ne va pas là dedans ?

Avec mes remerciements,

Franck