Comments (11)
I assume you mean the island.sdkmesh
from the legacy DirectX SDK. It contains only a single mesh(based off using sdkmeshdump.cpp)
SDKMESH C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Samples\Media\IslandScene\island.sdkmesh
Version 101, LittleEndian
1 meshes, 1 VBs, 1 IBs, 2 subsets, 1 frames, 2 materials
VB #0 - 55530 vertices, 32 stride
"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0
"NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12
"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24
IB #0 - 55530 indices (18510 faces) IT_32BIT
1: 0, 1, 2
2: 3, 4, 5
3: 6, 7, 8
4: 9, 10, 11
5: 12, 13, 14
...
18506: 55515, 55516, 55517
18507: 55518, 55519, 55520
18508: 55521, 55522, 55523
18509: 55524, 55525, 55526
18510: 55527, 55528, 55529
Meshes
Mesh #0 ''
1 VBs [ 0 ], 0 IB, 2 subsets, 0 bones
Subsets (2):
Subset 0 ''
material 0, TriangleList, start 0, count 20640
Subset 1 ''
material 1, TriangleList, start 0, count 34890
Materials
Material 0 ''
Diffuse: 'grass_turf_v2_tex.dds'
A: (0.000000, 0.000000, 0.000000, 1.000000)
D: (0.223529, 0.682353, 0.000000, 1.000000)
S: (0.000000, 0.000000, 0.000000, 1.000000) ^3.200000
E: (0.000000, 0.000000, 0.000000, 1.000000)
Material 1 ''
Diffuse: 'island_v1_tex.dds'
A: (0.000000, 0.000000, 0.000000, 1.000000)
D: (0.662745, 0.541176, 0.380392, 1.000000)
S: (0.000000, 0.000000, 0.000000, 1.000000) ^3.200000
E: (0.000000, 0.000000, 0.000000, 1.000000)
Frames
Frame 0 ''
Mesh 0 ('')
I see it has two mesh parts, and I don't see any specific reason why it wouldn't work. Let me try it out.
from directxtk.
Hello, sorry, I meant 2 subsets. Regards
from directxtk.
Model
is rendering both parts fine. The issue is that the way the model is modeled, the first model part must be drawn after the second model part because they sit immediately on top of one another. The only sorting built-into the generic Model::Draw
is to draw the non-alpha materials first, then draw the alpha material ones.
To render island.sdkmesh
, you need to not use the generic Model::Draw
and draw the individual parts in the 'correct' order for that particular model. See ModelMeshPart for how to draw the individual pieces.
from directxtk.
Ok, I'll try that, thanks for your advise.
from directxtk.
One quick hack for this specific model is to reach into the first ModelMeshPart
and set isAlpha
to true. This will cause the simple "non-alpha" vs. "alpha" sort to change the draw order.
model->meshes[0]->meshParts[0]->isAlpha = true;
from directxtk.
I tried checking the values of the meshParts members of the mentioned mesh:
for (int i=0; i<2; i++)
{
auto effect = m_model->meshes[0]->meshParts[i]->effect;
auto indexBuffer = m_model->meshes[0]->meshParts[i]->indexBuffer;
auto indexCount = m_model->meshes[0]->meshParts[i]->indexCount;
auto indexFormat = m_model->meshes[0]->meshParts[i]->indexFormat;
auto inputLayout = m_model->meshes[0]->meshParts[i]->inputLayout;
auto isAlpha = m_model->meshes[0]->meshParts[i]->isAlpha;
auto primitiveType = m_model->meshes[0]->meshParts[i]->primitiveType;
auto startIndex = m_model->meshes[0]->meshParts[i]->startIndex;
auto vbDecl = m_model->meshes[0]->meshParts[i]->vbDecl;
auto vertexBuffer = m_model->meshes[0]->meshParts[i]->vertexBuffer;
auto vertexOffset = m_model->meshes[0]->meshParts[i]->vertexOffset;
auto vertexStride = m_model->meshes[0]->meshParts[i]->vertexStride;
}
For the first meshPart I get:
indexCount = 20640
startIndex = 0
isAlpha = false
vertexOffset = 0
vertexStride = 32
For the second one I get:
indexCount = 34890
startIndex = 0
isAlpha = false
vertexOffset = 0
vertexStride = 32
I wonder if I should be getting different values for startIndex, vertexOffset or vertexStride for the second meshPart, or I am doing something wrong?
Thanks
from directxtk.
I see the problem. That model uses a non-zero vertexStart value for the second subset which is an offset to each index in the IB.
from directxtk.
Ignore my original comment about isAlpha
. I was wrong.
The fix is to add a single line to ModelLoadSDKMESH.cpp
:
part->indexCount = static_cast<uint32_t>( subset.IndexCount );
part->startIndex = static_cast<uint32_t>( subset.IndexStart );
part->vertexOffset = static_cast<uint32_t>( subset.VertexStart ); // This was MISSING!
part->vertexStride = static_cast<uint32_t>( vbArray[ mh.VertexBuffers[0] ].StrideBytes );
part->indexFormat = ( ibArray[ mh.IndexBuffer ].IndexType == DXUT::IT_32BIT ) ? DXGI_FORMAT_R32_UINT : DXGI_FORMAT_R16_UINT;
part->primitiveType = primType;
part->inputLayout = il;
part->indexBuffer = ibs[ mh.IndexBuffer ];
part->vertexBuffer = vbs[ mh.VertexBuffers[0] ];
part->effect = mat.effect;
part->vbDecl = vbDecls[ mh.VertexBuffers[0] ];
Thanks for digging into this one. I also need to add this information to my sdkmeshdump.cpp
from directxtk.
Fix submitted. Will be included in the next release. Thanks!
from directxtk.
BTW, after updating my dump utility, I can see the offset is in use:
Subset 0 ''
material 0, TriangleList
index start 0, index count 20640
vertex start 0, vertex count 20640
Subset 1 ''
material 1, TriangleList
index start 0, index count 34890
vertex start 20640, vertex count 34890
The Sample Content Exporter never uses a non-zero VertexStart
. It uses IndexStart
instead and doesn't currently merge/coalesce VBs/IBs. Therefore the bug was only reproducible with older sdkmesh
files produced by legacy exporter tools like the DirectX SDK's .x
file converter meshconvert
.
from directxtk.
That's great! thanks.
from directxtk.
Related Issues (20)
- Make use of C++/WinRT when building for C++17
- ARM64 version of xwbtool HOT 3
- `MapGuard` undefined behavior after move HOT 3
- DirectX Tool Kit for DX9
- DrawLine line thickness HOT 1
- Mesh Outline Effect HOT 2
- Point Light Shader HOT 2
- Clarify required WinSDK version HOT 2
- Hard fps lock to refresh rate value in fullscreen games - Win11 22H2 (DX11) HOT 2
- XWBtool makes all wav files the same name after repackaging HOT 5
- Audio: how to set distance attenuation/fall-off? HOT 4
- darker images loading HOT 1
- Request/question: Add a Vector4/floating point overload for the spritebatch's draw function
- undefined data type in PostProcess method HOT 3
- Aa
- Should Mouse use WM_MOUSELEAVE for Win32 raw input
- SimpleMath geometric random functions
- Error with custom shaders HOT 4
- Keyboard and mouse uses inconsistent coordinate systems, resulting in incorrect movement HOT 4
- Clang on windows fails to compile HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from directxtk.