3ds max simple mesh exporter for DirectX 10

Recommended Posts

hello, I'm making a simple mesh exporter using maxscript. I can export mesh vertices, indices and normals. Now the problem is with the texture vertices. I know how to export multiple texture vertices for every mesh vertex but I don't know how to use them in DX10 I have got already multiple TEXCOORDs for every vertex but how can i use them? so far i only know how to use one TEXCOORD (I'm new to DirectX 10, I've done some DX9 before but not much). this is how my vertex shader input struct looks like:
struct VS_INPUT
{
float3 Pos : POSITION;
float3 Norm: NORMAL;
float2 Tex : TEXCOORD;
float2 Tex1: TEXCOORD1;
};


struct PS_INPUT
{
float4 Pos : SV_POSITION0;
float3 Norm: TEXCOORD0;
float2 Tex : TEXCOORD1;
float2 Tex1 : TEXCOORD2;
};


PS_INPUT VS( VS_INPUT input)
{
PS_INPUT output=(PS_INPUT)0;

output.Pos=mul(float4(input.Pos,1),World);
output.Pos=mul(output.Pos,View);
output.Pos=mul(output.Pos,Projection);

output.Norm=mul(input.Norm,World);

output.Tex=input.Tex;
output.Tex1=input.Tex1;

return output;
}


float4 PS( PS_INPUT input ) : SV_Target
{
return txDiffuse.Sample(txsampler,output.Tex);
}


I assume that if I want it to use multiple texture vertices i have to change something in here but I don't have the slightest idea even where to start so I hope if you can give me some tips or links to some tuts...

Share on other sites
Quote:
 multiple TEXCOORDs for every vertex.. but how can i use them?

The simple answer is: "Use them any way you want to." [smile]

How do you want to use them?

By the way, I think:
return txDiffuse.Sample(txsampler,output.Tex);

should be:
return txDiffuse.Sample(txsampler,input.Tex);

Share on other sites
hm...I actually don't know how to ask it...

well, since a mesh vertex can have more uv vertices I'd like to know how can I render two faces that have two mesh vertices in common but they don't share uv vertices (so every face lies on its own in a totally different part of the uv map.

here's a picture to hopefully explain it a bit better:
now, what i have now is shown on the upper part of the image (divided by that black horizontal line). since there is one texture vertex per one mesh vertex i can't have separated face or vertices.
now i want it to be like on the lower part of the image, where there are more texture vertices per mesh vertex so i can split up faces. i have putted multiple texture coordinates per every vertex in my shader code already and load their UV coordinates but i don't know how to render a face like that.

i just can't find the right words to explain it...i have multiple uv coordinates but how do i "tell" it that "i want face_number_4 rendered with 2nd texture coordinates" and not the 1st?

about that shader code: i just didn't copied everything, i have it like you said :P

Share on other sites
Your explanation and picture are fine.

I'm not a DX10 person and not much on shaders, either. But it appears that you have to communicate to the shader which face is being rendered.

Suggestion: You can render a face at a time and set an effect variable to tell the vertex shader which set of tex coords to pass on (or have the vertex shader pass on 2 sets of tex coords and let the pixel shader decide). Unfortunately, that sort of defeats the purpose of having multiple tex coords in an indexed array of vertices. You may be just as well off setting individual face vertices with a single set of tex coords and using a non-indexed array.

Share on other sites
thx, I'll try doing that

Create an account

Register a new account

• Forum Statistics

• Total Topics
628345
• Total Posts
2982187

• 9
• 24
• 9
• 9
• 13