How to render a scene with multiple hierarchy objects in DirectX11?
This might sound a dumb question but I am trying to understand the basics of 3d game programming and wanted to know this thing.
I have looked at the samples here https://code.msdn.microsoft.com/Direct3D-Tutorial-Win32-829979ef and I get it how each object's vertices and indexes to those vertices are stored in vertex buffer
and index buffer
respectively.
What I want to understand is how would I render a scene where I have multiple objects ? How should the vertex and index buffers be set? And how should a draw
called be implemented ?
A reference or an example will help please.
directx directx-11
add a comment |
This might sound a dumb question but I am trying to understand the basics of 3d game programming and wanted to know this thing.
I have looked at the samples here https://code.msdn.microsoft.com/Direct3D-Tutorial-Win32-829979ef and I get it how each object's vertices and indexes to those vertices are stored in vertex buffer
and index buffer
respectively.
What I want to understand is how would I render a scene where I have multiple objects ? How should the vertex and index buffers be set? And how should a draw
called be implemented ?
A reference or an example will help please.
directx directx-11
1
Take a look at DirectX Tool Kit and in particular theModel
/ModelMesh
/ModelMeshPart
classes for an example. The docs are in the wiki
– Chuck Walbourn
Nov 8 '18 at 20:12
@ChuckWalbourn thanks for your response
– Monku
Nov 9 '18 at 16:11
add a comment |
This might sound a dumb question but I am trying to understand the basics of 3d game programming and wanted to know this thing.
I have looked at the samples here https://code.msdn.microsoft.com/Direct3D-Tutorial-Win32-829979ef and I get it how each object's vertices and indexes to those vertices are stored in vertex buffer
and index buffer
respectively.
What I want to understand is how would I render a scene where I have multiple objects ? How should the vertex and index buffers be set? And how should a draw
called be implemented ?
A reference or an example will help please.
directx directx-11
This might sound a dumb question but I am trying to understand the basics of 3d game programming and wanted to know this thing.
I have looked at the samples here https://code.msdn.microsoft.com/Direct3D-Tutorial-Win32-829979ef and I get it how each object's vertices and indexes to those vertices are stored in vertex buffer
and index buffer
respectively.
What I want to understand is how would I render a scene where I have multiple objects ? How should the vertex and index buffers be set? And how should a draw
called be implemented ?
A reference or an example will help please.
directx directx-11
directx directx-11
asked Nov 8 '18 at 17:43
MonkuMonku
73511223
73511223
1
Take a look at DirectX Tool Kit and in particular theModel
/ModelMesh
/ModelMeshPart
classes for an example. The docs are in the wiki
– Chuck Walbourn
Nov 8 '18 at 20:12
@ChuckWalbourn thanks for your response
– Monku
Nov 9 '18 at 16:11
add a comment |
1
Take a look at DirectX Tool Kit and in particular theModel
/ModelMesh
/ModelMeshPart
classes for an example. The docs are in the wiki
– Chuck Walbourn
Nov 8 '18 at 20:12
@ChuckWalbourn thanks for your response
– Monku
Nov 9 '18 at 16:11
1
1
Take a look at DirectX Tool Kit and in particular the
Model
/ ModelMesh
/ ModelMeshPart
classes for an example. The docs are in the wiki– Chuck Walbourn
Nov 8 '18 at 20:12
Take a look at DirectX Tool Kit and in particular the
Model
/ ModelMesh
/ ModelMeshPart
classes for an example. The docs are in the wiki– Chuck Walbourn
Nov 8 '18 at 20:12
@ChuckWalbourn thanks for your response
– Monku
Nov 9 '18 at 16:11
@ChuckWalbourn thanks for your response
– Monku
Nov 9 '18 at 16:11
add a comment |
1 Answer
1
active
oldest
votes
To elaborate on Chuck's link, the process by which you will render multiple objects will vary depending on the architecture you choose to use.
Every model is divided into a number sections equal to the number of textures/material combinations it has. Each of these sections consists of a unique texture/material combination and will have its own vertex/index buffer pair.
The reason for this is because the HLSL is primarily designed to operate on a single texture and material at a time. You bind the vertex and index buffers of a single section to the pipeline along with the corresponding texture/material, perform a draw call on it, then bind the buffers/texture/material for the next section until the whole model has been rendered.
The cool part is that you only need to load a model once. As long as you have the information for that model, you can create instances of the model using the same data but different position matricies. This lets you create hundreds or thousands of copies of an object.
My scratch codeed engine handles models like this: during initialization, a model manager class is used to load in all the different models I use and store each unique model into a model class. I then take a pointer to the model class and feed it into scenery managers which give information on what contexts the model appears in. When I populate the game world with scenery, my game tile uses a scenery list class to handle a list of instance structures and render lists. The instance structure holds information such as position/scale/orientation, an AABB, and a pointer to the model class. Each frame, I frustum cull the scenery and populate the render lists with only the instance structures of potentially visible objects and produce an instance buffer for each list to contain the positional information. Then, I can loop through each render list, assign the appropriate buffers and textures, and draw indexed instanced() to render all the copies of the model section.
I'm not sure how my process compares to other engines, but it should serve as a reasonable example of how you might handle multiple objects and then multiple instances of objects. The levels of abstraction I have in my process were chosen due to how my engine works (random world generation). The exact method you use will vary based on your application.
Here is a basic diagram showing a fairly bare-bones set up:
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53213380%2fhow-to-render-a-scene-with-multiple-hierarchy-objects-in-directx11%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
To elaborate on Chuck's link, the process by which you will render multiple objects will vary depending on the architecture you choose to use.
Every model is divided into a number sections equal to the number of textures/material combinations it has. Each of these sections consists of a unique texture/material combination and will have its own vertex/index buffer pair.
The reason for this is because the HLSL is primarily designed to operate on a single texture and material at a time. You bind the vertex and index buffers of a single section to the pipeline along with the corresponding texture/material, perform a draw call on it, then bind the buffers/texture/material for the next section until the whole model has been rendered.
The cool part is that you only need to load a model once. As long as you have the information for that model, you can create instances of the model using the same data but different position matricies. This lets you create hundreds or thousands of copies of an object.
My scratch codeed engine handles models like this: during initialization, a model manager class is used to load in all the different models I use and store each unique model into a model class. I then take a pointer to the model class and feed it into scenery managers which give information on what contexts the model appears in. When I populate the game world with scenery, my game tile uses a scenery list class to handle a list of instance structures and render lists. The instance structure holds information such as position/scale/orientation, an AABB, and a pointer to the model class. Each frame, I frustum cull the scenery and populate the render lists with only the instance structures of potentially visible objects and produce an instance buffer for each list to contain the positional information. Then, I can loop through each render list, assign the appropriate buffers and textures, and draw indexed instanced() to render all the copies of the model section.
I'm not sure how my process compares to other engines, but it should serve as a reasonable example of how you might handle multiple objects and then multiple instances of objects. The levels of abstraction I have in my process were chosen due to how my engine works (random world generation). The exact method you use will vary based on your application.
Here is a basic diagram showing a fairly bare-bones set up:
add a comment |
To elaborate on Chuck's link, the process by which you will render multiple objects will vary depending on the architecture you choose to use.
Every model is divided into a number sections equal to the number of textures/material combinations it has. Each of these sections consists of a unique texture/material combination and will have its own vertex/index buffer pair.
The reason for this is because the HLSL is primarily designed to operate on a single texture and material at a time. You bind the vertex and index buffers of a single section to the pipeline along with the corresponding texture/material, perform a draw call on it, then bind the buffers/texture/material for the next section until the whole model has been rendered.
The cool part is that you only need to load a model once. As long as you have the information for that model, you can create instances of the model using the same data but different position matricies. This lets you create hundreds or thousands of copies of an object.
My scratch codeed engine handles models like this: during initialization, a model manager class is used to load in all the different models I use and store each unique model into a model class. I then take a pointer to the model class and feed it into scenery managers which give information on what contexts the model appears in. When I populate the game world with scenery, my game tile uses a scenery list class to handle a list of instance structures and render lists. The instance structure holds information such as position/scale/orientation, an AABB, and a pointer to the model class. Each frame, I frustum cull the scenery and populate the render lists with only the instance structures of potentially visible objects and produce an instance buffer for each list to contain the positional information. Then, I can loop through each render list, assign the appropriate buffers and textures, and draw indexed instanced() to render all the copies of the model section.
I'm not sure how my process compares to other engines, but it should serve as a reasonable example of how you might handle multiple objects and then multiple instances of objects. The levels of abstraction I have in my process were chosen due to how my engine works (random world generation). The exact method you use will vary based on your application.
Here is a basic diagram showing a fairly bare-bones set up:
add a comment |
To elaborate on Chuck's link, the process by which you will render multiple objects will vary depending on the architecture you choose to use.
Every model is divided into a number sections equal to the number of textures/material combinations it has. Each of these sections consists of a unique texture/material combination and will have its own vertex/index buffer pair.
The reason for this is because the HLSL is primarily designed to operate on a single texture and material at a time. You bind the vertex and index buffers of a single section to the pipeline along with the corresponding texture/material, perform a draw call on it, then bind the buffers/texture/material for the next section until the whole model has been rendered.
The cool part is that you only need to load a model once. As long as you have the information for that model, you can create instances of the model using the same data but different position matricies. This lets you create hundreds or thousands of copies of an object.
My scratch codeed engine handles models like this: during initialization, a model manager class is used to load in all the different models I use and store each unique model into a model class. I then take a pointer to the model class and feed it into scenery managers which give information on what contexts the model appears in. When I populate the game world with scenery, my game tile uses a scenery list class to handle a list of instance structures and render lists. The instance structure holds information such as position/scale/orientation, an AABB, and a pointer to the model class. Each frame, I frustum cull the scenery and populate the render lists with only the instance structures of potentially visible objects and produce an instance buffer for each list to contain the positional information. Then, I can loop through each render list, assign the appropriate buffers and textures, and draw indexed instanced() to render all the copies of the model section.
I'm not sure how my process compares to other engines, but it should serve as a reasonable example of how you might handle multiple objects and then multiple instances of objects. The levels of abstraction I have in my process were chosen due to how my engine works (random world generation). The exact method you use will vary based on your application.
Here is a basic diagram showing a fairly bare-bones set up:
To elaborate on Chuck's link, the process by which you will render multiple objects will vary depending on the architecture you choose to use.
Every model is divided into a number sections equal to the number of textures/material combinations it has. Each of these sections consists of a unique texture/material combination and will have its own vertex/index buffer pair.
The reason for this is because the HLSL is primarily designed to operate on a single texture and material at a time. You bind the vertex and index buffers of a single section to the pipeline along with the corresponding texture/material, perform a draw call on it, then bind the buffers/texture/material for the next section until the whole model has been rendered.
The cool part is that you only need to load a model once. As long as you have the information for that model, you can create instances of the model using the same data but different position matricies. This lets you create hundreds or thousands of copies of an object.
My scratch codeed engine handles models like this: during initialization, a model manager class is used to load in all the different models I use and store each unique model into a model class. I then take a pointer to the model class and feed it into scenery managers which give information on what contexts the model appears in. When I populate the game world with scenery, my game tile uses a scenery list class to handle a list of instance structures and render lists. The instance structure holds information such as position/scale/orientation, an AABB, and a pointer to the model class. Each frame, I frustum cull the scenery and populate the render lists with only the instance structures of potentially visible objects and produce an instance buffer for each list to contain the positional information. Then, I can loop through each render list, assign the appropriate buffers and textures, and draw indexed instanced() to render all the copies of the model section.
I'm not sure how my process compares to other engines, but it should serve as a reasonable example of how you might handle multiple objects and then multiple instances of objects. The levels of abstraction I have in my process were chosen due to how my engine works (random world generation). The exact method you use will vary based on your application.
Here is a basic diagram showing a fairly bare-bones set up:
edited Nov 18 '18 at 23:11
answered Nov 18 '18 at 20:03
GaleRazorwindGaleRazorwind
896
896
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53213380%2fhow-to-render-a-scene-with-multiple-hierarchy-objects-in-directx11%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Take a look at DirectX Tool Kit and in particular the
Model
/ModelMesh
/ModelMeshPart
classes for an example. The docs are in the wiki– Chuck Walbourn
Nov 8 '18 at 20:12
@ChuckWalbourn thanks for your response
– Monku
Nov 9 '18 at 16:11