• Advertisement
Sign in to follow this  

mesh is crash rendered?

This topic is 4589 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 you se this image: http://www.freestylebitonto.com/backup/tiger.jpeg you cna see how my mesh is rendered. What i could wrong? I use directx-c#-swapchains and this is the second backbuffer (the first is rendered correctly). tnx

Share this post


Link to post
Share on other sites
Advertisement
maybe the problem stay in these rows:

Surface pBackBuffer2 = swapchain_1.GetBackBuffer(0, BackBufferType.Mono);
device.SetRenderTarget( 0, pBackBuffer2 );


i've create the second swapchain in this way:

presentParams[1].Windowed = true;
presentParams[1].SwapEffect = SwapEffect.Copy;

presentParams[1].BackBufferFormat = mode.Format;
presentParams[1].BackBufferWidth = panel2.Width;
presentParams[1].BackBufferHeight = panel2.Height;
presentParams[1].EnableAutoDepthStencil = true;
presentParams[1].AutoDepthStencilFormat = DepthFormat.D16;
swapchain_1 = new SwapChain(device, presentParams[1]);

Share this post


Link to post
Share on other sites
i've checked again, these rows are not the problem.
So in your opinion where the problem could be?

Share this post


Link to post
Share on other sites
Long shot, but do you clear the Z-buffer each frame?
(Is it a static pattern or is just garbled?)

Share this post


Link to post
Share on other sites
sorry friend i'm a newbie, where and with what function i clear it?
this is my render code:


Surface pBackBuffer = sc_0.GetBackBuffer(0, BackBufferType.Mono);
device.SetRenderTarget(0, pBackBuffer);

//Clear the backbuffer to a blue color
device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, System.Drawing.Color.DarkGray, 1.0f, 0);
device.BeginScene();
// Setup the world, view, and projection matrices
SetupMatrices();

// Meshes are divided into subsets, one for each material. Render them in
// a loop
for( int i=0; i<meshMaterials.Length; i++ )
{
// Set the material and texture for this subset
device.Material = meshMaterials;
device.SetTexture(0, meshTextures);

// Draw the mesh subset
((XFileObject)x_file_list[0]).xMesh.DrawSubset(i);
}


//End the scene
device.EndScene();
sc_0.Present(panel1);
//device.Present();
pBackBuffer.ReleaseGraphics();

// panel2
Surface pBackBuffer2 = sc_1.GetBackBuffer(0, BackBufferType.Mono);
device.SetRenderTarget( 0, pBackBuffer2 );

//Clear the backbuffer to a blue color
device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, System.Drawing.Color.DarkGray, 1.0f, 0);
device.BeginScene();
// Setup the world, view, and projection matrices
SetupMatrices();

// Meshes are divided into subsets, one for each material. Render them in
// a loop
for( int i=0; i<meshMaterials.Length; i++ )
{
// Set the material and texture for this subset
device.Material = meshMaterials;
device.SetTexture(0, meshTextures);

// Draw the mesh subset
((XFileObject)x_file_list[0]).xMesh.DrawSubset(i);
}


//End the scene
device.EndScene();
//device.Present();

sc_1.Present(panel2);
pBackBuffer2.ReleaseGraphics();


maybe you mean at pBackBuffer.ReleaseGraphics(); and pBackBuffer2.ReleaseGraphics();

Share this post


Link to post
Share on other sites
You are clearing the depth buffer, the following line is where it happens (twice):

device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, System.Drawing.Color.DarkGray, 1.0f, 0);

The highlighted flag is indicating that you clear the Z/Depth buffer.

Do you get the same results if you use the reference rasterizer?

I can't see anything obviously wrong with that fragment of code. Although, as Syranide asked - is it a static or animating pattern of distortion?

hth
Jack

PS - would you use [ source ] ... [ / source ] (without spaces) tags next time [smile]

Share this post


Link to post
Share on other sites
thank you for your interesting...
What does mean "static or animating pattern of distortion"?
How do i use "reference rasterizer"?

Sorry about my ignorance!

Share this post


Link to post
Share on other sites
Quote:
Original post by Say
What does mean "static or animating pattern of distortion"?

Is the pattern (that you showed us in your screenshot) the same on *every* frame, or does it change with time? If you rotate your model (etc..) does that cause the pattern to change?

