Own Material Plugin/Viewport Renderer: DirectX10 Hardware Rendering

Own Material Plugin/Viewport Renderer: DirectX10 Hardware Rendering

Anonymous
Not applicable
297 Views
0 Replies
Message 1 of 1

Own Material Plugin/Viewport Renderer: DirectX10 Hardware Rendering

Anonymous
Not applicable
Hi there,

I have created my own Material plugin and now I want it to be rendered inside the viewports by my own DX10 shaders. But I haven't quite figured out how to do that, maybe one of you can help me here.

This is what I did till now:

- I successfully created a material plugin
- I successfully implemented the "ID3D10ShaderResource" interface. Which means that the functions "InitializeDrawSequence()" and "DrawShaderResource()" are called by 3ds max

I want to use my own shaders which are stored in a DirectX FX-file and I want to draw the mesh using one of the techniques described in that FX-file. But the thing I don't get is how to get access to the hardware mesh. The function
DrawShaderResource(INode *node, Mesh *mesh, int mtlNum)
gives me the pointer of the max-mesh which is about to be rendered but the only thing I can do with that damn mesh is:
mesh->render(view->getGW(), .... )  


I tried it like this but obviously that wouldn't work:
void XMRenderer10::DrawShaderResource (INode *node, Mesh *mesh, int mtlNum)
{
D3D10_TECHNIQUE_DESC techDesc;
m_pDX10Technique->GetDesc( &techDesc )
for&#40; UINT p = 0; p < techDesc.Passes; ++p &#41;
{
m_pDX10Technique->GetPassByIndex&#40; p &#41;->Apply&#40;0&#41;
mesh->render&#40;...&#41;

}
}


What I needed would be something like a simple Draw function which just does a simple directx-drawcall... mesh-render&#40;&#41; is obviously doing more than just making a drawcall and it just renders the mesh in pure black&#40;ignoring my shader&#41; so setting the dx10 technique prior to rendering like above won't do anything.

I read the documentation and stumbled upon things like IRenderMesh and HWTupleMesh but that was not really useful either. Also the question is how to retrieve the vertex format of the 3ds Max Mesh. NOwhere in the docu is mentioned what kind of vertex format the standard 3ds max meshes use and how this is handled.

The only thing I could find on this topic is in : "Hardware Rendered Materials"
The developer can make use of the IRenderMesh interface to assist in creating a Hardware version of the 3ds Max mesh. If you want 3ds Max to do the drawing, then you are restricted to the vertex format being sent to the vertex buffer.

Does this mean that the Material has to create its own vertex+indexbuffers for every mesh that uses my material? I'd rather prefer if that wouldn't be necessary...

In my vertex-format/DX10 inputlayout I would need:

 D3D10_INPUT_ELEMENT_DESC layout[] = 
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 1, DXGI_FORMAT_R32G32_FLOAT, 0, 32, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 2, DXGI_FORMAT_R32G32_FLOAT, 0, 40, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 3, DXGI_FORMAT_R32G32_FLOAT, 0, 48, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 4, DXGI_FORMAT_R32G32_FLOAT, 0, 56, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 5, DXGI_FORMAT_R32G32_FLOAT, 0, 64, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 6, DXGI_FORMAT_R32G32_FLOAT, 0, 72, D3D10_INPUT_PER_VERTEX_DATA, 0 },
};


Ok, I hope that wasn't too confusing but what I really need is some sample coding where I can see how things are done.

Thank you!
Regards,
Gregory
0 Likes
298 Views
0 Replies
Replies (0)