I have a big problem in HLSL please help me....
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.
Have you set the correct constants (ie matrices, vectors, ect...) and the correct vertex declaration?
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?
yes i'm sure about everything.
can i use two or more effect files or i'm doing something wrong?
can i use two or more effect files or i'm doing something wrong?
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).
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); g_pTnLEffect->BeginPass(0); g_pMesh->DrawSubset(i); g_pTnLEffect->EndPass(); } g_pTnLEffect->End();
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); 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.
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement