• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
proanim

MD5 model rendering problem

7 posts in this topic

I menaged to implement md5 models in one of rastertek samples for dx 11, I can load model and animation and update animation. But i can't get it rendered. My rendering function for md5 is

[source lang="cpp"]void MD5ModelClass::Render(ID3D11DeviceContext* deviceContext, Model3D model)
{
stride = sizeof(Vertex);
offset = 0;

for(int i = 0; i < Model1.numSubsets; i ++)
{
deviceContext->IASetIndexBuffer(Model1.subsets[i].indexBuff, DXGI_FORMAT_R32_UINT, 0);
deviceContext->IASetVertexBuffers( 0, 1, &Model1.subsets[i].vertBuff, &stride, &offset );
deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
deviceContext->DrawIndexed( Model1.subsets[i].indices.size(), 0, 0 );
}

return;
}[/source]

no matter where i put DrawIndexed i get 'driver has stopped working and has recoverd' crash, if DrawIndexed is not included i can't get anything to render. In both cases program comiles without warnings or errors.

Can someone help with this, there is not much info on how to correctly implement md5 models with directx 11?
0

Share this post


Link to post
Share on other sites
I still can't fix this problem, should i upload my project or relevant files so somebody can help with this? I have no idea how to fix this. I tried debugging but model and animation load fine and then driver crashes on DrawIndexed, i don't know why is this.
0

Share this post


Link to post
Share on other sites
Driver crash means that you didn't initialize something correctly, check if your buffers actually have the required amount of data in them.

And use the debug feature of D3D: it probably tells you what went wrong just before the crash in the Output window.
0

Share this post


Link to post
Share on other sites
ok this is officially insane [img]http://public.gamedev.net//public/style_emoticons/default/angry.png[/img] , i am getting this in debugger

