Jump to content
  • Advertisement
Sign in to follow this  

POM(Parallax Occulsion Mapping) Bug...

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


Can you please supply us with the normal maps, and the source code so we can fully assist you in your problem.


And even if the source code is the same, the previous transformations can be different.


-MIGI0027 wink.png

Share this post

Link to post
Share on other sites

Normal map + heightMap - MSSDK ParallaxOcclusionMapping\Media : stones_NM_Height.tga



shader code - MSSDK ParallaxOcclusionMapping - ParallaxOcclusionMapping.fx




similar to DXUTCamera.cpp In MSSDK

    UpdateVelocity( fElapsedTime );

    // Simple euler method to calculate position delta
    D3DXVECTOR3 vPosDelta = m_vVelocity * fElapsedTime;

    // Update the pitch & yaw angle based on mouse movement
    float fYawDelta = m_vRotVelocity.x;
    float fPitchDelta = m_vRotVelocity.y;

    // Invert pitch if requested
    if( m_bInvertPitch )
       fPitchDelta = -fPitchDelta;

    m_fCameraPitchAngle += fPitchDelta;
    m_fCameraYawAngle += fYawDelta;

    // Limit pitch to straight up or straight down
    m_fCameraPitchAngle = __max( -D3DX_PI / 2.0f, m_fCameraPitchAngle );
    m_fCameraPitchAngle = __min( +D3DX_PI / 2.0f, m_fCameraPitchAngle );

    // Make a rotation matrix based on the camera's yaw & pitch
    D3DXMATRIX mCameraRot;
    D3DXMatrixRotationYawPitchRoll( &mCameraRot, m_fCameraYawAngle, m_fCameraPitchAngle, 0 );

    // Transform vectors based on camera's rotation matrix
    D3DXVECTOR3 vWorldUp, vWorldAhead;
    D3DXVECTOR3 vLocalUp = D3DXVECTOR3( 0, 1, 0 );
    D3DXVECTOR3 vLocalAhead = D3DXVECTOR3( 0, 0, 1 );
    D3DXVec3TransformCoord( &vWorldUp, &vLocalUp, &mCameraRot );
    D3DXVec3TransformCoord( &vWorldAhead, &vLocalAhead, &mCameraRot );

    // Transform the position delta by the camera's rotation 
    D3DXVECTOR3 vPosDeltaWorld;
    D3DXVec3TransformCoord( &vPosDeltaWorld, &vPosDelta, &mCameraRot );

    // Move the eye position 
    m_vEye += vPosDeltaWorld;

    // Update the lookAt position based on the eye position 
    m_vLookAt = m_vEye + vWorldAhead;

    // Update the view matrix
    D3DXMatrixLookAtLH( &m_mView, &m_vEye, &m_vLookAt, &vWorldUp );


	pEffect->SetVector( pEffectPOM->vEyePos, MainCamera::GetEyePos4() ); // Vector3( EyePos, 1.0f )

	for ( list<ObjectBase*>::iterator i = listObject.begin(); i != listObject.end(); i++ )
	        for ( vector<stMesh*>::iterator j = (*i)->pObject->pMesh->vlistMesh.begin(); j != (*i)->pObject->pMesh->vlistMesh.end(); j++ )
                        D3DXMATRIX mI;
                        D3DXMatrixIdentity( &mI );

			D3DXMatrixMultiply( &mWVP, &mI, MainCamera::GetView() );
			D3DXMatrixMultiply( &mWVP, &mWVP, MainCamera::GetProj() );

			pEffect->SetMatrix( pEffectPOM->mWorld, &mI );
			pEffect->SetMatrix( pEffectPOM->mWVP, &mWVP );
			pDevice->SetVertexDeclaration( (*j)->pDecl );
			pDevice->SetStreamSource( 0,
                                                  (*j)->nStride );
			pDevice->SetIndices( (*j)->pIB );
			UINT numPasses;
			pEffect->Begin( &numPasses, D3DXFX_DONOTSAVESTATE );
			pEffect->BeginPass( 0 );
			pEffect->SetTexture( pEffectPOM->tDiff, (*j)->tMaterial.ptDiffMap );
			pEffect->SetTexture( pEffectPOM->tNormHeight, (*j)->tMaterial.ptBumpMap );

			pDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST,
			                               (*j)->nNumFaces );

So simple....

Why not working? Why ? Why ? Why ?

Edited by AquaMacker

Share this post

Link to post
Share on other sites

Is TM bug or Vertices bug ?


MSSDK use XFile.

My App use MaxSDK.


Decl is Same.








But data may be different.


MSSDK is just only XFile ?

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.

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!