Questions about lightmapping, uvmapping, texels, .

Community Forums/General Help/Questions about lightmapping, uvmapping, texels, .

RemiD(Posted 2014) [#1]
Hello,

I am trying to code my own lightmapper because those that i have tried are either buggy, or not accurate enough, or do not produce the kind of lighting that i want, and also because i want to understand how to do it.

For now i have tried the lightmapper of 3D world studio, Deled, Giles, YAL.

If you have some understanding about lightmapping, can you please take a look at these questions and share your thoughts :
edit: some reformulations to i hope make it clearer ?



Q1)If i rebuild each surface with unwelded triangles which do not share vertices (easier to do it this way for me for the moment), will this not mess the UVMapping with the diffuse textures ?
For now, i use only one diffuse texture for each surface, and i want to apply the lightmap texture on top of the diffuse texture.
But what i don't understand is that if i unweld the triangles of the surface, then i calculate and define others UV coords so that the texel size is uniform, i think that it will mess how the diffuse is displayed, don't you think ?



Q2)I don't understand something with YAL, it does not seem to save the lightmapped mesh, but if i understand correctly, if the mesh is unwelded differently for the lightmap texture than it is for the diffuse texture (in order to have a precise texel size) then it is necessary to save the mesh after it has been unwelded and the UV coords have been calculated and defined. Isn't it ?



Q3)After the texel scale has been defined (example 1 texel for 0.1 unit), and after the vertex UV coords have been calculated and defined, how can i know if a texel is inside a triangle, knowing that some texel may be partly inside a triangle and partly outside (the texels which are positioned where the edges of the triangles are) ? Does this mean that for each texel i have to check if one of the 4 extremities (corners) of the texel are inside the triangle before deciding to calculate its illumination ?



Thanks,


RemiD(Posted 2014) [#2]
After some research and some tests, here are some answers which may help those who are interested about this :

Q1)>>No because for each surface, it is is possible to define 2 different sets of UVCoords, so a diffuse texture can be applied on the first set and a lightmap texture can be applied on the second set.
See :
http://www.blitzbasic.com/b3ddocs/command.php?name=VertexTexCoords
http://www.blitzbasic.com/b3ddocs/command.php?name=TextureCoords


Q2>>Yes, after each surface has been unwelded, each triangle "texelsfilled", each vertex uv mapped, the mesh need to be saved with these new properties.


Q3>>Yes, for the "texelsfilling" (to determine which texels are inside and around the triangle and should be considered for the calculation of the illumination) i first check if the center or a corner of a texel is inside the triangle, and if yes, i consider it for the future calculation of the illumination, then to prevent the "bleeding effect", i also consider the texels which are at left, at right, at up, at down, of the already considered texels.


fox95871(Posted 2014) [#3]
http://www.youtube.com/watch?v=qsd1QZ8nmgE

I hate to use the term, but have you tried baked lighting? I've posted this link before, but take a look. It uses absolutely nothing but a strait mesh and a texture file you can make in Photoshop. As for character lighting, keep in mind that no one ever holds it against Chrono trigger that the characters were fully lit in the Blackbird level, and baked on character lighting would look much better than that anyway.


RemiD(Posted 2014) [#4]

have you tried baked lighting?


This is exactly what my post is about ?

From what i understand :
baked lighting = precalculated lighting = precalculated lightmaps = precalculated colors of the texels of a lightmap texture

precalculated lighting can also mean precalculated colors of the vertices of a subdivided mesh.


RemiD(Posted 2014) [#5]
Or maybe you meant hand drawn shadows ?
If that's the case, i have no mental energy and time to spend doing this ! I prefer the automatic calculation of the lighted and shadowed areas.


fox95871(Posted 2014) [#6]


I guess it's not called baked lighting then. Anyway, everything done in Photoshop. It does take time and energy, but that's what Café bustelo is for :)