Sign in to follow this  
of_ownage

strange DrawSubset problem

Recommended Posts

of_ownage    110
hey guys i have a very strange problem :S i have two types of meshes, Statc + Dynamic Meshes. Both use different effects, and do never modify effect variables of the other effect. If i draw this way:: 1) Static 2) Dynamic it works pefect. Now if i draw :: 1) Dynamic 2) Static it looks strange. The Dynamic are always right rendered, but the static are sometimes pure black, sometimes looks like they should :S:S Its just the DrawSubset() from the Dynamic meshes, if i comment this out everything works (except dynamics do not get drawed). What could a DrawSubset do to another shader that the meshes rendered by that shader are black? thank you

Share this post


Link to post
Share on other sites
Buckeye    10747
Sounds like something in the fixed function pipeline that you're setting in one subset render loop and not resetting properly in the other.

Rather than having everyone guess what may be happening, post the code for rendering the subsets.

Share this post


Link to post
Share on other sites
of_ownage    110

//render them one by one
for(UINT i = 0; i < m_Containers[a]->m_dwNumSubsets; ++i)
{
for (iPaletteEntry = 0;
iPaletteEntry < m_Containers[a]->m_dwPaletteSize; ++iPaletteEntry)
{
iMatrixIndex = pBoneComb[i].BoneId[iPaletteEntry];
if (iMatrixIndex != UINT_MAX)
{
D3DXMatrixMultiply(
&g_CombinedBoneMatrices[iPaletteEntry], //matTemp
& m_Containers[a]->BoneOffsetMatrices[iMatrixIndex],
m_Containers[a]->BoneMatrixPointers[iMatrixIndex]);
}
}

MeshEffect->SetMatrixArray(g_CDynamicMeshManager->m_hFinalXForms,
g_CombinedBoneMatrices,
m_Containers[a]->m_dwPaletteSize);

MeshEffect->SetInt("CurNumBones", m_Containers[a]->m_dwMaxVertexInfluences -1);


MeshEffect->CommitChanges();

m_Containers[a]->exSkinMesh->DrawSubset(i);
}




this renders the Dynamic Meshes, if i comment this::

m_Containers[a]->exSkinMesh->DrawSubset(i));

everything works fine(only the dynamic meshes are not rendered). Im not setting any ffp render states nothing, and the static meshes use another shader so it cannot be a SetInt, SetFloat. But i also tryed commenting out every SetParameter here, its still back.

the problem is the DrawSubset but i have really no idea whats going on there^^

I used maximum debug and the DrawSubset always suceeds without any problem and i dont get any error anywhere

Why is the order of rendering important when both shaders have nothing to do with each other, its very strange

Share this post


Link to post
Share on other sites
Buckeye    10747
Need to look at a bit more code. Include the code where you draw the static meshes, where you Begin and End the effects and where you set materials/textures, lighting, etc.

Share this post


Link to post
Share on other sites
of_ownage    110
ok i tryed a lot and your right its one of the paramters, although it makes less sense now ^^

i have this in my shader:::

-----------------------------------------------------------

uniform extern float g_SunLightMesh;

//this is light calculation
float3 final = lerp(color, g_FogColor, fogLerpParam.x) * g_SunLightMesh;

-----------------------------------------------------------------

if i replace g_SunLightMesh with 1 it works perfect. Here is how i set this variable in my app::

m_hSunLight= m_MeshEffect->GetParameterByName(0, "g_SunLightMesh");

now if i do m_MeshEffect->SetFloat("g_SunLightMesh", 1.0f);

and do::
float tryV = 1000;
m_MeshEffect->GetFloat("g_SunLightMesh", tryV);

tryV is 1.0f but somehow in the shader this variable causes everything to be black

i have no idea whats going on there :D

Share this post


Link to post
Share on other sites
of_ownage    110
why the hell does this:::

float3 final = lerp(color, g_FogColor, fogLerpParam.x) * 1.0;

give right results and this::

float3 final = lerp(color, g_FogColor, fogLerpParam.x) * 0.999;

is total black i dont get it :S :( :S :(

Share this post


Link to post
Share on other sites
Buckeye    10747
You're posting single lines of code here and there without providing any information about how those variables are being used in your shader, what values you're setting them to, what mesh they're being applied to or what result you're trying to obtain.

Share this post


Link to post
Share on other sites
legalize    116
I don't think the problems are in your shader, but rather in the states you're setting in your effect file.

Things rendering wrong when you change the order of rendering indicates state contamination.

Share this post


Link to post
Share on other sites
of_ownage    110
i think your both right but i do not change any states

if i render anything!!! before meshes they are black for example::


UINT numPasses = 0;
m_FX->Begin(&numPasses, 0);

m_FX->BeginPass(1);
m_SkyDome->DrawSubset(0);
m_FX->EndPass();

m_FX->End();



it put this code before my meshes rendering, as you can see im not setting ANY render state or anything, nothing.

This is the technique::


technique SkyTech
{
pass P0 //this is not important its not used
{
vertexShader = compile vs_2_a SkyVS();
pixelShader = compile ps_2_a SkyPS();

CullMode = None;
}

pass P1
{
vertexShader = compile vs_2_a SkyVS2();
pixelShader = compile ps_2_a SkyPS2();
}
}



as you can see pass P1 does not change anything so why does this affect my meshes. Its whole different shader and i only call DrawSubset, if i comment here::

m_SkyDome->DrawSubset(0);

out it again works so its not Begin or BeginPass or anything it must be in DrawSubset but that makes absoluetly no sense.

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