Sign in to follow this  
kurlyak

Shader for DovphinVS (DirectX SDK)

Recommended Posts

Who knows what constants to bring in shader for mine примра SDK DolphinVS? My sample deduces any nonsense. In particular me constants of values of matrixes interest. D3DXMATRIX matWorld; D3DXMATRIX matView; D3DXMATRIX matProj; // MatrixWorld D3DXMatrixRotationY( &matWorld, 0.0f ); D3DXMatrixIdentity(&matWorld); p_d3d_Device->SetTransform( D3DTS_WORLD,&matWorld ); D3DXMatrixLookAtLH( &matView, &D3DXVECTOR3 ( 0.0f, 0.0f,-8.0f ), &D3DXVECTOR3 ( 0.0f, 0.0f, 0.0f ), &D3DXVECTOR3 ( 0.0f, 1.0f, 0.0f ) ); // pDirect3DDevice->SetTransform( D3DTS_VIEW, &MatrixView ); D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/5, 1.0f, 1.0f, 100.0f ); // pDirect3DDevice->SetTransform( D3DTS_PROJECTION, &MatrixProjection ); p_d3d_Device->Clear(NULL, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, WATER_COLOR, 1.0f, 0); p_d3d_Device->BeginScene (); D3DXMATRIXA16 matViewTranspose, matProjTranspose; D3DXMatrixTranspose(&matViewTranspose, &matView); D3DXMatrixTranspose(&matProjTranspose, &matProj); // Some basic constants ??????????????????????? // Set the vertex shader constants p_d3d_Device->SetVertexShaderConstantF( 12, (float*)&matViewTranspose, 4 ); p_d3d_Device->SetVertexShaderConstantF( 28, (float*)&matProjTranspose, 4 ); // Render the seafloor p_d3d_Device->SetTexture( 0, m_pSeaFloorTexture ); p_d3d_Device->SetVertexDeclaration( m_pSeaFloorVertexDeclaration ); p_d3d_Device->SetVertexShader( m_pSeaFloorVertexShader ); p_d3d_Device->SetStreamSource( 0, m_pSeaFloorVB, 0, sizeof(D3DVERTEX) ); p_d3d_Device->SetIndices( m_pSeaFloorIB ); p_d3d_Device->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, m_dwNumSeaFloorVertices, 0, m_dwNumSeaFloorFaces ); p_d3d_Device->EndScene (); p_d3d_Device->Present (NULL, NULL, NULL, NULL); Vertex Shader: vs.1.1 ;------------------------------------------------------------------------------ ; Constants specified by the app ; c0 = ( 0, 0, 0, 0 ) ; c1 = ( 1, 0.5, 2, 4 ) ; c4-c7 = world-view-projection matrix ; c8-c11 = world-view matrix ; c12-c15 = view matrix ; c20 = light direction ; c21 = material diffuse color * light diffuse color ; c22 = material ambient color ; c28 = projection matrix ; ; Vertex components (as specified in the vertex DECL) ; v0 = Position ; v3 = Normal ; v6 = Texcoords ;------------------------------------------------------------------------------ dcl_position0 v0 dcl_normal0 v3 dcl_texcoord0 v6 ;------------------------------------------------------------------------------ ; Vertex transformation ;------------------------------------------------------------------------------ ; Transform to view space (world matrix is identity) m4x4 r9, v0, c12 ; Transform to projection space m4x4 r10, r9, c28 ; Store output position mov oPos, r10 ;------------------------------------------------------------------------------ ; Texture coordinates ;------------------------------------------------------------------------------ ; Copy tex coords mov oT0.xy, v6

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