Jump to content
  • Advertisement
Sign in to follow this  
Anddos

Question about effects with RHW vertices

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

if i am using
[font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]#define [/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]CUSTOMFVF (D3DFVF_XYZRHW | D3DFVF_DIFFUSE)[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]what do i set the World,View and Projection to , i dont use any SetTransform in my code but i need to calculate World*View*Projection but there not set?[/font][/font]

Share this post


Link to post
Share on other sites
Advertisement
You shouldn't use FVF codes with vertex shaders, you need a vertex declaration. These are a little more effort to set up than a FVF, but are much more flexible, and you can use multiple streams for instancing and other stuff

// Setup/initialisation
IDirect3DVertexDeclaration9* g_pVertexDeclaration;
D3DVERTEXELEMENT9 elements[] =
{
{ 0, 0, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITIONT, 0 },
{ 0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
D3DDECL_END(),
};
g_pd3dDevice->CreateVertexDeclaration(elements, &g_pVertexDeclaration);

// Before drawing
g_pd3dDevice->SetVertexDeclaration(pDecl);

// Game closing
g_pVertexDeclaration->Release();

Share this post


Link to post
Share on other sites
(Sorry for double post, I can't find the edit button)

Then to set a matrix in an effect, use


// before drawing
D3DXMATRIX world, view, proj;
//...
// setup matrices
//...
g_pEffect->SetMatrix("WhateverYouCalledTheWorldViewProjVariableInTheEffectFile", &(world * view * proj));
// following call only required if you set matrix in between the BeginPass() / EndPass() pair
g_pEffect->CommitChanges();

Share this post


Link to post
Share on other sites
yeh but can you render to screenspace with vertex declarations?, RHW specifies that the vertices are pretransformed,so dosent D3DDECLUSAGE_POSITIONT mean poisiton in left hand cordinate system?

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!