D3D11: WARNING: ID3D11DeviceContext::DrawIndexed: Index buffer has not enough space! [ EXECUTION WARNING #359: DEVICE_DRAW_INDEX_BUFFER_TOO_SMALL ]

now the code i am using is copy/paste from tutorials, the man that wrote md5 tutorials made them functional but entire code is in one file! so i took functions that are relevant for md5 stuff and put them together with rastertek tutorial with 3d cube.

this is creation of the buffers from md5 tutorials

[source lang="cpp"]// Create index buffer
D3D11_BUFFER_DESC indexBufferDesc;
ZeroMemory(&indexBufferDesc, sizeof(indexBufferDesc));

indexBufferDesc.Usage = D3D11_USAGE_DEFAULT;
indexBufferDesc.ByteWidth = sizeof(DWORD) * subset.numTriangles * 3;
indexBufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
indexBufferDesc.CPUAccessFlags = 0;
indexBufferDesc.MiscFlags = 0;

D3D11_SUBRESOURCE_DATA iinitData;
iinitData.pSysMem = &subset.indices[0];
device->CreateBuffer(&indexBufferDesc, &iinitData, &subset.indexBuff);

//Create Vertex Buffer
D3D11_BUFFER_DESC vertexBufferDesc;
ZeroMemory(&vertexBufferDesc, sizeof(vertexBufferDesc));

vertexBufferDesc.Usage = D3D11_USAGE_DYNAMIC; // We will be updating this buffer, so we must set as dynamic
vertexBufferDesc.ByteWidth = sizeof(Vertex) * subset.vertices.size();
vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
vertexBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; // Give CPU power to write to buffer
vertexBufferDesc.MiscFlags = 0;

D3D11_SUBRESOURCE_DATA vertexBufferData;
ZeroMemory(&vertexBufferData, sizeof(vertexBufferData));
vertexBufferData.pSysMem = &subset.vertices[0];
hr = device->CreateBuffer(&vertexBufferDesc, &vertexBufferData, &subset.vertBuff);
[/source]

in rastertek tutorials you render object with shader like this

[source lang="cpp"]// render the model using color shader
result = m_ColorShader->Render(m_D3D->GetDeviceContext(), m_md5->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix);
if(!result)
return false;[/source]

all tutorials were working in their original state and nothing was changed here. how can i get correct number of indices to fix this. I tried with

[source lang="cpp"]int MD5ModelClass::GetIndexCount()
{
return sizeof(DWORD) * subset.numTriangles * 3;
//return Model1.subsets.size();
//return numVerts;
}[/source]

first return is original from md5 tutorial it also returns driver crash and debug warning? please help!
0

Share this post


Link to post
Share on other sites
That function int MD5ModelClass::GetIndexCount(){...} is wrong: it returns the size of the indices buffer in bytes.

It should return just 'subset.numTriangles * 3' (if you multiply that by DWORD (which is 4) you are trying to draw 4 times as many indices as there actually are).
2

Share this post


Link to post
Share on other sites
ok step forward, but now when placing break point on for loop from the first post it breaks with this

D3D11: ERROR: ID3D11DeviceContext::DrawIndexed: A Vertex Shader is always required when drawing, but none is currently bound. [ EXECUTION ERROR #341: DEVICE_DRAW_VERTEX_SHADER_NOT_SET ]
D3D11: ERROR: ID3D11DeviceContext::DrawIndexed: Rasterization Unit is enabled (PixelShader is not NULL or Depth/Stencil test is enabled and RasterizedStream is not D3D11_SO_NO_RASTERIZED_STREAM) but position is not provided by the last shader before the Rasterization Unit. [ EXECUTION ERROR #362: DEVICE_DRAW_POSITION_NOT_PRESENT ]

now the entire shader implementation is rastertek sample nothing is changed except i put together vs and ps files from tutorial into one so it looks like this

[source lang="cpp"]////////////////////////////////////////////////////////////////////////////////
// Filename: color.hlsl
////////////////////////////////////////////////////////////////////////////////

/////////////
// GLOBALS //
/////////////
cbuffer MatrixBuffer
{
matrix worldMatrix;
matrix viewMatrix;
matrix projectionMatrix;
};

//////////////
// TYPEDEFS //
//////////////
struct VertexInputType
{
float4 position : POSITION;
float4 color : COLOR;
};

struct PixelInputType
{
float4 position : SV_POSITION;
float4 color : COLOR;
};

////////////////////////////////////////////////////////////////////////////////
// Vertex Shader
////////////////////////////////////////////////////////////////////////////////
PixelInputType ColorVertexShader(VertexInputType input)
{
PixelInputType output;

// change the position vector to be 4 units for proper matrix calculations
input.position.w = 1.0f;

// calculate the position of the vertex against the world, view, and projection matrices
output.position = mul(input.position, worldMatrix);
output.position = mul(output.position, viewMatrix);
output.position = mul(output.position, projectionMatrix);

// store the input color for the pixel shader to use
output.color = input.color;

return output;
}

////////////////////////////////////////////////////////////////////////////////
// Pixel Shader
////////////////////////////////////////////////////////////////////////////////
float4 ColorPixelShader(PixelInputType input) : SV_TARGET
{
return input.color;
}[/source]

i looked around the net there is very little on this some are pointing on missing semantics in the code like : COLOR but the shader works no problem with triangle sample, so how can i fix this?
0

Share this post


Link to post
Share on other sites
You should look more into Direct3D before you continue to go on with what you're doing now, otherwise you wil be making a lot more posts like this.

For your problem: ID3D11DeviceContext::VSSetShader must be called to set the vertex shader, this is also why you are getting the second warning (..position is not provided by the last shader...)
0

Share this post


Link to post
Share on other sites
I have that function, as i said entire shader portion of the program is rastertek tutorial copy/paste see attachment. I know rules of the forum and the things like 'we wont write code for you' but this is different. Take a look at the project to see the problem, hopefully someone will tell me the solution to this?
0

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  
Followers 0