Jump to content
  • Advertisement
Sign in to follow this  
AquaMacker

POM(Parallax Occulsion Mapping) Bug...

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

Advertisement

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

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

 

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

Is TM bug or Vertices bug ?

 

MSSDK use XFile.

My App use MaxSDK.

 

Decl is Same.

 

POS

NORMAL

TEX

BINORMAL

TANGENT

 

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!