Sign in to follow this  
AquaMacker

POM(Parallax Occulsion Mapping) Bug...

Recommended Posts

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

-----------------------------------------------------------------------------------

 

shader code - MSSDK ParallaxOcclusionMapping - ParallaxOcclusionMapping.fx

----------------------------------------------------------------------------------

 

Camera 

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 );

Drawing...

	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 );

			D3DXMATRIX mWVP;
			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)->pVB,
                                                  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 );
			pEffect->CommitChanges();

			pDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST,
						       0,
						       0,
						       (*j)->nNumVerts,
						       0,
			                               (*j)->nNumFaces );
			pEffect->EndPass();
			pEffect->End();
		}

So simple....

Why not working? Why ? Why ? Why ?

Edited by AquaMacker

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this