Quote:
Original post by Say
How do i use "reference rasterizer"?

You need to specify D3DDEVTYPE_REF in your IDirect3D9::CreateDevice() call. Typically it'll replace the parameter that is set to D3DDEVTYPE_HAL.

hth
Jack

Share this post


Link to post
Share on other sites
no it doesn't animate.
my code was:
device = new Device(0, DeviceType.Hardware, this.panel1, flags, presentParams[0]);
i've now tried to change with:
device = new Device(0, DeviceType.Reference, this.panel1, flags, presentParams[0]);

but it is the same! :(

Share this post


Link to post
Share on other sites
ok now i've tried to replace with this and it works:
device = new Device(0, DeviceType.Hardware, this, flags, presentParams[0]);

but the two meshes rendered in the two windows (precisely form' panels) are stretched. why?

Share this post


Link to post
Share on other sites
Now the problem happen again...
I've changed a little the code but fixing other bugs.
How can fix it? What does it depend by?
when i use more presentparams for more swap chains i start the device in the same way, that is so:

// presentParams = presentParams[0] and presentParams[1]
device = new Device(0, DeviceType.Hardware, this, flags, presentParams);

Share this post


Link to post
Share on other sites
I also have a weird mesh problem, but i have never had this before. When the mesh is rendered, everything looks correct, even the textures are aplied correctly, but where therer is an area that uses a material, such as a blue color, it doesn't draw it.
I really don't know my problem, but does it have to do with loading the x file, or the setup of the lights.

Share this post


Link to post
Share on other sites
that problem (mine) happen just when i resize the window.
I call this:


public void OnResizingDevice()
{
if(initializedDirect3D)
{
pause = false;
Reset_Present_Params();
device.Reset(presentParams);
}
}

private void Reset_Present_Params()
{
DisplayMode mode = new DisplayMode();
presentParams[0].BackBufferFormat = mode.Format;
presentParams[0].BackBufferWidth = panel1.Width;
presentParams[0].BackBufferHeight = panel1.Height;
presentParams[0].EnableAutoDepthStencil = true;
presentParams[0].AutoDepthStencilFormat = DepthFormat.D16;

presentParams[1].BackBufferFormat = mode.Format;
presentParams[1].BackBufferWidth = panel2.Width;
presentParams[1].BackBufferHeight = panel2.Height;
presentParams[1].EnableAutoDepthStencil = true;
presentParams[1].AutoDepthStencilFormat = DepthFormat.D16;
}


where are bugs?

Share this post


Link to post
Share on other sites
Clear your Stencil buffer. I've had that same problem, and the image that got rendered had that exact aspect.

Clear you stencil buffer, or, if you're not using it at all, disable Stencil Checking.

Share this post


Link to post
Share on other sites
I guess i'm not using it.
How can i disable Stencil Checking?

[Edited by - Say on August 2, 2005 12:59:03 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Say
I guess i'm not using it.
How can i disable Stencil Checking?


I'm sorry Say, I'm an OpenGL coder, so you'll have to ask some other GDNetter what the code is to turn off Stencil Checks... :(

Share this post


Link to post
Share on other sites
I've found this:
device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, System.Drawing.Color.DarkGray, 1.0f, 0);

i've tried to use this
device.Clear(ClearFlags.Target | ClearFlags.ZBuffer | ClearFlags.Stencil, System.Drawing.Color.DarkGray, 1.0f, 0);
but it goes in crash!! please someone

Share this post


Link to post
Share on other sites
i need to repair this bug, i know it is a stupid bug and it can be happened to everybody so someone hve t know how fix.
I guess it's handled by using 2 chain swap so 2 backbuffer.
But where i forget to clear something, where i forget to do something somewhere... please some advice, please.

Share this post


Link to post
Share on other sites
If you only use 1 chain, does the problem still occur. That looks to me like an issue with clearing the xbuffer, but you are obviously doing so. Seem like a very strange problem. Have you tried rendering the same mesh without a swap chain (just render the first window)?

Share this post


Link to post
Share on other sites
hi friend, i use two panels 1 for evey chain (backbuffer) of the same scene, so the scene is render correctly in the first panel and in the second one.
But if i resize them, the first one is rendered yet correctly, the second one give me troubles.
I guess it depend by resizing the backbuffer, or clear backbuffer, maybe it goes to read other bad memory...
Advices?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement