Jump to content
  • Advertisement
Sign in to follow this  
fantasy_world

help me with lightmapping !

This topic is 4853 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

If 2 triangles share the same edge, so how to calculate the uv for 2 vertices of the same edge. My problem is : if I calculate the UV for the first triangle, after that, I calculate the uv for the second triangle, my the uv coords of 2 vertices of the same edge are recomputed so the previous uv coords were replaced. If one lightmap for one triangle, it's ok. but 2 triangles have the same edge how can I generate the lightmap ? Because mesh use indexbuffer when rendering so there are many triangles share the same vertices. How to calculate the uv for these shared vertices. thanks

Share this post


Link to post
Share on other sites
Advertisement
eg. : if your polygons has 2 texture, you will split them 2 subsets,
so : if you vertex has 2 uv you split it to 2 vertices.

OR dont use vertices to hold UV data. hold them in polygon your class. ;)

Share this post


Link to post
Share on other sites
Quote:

If a single world vertex has more than one uv, split it into 2 or more vertices


that means my vertexbuffer will be larger and I can't use DrawIndexPrimitive any more ? right ? I have thought like that. And if there is only this solution, I have to follow. I'll try this way.

Quote:

OR dont use vertices to hold UV data. hold them in polygon your class. ;)


sorry, I don't really understand. If holding uv data in a polygon class, so how to use it ? (if I want to use pixel shader to implement multi-texturing).

thanks

[Edited by - fantasy_world on August 8, 2005 4:15:21 AM]

Share this post


Link to post
Share on other sites
you can still use DrawIndexedPrimitive! With the second triangle you just have to create a new vertex with th new Uv-Coords and replace one Index with the an index that points to the new created vertex...

I hope i got my ideas across...

regards,
m4gnus

Share this post


Link to post
Share on other sites
Quote:
Original post by fantasy_world
Quote:

OR dont use vertices to hold UV data. hold them in polygon your class. ;)

sorry, I don't really understand. If holding uv data in a polygon class, so how to use it ? (if I want to use pixel shader to implement multi-texturing).
thanks
something like :

struct Vertex {
float x,y,z;
int boneId;
};

struct UV {
float u,v;
};

struct Poly{
int v[3];
int n[3];
int uv[3];
};

struct Mesh {

P=oly *faces;
Vertex *vertices;
UV *uvs;
Vec3 *normals;

int faceCount;
int vertexCount;
int uvCount;
int normalCount;

};



it means you will use seperate uv s for all triangles. uses much more memory, implementetion is not different because you are not using or adding something new. but you should prepare them for stream usage and pixel shader. not hard at all.
but these technic is not as good/fast as splitting vertex into 2 or more vertices. and i only used it for easier lightmapping my high poly buildings. i will post you its source if i find it (a bit old, i will look up my archives).
(in fact it makes same effect for all tris, even it is not necessery, ^^)

Share this post


Link to post
Share on other sites
Quote:
Original post by m4gnus
you can still use DrawIndexedPrimitive! With the second triangle you just have to create a new vertex with th new Uv-Coords and replace one Index with the an index that points to the new created vertex...

I hope i got my ideas across...

regards,
m4gnus


thanks, but I think using DIP is not required in this situation because you don't have to share vertices between faces.

Quote:
Original post by stroma
but you should prepare them for stream usage and pixel shader. not hard at all.
but these technic is not as good/fast as splitting vertex into 2 or more vertices. and i only used it for easier lightmapping my high poly buildings. i will post you its source if i find it (a bit old, i will look up my archives).


'stream usage', I have to read about it. As you told splitting vertex is the better way, I'll use it. I like the second way too, if you can post your code thanks alot [smile]

thanks all

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
>If 2 triangles share the same edge, so how to calculate the uv for 2 vertices of the same edge.

Just do average, if two triangles share the same vertex then just do normal:=(normal1 + normal2)/2,

One way i use for average normals into the vertex as they come is: current_vertex_normal:=(current_vertex_normal+new_vertex_normal)/2

it work preatey well,


good luck.


tp

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!