3 registered members (AndrewAMD, VoroneTZ, dpn),
1,346
guests, and 10
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: [Plugin] Import von 2. UVMap / Import of 2nd U
[Re: Excessus]
#119557
03/31/07 21:13
03/31/07 21:13
|
Joined: Jan 2004
Posts: 2,013 The Netherlands
Excessus
Expert
|
Expert
Joined: Jan 2004
Posts: 2,013
The Netherlands
|
Ok everyone! Good news! I dived into D3D and it's really not all that hard I have found a way to do this and maybe I can release a rough plugin as soon as tomorow. A touched up version should be done at the end of the next weekend. I have exams next week, so I can't work on this during the week.. What I've got now: A plugin that can copy the normal UV Map to the second UV map. I can test this with two small shaders that use either TEXCOORD0 or TEXCOORD1 for texture lookup. When I launch my app, the warlock looks normal with the TEXCOORD0 shader, and messed up with the TEXCOORD1 shader. If I call my plugin function, the TEXCOORD1 shader will look correct (because the TEXCOORD0 was copied there). So the only thing left to do is write a function that can read in the UV coord, instead of copying the first UV.. I hope the skin points exported by 'export skin mapping' in MED are in the right order, or I will have to come up with something clever.. @Ventilator: the vertex format used by 3DGS already has 3(!) texture coords per vertex, thus no need to duplicate vertices. EDIT: could someone (frank?) send me a model with 2 UV maps and a shadow map? You could send one .mdl with a normal diffuse texture and the normal skin mapping, and another one with the shadowmap and different UV mapping. My email is taco dot cohen at gmail dot com.
|
|
|
Re: [Plugin] Import von 2. UVMap / Import of 2nd U
[Re: Excessus]
#119560
03/31/07 22:55
03/31/07 22:55
|
Joined: May 2002
Posts: 7,441
ventilator
Senior Expert
|
Senior Expert
Joined: May 2002
Posts: 7,441
|
Quote:
@Ventilator: the vertex format used by 3DGS already has 3(!) texture coords per vertex, thus no need to duplicate vertices.
yes, there are 3 texture coordinates in the vertex struct but this doesn't solve the problem in any way. you will notice it once you get real model data to play with. if the seams of the first uv-set and the seams of the second uv-set aren't the same then you will have to duplicate vertices. for light maps with their automatic atlas mapping they very likely won't be the same.
<edit> with seams i mean the borders of the uv-patches. look at maybenew's example or here:
the light map uvs on the right have a lot more seams/borders. in this example the mesh has 24 vertices, the texture uv-map has 24 uv-vertices (but this is just a coincidence - most of the time the number won't be the same) and the light map uv-map has 72 uv-vertices if i counted them correctly. so how will you store them in a vertex buffer which contains only 24 vertices? you need to duplicate the vertices correctly! </edit>
but it would be nice if you could post your source code so far since my first tries showed that i seem to be too stupid even for the most basic direct3d buffer stuff. maybe some of my problems are related to lite-c though. for example d3d9.h doesn't seem to be very complete.
|
|
|
Re: [Plugin] Import von 2. UVMap / Import of 2nd U
[Re: ventilator]
#119561
04/01/07 06:12
04/01/07 06:12
|
Joined: Jan 2004
Posts: 2,013 The Netherlands
Excessus
Expert
|
Expert
Joined: Jan 2004
Posts: 2,013
The Netherlands
|
I knew it couldn't be that easy or someone would have done it ! So I understand the core of the problem now: a vertex can have multiple skin points, even on a single UVmap. Ofcourse.. I wonder, though.. If you where to edit the mesh, breaking vertices everywhere, wouldn't that affect the shading? When a vertex (in 3D space, not on the UV) is duplicated its normal cannot be interpolated and you will get 'flat shading'. Maybe this just isn't a problem when all the lighting is in the skin anyway? I looked in the sampledll and it uses d3dx9.h not d3d9.h. This file is included in the directX SDK, which you can download from microsoft. The code I have so far (quick and dirty without much error handling): Code:
DLLFUNC var assignUV(ENTITY* ent) { if (!ent) return 0; LPD3DXMESH entMesh = (LPD3DXMESH)ent_mesh(ent, 0); int numVertices = _INT(ent_vertices(ent)); VERTEX* pVerts = NULL; entMesh->LockVertexBuffer(0, reinterpret_cast<void**> (&pVerts));
for(int i = 0; i < numVertices; i++) { //pVerts[i].tu2 = pVerts[i].tu1; // Copy v1 to v2 //pVerts[i].tv2 = pVerts[i].tv1; //pVerts[i].tu1 = 0.0f; //pVerts[i].tv1 = 0.0f;
pVerts[i].tu2 = 0.0f; // alternative: empty v2 (seems to contain v1 usually) pVerts[i].tv2 = 0.0f; }
entMesh->UnlockVertexBuffer(); return _VAR(1); }
pVerts is just a pointer, so using [] translates to pointer arithmetic. It's the same as &(pVerts + i), it moves the pointer ahead i * sizeof(VERTEX) each time (sorry if you knew this, I have no idea of your C++ skill but I thought this was pretty smart ).
|
|
|
Re: [Plugin] Import von 2. UVMap / Import of 2nd U
[Re: Excessus]
#119562
04/01/07 11:52
04/01/07 11:52
|
Joined: May 2002
Posts: 7,441
ventilator
Senior Expert
|
Senior Expert
Joined: May 2002
Posts: 7,441
|
the vertex struct also contains the normal. the normals of broken vertices could all point in the same direction so shading shouldn't get affected. but there are cases when the normals get recalculated (ent_fixnormals(),...) and i am not sure how this could get handled. maybe there is some other additional buffer which contains information about which broken vertices should be handled as a single vertex. thanks for posting your example! i think i understand how arrays and pointers relate to each other but a reminder is always good since i still sometimes make mistakes with it. my example from yesterday looks similar. not sure what's wrong with it but i will experiment...
|
|
|
Re: [Plugin] Import von 2. UVMap / Import of 2nd U
[Re: ventilator]
#119563
04/02/07 14:55
04/02/07 14:55
|
Joined: May 2002
Posts: 7,441
ventilator
Senior Expert
|
Senior Expert
Joined: May 2002
Posts: 7,441
|
Quote:
[...] pVerts is just a pointer, so using [] translates to pointer arithmetic. It's the same as &(pVerts + i), [...]
don't you mean *(pVerts + 1) instead of &(pVerts + 1)?
darn, i still didn't succeed in getting my example working in lite-c.
|
|
|
Re: [Plugin] Import von 2. UVMap / Import of 2nd U
[Re: ventilator]
#119564
04/03/07 14:05
04/03/07 14:05
|
Joined: Jan 2004
Posts: 2,013 The Netherlands
Excessus
Expert
|
Expert
Joined: Jan 2004
Posts: 2,013
The Netherlands
|
Quote:
don't you mean *(pVerts + 1) instead of &(pVerts + 1)?
Oh yea, ofcourse. As you can see I'm still sometimes making errors with pointers aswell.
Have you tried to copy/paste my code in lite-c? I don't know what the problem could be as I've not used lite-c extensively yet. My code doesn't use any C++ specific constructs, so you should be able to use it in lite-c aswell (maybe remove the type conversion macros).
Do you need this for your newton plugin, or for this plugin? Are you planning on doing this plugin, once you get the hang of d3d? I've given the algorithm some thought and I must admit it hurts my brain.
|
|
|
|