Sign in to follow this  

I have a big problem in HLSL please help me....

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

HI I have two FX files the first do TnL basics like ambient diffuse and specular lighting which has four techniqes and each has one pass. the second is a multi texturing effect which has one technique and one pass. I wrote in my code... g_pTnLEffect->SetTechnique(TnLTexEnvHandle); g_pTnLEffect->Begin(&NumPasses, NULL); // //the loop for drawing subsets. // g_pTnLEffect->End(); and for the second one g_pScreenShader->SetTechnique(MultiTexScreen_2_0Handle); g_pScreenShader->Begin(&NumPasses, NULL); // //the loop for drawing subsets. // g_pScreenShader->End(); why only the first one works(g_pTnLEffect) and the second effect doesnt render anything considering that each of these effects(alone) works properly.

Share this post


Link to post
Share on other sites
Quote:
Original post by ehsan_the_tiamat
HI
I have two FX files the first do TnL basics like ambient diffuse and specular lighting which has four techniqes and each has one pass. the second is a multi texturing effect which has one technique and one pass. I wrote in my code...

g_pTnLEffect->SetTechnique(TnLTexEnvHandle);
g_pTnLEffect->Begin(&NumPasses, NULL);
//
//the loop for drawing subsets.
//
g_pTnLEffect->End();

and for the second one

g_pScreenShader->SetTechnique(MultiTexScreen_2_0Handle);
g_pScreenShader->Begin(&NumPasses, NULL);
//
//the loop for drawing subsets.
//
g_pScreenShader->End();

why only the first one works(g_pTnLEffect) and the second effect doesnt render anything considering that each of these effects(alone) works properly.


Are you calling BeginPass/Endpass and CommitChanges before each draw?

Share this post


Link to post
Share on other sites
Quote:
Original post by ehsan_the_tiamat
can i use two or more effect files or i'm doing something wrong?

Yep, you can use multiple effects per frame. If you post your entire rendering and effect code, perhaps we can identify the problem. Remember to surround it in [ source ] tags to keep the code formatting (details in FAQ).

Share this post


Link to post
Share on other sites
g_pScreenShader->SetTechnique(MultiTexScreen_2_0Handle);
g_pScreenShader->Begin(&NumPassesScr, NULL);
D3DXMatrixIdentity(&WorldMat);
g_WorldViewProj = WorldMat* V * matProj ;
g_pScreenShader->SetMatrix(g_mScreenWorldViewProjHandle,&g_WorldViewProj);
for(DWORD i = 0; i< g_dwScreenNumMaterials; i++)
{

g_pScreenShader->BeginPass(0);
g_pScreen->DrawSubset(i);
g_pScreenShader->EndPass();
}
g_pScreenShader->End();

///////////////////////////////////////////////////////////////////////////////////////////////////////
g_pTnLEffect->SetTechnique(TnLTexEnvHandle);
g_pTnLEffect->Begin(&NumPasses, NULL);

D3DXMatrixIdentity(&WorldMat);
g_pTnLEffect->SetMatrix(g_mWorldHandle,&WorldMat);
g_WorldViewProj = WorldMat* V * matProj ;
g_pTnLEffect->SetMatrix(g_mWorldViewProjectionHandle,&g_WorldViewProj);
for(DWORD i = 0; i< g_dwNumMaterials; i++)
{
g_pTnLEffect->SetTexture(g_MeshTextureHandle, g_pMeshTextures[i]);
g_pTnLEffect->BeginPass(0);
g_pMesh->DrawSubset(i);
g_pTnLEffect->EndPass();
}
g_pTnLEffect->End();

Share this post


Link to post
Share on other sites

g_pScreenShader->SetTechnique(MultiTexScreen_2_0Handle);
g_pScreenShader->Begin(&NumPassesScr, NULL);

D3DXMatrixIdentity(&WorldMat);
g_WorldViewProj = WorldMat* V * matProj ;
g_pScreenShader->SetMatrix(g_mScreenWorldViewProjHandle,&g_WorldViewProj);

g_pScreenShader->BeginPass(0);
for(DWORD i = 0; i< g_dwScreenNumMaterials; i++)
{
// ?? set texture ??
// g_pScreenShader->CommitChanges(); // uncomment this if you do set a texture in the line above
g_pScreen->DrawSubset(i);
}
g_pScreenShader->EndPass();

g_pScreenShader->End();

///////////////////////////////////////////////////////////////////////////////////////////////////////
g_pTnLEffect->SetTechnique(TnLTexEnvHandle);
g_pTnLEffect->Begin(&NumPasses, NULL);

D3DXMatrixIdentity(&WorldMat);
g_pTnLEffect->SetMatrix(g_mWorldHandle,&WorldMat);
g_WorldViewProj = WorldMat* V * matProj ;
g_pTnLEffect->SetMatrix(g_mWorldViewProjectionHandle,&g_WorldViewProj);

g_pTnLEffect->BeginPass(0);
for(DWORD i = 0; i< g_dwNumMaterials; i++)
{
g_pTnLEffect->SetTexture(g_MeshTextureHandle, g_pMeshTextures[i]);
g_pTnLEffect->CommitChanges();
g_pMesh->DrawSubset(i);
}
g_pTnLEffect->EndPass();

g_pTnLEffect->End();





I've included a modified version of your code above. If you put in the appropriate SetTexture call in the first loop, then it should work.

Also, just as a note, you do not need to call BeginPass() for each subset, only for new passes. That is why I moved the BeginPass/EndPass calls outside of the loops.

Share this post


Link to post
Share on other sites
CommitChanges() commits your changes :)

Basically, whenever an effect changes a state on the device, that change gets tossed until you say "hey I'm serious about the changes I'm making." Its one of those DX things to keep you from murdering performance accidentally

Share this post


Link to post
Share on other sites

This topic is 4688 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.

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