Advertisement Jump to content
Sign in to follow this  

Tweening with HLSL lerp(), No textures!

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

I load 2 meshes from ".x" file, The ".x" file already had more than 10 textures on various surfaces. DX Mesh Viewer display them very well(with textures). The vertex FVF is D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1 .the number of bytes of pre vertex is 32 . mesh01--- m_pVB1 mesh02--- m_pVB2 The vertex decl is D3DVERTEXELEMENT9 decl[] = { {0, 0,D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, {0, 12,D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0}, {0, 24,D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 }, {1,0,D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 1 }, {1,12,D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 1}, {1,24,D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD,1}, D3DDECL_END() }; I tween them with HLSL lerp(a,b,s) . s is the tweening factor which is from API constant table. It works well except none textures. The following sentences are my shader.txt file matrix ViewMatrix; matrix ViewProjMatrix; vector AmbientMtrl; vector DiffuseMtrl; vector LightDirection; float factor; vector DiffuseLightIntensity = {0.0f, 0.0f, 1.0f, 1.0f}; vector AmbientLightIntensity = {0.0f, 0.0f, 0.2f, 1.0f}; // // Input and Output structures. // struct VS_INPUT { vector position : POSITION0; vector normal : NORMAL0; float2 base:TEXCOORD0; vector position1 : POSITION1; vector normal1 : NORMAL1; float2 base1 : TEXCOORD1; }; struct VS_OUTPUT { vector position : POSITION; vector diffuse : COLOR; float2 base : TEXCOORD0; }; VS_OUTPUT Main(VS_INPUT input) { // zero out all members of the output instance. VS_OUTPUT output = (VS_OUTPUT)0; vector Temp=lerp(input.position,input.position1,factor); Temp.w=1.0f; vector TempNormal=lerp(input.normal,input.normal1,factor); TempNormal.w=1.0f; input.normal=TempNormal; output.position =mul( Temp,ViewProjMatrix); LightDirection.w = 0.0f; input.normal.w = 0.0f; LightDirection = mul(LightDirection, ViewMatrix); input.normal = mul(input.normal, ViewMatrix); float s = dot(LightDirection, input.normal); if( s < 0.0f ) s = 0.0f; output.diffuse = (AmbientMtrl * AmbientLightIntensity) + (s * (DiffuseLightIntensity * DiffuseMtrl)); output.base=input.base; return output; } I render them with: m_pd3dDevice->SetStreamSource( 0, m_pVB1,0,sizeof(D3DVERTEX) ); m_pd3dDevice->SetStreamSource(1, m_pVB2,0,sizeof(D3DVERTEX) ); ...m_pd3dDevice->SetIndices( m_pMeshIB ); m_pd3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, m_dwNumMeshVertices, 0, m_dwNumMeshFaces ); U know, if I render mesh01(or mesh02)in a loop of materials ->DrawSubset(i) It works with all textures very well. Now ,the output.position is interpolated how can i get the interpolated "mesh" to DrawSubset(i) ? U know DirectX tweening sample "Dolphin" is different from my case, dolphin ".x" file have none texture at all, just mesh. Help!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!