#### Archived

This topic is now archived and is closed to further replies.

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

## Recommended Posts

##### Share on other sites
Try using D3DXComputeNormals if your mesh is stored in an ID3DXMesh object. Also, try lowering your light''s attentuation0 to something like 0.5 or 0.2 and see if it makes it smoother.

home.att.net/~rpgbook
Author, Programming Role-Playing Games with DirectX
and Focus On: Advanced Animation with DirectX

##### Share on other sites
Test

  Real reply to come

##### Share on other sites
Hi Jim,

Thanks for your response. I was sure that your suggestions would drive this issue home. It made perfect sense, but I encountered some unexpected results that I was hoping someone might be able to clear up. I'll summarise the events:

"Try using D3DXComputeNormals if your mesh is stored in an ID3DXMesh object" - I was sure this would fix the problem, as I felt from the visuals that the vertex normals in my mesh were not averaged with the adjacent faces.

Reading up about D3DXComputeNormals, it takes 2 params, and seems to solve specifically the problem I thought I had. Unfortunately, my mesh was not a ID3DXMesh object. I converted it in a few minutes, and implemented the call to D3DXComputeNormals. Here is my code:

    HRESULT hr;LPD3DXBUFFER pAdjacencyBuffer = NULL;hr = D3DXLoadMeshFromX( "sphere.x", D3DXMESH_SYSTEMMEM, m_pd3dDevice, &pAdjacencyBuffer, NULL, NULL, &m_pMesh );if(FAILED(hr))    return hr;hr = D3DXComputeNormals( m_pMesh, (DWORD*)pAdjacencyBuffer->GetBufferPointer() )if(FAILED(hr))    return hr;

This executed without any (perceived) problems or exceptions, and rendered the mesh... but in exactly the same way as before. There seemed to be no difference at all to the shading of te rendered sphere. Still not smooothly shaded.

Viewing this sphere mesh in "Mesh Viewer" I see a smooth-shaded rendered sphere... so I know it's possible with this specific mesh, but I don't understand why computing the vertex normals didn't work. Everything I have read indicates that this is the cause. In fact, I still think it is the cause, and my opinion now is that somehow D3DXComputeNormals is not successfully computing the vertex normals (Insanity is creeping up on me).

When I tried this initially, I had the second parameter of D3DXComputeNormals as NULL, which also resulted in a rendered non-smooth shaded sphere. I guessed that the second parameter was needed (a buffer indicating adjacent vertices/faces), and the SDK documentation seemed to say the same thing. I googled the D3DXComputeNormals, and could not find any more information other than what the SDK had already stated.

I played with the lighting attenuation0 but any value betwee 0.0 and 1.0 has no effect. attenuation1 seems to have an effect on the shading, but nothing to fix the issue.

I am convinced that a smoothly shaded sphere can be rendered without incurring insane poly counts, but it just is not happening.

I would be grateful if someone could point me in the right direction.

Once again, thanks for the help.

[edited by - Lythic on October 1, 2002 3:21:00 PM]

• 10
• 9
• 48
• 12
• 10
• ### Forum Statistics

• Total Topics
631383
• Total Posts
2999687
×